PageRenderTime 60ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/WebCalendar-1.2.5/includes/menu/index.php

#
PHP | 724 lines | 632 code | 29 blank | 63 comment | 110 complexity | d4e243c848d75cef93792fcfec5a31ab MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /* $Id: index.php,v 1.60.2.15 2008/04/23 20:22:55 umcesrjones Exp $
  3. *
  4. * This menu was created using some fantastic free tools out on the internet:
  5. * http://jscook.yuanheng.org/JSCookMenu/MenuBuilder.html
  6. * See README.LICENSE in icons directory.
  7. */
  8. defined ( '_ISVALID' ) or die ( 'You cannot access this file directly!' );
  9. // Configure your menu using this file.
  10. include_once 'includes/menu/menu_config.php';
  11. global $ALLOW_VIEW_OTHER, $BodyX, $CATEGORIES_ENABLED, $DISPLAY_TASKS,
  12. $DISPLAY_TASKS_IN_GRID, $fullname, $has_boss, $HOME_LINK, $is_admin,
  13. $is_assistant, $is_nonuser, $is_nonuser_admin, $login, $login_return_path,
  14. $MENU_DATE_TOP, $menuHtml, $menuScript, $NONUSER_ENABLED, $PUBLIC_ACCESS,
  15. $PUBLIC_ACCESS_ADD_NEEDS_APPROVAL, $PUBLIC_ACCESS_CAN_ADD,
  16. $PUBLIC_ACCESS_OTHERS, $readonly, $REMOTES_ENABLED, $REPORTS_ENABLED,
  17. $REQUIRE_APPROVALS, $show_printer, $single_user, $START_VIEW, $thisday,
  18. $thismonth, $thisyear, $use_http_auth, $user, $views, $OVERRIDE_PUBLIC;
  19. /* -----------------------------------------------------------------------------
  20. First figure out what options are on and privileges we have
  21. ----------------------------------------------------------------------------- */
  22. $can_add = ( ! empty ( $readonly ) && $readonly != 'Y' );
  23. if ( access_is_enabled () )
  24. $can_add = access_can_access_function ( ACCESS_EVENT_EDIT, $user );
  25. if ( $login == '__public__' )
  26. $can_add = ( access_is_enabled () ? $can_add : $PUBLIC_ACCESS_CAN_ADD == 'Y' );
  27. if (!$is_admin && !$is_assistant && !$is_nonuser_admin) {
  28. if ($is_nonuser)
  29. $can_add = false;
  30. else if (!empty($user) && $user != $login && $user != '__public__')
  31. $can_add = false;
  32. }
  33. $export_url = $import_url = $new_entry_url = $new_task_url = '';
  34. $search_url = $select_user_url = $unapproved_url = '';
  35. $help_url = 'help_index.php';
  36. $month_url = 'month.php';
  37. $today_url = 'day.php';
  38. $week_url = 'week.php';
  39. $year_url = 'year.php';
  40. $mycal = ( empty ( $STARTVIEW ) ? 'index.php' : $STARTVIEW );
  41. $mycal .= ( ! strpos ( $mycal, '.php' ) ? '.php' : '' );
  42. if ( $can_add ) {
  43. // Add new entry.
  44. $new_entry_url = 'edit_entry.php';
  45. if ( ! empty ( $thisyear ) ) {
  46. $good_date = 'year=' . $thisyear
  47. . ( empty ( $thismonth ) ? '' : '&month=' . $thismonth )
  48. . ( empty ( $thisday ) ? '' : '&day=' . $thisday );
  49. $new_entry_url .= "?$good_date";
  50. }
  51. // Add new task.
  52. if ( $DISPLAY_TASKS_IN_GRID == 'Y' || $DISPLAY_TASKS == 'Y' )
  53. $new_task_url = 'edit_entry.php?eType=task'
  54. . ( empty ( $thisyear ) ? '' : "&$good_date" );
  55. }
  56. if ( $single_user != 'Y' ) {
  57. // Today
  58. if ( ! empty ( $user ) && $user != $login ) {
  59. $month_url .= '?user=' . $user;
  60. $today_url .= '?user=' . $user;
  61. $week_url .= '?user=' . $user;
  62. $year_url .= '?user=' . $user;
  63. if ( ! empty ( $new_entry_url ) )
  64. $new_entry_url .= (strpos($new_entry_url, '?') !== FALSE? '&': '?') . 'user=' . $user;
  65. if ( ! empty ( $new_task_url ) )
  66. $new_task_url .= '&user=' . $user;
  67. }
  68. // List Unapproved.
  69. if ( $login != '__public__' && ! $is_nonuser && $readonly == 'N' &&
  70. ( $REQUIRE_APPROVALS == 'Y' || $PUBLIC_ACCESS == 'Y' ) )
  71. $unapproved_url = 'list_unapproved.php'
  72. . ( $is_nonuser_admin ? '?user=' . getValue ( 'user' ) : '' );
  73. // Another User's Calendar.
  74. if ( ( $login == '__public__' && $PUBLIC_ACCESS_OTHERS != 'Y' ) ||
  75. ( $is_nonuser && ! access_is_enabled () ) ) {
  76. // Don't allow them to see other people's calendar.
  77. } else
  78. if ( $ALLOW_VIEW_OTHER == 'Y' || $is_admin ) {
  79. // Also, make sure they able to access either day/week/month/year view.
  80. // If not, the only way to view another user's calendar is a custom view.
  81. if ( ! access_is_enabled () ||
  82. access_can_access_function ( ACCESS_ANOTHER_CALENDAR ) ) {
  83. // Get count of users this user can see. If > 1, then...
  84. $ulist = array_merge (
  85. get_my_users ( $login, 'view' ), get_my_nonusers ( $login, true, 'view' ) );
  86. //remove duplicates if any
  87. if ( function_exists ( 'array_intersect_key' ) )
  88. $ulist = array_intersect_key($ulist, array_unique(array_map('serialize', $ulist)));
  89. if ( count ( $ulist ) > 1 )
  90. $select_user_url = 'select_user.php';
  91. }
  92. }
  93. }
  94. // Only display some links if we're viewing our own calendar.
  95. if ( ( empty ( $user ) || $user == $login ) || ( ! empty ( $user ) && access_is_enabled () &&
  96. access_user_calendar ( 'view', $user) ) ) {
  97. // Search
  98. if ( access_can_access_function ( ACCESS_SEARCH, $user ) )
  99. $search_url = 'search.php';
  100. }
  101. if ( empty ( $user ) || $user == $login ) {
  102. // Import/Export
  103. if ( access_is_enabled () || ( $login != '__public__' && ! $is_nonuser ) ) {
  104. if ( $readonly != 'Y' &&
  105. access_can_access_function ( ACCESS_IMPORT, $user ) )
  106. $import_url = 'import.php';
  107. if ( access_can_access_function ( ACCESS_EXPORT, $user ) )
  108. $export_url = 'export.php';
  109. }
  110. }
  111. // Help
  112. $showHelp = ( access_is_enabled ()
  113. ? access_can_access_function ( ACCESS_HELP, $user )
  114. : ( $login != '__public__' && ! $is_nonuser ) );
  115. // Views
  116. $view_cnt = count ( $views );
  117. if ( ( access_can_access_function ( ACCESS_VIEW, $user ) && $ALLOW_VIEW_OTHER != 'N' ) && $view_cnt > 0 ) {
  118. $views_link = array ();
  119. for ( $i = 0; $i < $view_cnt; $i++ ) {
  120. $tmp['name'] = htmlspecialchars ( $views[$i]['cal_name'], ENT_QUOTES );
  121. $tmp['url'] = str_replace ( '&amp;', '&', $views[$i]['url'] )
  122. . ( empty ( $thisdate ) ? '' : '&date=' . $thisdate );
  123. $views_link[$i] = $tmp;
  124. }
  125. $views_linkcnt = count ( $views_link );
  126. $tmp = '';
  127. }
  128. // Reports
  129. $reports_linkcnt = 0;
  130. if ( ! empty ( $REPORTS_ENABLED ) && $REPORTS_ENABLED == 'Y' &&
  131. access_can_access_function ( ACCESS_REPORT, $user ) ) {
  132. $reports_link = array ();
  133. $u_url = ( ! empty ( $user ) && $user != $login ? '&user=' . $user : '' );
  134. $rows = dbi_get_cached_rows ( 'SELECT cal_report_name, cal_report_id
  135. FROM webcal_report WHERE cal_login = ? OR ( cal_is_global = \'Y\'
  136. AND cal_show_in_trailer = \'Y\' ) ORDER BY cal_report_id',
  137. array ( $login ) );
  138. if ( $rows ) {
  139. for ( $i = 0, $cnt = count ( $rows ); $i < $cnt; $i++ ) {
  140. $row = $rows[$i];
  141. $tmp['name'] = htmlspecialchars ( $row[0], ENT_QUOTES );
  142. $tmp['url'] = 'report.php?report_id=' . $row[1] . $u_url;
  143. $reports_link[] = $tmp;
  144. }
  145. }
  146. $reports_linkcnt = count ( $reports_link );
  147. $tmp = '';
  148. }
  149. // Logout/Login URL
  150. if ( ! $use_http_auth && $single_user != 'Y' ) {
  151. $login_url = 'login.php';
  152. if ( empty ( $login_return_path ) )
  153. $logout_url = $login_url . '?';
  154. else {
  155. $login_url .= '?return_path=' . $login_return_path;
  156. $logout_url = $login_url . '&';
  157. }
  158. $logout_url .= 'action=logout';
  159. // Should we use another application's login/logout pages?
  160. if ( substr ( $GLOBALS['user_inc'], 0, 9 ) == 'user-app-' ) {
  161. global $app_login_page, $app_logout_page;
  162. $login_url = 'login-app.php'
  163. . ( $login_return_path != '' && $app_login_page['return'] != ''
  164. ? '?return_path=' . $login_return_path : '' );
  165. $logout_url = $app_logout_page;
  166. }
  167. }
  168. // Manage Calendar links.
  169. if ( ! empty ( $NONUSER_ENABLED ) && $NONUSER_ENABLED == 'Y' )
  170. $admincals = get_nonuser_cals ( $login );
  171. // Make sure they have access to either month/week/day view. If they do not,
  172. // then we cannot create a URL that shows just the boss' events. So, we would
  173. // not include any of the "manage calendar of" links.
  174. $have_boss_url = true;
  175. if ( ! access_can_access_function ( ACCESS_MONTH, $user ) && !
  176. access_can_access_function ( ACCESS_WEEK, $user ) && !
  177. access_can_access_function ( ACCESS_DAY, $user ) )
  178. $have_boss_url = false;
  179. if ( $have_boss_url && ( $has_boss || ! empty ( $admincals[0] ) ||
  180. ( $is_admin && $PUBLIC_ACCESS ) ) ) {
  181. $grouplist = user_get_boss_list ( $login );
  182. if ( ! empty ( $admincals[0] ) )
  183. $grouplist = array_merge ( $admincals, $grouplist );
  184. if ( $is_admin && $PUBLIC_ACCESS == 'Y' ) {
  185. $public = array (
  186. 'cal_login' => '__public__',
  187. 'cal_fullname' => translate ( 'Public Access' )
  188. );
  189. array_unshift ( $grouplist, $public );
  190. }
  191. $groups = '';
  192. $grouplistcnt = count ( $grouplist );
  193. $gdone = array();
  194. for ( $i = 0; $i < $grouplistcnt; $i++ ) {
  195. $l = $grouplist[$i]['cal_login'];
  196. $f = $grouplist[$i]['cal_fullname'];
  197. // Don't display current $user in group list.
  198. if ( ! empty ( $user ) && $user == $l )
  199. continue;
  200. // Do not show duplicate entries.
  201. if (isset($gdone[$l]))
  202. continue;
  203. $gdone[$l] = true;
  204. /*
  205. Use the preferred view if it is day/month/week/year.php. Try not to use a
  206. user-created view because it might not display the proper user's events.
  207. (Fallback to month.php if this is true.) Of course, if this user cannot
  208. view any of the standard D/M/W/Y pages, that will force us to use the view.
  209. */
  210. $xurl = get_preferred_view ( '', 'user=' . $l );
  211. if ( strstr ( $xurl, 'view_' ) ) {
  212. if ( access_can_access_function ( ACCESS_MONTH, $user ) )
  213. $xurl = 'month.php?user=' . $l;
  214. elseif ( access_can_access_function ( ACCESS_WEEK, $user ) )
  215. $xurl = 'week.php?user=' . $l;
  216. elseif ( access_can_access_function ( ACCESS_DAY, $user ) )
  217. $xurl = 'day.php?user=' . $l;
  218. // Year does not show events, so you cannot manage someone's cal.
  219. }
  220. $xurl = str_replace ( '&amp;', '&', $xurl );
  221. $tmp['name'] = $f;
  222. $tmp['url'] = $xurl;
  223. $groups[] = $tmp;
  224. }
  225. }
  226. // Help URL
  227. $help_url = ( access_can_access_function ( ACCESS_HELP, $user ) );
  228. /* -----------------------------------------------------------------------------
  229. Lets make a few functions for printing menu items.
  230. ----------------------------------------------------------------------------- */
  231. /*
  232. JSCookMenu top menu item looks like:
  233. [null,'Title',null,null,null,
  234. Followed by items for that menu:
  235. ['<img src="image.png" />','Title','link.php',null,''],
  236. Close a top level menu item:
  237. ],
  238. Custom actions inside a menu can be done with:
  239. [_cmNoAction, 'HTML code']
  240. For full menu options see JSCookMenu documentation.
  241. */
  242. $menuHtml = $menuScript = '';
  243. /* A menu link.
  244. */
  245. function jscMenu_menu ( $title='', $url = false, $translate=true ) {
  246. global $menuScript;
  247. $menuScript .= '[null,\'' . ( $translate ? translate ( $title ) : $title )
  248. . "','$url'" . ',null,null' . ( $url ? ']' : '' ) . ',';
  249. }
  250. /* Dropdown menu item.
  251. */
  252. function jscMenu_item ( $icon, $title='', $url, $translate=true, $target = '' ) {
  253. global $menuScript;
  254. // escape single quite to avoid javascript error
  255. $str = preg_replace ( "/'/", "\\'", $title );
  256. $menuScript .= '[\'<img src="includes/menu/icons/' . $icon
  257. . '" alt="'. $str .'" />\',\'' . ( $translate ? translate ( $str ) : $str )
  258. . "','$url','$target',''],\n";
  259. }
  260. /* Dropdown menu item that has a sub menu.
  261. */
  262. function jscMenu_sub_menu ( $icon, $title='', $translate=true ) {
  263. global $menuScript;
  264. // escape single quite to avoid javascript error
  265. $str = preg_replace ( "/'/", "\\'", $title );
  266. $menuScript .= '[\'<img src="includes/menu/icons/' . $icon
  267. . '" alt="" />\',\'' . ( $translate ? translate ( $str ) : $str )
  268. . "','',null,'',\n";
  269. }
  270. /* Dropdown menu item is custom HTML.
  271. */
  272. function jscMenu_custom ( $html ) {
  273. global $menuScript;
  274. $menuScript .= '[_cmNoClick,' . "'$html']\n";
  275. }
  276. /* Closing tag.
  277. */
  278. function jscMenu_close () {
  279. global $menuScript;
  280. $menuScript .= '],
  281. ';
  282. }
  283. /* A divider line.
  284. */
  285. function jscMenu_divider () {
  286. global $menuScript;
  287. $menuScript .= '_cmSplit,
  288. ';
  289. }
  290. /* -----------------------------------------------------------------------------
  291. Now we need to print the menu
  292. ----------------------------------------------------------------------------- */
  293. $menuScript .= '
  294. <script language="JavaScript" type="text/javascript">
  295. <!-- <![CDATA[
  296. var myMenu =
  297. ['
  298. // Add Menu Extra if defined.
  299. . ( empty ( $menuExtras[0] ) ? '' : parse_menu_extras ( $menuExtras[0] ) );
  300. // My Calendar Menu
  301. // translate ( 'This Week' ) translate ( 'This Month' )
  302. // translate ( 'This Year' ) translate ( 'Exit' )
  303. if ( $menuConfig['My Calendar'] ) {
  304. jscMenu_menu ( 'My Calendar' );
  305. if ( $menuConfig['Home'] )
  306. jscMenu_item ( 'home.png', 'Home', $mycal );
  307. if ( $menuConfig['Today'] && access_can_access_function ( ACCESS_DAY ) )
  308. jscMenu_item ( 'today.png', 'Today', $today_url );
  309. if ( $menuConfig['This Week'] && access_can_access_function ( ACCESS_WEEK ) )
  310. jscMenu_item ( 'week.png', 'This Week', $week_url );
  311. if ( $menuConfig['This Month'] && access_can_access_function ( ACCESS_MONTH ) )
  312. jscMenu_item ( 'month.png', 'This Month', $month_url );
  313. if ( $menuConfig['This Year'] && access_can_access_function ( ACCESS_YEAR ) )
  314. jscMenu_item ( 'year.png', 'This Year', $year_url );
  315. if ( ! empty ( $HOME_LINK ) && $menuConfig['Exit'] )
  316. jscMenu_item ( 'exit.png', 'Exit', $HOME_LINK );
  317. jscMenu_close ();
  318. }
  319. // Add Menu Extra if defined.
  320. if ( ! empty ( $menuExtras[1] ) )
  321. $menuScript .= parse_menu_extras ( $menuExtras[1] );
  322. // Events Menu
  323. // translate ( 'Add New Event' ) translate ( 'Delete Entries' )
  324. if ( $menuConfig['Events'] ) {
  325. //allow us to back out menu if empty
  326. $tmp1_menuScript = $menuScript;
  327. jscMenu_menu ( 'Events' );
  328. $tmp2_menuScript = $menuScript;
  329. if ( $new_entry_url != '' && $menuConfig['Add New Event'] )
  330. jscMenu_item ( 'add.png', 'Add New Event', $new_entry_url );
  331. if ( $new_task_url != '' && $menuConfig['Add New Task'] )
  332. jscMenu_item ( 'newtodo.png', 'Add New Task', $new_task_url );
  333. if ( $is_admin && $readonly != 'Y' && $menuConfig['Delete Entries'] )
  334. jscMenu_item ( 'delete.png', 'Delete Entries', 'purge.php' );
  335. if ( $unapproved_url != '' && $menuConfig['Unapproved Entries'] )
  336. jscMenu_item ( 'unapproved.png', 'Unapproved Entries', $unapproved_url );
  337. if ( $export_url != '' && $menuConfig['Export'] )
  338. jscMenu_item ( 'up.png', 'Export', $export_url );
  339. if ( $import_url != '' && $menuConfig['Import'] )
  340. jscMenu_item ( 'down.png', 'Import', $import_url );
  341. //if nothing was added, remove the menu
  342. if ( $menuScript == $tmp2_menuScript )
  343. $menuScript = $tmp1_menuScript;
  344. else
  345. jscMenu_close ();
  346. }
  347. // Add Menu Extra if defined.
  348. if ( ! empty ( $menuExtras[2] ) )
  349. $menuScript .= parse_menu_extras ( $menuExtras[2] );
  350. // Views Menu
  351. // translate ( 'My Views' ) translate ( 'Manage Calendar of' );
  352. if ( $menuConfig['Views'] &&
  353. ( $select_user_url != '' || ! empty ( $views_link ) ) ) {
  354. //allow us to back out menu if empty
  355. $tmp1_menuScript = $menuScript;
  356. jscMenu_menu ( 'Views' );
  357. $tmp2_menuScript = $menuScript;
  358. if ( $select_user_url != '' && $menuConfig['Another Users Calendar'] )
  359. jscMenu_item ( 'display.png', 'Another Users Calendar',
  360. $select_user_url );
  361. if ( $login != '__public__' ) {
  362. if ( ! empty ( $views_link ) && $views_linkcnt > 0 && $menuConfig['My Views'] ) {
  363. jscMenu_sub_menu ( 'views.png', 'My Views' );
  364. for ( $i = 0; $i < $views_linkcnt; $i++ ) {
  365. jscMenu_item ( 'views.png', $views_link[$i]['name'],
  366. $views_link[$i]['url'], false );
  367. }
  368. jscMenu_close ();
  369. }
  370. if ( ! empty ( $groups ) && $menuConfig['Manage Calendar of'] ) {
  371. jscMenu_sub_menu ( 'manage_cal.png', 'Manage Calendar of' );
  372. $groupcnt = count ( $groups );
  373. for ( $i = 0; $i < $groupcnt; $i++ ) {
  374. jscMenu_item ( 'display.png', $groups[$i]['name'],
  375. $groups[$i]['url'], false );
  376. }
  377. jscMenu_close ();
  378. }
  379. if ( ! $is_nonuser && ( ! access_is_enabled () ||
  380. access_can_access_function ( ACCESS_VIEW_MANAGEMENT, $user ) ) && $readonly != 'Y' && $menuConfig['Manage Views'] ) {
  381. jscMenu_divider ();
  382. jscMenu_item ( 'manage_views.png', 'Manage Views', 'views.php' );
  383. }
  384. }
  385. //if nothing was added, remove the menu
  386. if ( $menuScript == $tmp2_menuScript )
  387. $menuScript = $tmp1_menuScript;
  388. else
  389. jscMenu_close ();
  390. }
  391. // Add Menu Extra if defined.
  392. if ( ! empty ( $menuExtras[3] ) )
  393. $menuScript .= parse_menu_extras ( $menuExtras[3] );
  394. // Reports Menu
  395. // translate ( 'My Reports' )
  396. if ( ( $is_admin || $reports_linkcnt > 0 ) && $menuConfig['Reports'] ) {
  397. //allow us to back out menu if empty
  398. $tmp1_menuScript = $menuScript;
  399. jscMenu_menu ( 'Reports' );
  400. $tmp2_menuScript = $menuScript;
  401. if ( $is_admin && $menuConfig['Activity Log'] && ( ! access_is_enabled () ||
  402. access_can_access_function ( ACCESS_ACTIVITY_LOG, $user ) ) )
  403. jscMenu_item ( 'log.png', 'Activity Log', 'activity_log.php' );
  404. if ( $is_admin && $menuConfig['System Log'] && ( ! access_is_enabled () ||
  405. access_can_access_function ( ACCESS_ACTIVITY_LOG, $user ) ) )
  406. jscMenu_item ( 'log.png', 'System Log', 'activity_log.php?system=1' );
  407. if ( $is_admin && $menuConfig['Security Audit'] && ( ! access_is_enabled () ||
  408. access_can_access_function ( ACCESS_SECURITY_AUDIT, $user ) ) )
  409. jscMenu_item ( 'log.png', 'Security Audit', 'security_audit.php' );
  410. if ( ! empty ( $reports_link ) && $reports_linkcnt > 0 && $menuConfig['My Reports'] ) {
  411. jscMenu_sub_menu ( 'reports.png', 'My Reports' );
  412. for ( $i = 0; $i < $reports_linkcnt; $i++ ) {
  413. jscMenu_item ( 'document.png', $reports_link[$i]['name'],
  414. $reports_link[$i]['url'], false );
  415. }
  416. jscMenu_close ();
  417. }
  418. if ( $login != '__public__' && ! $is_nonuser && $REPORTS_ENABLED == 'Y' && $readonly != 'Y' && $menuConfig['Manage Reports'] && ( ! access_is_enabled () ||
  419. access_can_access_function ( ACCESS_REPORT, $user ) ) ) {
  420. jscMenu_divider ();
  421. jscMenu_item ( 'manage_reports.png', 'Manage Reports', 'report.php' );
  422. }
  423. //if nothing was added, remove the menu
  424. if ( $menuScript == $tmp2_menuScript )
  425. $menuScript = $tmp1_menuScript;
  426. else
  427. jscMenu_close ();
  428. }
  429. // Add Menu Extra if defined.
  430. if ( ! empty ( $menuExtras[4] ) )
  431. $menuScript .= parse_menu_extras ( $menuExtras[4] );
  432. // Settings Menu
  433. // translate ( 'My Profile' ) translate ( 'Public Calendar' )
  434. // translate ( 'Unapproved Events' ) translate ( 'User Manager' )
  435. if ( $login != '__public__' && ! $is_nonuser && $readonly
  436. != 'Y' && $menuConfig['Settings'] ) {
  437. //allow us to back out menu if empty
  438. $tmp1_menuScript = $menuScript;
  439. jscMenu_menu ( 'Settings' );
  440. $tmp2_menuScript = $menuScript;
  441. // Nonuser Admin Settings.
  442. if ( $is_nonuser_admin ) {
  443. if ( $single_user != 'Y' && $readonly != 'Y' && $menuConfig['NUC_Assistants'] ) {
  444. if ( ! access_is_enabled () ||
  445. access_can_access_function ( ACCESS_ASSISTANTS, $user ) )
  446. jscMenu_item ( 'users.png', 'Assistants',
  447. 'assistant_edit.php?user=' . $user );
  448. }
  449. if ( $menuConfig['NUC_Preferences'] && ( ! access_is_enabled () ||
  450. access_can_access_function ( ACCESS_PREFERENCES, $user ) ) )
  451. jscMenu_item ( 'settings.png', 'Preferences', 'pref.php?user=' . $user );
  452. // Normal User Settings.
  453. } else {
  454. if ( $single_user != 'Y' &&
  455. ( $menuConfig['Assistants'] && ( ! access_is_enabled () ||
  456. access_can_access_function ( ACCESS_ASSISTANTS, $user ) ) ) )
  457. jscMenu_item ( 'users.png', 'Assistants', 'assistant_edit.php' );
  458. if ( $CATEGORIES_ENABLED == 'Y' && $menuConfig['Categories'] &&
  459. ( ! access_is_enabled () ||
  460. access_can_access_function ( ACCESS_CATEGORY_MANAGEMENT, $user ) ) )
  461. jscMenu_item ( 'folder.png', 'Categories', 'category.php' );
  462. if ( $menuConfig['Layers'] && ( ! access_is_enabled () ||
  463. access_can_access_function ( ACCESS_LAYERS, $user ) ) )
  464. jscMenu_item ( 'layers.png', 'Layers', 'layers.php' );
  465. if ( ! $is_admin && $menuConfig['My Profile'] )
  466. jscMenu_item ( 'profile.png', 'My Profile', 'users.php' );
  467. if ( $REMOTES_ENABLED == 'Y' && $menuConfig['Remote Calendars'] &&
  468. ( ! access_is_enabled () ||
  469. access_can_access_function ( ACCESS_IMPORT ) ) )
  470. jscMenu_item ( 'vcalendar.png', 'Remote Calendars',
  471. 'users.php?tab=remotes' );
  472. if ( $menuConfig['Preferences'] && ( ! access_is_enabled () ||
  473. access_can_access_function ( ACCESS_PREFERENCES, $user ) ) )
  474. jscMenu_item ( 'settings.png', 'Preferences', 'pref.php' );
  475. if ( $menuConfig['Public Calendar'] && $is_admin && !
  476. empty ( $PUBLIC_ACCESS ) && $PUBLIC_ACCESS == 'Y' ) {
  477. jscMenu_sub_menu ( 'public.png', 'Public Calendar' );
  478. if ( $menuConfig['Public Preferences'] )
  479. jscMenu_item ( 'settings.png', 'Preferences', 'pref.php?public=1' );
  480. if ( $PUBLIC_ACCESS_CAN_ADD == 'Y' && $PUBLIC_ACCESS_ADD_NEEDS_APPROVAL == 'Y' && $menuConfig['Public Unapproved Events'] )
  481. jscMenu_item ( 'unapproved.png', 'Unapproved Events',
  482. 'list_unapproved.php?user=__public__' );
  483. jscMenu_close ();
  484. }
  485. if ( ( $is_admin && $menuConfig['System Settings'] && !
  486. access_is_enabled () ) || ( access_is_enabled () &&
  487. access_can_access_function ( ACCESS_SYSTEM_SETTINGS, $user ) ) )
  488. jscMenu_item ( 'config.png', 'System Settings', 'admin.php' );
  489. if ( $menuConfig['User Access Control'] && access_is_enabled () &&
  490. ( $is_admin ||
  491. access_can_access_function ( ACCESS_ACCESS_MANAGEMENT, $user ) ) )
  492. jscMenu_item ( 'access.png', 'User Access Control', 'access.php' );
  493. if ( $is_admin && $menuConfig['User Manager'] && ( ( ! access_is_enabled () ||
  494. ( access_is_enabled () &&
  495. access_can_access_function ( ACCESS_USER_MANAGEMENT, $user ) ) ) ) )
  496. jscMenu_item ( 'user.png', 'User Manager', 'users.php' );
  497. }
  498. //if nothing was added, remove the menu
  499. if ( $menuScript == $tmp2_menuScript )
  500. $menuScript = $tmp1_menuScript;
  501. else
  502. jscMenu_close ();
  503. }
  504. // Add Menu Extra if defined.
  505. if ( ! empty ( $menuExtras[5] ) )
  506. $menuScript .= parse_menu_extras ( $menuExtras[5] );
  507. // Search Menu
  508. if ( ( $search_url != '' && $menuConfig['Search'] ) &&
  509. ( $login != '__public__' || $OVERRIDE_PUBLIC != 'Y' ) ) {
  510. jscMenu_menu ( 'Search' );
  511. $doAdv = false;
  512. if ( ! empty ( $menuConfig['Advanced Search'] ) ) {
  513. // Use UAC if enabled...
  514. if ( access_is_enabled () &&
  515. access_can_access_function ( ACCESS_ADVANCED_SEARCH ) )
  516. $doAdv = true;
  517. else if ( ! access_is_enabled () &&
  518. ! $is_nonuser && $login != '__public__' )
  519. $doAdv = true;
  520. }
  521. if ( $doAdv ) {
  522. jscMenu_item ( 'search.png', 'Advanced Search', 'search.php?adv=1' );
  523. jscMenu_divider ();
  524. }
  525. jscMenu_custom ( '<td class="ThemeMenuItemLeft"><img src="includes/menu/icons'
  526. . '/spacer.gif" /></td><td colspan="2"><form action="search_handler.php'
  527. . ( ! empty ( $user ) ? '?users[]=' . $user : '' ) . '" '
  528. . 'method="post"><input type="text" name="keywords" size="25" /><input '
  529. . 'type="submit" value="' . translate ( 'Search' )
  530. . '" /></form></td>' );
  531. jscMenu_close ();
  532. }
  533. // Add Menu Extra if defined.
  534. if ( ! empty ( $menuExtras[6] ) )
  535. $menuScript .= parse_menu_extras ( $menuExtras[6] );
  536. // Help Menu (Link)
  537. // translate ( 'Help Contents' ) translate ( 'About WebCalendar' )
  538. if ( $menuConfig['Help'] ) {
  539. jscMenu_menu ( 'Help' );
  540. if ( $menuConfig['Help Contents'] )
  541. jscMenu_item ( 'help.png', 'Help Contents', 'javascript:openHelp()' );
  542. if ( $menuConfig['About WebCalendar'] && $menuConfig['Help Contents'] )
  543. jscMenu_divider ();
  544. if ( $menuConfig['About WebCalendar'] )
  545. jscMenu_item ( 'k5n.png', 'About WebCalendar', 'javascript:openAbout()' );
  546. jscMenu_close ();
  547. }
  548. // Add spacer.
  549. $menuScript .= "[_cmNoAction, '<td>&nbsp;&nbsp;</td>'],";
  550. // Unapproved Icon if any exist.
  551. $unapprovedStr = display_unapproved_events ( $is_assistant || $is_nonuser_admin
  552. ? $user : $login );
  553. if ( ! empty ( $unapprovedStr ) && $unapproved_url != '' && $menuConfig['Unapproved Icon'] )
  554. jscMenu_item ( 'unapproved.png', '', $unapproved_url );
  555. // Generate Printer Friendly Icon.
  556. if ( $show_printer && $menuConfig['Printer'] )
  557. jscMenu_item ( 'printer.png', '', generate_printer_friendly (),
  558. 'cal_printer_friendly' );
  559. // Add Menu Extra if defined.
  560. if ( ! empty ( $menuExtras[7] ) )
  561. $menuScript .= parse_menu_extras ( $menuExtras[7] );
  562. $menuScript .= '];
  563. //]]> -->
  564. </script>' . "\n";
  565. $loginStr = translate ( 'Login' );
  566. $logoutStr = translate ( 'Logout' );
  567. $menuHtml .= '
  568. <table width="100%" class="ThemeMenubar" cellspacing="0" cellpadding="0" summary="">
  569. <tr>
  570. <td class="ThemeMenubackgr"><div id="myMenuID"></div></td>'
  571. . ( $MENU_DATE_TOP == 'Y' && $menuConfig['MENU_DATE_TOP'] ? '
  572. <td class="ThemeMenubackgr ThemeMenu" align="right">
  573. ' . print_menu_dates ( true ) . '
  574. </td>' : '' ) . '
  575. <td class="ThemeMenubackgr ThemeMenu" align="right">'
  576. . ( ! empty ( $logout_url ) && $menuConfig['Login'] // Using http_auth.
  577. ? '<a class="menuhref" title="'
  578. . ( strlen ( $login ) && $login != '__public__'
  579. ? $logoutStr . '" href="' . $logout_url . '">' . $logoutStr
  580. . ':</a>&nbsp;<label>'
  581. . ( $menuConfig['Login Fullname'] ? $fullname : $login ) . '</label>'
  582. : // For public user.
  583. $loginStr . '" href="' . $login_url . '">' . $loginStr . '</a>' )
  584. : '&nbsp;&nbsp;&nbsp;' // TODO replace with something???
  585. ) . '&nbsp;</td>
  586. </tr>
  587. </table>';
  588. // Add function to onload string as needed.
  589. $BodyX = ( empty ( $BodyX ) ? 'onload="' : substr ( $BodyX, 0, -1 ) )
  590. . "cmDraw( 'myMenuID', myMenu, 'hbr', cmTheme, 'Theme' );\"";
  591. /* This function allows admins to add static content to their menu.
  592. */
  593. function parse_menu_extras ( $menuA ) {
  594. $ret = '';
  595. if ( $menuA[0] == 'menu' ) {
  596. $ret .= jscMenu_menu ( $menuA[1], $menuA[2], false );
  597. if ( is_array ( $menuA[3] ) ) {
  598. foreach ( $menuA[3] as $menuB ) {
  599. if ( $menuB[0] == 'item' )
  600. $ret .= jscMenu_item ( $menuB[1], $menuB[2], $menuB[3], false, $menuB[4] );
  601. elseif ( $menuB[0] == 'submenu' ) {
  602. $ret .= jscMenu_sub_menu ( $menuB[1], $menuB[2], false );
  603. foreach ( $menuB[3] as $menuC ) {
  604. $ret .= jscMenu_item ( $menuC[1], $menuC[2], $menuC[3], false, $menuC[4] );
  605. }
  606. $ret .= jscMenu_close ();
  607. } elseif ( $menuB[0] == 'divider' )
  608. $ret .= jscMenu_divider ();
  609. elseif ( $menuB[0] == 'spacer' )
  610. $ret .= "[_cmNoAction, '<td>&nbsp;&nbsp;</td>'],";
  611. }
  612. }
  613. $ret .= jscMenu_close ();
  614. } elseif ( $menuA[0] == 'item' )
  615. $ret .= jscMenu_item ( $menuA[1], $menuA[2], $menuA[3], false, $menuA[4] );
  616. return $ret;
  617. }
  618. ?>