PageRenderTime 26ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/frontend/php/my/admin/index.php

#
PHP | 362 lines | 206 code | 102 blank | 54 comment | 37 complexity | 02b65c5d6099dc4221c9c957de772a0a MD5 | raw file
Possible License(s): AGPL-3.0
  1. <?php
  2. # Manage user preferences
  3. # Copyright 1999-2000 (c) The SourceForge Crew
  4. # Copyright 2002-2006 (c) Mathieu Roy <yeupou--gnu.org>
  5. # Copyright (C) 2007 Sylvain Beucler
  6. #
  7. # This file is part of Savane.
  8. #
  9. # Savane is free software: you can redistribute it and/or modify
  10. # it under the terms of the GNU Affero General Public License as
  11. # published by the Free Software Foundation, either version 3 of the
  12. # License, or (at your option) any later version.
  13. #
  14. # Savane is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. # GNU Affero General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU Affero General Public License
  20. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. # we need to define the theme before loading the pre.php init script,
  22. # otherwise the page needs to be reloaded for the change to take effect.
  23. # see bug #1987
  24. require_once('../../include/sane.php');
  25. extract(sane_import('post',
  26. array(
  27. 'update',
  28. 'form_keep_only_one_session',
  29. 'form_timezone', 'user_theme', 'theme_rotate_jump',
  30. 'form_reverse_comments_order', 'form_stone_age_menu', 'form_nonfixed_feedback',
  31. 'form_use_bookmarks', 'form_email_hide',
  32. )));
  33. if ($update and $user_theme != "random" and $user_theme != "rotate")
  34. {
  35. define('SV_THEME', $user_theme);
  36. }
  37. require_once('../../include/init.php');
  38. require_once('../../include/timezones.php');
  39. extract(sane_import('request', array('feedback')));
  40. #######################
  41. ####################### UPDATE DATABASE
  42. session_require(array('isloggedin'=>1));
  43. if ($update)
  44. {
  45. # Update theme
  46. if ($user_theme == "Default")
  47. { $user_theme = ""; }
  48. if ($theme_rotate_jump == "1")
  49. {
  50. theme_rotate_jump();
  51. }
  52. setcookie("SV_THEME", $user_theme, time() + 60*60*24*365, $GLOBALS['sys_url_topdir']);
  53. # Update the rest
  54. if ($form_timezone == 100)
  55. { $form_timezone = "GMT"; }
  56. $success = db_autoexecute('user',
  57. array(
  58. 'email_hide' => ($form_email_hide ? "1" : "0"),
  59. 'theme' => $user_theme,
  60. 'timezone' => $form_timezone,
  61. ), DB_AUTOQUERY_UPDATE,
  62. "user_id=?", array(user_getid()));
  63. # Integrated bookmarks
  64. if ($form_use_bookmarks == "1")
  65. { user_set_preference("use_bookmarks", 1); }
  66. else
  67. { user_unset_preference("use_bookmarks"); }
  68. # Relative position feedback
  69. if ($form_nonfixed_feedback == "1")
  70. { user_set_preference("nonfixed_feedback", 1); }
  71. else
  72. { user_unset_preference("nonfixed_feedback"); }
  73. # Stone Age menu
  74. if ($form_stone_age_menu == "1")
  75. {
  76. user_set_preference("stone_age_menu", 1);
  77. # Too late for the stone age menu to be effective
  78. fb(_("Stone age menu activated, it will be effective the next time a page is loaded"));
  79. }
  80. else
  81. { user_unset_preference("stone_age_menu"); }
  82. # Reversed comment order
  83. if ($form_reverse_comments_order == "1")
  84. { user_set_preference("reverse_comments_order", 1); }
  85. else
  86. { user_unset_preference("reverse_comments_order"); }
  87. # Keep only one session comment order
  88. if ($form_keep_only_one_session == "1")
  89. { user_set_preference("keep_only_one_session", 1); }
  90. else
  91. { user_unset_preference("keep_only_one_session"); }
  92. if ($success)
  93. {
  94. fb(_("Database successfully updated"));
  95. }
  96. else
  97. {
  98. fb(_("Failed to update the database"),1);
  99. }
  100. }
  101. #######################
  102. ####################### PRINT FORM + LINKS
  103. site_user_header(array('context'=>'account'));
  104. # get global user vars
  105. $res_user = db_execute("SELECT * FROM user WHERE user_id=?", array(user_getid()));
  106. $row_user = db_fetch_array($res_user);
  107. print '<p>'._("You can view/change all of your account features from here.").'</p>';
  108. # we get site-specific content
  109. utils_get_content("account/index_intro");
  110. print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
  111. #####################################################################
  112. #####################################################################
  113. print '<h3>'._("Significant Arrangements").'</h3>';
  114. print "\n".html_splitpage(1);
  115. ############## Passwd / SSH
  116. print $HTML->box_top(_('Authentication Setup'));
  117. print '<a href="change.php?item=password">'._("Change Password").'</a>';
  118. print '<p class="smaller">'._("This password gives access to the web interface.").'<br />';
  119. utils_get_content("account/index_passwd");
  120. print '</p>';
  121. # get shared key count from db
  122. $expl_keys = explode("###",$row_user['authorized_keys']);
  123. # If the last 'key' is empty, then it is because of a trailing separator;
  124. # so do not count it
  125. $keynum = (sizeof($expl_keys));
  126. if ($expl_keys[$keynum-1] == "")
  127. $keynum--;
  128. $i = 0;
  129. print $HTML->box_nextitem(utils_get_alt_row_color($i));
  130. print '<a href="editsshkeys.php">';
  131. if ($keynum > 0)
  132. { printf(ngettext("Edit the %d SSH Public Key registered", "Edit the %d SSH Public Keys registered", $keynum), $keynum); }
  133. else
  134. { print gettext("Register an SSH Public Key"); }
  135. print '</a><p class="smaller">';
  136. utils_get_content("account/index_ssh");
  137. print '</p>';
  138. $i++;
  139. print $HTML->box_nextitem(utils_get_alt_row_color($i));
  140. print '<a href="change.php?item=gpgkey">'._("Edit GPG Key").'</a>';
  141. print '<p class="smaller">';
  142. utils_get_content("account/index_gpg");
  143. print '</p>';
  144. $i++;
  145. print $HTML->box_nextitem(utils_get_alt_row_color($i));
  146. print '<a href="sessions.php">';
  147. printf(ngettext("Manage the %d opened session", "Manage the %d opened sessions", session_count(user_getid())),session_count(user_getid()));
  148. print '</a><br /><br />';
  149. $i++;
  150. print $HTML->box_nextitem(utils_get_alt_row_color($i));
  151. print '<input type="checkbox" name="form_keep_only_one_session" value="1" '.(user_get_preference("keep_only_one_session") ? 'checked="checked"':'').' /> '._("Keep only one session opened at a time");
  152. print '<p class="smaller">'._("By default, you can open as many session concurrently as you want. But you may prefer to allow only one session to be opened at a time, killing previous sessions each time you log in.").'</p>';
  153. print $HTML->box_bottom();
  154. print "<br />\n";
  155. ################### Personal Record
  156. print html_splitpage(2);
  157. print $HTML->box_top(_('Identity Record'));
  158. print sprintf(_("Account #%s"), $row_user['user_id']);
  159. print '<p class="smaller">'.sprintf(_("Your login is %s."), '<strong>'.$row_user['user_name'].'</strong>').' '.sprintf(_("You registered your account on %s."), '<strong>'.utils_format_date($row_user['add_date']).'</strong>').'</p>';
  160. $i = 0;
  161. print $HTML->box_nextitem(utils_get_alt_row_color($i));
  162. print '<a href="change.php?item=realname">'._("Change Real Name").'</a>';
  163. print '<p class="smaller">'.sprintf(_("You are %s."), '<strong>'.$row_user['realname'].'</strong>').'</p>';
  164. $i++;
  165. print $HTML->box_nextitem(utils_get_alt_row_color($i));
  166. print '<a href="resume.php">'._("Edit Resume and Skills").'</a>';
  167. print '<p class="smaller">'._("Details about your experience and skills may be of interest to other users or visitors.").'</p>';
  168. $i++;
  169. print $HTML->box_nextitem(utils_get_alt_row_color($i));
  170. print '<a href="'.$GLOBALS['sys_home'].'users/'.$row_user['user_name'].'">'._("View your Public Profile").'</a>';
  171. print '<p class="smaller">'._("Your profile can be viewed by everybody.").'</p>';
  172. print $HTML->box_bottom();
  173. print "<br />\n";
  174. ################### Email Related
  175. print $HTML->box_top(_('Mail Setup'));
  176. print '<a href="change.php?item=email">'._("Change Email Address").'</a>';
  177. print '<p class="smaller">'.sprintf(_("Your current address is %s. It is essential to us that this address remains valid. Keep it up to date."), '<strong>'.$row_user['email'].'</strong>').'</p>';
  178. $i = 0;
  179. print $HTML->box_nextitem(utils_get_alt_row_color($i));
  180. print '<a href="change_notifications.php">'._("Edit Personal Notification Settings").'</a>';
  181. print '<p class="smaller">'._("Here is defined when the trackers should send email notifications. It permits also to configure the subject line prefix of sent mails.").'</p>';
  182. $i++;
  183. print $HTML->box_nextitem(utils_get_alt_row_color($i));
  184. print '<a href="cc.php">'._("Cancel Mail Notifications").'</a>';
  185. print '<p class="smaller">'._("Here, you can cancel all mail notifications.").'</p>';
  186. print $HTML->box_bottom();
  187. print "<br />\n";
  188. print html_splitpage(3);
  189. #####################################################################
  190. #####################################################################
  191. print '<span class="clearr" /><p class="center"><input type="submit" name="update" value="'._("Update").'" /></p></span>';
  192. print "<br />\n";
  193. print '<h3>'._("Secondary Arrangements").'</h3>';
  194. # warning about MSIE hacks
  195. if (is_broken_msie() && empty($_GET["printer"]))
  196. print '<p>'._("Caution: your current web browser identifies itself as Microsoft Internet Explorer. Unexpected behavior of this software in several regards may cause rendering problems, most notably break the interface layout.").' <span class="warn">'._("You are strongly advised to use a browser like Mozilla or Konqueror if you encounter such troubles.").'</span></p>';
  197. print html_splitpage(1);
  198. ################### Account Deletion
  199. print $HTML->box_top(_('Account Deletion'));
  200. print '<a href="change.php?item=delete">'._("Delete Account").'</a>';
  201. print '<p class="smaller">'.sprintf(_("If you are no longer member of any project and do not intend to use %s further, you may want to delete your account. This action cannot be undone and your current login will be forever lost."), $GLOBALS['sys_name']).'</strong></p>';
  202. print $HTML->box_bottom();
  203. print "<br />\n";
  204. ################### Optional features
  205. print $HTML->box_top(_('Optional Features'));
  206. print '<input type="checkbox" name="form_use_bookmarks" value="1" '.(user_get_preference("use_bookmarks") ? 'checked="checked"':'').' /> '._("Use integrated bookmarks");
  207. print '<p class="smaller">'._("By default, integrated bookmarks are deactivated to avoid redundancy with the bookmark feature provided by most modern web browsers. However, you may prefer integrated bookmarks if you frequently use different workstations without web browsers bookmarks synchronization.").'</p>';
  208. $i = 0;
  209. print $HTML->box_nextitem(utils_get_alt_row_color($i));
  210. print '<input type="checkbox" name="form_email_hide" value="1" '.($row_user['email_hide'] ? 'checked="checked"':'').' /> '._("Hide email address from your account information");
  211. print '<p class="smaller">'._("When checked, the only way for users to get in touch with you would be to use the form available to logged-in users. It is generally a bad idea to choose this option, especially if you are a project administrator.").'</p>';
  212. print $HTML->box_bottom();
  213. print "<br />\n";
  214. print html_splitpage(2);
  215. ################### Prefs
  216. print $HTML->box_top(_('Cosmetics Setup'));
  217. # The select box comes before the name of the category so all the clickable
  218. # part of the form stays on a same line (better UI design)
  219. print html_build_select_box_from_arrays($TZs,$TZs,'form_timezone',$row_user['timezone'], true, 'GMT');
  220. print ' '._("Timezone");
  221. print '<p class="smaller">'._("No matter where you live, you can see all dates and times as if it were in your neighborhood.").'</p>';
  222. $i = 0;
  223. print $HTML->box_nextitem(utils_get_alt_row_color($i));
  224. html_select_theme_box("user_theme", $row_user['theme']);
  225. print ' '._("Theme");
  226. if ("rotate"==$row_user['theme'])
  227. {
  228. print '<br /><input type="checkbox" name="theme_rotate_jump" value="1" /> '._("Jump to the next theme").'';
  229. }
  230. print '<p class="smaller">'._("Not satisfied with the default color theme of the interface?").'</p>';
  231. if (!theme_guidelines_check(SV_THEME))
  232. {
  233. print '<p class="smaller"><span class="warn">'._("The theme you are currently using does not follow the latest Savane CSS guidelines. As a result, page layout may be more or less severely broken. It is not advised to use this theme.").' ';
  234. # If the non-valid theme is the default one, tell users they should fill
  235. # a support request
  236. if (SV_THEME == $GLOBALS['sys_themedefault'])
  237. {
  238. print utils_link($GLOBALS['sys_home'].'support/?group='.$GLOBALS['sys_unix_group_name'],
  239. sprintf(_("%s administrators should be asked to take care of Savane CSS Guidelines, since it is the default theme"), $GLOBALS['sys_name']), "warn");
  240. }
  241. print '</span></p>';
  242. }
  243. $i++;
  244. print $HTML->box_nextitem(utils_get_alt_row_color($i));
  245. print '<input type="checkbox" name="form_reverse_comments_order" value="1" '.(user_get_preference("reverse_comments_order") ? 'checked="checked"':'').' /> '._("Print items comments from the oldest to the latest");
  246. print '<p class="smaller">'._("By default, comments are listed in reverse chronological order. This means that for a given item, comments are printed from the latest to the oldest. If this behavior does not suit you, select this option.").'</p>';
  247. $i++;
  248. print $HTML->box_nextitem(utils_get_alt_row_color($i));
  249. print '<input type="checkbox" name="form_stone_age_menu" value="1" '.(user_get_preference("stone_age_menu") ? 'checked="checked"':'').' /> '._("Use the Stone Age menu");
  250. print '<p class="smaller">'._("By default, the top menu includes links, via dropdown submenus, to all relevant pages in the current context (project area, personal area). However, the dropdown submenu mechanism may not work with few old browsers, for instance very old Konqueror versions (< 3.1, before 2003). Selecting this option enables an old fashioned submenu like the one shipped in older Savane releases (< 2.0).").'</p>';
  251. $i++;
  252. print $HTML->box_nextitem(utils_get_alt_row_color($i));
  253. print '<input type="checkbox" name="form_nonfixed_feedback" value="1" '.(user_get_preference("nonfixed_feedback") ? 'checked="checked"':'').' /> '._("Show feedback in relative position");
  254. print '<p class="smaller">'._("By default, the feedback box appear as a fixed box on top of the window and you can hide it by clicking on it. If you check this option, the feedback will be added in the page flow, after the top menu. Note: feedback is always in relative position with Microsoft Internet Explorer < 7, whatever this setting is set to.").'</p>';
  255. print $HTML->box_bottom();
  256. print "<br />\n";
  257. print html_splitpage(3);
  258. print '<span class="clearr" /><p class="center"><input type="submit" name="update" value="'._("Update").'" /></p></span>';
  259. print '</form>';
  260. $HTML->footer(array());