# HG changeset patch # User Christophe Lincoln # Date 1486766596 -3600 # Node ID 0dfc02021c9287050b829f3721e8b9424e797ab3 # Parent cad6d88c1fab544f87e95080565330306cfd04f1 Backport users plugins from TinyCM diff -r cad6d88c1fab -r 0dfc02021c92 web/plugins/users/users.cgi --- a/web/plugins/users/users.cgi Fri Feb 10 19:48:13 2017 +0100 +++ b/web/plugins/users/users.cgi Fri Feb 10 23:43:16 2017 +0100 @@ -3,6 +3,40 @@ # TinyCM/TazBug Plugin - Users profile and admin # +# Display user public profile. +public_people() { + echo "" + # Display personal user profile + if [ -f "$PEOPLE/$USER/profile.txt" ]; then + cat $PEOPLE/$USER/profile.txt | wiki_parser + fi +} + +# Display authenticated user profile. TODO: change password +auth_people() { + cat << EOT +Email : $MAIL + +EOT + # Each user can have personal profile page + if [ -f "$PEOPLE/$USER/profile.txt" ]; then + cat $PEOPLE/$USER/profile.txt | wiki_parser + cat << EOT +
+ $(gettext "Modify profile") + Dashboard +
+EOT + else + cat << EOT +
+ $(gettext "Create a profile page") + Dashboard +
+EOT + fi +} + case " $(GET) " in *\ users\ *) d="Users" @@ -66,4 +100,72 @@ done echo "" html_footer && exit 0 ;; + + *\ user\ *) + # User profile page + d="$(GET user)" + last="$(cat $PEOPLE/"$(GET user)"/last)" + header + html_header + user_box + . $PEOPLE/"$(GET user)"/account.conf +cat << EOT +

$(get_gravatar $MAIL) $NAME

+ +
+$(gettext "User name  :") $USER
+$(gettext "Last login :") $last
+EOT
+		if check_auth && [ "$(GET user)" == "$user" ]; then
+			auth_people
+		else
+			# check_auth will set VARS to current logged user: re-source
+			. $PEOPLE/"$(GET user)"/account.conf
+			public_people
+		fi
+		html_footer && exit 0 ;;
+		
+	*\ modprofile\ *)
+		# Let user edit there profile
+		if ! check_auth; then
+			echo "ERROR" && exit 0
+		fi
+		d="$user profile"
+		path=${PEOPLE}/${user}
+		header
+		html_header
+		user_box
+		cat << EOT
+

$(gettext "User:") $user

+

$(gettext "Modify your profile settings") +

+ +
+ +

Name

+ +

Email

+ +

About you

+ + +
+ +
+EOT + html_footer && exit 0 ;; + + *\ saveprofile\ *) + # Save a user profile + if check_auth; then + path="$PEOPLE/$user" + sed -i s"/^NAME=.*/NAME=\"$(GET name)\"/" ${path}/account.conf + sed -i s"/^MAIL=.*/MAIL=\"$(GET mail)\"/" ${path}/account.conf + cp -f ${path}/profile.txt ${path}/profile.bak + sed "s/$(echo -en '\r') /\n/g" > ${path}/profile.txt << EOT +$(GET profile) +EOT + header "Location: $script?user=$user" + fi && exit 0 ;; + esac diff -r cad6d88c1fab -r 0dfc02021c92 web/style.css --- a/web/style.css Fri Feb 10 19:48:13 2017 +0100 +++ b/web/style.css Fri Feb 10 23:43:16 2017 +0100 @@ -118,6 +118,8 @@ #newbug textarea, #editbug textarea { width: 490px; height: 180px; } +#edit textarea { width: 630px; height: 140px; } +#edit input[type="text"] { width: 620px; } .box, pre, #login, #account-info { background-color: #f8f8f8;