tazbug rev 66

Add users plugin (splited from dashboard) and improve it. This plugin is compatible with TinyCM
author Christophe Lincoln <pankso@slitaz.org>
date Tue Jan 07 23:17:19 2014 +0100 (2014-01-07)
parents 17bc5f665bf5
children 6144a840e058
files web/plugins/dashboard/dashboard.cgi web/plugins/dashboard/dashboard.conf web/plugins/users/users.cgi web/plugins/users/users.conf
line diff
     1.1 --- a/web/plugins/dashboard/dashboard.cgi	Tue Jan 07 22:41:49 2014 +0100
     1.2 +++ b/web/plugins/dashboard/dashboard.cgi	Tue Jan 07 23:17:19 2014 +0100
     1.3 @@ -1,66 +1,10 @@
     1.4  #!/bin/sh
     1.5  #
     1.6 -# TinyCM/TazBug Plugin - Dashboard
     1.7 +# TazBug Plugin - Dashboard
     1.8  #
     1.9  . /usr/lib/slitaz/httphelper
    1.10  
    1.11  case " $(GET) " in
    1.12 -	*\ users\ *)
    1.13 -		d="Users"
    1.14 -		header
    1.15 -		html_header
    1.16 -		user_box
    1.17 -		if check_auth && ! admin_user; then
    1.18 -			gettext "You must be admin to manage users."
    1.19 -			exit 0
    1.20 -		fi
    1.21 -		users=$(ls -1 $PEOPLE | wc -l)
    1.22 -		cat << EOT
    1.23 -<h2>Users: $users</h2>
    1.24 -<div id="tools">
    1.25 -	<a href="$script?dashboard">Dashboard</a>
    1.26 -</div>
    1.27 -<pre>
    1.28 -EOT
    1.29 -		for u in $(ls $PEOPLE)
    1.30 -		do
    1.31 -			. "${PEOPLE}/${u}/account.conf"
    1.32 -			cat << EOT
    1.33 -$(get_gravatar $MAIL 24) <a href="?user=$USER">$USER</a> | $NAME | $MAIL
    1.34 -EOT
    1.35 -# deluser link
    1.36 -#: <a href="?users&amp;deluser=$USER">$(gettext "delete")</a>
    1.37 -			unset NAME USER 
    1.38 -		done
    1.39 -		echo "</pre>" && exit 0 ;;
    1.40 -	
    1.41 -	*\ online\ *)
    1.42 -		# Show online users based on sessions files.
    1.43 -		d="Online users"
    1.44 -		header
    1.45 -		html_header
    1.46 -		user_box
    1.47 -		if ! check_auth; then
    1.48 -			gettext "You must be logged in to view online user"
    1.49 -			exit 0
    1.50 -		fi
    1.51 -		cat << EOT
    1.52 -<h2>Online users</h2>
    1.53 -<div id="tools">
    1.54 -	<a href="$script?dashboard">Dashboard</a>
    1.55 -</div>
    1.56 -<pre>
    1.57 -EOT
    1.58 -		for u in $(ls $sessions)
    1.59 -		do
    1.60 -			. "${PEOPLE}/${u}/account.conf"
    1.61 -			cat << EOT
    1.62 -$(get_gravatar $MAIL 24) <a href="?user=$USER">$USER</a> | $NAME
    1.63 -EOT
    1.64 -		done
    1.65 -		echo "</pre>"
    1.66 -		html_footer && exit 0 ;;
    1.67 -		
    1.68  	*\ dashboard\ *)
    1.69  		d="Dashboard"
    1.70  		users=$(ls -1 $PEOPLE | wc -l)
    1.71 @@ -73,15 +17,19 @@
    1.72  			gettext "You must be logged in to view the dashboard"
    1.73  			exit 0
    1.74  		fi
    1.75 -		if check_auth && admin_user; then
    1.76 -			admintools="<a href='?users'>List users</a>"
    1.77 +		# Source all plugins configs to get DASHBOARD_TOOLS and ADMIN_TOOLS
    1.78 +		for p in $(ls $plugins)
    1.79 +		do
    1.80 +			. $plugins/$p/$p.conf
    1.81 +		done
    1.82 +		if check_auth && ! admin_user; then
    1.83 +			ADMIN_TOOLS=""
    1.84  		fi
    1.85  		cat << EOT
    1.86  <h2>Dashboard</h2>
    1.87  
    1.88  <div id="tools">
    1.89 -	<a href='?online'>Online users</a>
    1.90 -	$admintools
    1.91 +	$DASHBOARD_TOOLS $ADMIN_TOOLS
    1.92  </div>
    1.93  
    1.94  <pre>
    1.95 @@ -104,12 +52,12 @@
    1.96  <h3>$(gettext "Plugins")</h3>
    1.97  <pre>
    1.98  EOT
    1.99 +		# List all plugins
   1.100  		for p in $(ls -1 $plugins)
   1.101  		do
   1.102  			. $plugins/$p/$p.conf
   1.103  			echo "<a href='?$p'>$PLUGIN</a> - $SHORT_DESC"
   1.104  		done
   1.105  		echo '</pre>'
   1.106 -		html_footer
   1.107 -		exit 0 ;;
   1.108 +		html_footer && exit 0 ;;
   1.109  esac
     2.1 --- a/web/plugins/dashboard/dashboard.conf	Tue Jan 07 22:41:49 2014 +0100
     2.2 +++ b/web/plugins/dashboard/dashboard.conf	Tue Jan 07 23:17:19 2014 +0100
     2.3 @@ -1,8 +1,10 @@
     2.4 -# TinycM/TazBug Plugin configuration
     2.5 +# TazBug Plugin configuration
     2.6  
     2.7  PLUGIN="TazBug Dashboard"
     2.8  SHORT_DESC="Light TazBug Dashboard"
     2.9  MAINTAINER="devel@slitaz.org"
    2.10 +
    2.11 +# Authentfied users
    2.12  PLUGINS_TOOLS="<a href='?dashboard'>Dashboard</a> ${PLUGINS_TOOLS}"
    2.13  
    2.14  # Configurable variables used in plugin.cgi
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/web/plugins/users/users.cgi	Tue Jan 07 23:17:19 2014 +0100
     3.3 @@ -0,0 +1,64 @@
     3.4 +#!/bin/sh
     3.5 +#
     3.6 +# TinyCM/TazBug Plugin - Users Admin
     3.7 +#
     3.8 +. /usr/lib/slitaz/httphelper
     3.9 +
    3.10 +case " $(GET) " in
    3.11 +	*\ users\ *)
    3.12 +		d="Users"
    3.13 +		header
    3.14 +		html_header
    3.15 +		user_box
    3.16 +		if check_auth && ! admin_user; then
    3.17 +			gettext "You must be admin to manage users"
    3.18 +			exit 0
    3.19 +		fi
    3.20 +		users=$(ls -1 $PEOPLE | wc -l)
    3.21 +		cat << EOT
    3.22 +<h2>Users: $users</h2>
    3.23 +<div id="tools">
    3.24 +	<a href="$script?dashboard">Dashboard</a>
    3.25 +	<a href='?online'>Online users</a>
    3.26 +</div>
    3.27 +<pre>
    3.28 +EOT
    3.29 +		for u in $(ls $PEOPLE)
    3.30 +		do
    3.31 +			. "${PEOPLE}/${u}/account.conf"
    3.32 +			cat << EOT
    3.33 +$(get_gravatar $MAIL 24) <a href="?user=$USER">$USER</a> | $NAME | $MAIL
    3.34 +EOT
    3.35 +# deluser link
    3.36 +#: <a href="?users&amp;deluser=$USER">$(gettext "delete")</a>
    3.37 +			unset NAME USER 
    3.38 +		done
    3.39 +		echo "</pre>" && exit 0 ;;
    3.40 +	
    3.41 +	*\ online\ *)
    3.42 +		# Show online users based on sessions files.
    3.43 +		d="Online users"
    3.44 +		header
    3.45 +		html_header
    3.46 +		user_box
    3.47 +		if ! check_auth; then
    3.48 +			gettext "You must be logged in to view online user"
    3.49 +			exit 0
    3.50 +		fi
    3.51 +		cat << EOT
    3.52 +<h2>Online users</h2>
    3.53 +<div id="tools">
    3.54 +	<a href="$script?dashboard">Dashboard</a>
    3.55 +</div>
    3.56 +<pre>
    3.57 +EOT
    3.58 +		for u in $(ls $sessions)
    3.59 +		do
    3.60 +			. "${PEOPLE}/${u}/account.conf"
    3.61 +			cat << EOT
    3.62 +$(get_gravatar $MAIL 24) <a href="?user=$USER">$USER</a> | $NAME
    3.63 +EOT
    3.64 +		done
    3.65 +		echo "</pre>"
    3.66 +		html_footer && exit 0 ;;
    3.67 +esac
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/web/plugins/users/users.conf	Tue Jan 07 23:17:19 2014 +0100
     4.3 @@ -0,0 +1,14 @@
     4.4 +# TinyCM/TazBug Plugin configuration
     4.5 +
     4.6 +PLUGIN="Users Admin"
     4.7 +SHORT_DESC="Handle TinyCM/TazBug users"
     4.8 +MAINTAINER="devel@slitaz.org"
     4.9 +
    4.10 +# Authentfied users
    4.11 +PLUGINS_TOOLS="${PLUGINS_TOOLS}"
    4.12 +DASHBOARD_TOOLS="<a href='?online'>Online users</a>"
    4.13 +
    4.14 +# Admin only in Dashboard
    4.15 +ADMIN_TOOLS="${ADMIN_TOOLS} <a href='?users'>List users</a>"
    4.16 +
    4.17 +# Configurable variables used in plugin.cgi