tinycm rev 92

Improve users and community plugin
author Christophe Lincoln <pankso@slitaz.org>
date Fri Feb 17 12:44:05 2017 +0100 (2017-02-17)
parents 6a565d525bda
children 97dca04ea0fa
files plugins/community/community.cgi plugins/community/community.conf plugins/users/users.cgi
line diff
     1.1 --- a/plugins/community/community.cgi	Fri Feb 17 00:46:34 2017 +0100
     1.2 +++ b/plugins/community/community.cgi	Fri Feb 17 12:44:05 2017 +0100
     1.3 @@ -13,8 +13,8 @@
     1.4  		user_box
     1.5  		
     1.6  		# Wall is only for logged users
     1.7 -		if ! check_auth; then
     1.8 -			gettext "You must be logged in to read the wall" 
     1.9 +		if [ "$WALL_MODE" == "private" ] && ! check_auth; then
    1.10 +			gettext "Private Wall - You must be logged in to read the wall" 
    1.11  			html_footer && exit 0
    1.12  		fi
    1.13  		
    1.14 @@ -39,15 +39,16 @@
    1.15  		fi
    1.16  		
    1.17  		# Message form
    1.18 -		cat << EOT
    1.19 -<h2>$d</h2>
    1.20 +		echo "<h2>$d</h2>"
    1.21 +		if check_auth; then
    1.22 +			cat << EOT
    1.23  
    1.24  <form method="get" action="$script" id="wall-form" name ="wall" onsubmit="return checkWall();">
    1.25  	<input type="hidden" name="wall" />
    1.26 -	<textarea name="message" maxlength="${MESSAGE_LENGTH}"></textarea>
    1.27 +	<textarea name="message" maxlength="${WALL_MESSAGES_LENGTH}"></textarea>
    1.28  	<div>
    1.29  		<input type="submit" value="$(gettext 'Send message')" />
    1.30 -		$(eval_gettext "Date: $date - Max char:") ${MESSAGE_LENGTH} -
    1.31 +		$(eval_gettext "Date: $date - Max char:") ${WALL_MESSAGES_LENGTH} -
    1.32  		$(gettext "Wiki syntax is supported:")
    1.33  		<a href="?d=en/help">$(gettext "Help page")</a>
    1.34  	</div>
    1.35 @@ -55,6 +56,7 @@
    1.36  
    1.37  <h2>$(gettext "Latest Messages")</h2>
    1.38  EOT
    1.39 +		fi
    1.40  		# Display messages &nb=40
    1.41  		msg_nb=40
    1.42  		if [ "$(GET nb)" ]; then
    1.43 @@ -83,17 +85,38 @@
    1.44  EOT
    1.45  		html_footer && exit 0 ;;
    1.46  	
    1.47 +	*\ community-config\ *)
    1.48 +		d="Community plugin config"
    1.49 +		header
    1.50 +		html_header
    1.51 +		user_box
    1.52 +		cat << EOT
    1.53 +<div id="tools">
    1.54 +	<a href="$script?dashboard">Dashboard</a>
    1.55 +	<a href="$script?community">Community Tools</a>
    1.56 +</div>
    1.57 +
    1.58 +<h2>$d</h2>
    1.59 +<pre>
    1.60 +Wall mode        : $WALL_MODE
    1.61 +Messages length  : $WALL_MESSAGES_LENGTH
    1.62 +</pre>
    1.63 +EOT
    1.64 +		html_footer && exit 0 ;;
    1.65 +	
    1.66  	*\ community\ *)
    1.67  		d="Community Tools"
    1.68  		header
    1.69  		html_header
    1.70  		user_box
    1.71  		cat << EOT
    1.72 +<div id="tools">
    1.73 +	<a href="$script?dashboard">Dashboard</a>
    1.74 +	<a href="$script?wall">Community Wall</a>
    1.75 +	<a href="$script?community-config">Plugin Config</a>
    1.76 +</div>
    1.77  <h2>$d</h2>
    1.78  <p>$SHORT_DESC</p>
    1.79 -<div id="tools">
    1.80 -	<a href="$script?wall">Community Wall</a>
    1.81 -</div>
    1.82  EOT
    1.83  		
    1.84  		html_footer && exit 0 ;;
     2.1 --- a/plugins/community/community.conf	Fri Feb 17 00:46:34 2017 +0100
     2.2 +++ b/plugins/community/community.conf	Fri Feb 17 12:44:05 2017 +0100
     2.3 @@ -6,7 +6,10 @@
     2.4  
     2.5  DASHBOARD_TOOLS="${DASHBOARD_TOOLS} <a href='?community'>Community</a>"
     2.6  
     2.7 -# Configurable variables used in plugin.cgi
     2.8 +# Configurable variables used in community.cgi
     2.9 +
    2.10 +# Wall mode: public/private
    2.11 +WALL_MODE="public"
    2.12  
    2.13  # Max length for messages on the Wall.
    2.14 -MESSAGE_LENGTH="240"
    2.15 +WALL_MESSAGES_LENGTH="240"
     3.1 --- a/plugins/users/users.cgi	Fri Feb 17 00:46:34 2017 +0100
     3.2 +++ b/plugins/users/users.cgi	Fri Feb 17 12:44:05 2017 +0100
     3.3 @@ -13,23 +13,12 @@
     3.4  	cat << EOT
     3.5  Email      : $MAIL
     3.6  </pre>
     3.7 -EOT
     3.8 -	# Each user can have personal profile page
     3.9 -	if [ -f "$PEOPLE/$USER/profile.txt" ]; then
    3.10 -		cat << EOT
    3.11 +
    3.12  <div id="tools">
    3.13 +	<a href="$script?dashboard">Dashboard</a>
    3.14  	<a href="$script?modprofile">$(gettext "Modify profile")</a>
    3.15 -	<a href="$script?dashboard">Dashboard</a>
    3.16  </div>
    3.17  EOT
    3.18 -	else
    3.19 -		cat << EOT
    3.20 -<div id="tools">
    3.21 -	<a href="$script?modprofile">$(gettext "Create a profile page")</a>
    3.22 -	<a href="$script?dashboard">Dashboard</a>
    3.23 -</div>
    3.24 -EOT
    3.25 -	fi
    3.26  }
    3.27  
    3.28  case " $(GET) " in