PageRenderTime 78ms CodeModel.GetById 36ms RepoModel.GetById 1ms app.codeStats 0ms

/WebCalendar-1.2.5/edit_entry.php

#
PHP | 1644 lines | 1573 code | 30 blank | 41 comment | 117 complexity | 0db34b9c933e1a61b76f0b20c2165b3c MD5 | raw file
Possible License(s): LGPL-2.1

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /* $Id: edit_entry.php,v 1.203.2.13 2012/02/28 02:49:39 cknudsen Exp $
  3. *
  4. * Description:
  5. * Presents page to edit/add an event/task/journal
  6. *
  7. * Notes:
  8. * A SysAdmin can enable HTML for event full descriptions. If one of the
  9. * supported HTML edit widgets is also installed, users can use WYSIWYG editing.
  10. * See the WebCalendar page at
  11. * http://www.k5n.us/webcalendar.php?topic=Add-Ons
  12. * for download and install instructions for these packages.
  13. */
  14. include_once 'includes/init.php';
  15. /* Generate HTML for a time selection for use in a form.
  16. *
  17. * @param string $prefix Prefix to use in front of form element names
  18. * @param string $time Currently selected time in HHMMSS
  19. * @param bool $trigger Add onchange event trigger that
  20. * calls javascript function $prefix_timechanged ()
  21. *
  22. * @return string HTML for the selection box
  23. */
  24. function time_selection ( $prefix, $time = '', $trigger = false ) {
  25. global $checked, $ENTRY_SLOTS, $selected, $TIME_FORMAT, $WORK_DAY_START_HOUR;
  26. $amsel = $pmsel = $ret = '';
  27. $trigger_str = ( $trigger ? 'onchange="' . $prefix . 'timechanged() ' : '' );
  28. if ( ! isset ( $time ) && $time != 0 ) {
  29. $hour = $WORK_DAY_START_HOUR;
  30. $minute = 0;
  31. } else {
  32. $hour = floor ( $time / 10000 );
  33. $minute = ( ( $time / 100 ) % 100 ) % 60;
  34. }
  35. if ( $TIME_FORMAT == '12' ) {
  36. $maxhour = 12;
  37. if ( $hour < 12 || $hour == 24 )
  38. $amsel = $checked;
  39. else
  40. $pmsel = $checked;
  41. $hour %= 12;
  42. if ( $hour == 0 )
  43. $hour = 12;
  44. } else {
  45. $maxhour = 24;
  46. $hour = sprintf ( "%02d", $hour );
  47. }
  48. $minute = sprintf ( "%02d", $minute );
  49. $ret .= '
  50. <select ' . 'name="' . $prefix . 'hour" id="' . $prefix . 'hour" '
  51. . $trigger_str . '>';
  52. for ( $i = 0; $i < $maxhour; $i++ ) {
  53. $ihour = ( $TIME_FORMAT == '24' ? sprintf ( "%02d", $i ) : $i );
  54. if ( $i == 0 && $TIME_FORMAT == '12' )
  55. $ihour = 12;
  56. $ret .= '
  57. <option value="' . "$i\"" . ( $ihour == $hour ? $selected : '' )
  58. . ">$ihour" . '</option>';
  59. }
  60. $ret .= '
  61. </select>:
  62. <select ' . 'name="' . $prefix . 'minute" id="' . $prefix
  63. . 'minute" ' . $trigger_str . '>';
  64. // We use $TIME_SLOTS to populate the minutes pulldown.
  65. $found = false;
  66. for ( $i = 0; $i < 60; ) {
  67. $imin = sprintf ( "%02d", $i );
  68. $isselected = '';
  69. if ( $imin == $minute ) {
  70. $found = true;
  71. $isselected = $selected;
  72. }
  73. $ret .= '
  74. <option value="' . "$i\"$isselected>$imin" . '</option>';
  75. $i += ( 1440 / $ENTRY_SLOTS );
  76. }
  77. // We'll add an option with the exact time if not found above.
  78. return $ret . ( $found ? '' : '
  79. <option value="' . "$minute\" $selected>$minute" . '</option>' ) . '
  80. </select>' . ( $TIME_FORMAT == '12' ? '
  81. <label><input type="radio" name="' . $prefix . 'ampm" id="'
  82. . $prefix . 'ampmA" value="0" ' . $amsel . ' />&nbsp;' . translate ( 'am' )
  83. . '</label>
  84. <label><input type="radio" name="' . $prefix . 'ampm" id="'
  85. . $prefix . 'ampmP" value="12" ' . $pmsel . ' />&nbsp;' . translate ( 'pm' )
  86. . '</label>' : '
  87. <input type="hidden" name="' . $prefix . 'ampm" value="0" />' );
  88. }
  89. $daysStr = translate ( 'days' );
  90. $hoursStr = translate ( 'hours' );
  91. $minutStr = translate ( 'minutes' );
  92. $saveStr = translate ( 'Save' );
  93. load_user_categories ();
  94. // Default for using tabs is enabled.
  95. if ( empty ( $EVENT_EDIT_TABS ) )
  96. $EVENT_EDIT_TABS = 'Y'; // default
  97. $useTabs = ( $EVENT_EDIT_TABS == 'Y' );
  98. // Make sure this is not a read-only calendar.
  99. $can_edit = false;
  100. $others_complete = 'yes';
  101. $checked = ' checked="checked"';
  102. $selected = ' selected="selected"';
  103. // Public access can only add events, not edit.
  104. if ( empty ( $login ) || ( $login == '__public__' && $id > 0 ) )
  105. $id = 0;
  106. $eType = getGetValue ( 'eType' );
  107. if ( empty ( $eType ) )
  108. $eType = 'event';
  109. $copy = getValue ( 'copy', '[01]' );
  110. $date = getValue ( 'date', '-?[0-9]+' );
  111. $day = getValue ( 'day', '-?[0-9]+' );
  112. $month = getValue ( 'month', '-?[0-9]+' );
  113. $year = getValue ( 'year', '-?[0-9]+' );
  114. if ( empty ( $date ) && empty ( $month ) ) {
  115. if ( empty ( $year ) )
  116. $year = date ( 'Y' );
  117. $month = date ( 'm' );
  118. if ( empty ( $day ) )
  119. $day = date ( 'd' );
  120. $date = sprintf ( "%04d%02d%02d", $year, $month, $day );
  121. }
  122. $BodyX = 'onload="onLoad();"';
  123. $INC = array ( 'js/edit_entry.php/false/' . $user, 'js/visible.php' );
  124. $textareasize = '15';
  125. // Can we use HTMLArea or FCKEditor? (Relax! That's the authors initials.)
  126. // Note: HTMLArea has been discontinued, so FCKEditor is preferred.
  127. $use_fckeditor = $use_htmlarea = false;
  128. if ( $ALLOW_HTML_DESCRIPTION == 'Y' ) {
  129. // Allow HTML in description.
  130. // If they have installed an HTML edit widget, make use of it.
  131. if ( file_exists ( 'includes/FCKeditor-2.0/fckeditor.js' ) &&
  132. file_exists ( 'includes/FCKeditor-2.0/fckconfig.js' ) ) {
  133. $textareasize = '20';
  134. $use_fckeditor = true;
  135. } else
  136. if ( file_exists ( 'includes/htmlarea/htmlarea.php' ) ) {
  137. $BodyX = 'onload="onLoad();initEditor();';
  138. $INC[] = 'htmlarea/core.php/true';
  139. $INC[] = 'htmlarea/htmlarea.php/true';
  140. $use_htmlarea = true;
  141. }
  142. }
  143. $byday = $bymonth = $bymonthday = $bysetpos = $participants = array ();
  144. $exceptions = $inclusions = $reminder = array ();
  145. $byweekno = $byyearday = $catList = $catNames = $external_users = $rpt_count = '';
  146. $create_by = $login;
  147. //This is the default per RFC2445
  148. //We could override it and use $byday_names[$WEEK_START]
  149. $wkst = 'MO';
  150. $real_user = ( ( ! empty ( $user ) && strlen ( $user ) ) &&
  151. ( $is_assistant || $is_admin ) ) ? $user : $login;
  152. print_header ( $INC, '', $BodyX, false, false, false, true );
  153. ob_start ();
  154. if ( $readonly == 'Y' || $is_nonuser )
  155. $can_edit = false;
  156. else
  157. if ( ! empty ( $id ) && $id > 0 ) {
  158. // First see who has access to edit this entry.
  159. if ( $is_admin )
  160. $can_edit = true;
  161. $res = dbi_execute ( 'SELECT cal_create_by, cal_date, cal_time, cal_mod_date,
  162. cal_mod_time, cal_duration, cal_priority, cal_type, cal_access, cal_name,
  163. cal_description, cal_group_id, cal_location, cal_due_date, cal_due_time,
  164. cal_completed, cal_url FROM webcal_entry WHERE cal_id = ?', array ( $id ) );
  165. if ( $res ) {
  166. $row = dbi_fetch_row ( $res );
  167. // If current user is creator of event, then they can edit.
  168. if ( $row[0] == $login )
  169. $can_edit = true;
  170. $cal_date = ( ! empty ( $override ) && ! empty ( $date )
  171. ? $date // Leave $cal_date to what was set in URL with date=YYYYMMDD.
  172. : $row[1] );
  173. $create_by = $row[0];
  174. if ( ( $user == $create_by ) && ( $is_assistant || $is_nonuser_admin ) )
  175. $can_edit = true;
  176. $cal_time = sprintf ( "%06d", $row[2] );
  177. $due_date = $row[13];
  178. $due_time = $row[14];
  179. $calTS = date_to_epoch ( $cal_date . $cal_time );
  180. // Don't adjust for All Day entries.
  181. if ( $cal_time > 0 || ( $cal_time == 0 && $row[5] != 1440 ) ) {
  182. $cal_date = date ( 'Ymd', $calTS );
  183. $cal_time = date ( 'His', $calTS );
  184. }
  185. $hour = floor ( $cal_time / 10000 );
  186. $minute = ( $cal_time / 100 ) % 100;
  187. $dueTS = date_to_epoch ( $due_date . $due_time );
  188. $due_date = date ( 'Ymd', $dueTS );
  189. $due_time = date ( 'His', $dueTS );
  190. $due_hour = floor ( $due_time / 10000 );
  191. $due_minute = ( $due_time / 100 ) % 100;
  192. $priority = $row[6];
  193. $type = $row[7];
  194. $access = $row[8];
  195. $name = $row[9];
  196. $description = $row[10];
  197. $parent = $row[11];
  198. $location = $row[12];
  199. $completed = ( empty ( $row[15] ) ? date ( 'Ymd' ) : $row[15] );
  200. $cal_url = $row[16];
  201. // What kind of entry are we dealing with?
  202. if ( strpos ( 'EM', $type ) !== false )
  203. $eType = 'event';
  204. elseif ( strpos ( 'JO', $type ) !== false )
  205. $eType = 'journal';
  206. elseif ( strpos ( 'NT', $type ) !== false )
  207. $eType = 'task';
  208. // Public access has no access to tasks.
  209. // translate ( 'You are not authorized to edit this task' )
  210. if ( $login == '__public__' && $eType == 'task' )
  211. echo str_replace ( 'XXX', translate ( 'task' ),
  212. translate ( 'You are not authorized to edit this XXX.' ) );
  213. // Check UAC.
  214. if ( access_is_enabled () )
  215. $can_edit =
  216. access_user_calendar ( 'edit', $create_by, $login, $type, $access );
  217. $day = $cal_date % 100;
  218. $month = ( $cal_date / 100 ) % 100;
  219. $year = intval ( $cal_date / 10000 );
  220. $time = $row[2];
  221. if ( $time >= 0 )
  222. $duration = $row[5];
  223. else {
  224. $duration = '';
  225. $hour = -1;
  226. }
  227. // Check for repeating event info...
  228. // but not if we're overriding a single entry of an already repeating event...
  229. // confusing, eh?
  230. if ( ! empty ( $override ) ) {
  231. $rpt_end = 0;
  232. $rpt_end_date = $cal_date;
  233. $rpt_freq = 1;
  234. $rpt_type = 'none';
  235. } else {
  236. $res = dbi_execute ( 'SELECT cal_id, cal_type, cal_end, cal_endtime,
  237. cal_frequency, cal_byday, cal_bymonth, cal_bymonthday, cal_bysetpos,
  238. cal_byweekno, cal_byyearday, cal_wkst, cal_count
  239. FROM webcal_entry_repeats WHERE cal_id = ?', array ( $id ) );
  240. if ( $res ) {
  241. if ( $row = dbi_fetch_row ( $res ) ) {
  242. $rpt_type = $row[1];
  243. $rpt_end = ( $row[2] > 0 ? date_to_epoch ( $row[2] . $row[3] ) : 0 );
  244. if ( empty ( $row[2] ) ) {
  245. $rpt_end_date = $cal_date;
  246. $rpt_end_time = $cal_time;
  247. } else {
  248. $rpt_endTS = date_to_epoch ( $row[2] . $row[3] );
  249. $rpt_end_date = date ( 'Ymd', $rpt_endTS );
  250. $rpt_end_time = date ( 'His', $rpt_endTS );
  251. }
  252. $rpt_freq = $row[4];
  253. if ( ! empty ( $row[5] ) )
  254. $byday = explode ( ',', $row[5] );
  255. $bydayStr = $row[5];
  256. if ( ! empty ( $row[6] ) )
  257. $bymonth = explode ( ',', $row[6] );
  258. if ( ! empty ( $row[7] ) )
  259. $bymonthday = explode ( ',', $row[7] );
  260. $bymonthdayStr = $row[7];
  261. if ( ! empty ( $row[8] ) )
  262. $bysetpos = explode ( ',', $row[8] );
  263. $bysetposStr = $row[8];
  264. $byweekno = $row[9];
  265. $byyearday = $row[10];
  266. $wkst = $row[11];
  267. $rpt_count = $row[12];
  268. // Check to see if Weekends Only is applicable.
  269. $weekdays_only = ( $rpt_type == 'daily' && $byday == 'MO,TU,WE,TH,FR' );
  270. }
  271. dbi_free_result ( $res );
  272. }
  273. }
  274. $res = dbi_execute ( 'SELECT cal_login, cal_percent, cal_status
  275. FROM webcal_entry_user WHERE cal_id = ?', array ( $id ) );
  276. if ( $res ) {
  277. while ( $row = dbi_fetch_row ( $res ) ) {
  278. $overall_percent[] = $row;
  279. if ( $login == $row[0] || ( $is_admin && $user == $row[0] ) ) {
  280. $task_percent = $row[1];
  281. $task_status = $row[2];
  282. }
  283. }
  284. dbi_free_result ( $res );
  285. }
  286. // Determine if Expert mode needs to be set.
  287. $expert_mode = ( count ( $byday ) || count ( $bymonth ) ||
  288. count ( $bymonthday ) || count ( $bysetpos ) ||
  289. isset ( $byweekno ) || isset ( $byyearday ) || isset ( $rpt_count ) );
  290. // Get Repeat Exceptions.
  291. $res = dbi_execute ( 'SELECT cal_date, cal_exdate
  292. FROM webcal_entry_repeats_not WHERE cal_id = ?', array ( $id ) );
  293. if ( $res ) {
  294. while ( $row = dbi_fetch_row ( $res ) ) {
  295. if ( $row[1] == 1 )
  296. $exceptions[] = $row[0];
  297. else
  298. $inclusions[] = $row[0];
  299. }
  300. dbi_free_result ( $res );
  301. }
  302. }
  303. if ( $CATEGORIES_ENABLED == 'Y' ) {
  304. $catById = get_categories_by_id ( $id, $real_user, true );
  305. if ( ! empty ( $catById ) ) {
  306. $catNames = implode ( ', ', $catById );
  307. $catList = implode ( ',', array_keys ( $catById ) );
  308. }
  309. } //end CATEGORIES_ENABLED test
  310. // Get reminders.
  311. $reminder = getReminders ( $id );
  312. $reminder_offset = ( empty ( $reminder ) ? 0 : $reminder['offset'] );
  313. $rem_status = ( count ( $reminder ));
  314. $rem_use_date = ( ! empty ( $reminder['date'] ) );
  315. // Get participants.
  316. $res = dbi_execute ( 'SELECT cal_login, cal_status FROM webcal_entry_user WHERE cal_id = ?
  317. AND cal_status IN ( \'A\', \'W\' )', array ( $id ) );
  318. if ( $res ) {
  319. while ( $row = dbi_fetch_row ( $res ) ) {
  320. $participants[$row[0]] = 1;
  321. $selectedStatus[$row[0]] = $row[1];
  322. }
  323. dbi_free_result ( $res );
  324. }
  325. // Not allowed for tasks or journals.
  326. if ( $eType == 'event' && !
  327. empty ( $ALLOW_EXTERNAL_USERS ) && $ALLOW_EXTERNAL_USERS == 'Y' )
  328. $external_users = event_get_external_users ( $id );
  329. } else {
  330. // ########## New entry ################
  331. $id = 0; // To avoid warnings below about use of undefined var.
  332. // We'll use $WORK_DAY_START_HOUR and $WORK_DAY_END_HOUR
  333. // as our starting and due times.
  334. $cal_time = $WORK_DAY_START_HOUR . '0000';
  335. $completed = '';
  336. $due_hour = $WORK_DAY_END_HOUR;
  337. $due_minute = $task_percent = 0;
  338. $due_time = $WORK_DAY_END_HOUR . '0000';
  339. $overall_percent = array ();
  340. // Get category if passed in URL as cat_id.
  341. $cat_id = getValue ( 'cat_id', '-?[0-9,\-]*', true );
  342. if ( ! empty ( $cat_id ) ) {
  343. $res = dbi_execute ( 'SELECT cat_name FROM webcal_categories
  344. WHERE cat_id = ? AND ( cat_owner = ? OR cat_owner IS NULL )',
  345. array ( $cat_id, $real_user ) );
  346. if ( $res ) {
  347. $row = dbi_fetch_row ( $res );
  348. $catNames = $row[0];
  349. $catList = $cat_id;
  350. }
  351. }
  352. // Reminder settings.
  353. $reminder_offset = ( $REMINDER_WITH_DATE == 'N' ? $REMINDER_OFFSET : 0 );
  354. $rem_status = ( $REMINDER_DEFAULT == 'Y' );
  355. $rem_use_date = ( $reminder_offset == 0 && $REMINDER_WITH_DATE == 'Y' );
  356. if ( $eType == 'task' )
  357. $hour = $WORK_DAY_START_HOUR;
  358. // Anything other then testing for strlen breaks either hour=0 or no hour in URL.
  359. if ( strlen ( $hour ) )
  360. $time = $hour * 100;
  361. else
  362. $hour = $time = -1;
  363. if ( ! empty ( $defusers ) ) {
  364. $tmp_ar = explode ( ',', $defusers );
  365. for ( $i = 0, $cnt = count ( $tmp_ar ); $i < $cnt; $i++ ) {
  366. $participants[$tmp_ar[$i]] = 1;
  367. }
  368. }
  369. //Add the logged in user if none other supplied
  370. if ( count ( $participants ) == 0 )
  371. $participants[$login] = 1;
  372. if ( $readonly == 'N' ) {
  373. // Is public allowed to add events?
  374. if ( $login == '__public__' && $PUBLIC_ACCESS_CAN_ADD != 'Y' )
  375. $can_edit = false;
  376. else
  377. $can_edit = true;
  378. }
  379. }
  380. $dateYmd = date ( 'Ymd' );
  381. $thisday = $day;
  382. $thismonth = $month;
  383. $thisyear = $year;
  384. if ( empty ( $rpt_type ) || ! $rpt_type )
  385. $rpt_type = 'none';
  386. // Avoid error for using undefined vars.
  387. if ( ! isset ( $hour ) && $hour != 0 )
  388. $hour = -1;
  389. else
  390. if ( isset ( $hour ) && $hour >= 0 )
  391. $cal_time = ( $hour * 10000 ) + ( isset ( $minute ) ? $minute * 100 : 0 );
  392. if ( empty ( $access ) )
  393. $access = '';
  394. if ( empty ( $cal_url ) )
  395. $cal_url = '';
  396. if ( empty ( $description ) || $description == '<br />' )
  397. $description = '';
  398. if ( empty ( $duration ) )
  399. $duration = 0;
  400. if ( $duration == 1440 && $time == 0 ) {
  401. $duration = $hour = $minute = '';
  402. $allday = 'Y';
  403. } else
  404. $allday = 'N';
  405. if ( empty ( $location ) )
  406. $location = '';
  407. if ( empty ( $name ) )
  408. $name = '';
  409. if ( empty ( $priority ) )
  410. $priority = 5;
  411. if ( empty ( $rpt_end_date ) )
  412. $rpt_end_date = 0;
  413. if ( empty ( $rpt_end_time ) )
  414. $rpt_end_time = 0;
  415. if ( empty ( $rpt_freq ) )
  416. $rpt_freq = 0;
  417. if ( empty ( $cal_date ) ) {
  418. $cal_date = ( ! empty ( $date ) && $eType != 'task' ? $date : $dateYmd );
  419. if ( empty ( $due_date ) )
  420. $due_date = $dateYmd;
  421. }
  422. if ( empty ( $thisyear ) )
  423. $thisdate = $dateYmd;
  424. else {
  425. $thisdate = sprintf ( "%04d%02d%02d", $thisyear,
  426. empty ( $thismonth ) ? date ( 'm' ) : $thismonth,
  427. empty ( $thisday ) ? date ( 'd' ) : $thisday );
  428. }
  429. if ( empty ( $cal_date ) || ! $cal_date )
  430. $cal_date = $thisdate;
  431. if ( empty ( $due_date ) || ! $due_date )
  432. $due_date = $thisdate;
  433. // Setup to display user's timezone difference if Admin or Assistant.
  434. // Even though event is stored in GMT,
  435. // an Assistant may need to know that the boss is in a different Timezone.
  436. if ( $is_assistant || $is_admin && ! empty ( $user ) ) {
  437. $tz_offset = date ( 'Z', date_to_epoch ( $cal_date . $cal_time ) );
  438. $user_TIMEZONE = get_pref_setting ( $user, 'TIMEZONE' );
  439. set_env ( 'TZ', $user_TIMEZONE );
  440. $user_tz_offset = date ( 'Z', date_to_epoch ( $cal_date . $cal_time ) );
  441. if ( $tz_offset != $user_tz_offset ) { // Different TZ_Offset.
  442. user_load_variables ( $user, 'temp' );
  443. $tz_diff = ( $user_tz_offset - $tz_offset ) / 3600;
  444. $abs_diff = abs ( $tz_diff );
  445. // translate ( 'is in a different timezone than you are. Currently' )
  446. // translate ( 'hour ahead of you' ) translate ( 'hour behind you' )
  447. // translate ( 'hours ahead of you' ) translate ( 'hours behind you' )
  448. // translate ( 'XXX is in a different timezone (ahead)' )
  449. // translate ( 'XXX is in a different timezone (behind)' )
  450. // Line breaks in translates below are to bypass update_translation.pl.
  451. $TZ_notice = str_replace ( 'XXX',
  452. array ( $tempfullname,
  453. // TODO show hh:mm instead of abs.
  454. $abs_diff . ' ' . translate ( 'hour'
  455. . ( $abs_diff == 1 ? '' : 's' ) ),
  456. translate ( 'Time entered here is based on your Timezone.' ) ),
  457. translate ( 'XXX is in a different timezone ('
  458. . ( $tz_diff > 0 ? 'ahead)' : 'behind)' ) ) );
  459. }
  460. // Return to $login TIMEZONE.
  461. set_env ( 'TZ', $TIMEZONE );
  462. }
  463. $eType_label = ' ( ' . translate ( $eType ) . ' )';
  464. echo '
  465. <h2>' . ( $id ? translate ( 'Edit Entry' ) : translate ( 'Add Entry' ) )
  466. . $eType_label . '&nbsp;<img src="images/help.gif" alt="' . translate ( 'Help' )
  467. . '" class="help" onclick="window.open( \'help_edit_entry.php'
  468. . ( empty ( $id ) ? '?add=1' : '' )
  469. . '\', \'cal_help\', \'dependent,menubar,scrollbars,height=400,width=400,'
  470. . 'innerHeight=420,outerWidth=420\' );" /></h2>';
  471. if ( $can_edit ) {
  472. $tabs_ar = array ( 'details', translate ( 'Details' ) );
  473. if ( $DISABLE_PARTICIPANTS_FIELD != 'Y' ) {
  474. $tabs_ar[] = 'participants';
  475. $tabs_ar[] = translate ( 'Participants' );
  476. }
  477. if ( $DISABLE_REPEATING_FIELD != 'Y' ) {
  478. $tabs_ar[] = 'pete';
  479. $tabs_ar[] = translate ( 'Repeat' );
  480. }
  481. if ( $DISABLE_REMINDER_FIELD != 'Y' ) {
  482. $tabs_ar[] = 'reminder';
  483. $tabs_ar[] = translate ( 'Reminders' );
  484. }
  485. $tabs = '';
  486. for ( $i = 0, $cnt = count ( $tabs_ar ); $i < $cnt; $i++ ) {
  487. $tabs .= '
  488. <span class="tab'
  489. . ( $i > 0 ? 'bak' : 'for' )
  490. . '" id="tab_' . $tabs_ar[$i]
  491. . '"><a href="#tab' . $tabs_ar[$i] . '" onclick="return showTab( \''
  492. . $tabs_ar[$i] . '\' )">' . $tabs_ar[++$i] . '</a></span>';
  493. }
  494. echo '
  495. <form action="edit_entry_handler.php" method="post" name="editentryform" '
  496. . 'id="editentryform">
  497. <input type="hidden" name="eType" value="' . $eType . '" />'
  498. . ( ! empty ( $id ) && ( empty ( $copy ) || $copy != '1' ) ? '
  499. <input type="hidden" name="cal_id" value="' . $id . '" />' : '' )
  500. /* We need an additional hidden input field. */ . '
  501. <input type="hidden" name="entry_changed" value="" />'
  502. // Are we overriding an entry from a repeating event...
  503. . ( empty ( $override ) ? '' : '
  504. <input type="hidden" name="override" value="1" />
  505. <input type="hidden" name="override_date" value="' . $cal_date . '" />' )
  506. // If assistant, need to remember boss = user.
  507. . ( $is_assistant || $is_nonuser_admin || ! empty ( $user ) ? '
  508. <input type="hidden" name="user" value="' . $user . '" />' : '' )
  509. // If has cal_group_id was set, need to set parent = $parent.
  510. . ( empty ( $parent ) ? '' : '
  511. <input type="hidden" name="parent" value="' . $parent . '" />' ) . '
  512. <!-- TABS -->' . ( $useTabs ? '
  513. <div id="tabs">' . $tabs . '
  514. </div>' : '' ) . '
  515. <!-- TABS BODY -->' . ( $useTabs ? '
  516. <div id="tabscontent">
  517. <!-- DETAILS -->
  518. <a name="tabdetails"></a>
  519. <div id="tabscontent_details">' : '
  520. <fieldset>
  521. <legend>' . translate ( 'Details' ) . '</legend>' ) . '
  522. <table border="0" summary="">
  523. <tr>
  524. <td style="width:14%;" class="tooltip" title="'
  525. . tooltip ( 'brief-description-help' ) . '"><label for="entry_brief">'
  526. . translate ( 'Brief Description' ) . ':</label></td>
  527. <td colspan="2"><input type="text" name="name" id="entry_brief" '
  528. . 'size="25" value="' . htmlspecialchars ( $name ) . '" /></td>
  529. </tr>
  530. <tr>
  531. <td class="tooltip aligntop" title="'
  532. . tooltip ( 'full-description-help' ) . '"><label for="entry_full">'
  533. . translate ( 'Full Description' ) . ':</label></td>
  534. <td><textarea name="description" id="entry_full" rows="'
  535. . $textareasize . '" cols="50"' . '>' . htmlspecialchars ( $description )
  536. . '</textarea></td>' . ( $use_fckeditor || $use_htmlarea ? '
  537. </tr>
  538. <tr>
  539. <td colspan="2"' : '
  540. <td' ) . ' class="aligntop">'
  541. . ( ! empty ( $categories ) || $DISABLE_ACCESS_FIELD != 'Y' ||
  542. ( $DISABLE_PRIORITY_FIELD != 'Y' )
  543. /* New table for extra fields. */ ? '
  544. <table border="0" width="90%" summary="">' : '' )
  545. . ( $DISABLE_ACCESS_FIELD != 'Y' ? '
  546. <tr>
  547. <td class="tooltip" title="' . tooltip ( 'access-help' )
  548. . '"><label for="entry_access">' . translate ( 'Access' ) . ':</label></td>
  549. <td width="80%">
  550. <select name="access" id="entry_access">
  551. <option value="P"' . ( $access == 'P' || !
  552. strlen ( $access ) ? $selected : '' ) . '>' . translate ( 'Public' )
  553. . '</option>
  554. <option value="R"' . ( $access == 'R' ? $selected : '' )
  555. . '>' . translate ( 'Private' ) . '</option>
  556. <option value="C"' . ( $access == 'C' ? $selected : '' )
  557. . '>' . translate ( 'Confidential' ) . '</option>
  558. </select>
  559. </td>
  560. </tr>' : '' );
  561. if ( $DISABLE_PRIORITY_FIELD != 'Y' ) {
  562. echo '
  563. <tr>
  564. <td class="tooltip" title="' . tooltip ( 'priority-help' )
  565. . '"><label for="entry_prio">' . translate ( 'Priority' )
  566. . ':&nbsp;</label></td>
  567. <td>
  568. <select name="priority" id="entry_prio">';
  569. $pri = array ( '',
  570. translate ( 'High' ),
  571. translate ( 'Medium' ),
  572. translate ( 'Low' ) );
  573. for ( $i = 1; $i <= 9; $i++ ) {
  574. echo '
  575. <option value="' . $i . '"'
  576. . ( $priority == $i ? $selected : '' )
  577. . '>' . $i . '-' . $pri[ceil ( $i / 3 )] . '</option>';
  578. }
  579. echo '
  580. </select>
  581. </td>
  582. </tr>';
  583. }
  584. echo ( ! empty ( $categories ) && $CATEGORIES_ENABLED == 'Y' ? '
  585. <tr>
  586. <td class="tooltip" title="' . tooltip ( 'category-help' )
  587. . '" valign="top">
  588. <label for="entry_categories">' . translate ( 'Category' )
  589. . ':<br /></label>
  590. <input type="button" value="' . translate ( 'Edit' )
  591. . '" onclick="editCats( event )" />
  592. </td>
  593. <td valign="top">
  594. <input readonly="readonly" type="text" name="catnames" '
  595. . 'id="entry_categories" value="' . $catNames
  596. . '" size="30" onclick="editCats( event )"/>
  597. <input type="hidden" name="cat_id" value="' . $catList
  598. . '" />
  599. </td>
  600. </tr>' : '' )
  601. . ( ! empty ( $categories ) || $DISABLE_ACCESS_FIELD != 'Y' ||
  602. ( $DISABLE_PRIORITY_FIELD != 'Y' ) ? '
  603. </table>' : '' );
  604. if ( $eType == 'task' ) { // Only for tasks.
  605. $completed_visible = ( strlen ( $completed ) ? 'visible' : 'hidden' );
  606. echo '<br />
  607. <table border="0" summary="">
  608. <tr id="completed">
  609. <td class="tooltip" title="' . tooltip ( 'completed-help' )
  610. . '"><label for="task_percent">' . translate ( 'Date Completed' )
  611. . ':&nbsp;</label></td>
  612. <td>' . date_selection ( 'completed_', $completed ) . '</td>
  613. </tr>
  614. <tr>
  615. <td class="tooltip" title="' . tooltip ( 'percent-help' )
  616. . '"><label for="task_percent">' . translate ( 'Percent Complete' )
  617. . ':&nbsp;</label></td>
  618. <td>
  619. <select name="percent" id="task_percent" '
  620. . 'onchange="completed_handler()">';
  621. for ( $i = 0; $i < 101; $i += 10 ) {
  622. echo '
  623. <option value="' . "$i\" "
  624. . ( $task_percent == $i ? $selected : '' )
  625. . '>' . $i . '</option>';
  626. }
  627. echo '
  628. </select>
  629. </td>
  630. </tr>';
  631. if ( ! empty ( $overall_percent ) ) {
  632. echo '
  633. <tr>
  634. <td colspan="2">
  635. <table width="100%" border="0" cellpadding="2" '
  636. . 'cellspacing="5" summary="">
  637. <tr>
  638. <td colspan="2">' . translate ( 'All Percentages' )
  639. . '</td>
  640. </tr>';
  641. $others_complete = 'yes';
  642. for ( $i = 0, $cnt = count ( $overall_percent ); $i < $cnt; $i++ ) {
  643. user_load_variables ( $overall_percent[$i][0], 'percent' );
  644. echo '
  645. <tr>
  646. <td>' . $percentfullname . '</td>
  647. <td>' . $overall_percent[$i][1] . '</td>
  648. </tr>';
  649. if ( $overall_percent[$i][0] != $real_user &&
  650. $overall_percent[$i][1] < 100 )
  651. $others_complete = 'no';
  652. }
  653. echo '
  654. </table>';
  655. }
  656. echo '
  657. </td>
  658. </tr>
  659. </table>
  660. <input type="hidden" name="others_complete" value="'
  661. . $others_complete . '" />';
  662. } //end tasks only
  663. echo '
  664. </td>
  665. </tr>' . ( $DISABLE_LOCATION_FIELD != 'Y' ? '
  666. <tr>
  667. <td class="tooltip" title="' . tooltip ( 'location-help' )
  668. . '"><label for="entry_location">' . translate ( 'Location' )
  669. . ':</label></td>
  670. <td colspan="2"><input type="text" name="location" '
  671. . 'id="entry_location" size="55" value="' . htmlspecialchars ( $location )
  672. . '" /></td>
  673. </tr>' : '' ) . ( $DISABLE_URL_FIELD != 'Y' ? '
  674. <tr>
  675. <td class="tooltip" title="' . tooltip ( 'url-help' )
  676. . '"><label for="entry_url">' . translate ( 'URL' ) . ':</label></td>
  677. <td colspan="2"><input type="text" name="entry_url" id="entry_url" '
  678. . 'size="100" value="' . htmlspecialchars ( $cal_url ) . '" /></td>
  679. </tr>' : '' ) . '
  680. <tr>
  681. <td class="tooltip" title="' . tooltip ( 'date-help' )
  682. . '"><label>'
  683. . ( $eType == 'task' ? translate ( 'Start Date' ) : translate ( 'Date' ) )
  684. . ':</label></td>
  685. <td colspan="2">' . date_selection ( '', $cal_date ) . '</td>
  686. </tr>
  687. <tr>
  688. <td';
  689. if ( $eType != 'task' ) {
  690. $dur_h = intval ( $duration / 60 );
  691. echo '>&nbsp;</td>
  692. <td colspan="2">
  693. <select name="timetype" onchange="timetype_handler()">
  694. <option value="U" '
  695. . ( $allday != 'Y' && $hour == -1 ? $selected : '' ) . '>'
  696. . translate ( 'Untimed event' ) . '</option>
  697. <option value="T" '
  698. . ( $allday != 'Y' && $hour >= 0 ? $selected : '' ) . '>'
  699. . translate ( 'Timed event' ) . '</option>
  700. <option value="A" '
  701. . ( $allday == 'Y' ? $selected : '' ) . '>'
  702. . translate ( 'All day event' ) . '</option>
  703. </select>
  704. </td>
  705. </tr>' . ( empty ( $TZ_notice ) ? '' : '
  706. <tr id="timezonenotice">
  707. <td class="tooltip" title="'
  708. . tooltip ( 'Time entered here is based on your Timezone.' ) . '">'
  709. . translate ( 'Timezone Offset' ) . ':</td>
  710. <td colspan="2">' . $TZ_notice . '</td>
  711. </tr>' ) . '
  712. <tr id="timeentrystart" style="visibility:hidden;">
  713. <td class="tooltip" title="' . tooltip ( 'time-help' ) . '">'
  714. . translate ( 'Time' ) . ':' . '</td>
  715. <td colspan="2">' . time_selection ( 'entry_', $cal_time );
  716. if ( $TIMED_EVT_LEN != 'E' ) {
  717. echo '
  718. </td>
  719. </tr>
  720. <tr id="timeentryduration" style="visibility:hidden;">
  721. <td><span class="tooltip" title="' . tooltip ( 'duration-help' )
  722. . '">' . translate ( 'Duration' ) . ':&nbsp;</span></td>
  723. <td colspan="2">
  724. <input type="text" name="duration_h" id="duration_h" size="2" '
  725. . 'maxlength="2" value="';
  726. if ( $allday != 'Y' )
  727. printf ( "%d", $dur_h );
  728. echo '" />:
  729. <input type="text" name="duration_m" id="duration_m" size="2" '
  730. . 'maxlength="2" value="';
  731. if ( $allday != 'Y' )
  732. printf ( "%02d", $duration - ( $dur_h * 60 ) );
  733. echo '" />&nbsp;(<label for="duration_h">' . $hoursStr
  734. . '</label>: <label for="duration_m">' . $minutStr
  735. . '</label>)
  736. </td>
  737. </tr>';
  738. } else
  739. echo '
  740. <span id="timeentryend" class="tooltip" title="'
  741. . tooltip ( 'end-time-help' ) . '">&nbsp;-&nbsp;'
  742. . time_selection ( 'end_',
  743. ( $id ? add_duration ( $cal_time, $duration ) : $cal_time ) ) . '</span>
  744. </td>
  745. </tr>';
  746. } else { // eType == task
  747. echo ' class="tooltip" title="' . tooltip ( 'time-help' ) . '">'
  748. . translate ( 'Start Time' ) . ':</td>
  749. <td colspan="2">' . time_selection ( 'entry_', $cal_time ) . '</td>
  750. </tr>
  751. <tr>
  752. <td colspan="3">&nbsp;</td>
  753. </tr>
  754. <tr>
  755. <td class="tooltip" title="' . tooltip ( 'date-help' ) . '">'
  756. . translate ( 'Due Date' ) . ':</td>
  757. <td colspan="2">' . date_selection ( 'due_', $due_date ) . '</td>
  758. </tr>
  759. <tr>
  760. <td class="tooltip" title="' . tooltip ( 'time-help' ) . '">'
  761. . translate ( 'Due Time' ) . ':</td>
  762. <td colspan="2">' . time_selection ( 'due_', $due_time ) . '</td>
  763. </tr>';
  764. }
  765. // Site-specific extra fields (see site_extras.php).
  766. // load and display any site-specific fields.
  767. if ( $id > 0 )
  768. $extras = get_site_extra_fields ( $id );
  769. $site_extracnt = count ( $site_extras );
  770. echo '
  771. </table>' . ( $site_extracnt ? ( ! empty ( $site_extras[0]['FIELDSET'] ) ? '
  772. <div>
  773. <fieldset>
  774. <legend>' . translate ( 'Site Extras' ) . '</legend>' : '' ) . '
  775. <table summary="">' : '' );
  776. for ( $i = 0; $i < $site_extracnt; $i++ ) {
  777. if ( $site_extras[$i] == 'FIELDSET' )
  778. continue;
  779. $extra_name = $site_extras[$i][0];
  780. $extra_descr = $site_extras[$i][1];
  781. $extra_type = $site_extras[$i][2];
  782. $extra_arg1 = $site_extras[$i][3];
  783. $extra_arg2 = $site_extras[$i][4];
  784. // Default value if needed.
  785. $defIdx = ( empty ( $extras[$extra_name]['cal_data'] )
  786. ? $extra_arg2 : $extras[$extra_name]['cal_data'] );
  787. echo '
  788. <tr>
  789. <td class="aligntop bold">'
  790. . ( $extra_type == EXTRA_MULTILINETEXT ? '<br />' : '' )
  791. . translate ( $extra_descr ) . ':</td>
  792. <td>';
  793. if ( $extra_type == EXTRA_URL )
  794. echo '
  795. <input type="text" size="50" name="' . $extra_name . '" value="'
  796. . ( empty ( $extras[$extra_name]['cal_data'] )
  797. ? '' : htmlspecialchars ( $extras[$extra_name]['cal_data'] ) ) . '" />';
  798. elseif ( $extra_type == EXTRA_EMAIL )
  799. echo '
  800. <input type="text" size="30" name="' . $extra_name . '" value="'
  801. . ( empty ( $extras[$extra_name]['cal_data'] )
  802. ? '' : htmlspecialchars ( $extras[$extra_name]['cal_data'] ) ) . '" />';
  803. elseif ( $extra_type == EXTRA_DATE )
  804. echo date_selection ( $extra_name,
  805. ( empty ( $extras[$extra_name]['cal_date'] )
  806. ? $cal_date : $extras[$extra_name]['cal_date'] ) );
  807. elseif ( $extra_type == EXTRA_TEXT ) {
  808. $size = ( $extra_arg1 > 0 ? $extra_arg1 : 50 );
  809. echo '
  810. <input type="text" size="' . $size . '" name="' . $extra_name
  811. . '" value="' . ( empty ( $extras[$extra_name]['cal_data'] )
  812. ? '' : htmlspecialchars ( $extras[$extra_name]['cal_data'] ) ) . '" />';
  813. } elseif ( $extra_type == EXTRA_MULTILINETEXT )
  814. echo '
  815. <textarea rows="' . ( $extra_arg2 > 0 ? $extra_arg2 : 5 )
  816. . '" cols="' . ( $extra_arg1 > 0 ? $extra_arg1 : 50 ) . '" name="'
  817. . $extra_name . '">' . ( empty ( $extras[$extra_name]['cal_data'] )
  818. ? '' : htmlspecialchars ( $extras[$extra_name]['cal_data'] ) )
  819. . '</textarea>';
  820. elseif ( $extra_type == EXTRA_USER ) {
  821. // Show list of calendar users...
  822. echo '
  823. <select name="' . $extra_name . '">
  824. <option value="">None</option>';
  825. $userlist = get_my_users ( get_my_users );
  826. $usercnt = count ( $userlist );
  827. for ( $j = 0; $j < $usercnt; $j++ ) {
  828. if ( access_is_enabled () && !
  829. access_user_calendar ( 'view', $userlist[$j]['cal_login'] ) )
  830. continue; // Cannot view calendar so cannot add to their cal.
  831. echo '
  832. <option value="' . $userlist[$j]['cal_login'] . '"'
  833. . ( ! empty ( $extras[$extra_name]['cal_data'] ) &&
  834. ( $userlist[$j]['cal_login'] == $extras[$extra_name]['cal_data'] )
  835. ? $selected : '' )
  836. . '>' . $userlist[$j]['cal_fullname'] . '</option>';
  837. }
  838. echo '
  839. </select>';
  840. } elseif ( $extra_type == EXTRA_SELECTLIST ) {
  841. // Show custom select list.
  842. $extraSelectArr = $isMultiple = $multiselect = '';
  843. if ( is_array ( $extra_arg1 ) ) {
  844. $extra_arg1cnt = count ( $extra_arg1 );
  845. if ( $extra_arg2 > 0 ) {
  846. $multiselect = ' multiple="multiple" size="'
  847. . min ( $extra_arg2, $extra_arg1cnt ) . '" ';
  848. $isMultiple = '[]';
  849. if ( ! empty ( $extras ) )
  850. $extraSelectArr = explode ( ',', $extras[$extra_name]['cal_data'] );
  851. }
  852. echo '
  853. <select name="' . $extra_name . $isMultiple . '"'
  854. . $multiselect . '>';
  855. for ( $j = 0; $j < $extra_arg1cnt; $j++ ) {
  856. echo '
  857. <option value="' . $extra_arg1[$j] . '" ';
  858. if ( ! empty ( $extras[$extra_name]['cal_data'] ) ) {
  859. if ( $extra_arg2 == 0 &&
  860. $extra_arg1[$j] == $extras[$extra_name]['cal_data'] )
  861. echo $selected;
  862. else
  863. if ( $extra_arg2 > 0 &&
  864. in_array ( $extra_arg1[$j], $extraSelectArr ) )
  865. echo $selected;
  866. } else
  867. echo ( $j == 0 ? $selected : '' );
  868. echo '>' . $extra_arg1[$j] . '</option>';
  869. }
  870. }
  871. echo '
  872. </select>';
  873. } elseif ( $extra_type == EXTRA_RADIO )
  874. // Show custom radio selections.
  875. echo print_radio ( $extra_name, $extra_arg1, '', $defIdx );
  876. elseif ( $extra_type == EXTRA_CHECKBOX )
  877. // Show custom checkbox option.
  878. echo print_checkbox ( array ( $extra_name, $extra_arg1, '', $defIdx ) );
  879. echo '
  880. </td>
  881. </tr>';
  882. }
  883. if ( $site_extracnt ) {
  884. echo '
  885. </table>' . ( empty ( $site_extras[0]['FIELDSET'] ) ? '' : '
  886. </fieldset>
  887. </div>' );
  888. }
  889. // end site-specific extra fields
  890. echo ( $useTabs ? '
  891. </div>' : '
  892. </fieldset>' ) . '
  893. <!-- PARTICIPANTS -->' . ( $useTabs ? '
  894. <a name="tabparticipants"></a>
  895. <div id="tabscontent_participants">' : '
  896. <fieldset>
  897. <legend>' . translate ( 'Participants' ) . '</legend>' ) . '
  898. <table>';
  899. // .
  900. // Only ask for participants if we are multi-user.
  901. $show_participants = ( $DISABLE_PARTICIPANTS_FIELD != 'Y' );
  902. if ( $is_admin )
  903. $show_participants = true;
  904. if ( $login == '__public__' && $PUBLIC_ACCESS_OTHERS != 'Y' )
  905. $show_participants = false;
  906. if ( $single_user == 'N' && $show_participants ) {
  907. $userlist = get_my_users ( $create_by, 'invite' );
  908. if ( $NONUSER_ENABLED == 'Y' ) {
  909. // Include public NUCs.
  910. $nonusers = get_my_nonusers ( $real_user, false );
  911. $userlist = ( $NONUSER_AT_TOP == 'Y'
  912. ? array_merge ( $nonusers, $userlist )
  913. : array_merge ( $userlist, $nonusers ) );
  914. }
  915. $num_users = $size = 0;
  916. $usercnt = count ( $userlist );
  917. $users = '';
  918. for ( $i = 0; $i < $usercnt; $i++ ) {
  919. $l = $userlist[$i]['cal_login'];
  920. $size++;
  921. $users .= '
  922. <option value="' . $l . '"';
  923. if ( $id > 0 ) {
  924. if ( ! empty ( $participants[$l] ) )
  925. $users .= $selected;
  926. } else {
  927. if ( ! empty ( $defusers ) && ! empty ( $participants[$l] ) )
  928. // Default selection of participants was in the URL.
  929. $users .= $selected;
  930. if ( ( $l == $login && ! $is_assistant && ! $is_nonuser_admin ) ||
  931. ( ! empty ( $user ) && $l == $user ) )
  932. $users .= $selected;
  933. if ( $l == '__public__' && !
  934. empty ( $PUBLIC_ACCESS_DEFAULT_SELECTED ) &&
  935. $PUBLIC_ACCESS_DEFAULT_SELECTED == 'Y' )
  936. $users .= $selected;
  937. }
  938. $users .= '>' . $userlist[$i]['cal_fullname'] . '</option>';
  939. }
  940. if ( $size > 50 )
  941. $size = 50;
  942. elseif ( $size > 20 )
  943. $size = 20;
  944. elseif ( $size > 5 )
  945. $size = 5;
  946. echo '
  947. <tr title="' . tooltip ( 'participants-help' ) . '">
  948. <td class="tooltipselect"><label for="entry_part">'
  949. . translate ( 'Participants' ) . ':</label></td>
  950. <td>
  951. <select name="participants[]" id="entry_part" size="' . $size
  952. . '" multiple="multiple">' . $users . '
  953. </select>' . ( $GROUPS_ENABLED == 'Y' ? '
  954. <input type="button" onclick="selectUsers()" value="'
  955. . translate ( 'Select' ) . '..." />' : '' ) . '
  956. <input type="button" onclick="showSchedule()" value="'
  957. . translate ( 'Availability' ) . '..." />
  958. </td>
  959. </tr>'
  960. // External users.
  961. . ( ! empty ( $ALLOW_EXTERNAL_USERS ) && $ALLOW_EXTERNAL_USERS == 'Y' ? '
  962. <tr title="' . tooltip ( 'external-participants-help' ) . '">
  963. <td class="tooltip aligntop"><label for="entry_extpart">'
  964. . translate ( 'External Participants' ) . ':</label></td>
  965. <td><textarea name="externalparticipants" id="entry_extpart" rows="5" '
  966. . 'cols="40">' . $external_users . '</textarea></td>
  967. </tr>' : '' );
  968. }
  969. echo '
  970. </table>' . ( $useTabs ? '
  971. </div>' : '
  972. </fieldset>' ) . '
  973. <!-- REPEATING INFO -->';
  974. if ( $DISABLE_REPEATING_FIELD != 'Y' ) {
  975. echo ( $useTabs ? '
  976. <a name="tabpete"></a>
  977. <div id="tabscontent_pete">' : '
  978. <fieldset>
  979. <legend>' . translate ( 'Repeat' ) . '</legend>' ) . '
  980. <table border="0" cellspacing="0" cellpadding="3" summary="">
  981. <tr>
  982. <td class="tooltip" title="' . tooltip ( 'repeat-type-help' )
  983. . '"><label for="rpttype">' . translate ( 'Type' ) . ':</label></td>
  984. <td colspan="2">
  985. <select name="rpt_type" id="rpttype" '
  986. . 'onchange="rpttype_handler(); rpttype_weekly()">
  987. <option value="none"' . ( strcmp ( $rpt_type, 'none' ) == 0
  988. ? $selected : '' ) . '>' . translate ( 'None' ) . '</option>
  989. <option value="daily"' . ( strcmp ( $rpt_type, 'daily' ) == 0
  990. ? $selected : '' ) . '>' . translate ( 'Daily' ) . '</option>
  991. <option value="weekly"' . ( strcmp ( $rpt_type, 'weekly' ) == 0
  992. ? $selected : '' ) . '>' . translate ( 'Weekly' ) . '</option>
  993. <option value="monthlyByDay"'
  994. . ( strcmp ( $rpt_type, 'monthlyByDay' ) == 0 ? $selected : '' )
  995. // translate ( 'Monthly' ) translate ( 'by day' ) translate ( 'by date' )
  996. // translate ( 'by position' )
  997. . '>' . translate ( 'Monthly (by day)' ) . '</option>
  998. <option value="monthlyByDate"'
  999. . ( strcmp ( $rpt_type, 'monthlyByDate' ) == 0 ? $selected : '' )
  1000. . '>' . translate ( 'Monthly (by date)' ) . '</option>
  1001. <option value="monthlyBySetPos"'
  1002. . ( strcmp ( $rpt_type, 'monthlyBySetPos' ) == 0 ? $selected : '' )
  1003. . '>' . translate ( 'Monthly (by position)' ) . '</option>
  1004. <option value="yearly"' . ( strcmp ( $rpt_type, 'yearly' ) == 0
  1005. ? $selected : '' ) . '>' . translate ( 'Yearly' ) . '</option>
  1006. <option value="manual"'
  1007. . ( strcmp ( $rpt_type, 'manual' ) == 0 ? $selected : '' )
  1008. . '>' . translate ( 'Manual' ) . '</option>
  1009. </select>&nbsp;&nbsp;&nbsp;<label id="rpt_mode"><input '
  1010. . 'type="checkbox" name="rptmode" id="rptmode" value="y" '
  1011. . 'onclick="rpttype_handler()" '
  1012. . ( empty ( $expert_mode ) ? '' : $checked )
  1013. . '/>' . translate ( 'Expert Mode' ) . '</label>
  1014. </td>
  1015. </tr>
  1016. <tr id="rptenddate1" style="visibility:hidden;">
  1017. <td class="tooltip" title="' . tooltip ( 'repeat-end-date-help' )
  1018. . '" rowspan="3"><label for="rpt_day">' . translate ( 'Ending' )
  1019. . ':</label></td>
  1020. <td colspan="2" class="boxtop boxright boxleft"><input type="radio" '
  1021. . 'name="rpt_end_use" id="rpt_untilf" value="f" '
  1022. . ( empty ( $rpt_end ) && empty ( $rpt_count ) ? $checked : '' )
  1023. . ' onclick="toggle_until()" /><label for="rpt_untilf">'
  1024. . translate ( 'Forever' ) . '</label></td>
  1025. </tr>
  1026. <tr id="rptenddate2" style="visibility:hidden;">
  1027. <td class="boxleft"><input type="radio" name="rpt_end_use" '
  1028. . 'id="rpt_untilu" value="u" ' . ( empty ( $rpt_end ) ? '' : $checked )
  1029. . ' onclick="toggle_until()" />&nbsp;<label for="rpt_untilu">'
  1030. . translate ( 'Use end date' ) . '</label></td>
  1031. <td class="boxright"><span class="end_day_selection" '
  1032. . 'id="rpt_end_day_select">'
  1033. . date_selection ( 'rpt_', ( $rpt_end_date ? $rpt_end_date : $cal_date ) )
  1034. . '</span><span id="rpt_until_time_date"><br />' . time_selection ( 'rpt_', $rpt_end_time ) . '</span></td>
  1035. </tr>
  1036. <tr id="rptenddate3" style="visibility:hidden;">
  1037. <td class="boxbottom boxleft"><input type="radio" name="rpt_end_use" '
  1038. . 'id="rpt_untilc" value="c" ' . ( empty ( $rpt_count ) ? '' : $checked )
  1039. . ' onclick="toggle_until()" />&nbsp;<label for="rpt_untilc">'
  1040. . translate ( 'Number of times' ) . '</label></td>
  1041. <td class="boxright boxbottom"><input type="text" name="rpt_count" '
  1042. . 'id="rpt_count" size="4" maxlength="4" value="' . $rpt_count . '" /></td>
  1043. </tr>
  1044. <tr id="rptfreq" style="visibility:hidden;" title="'
  1045. . tooltip ( 'repeat-frequency-help' ) . '">
  1046. <td class="tooltip"><label for="entry_freq">'
  1047. . translate ( 'Frequency' ) . ':</label></td>
  1048. <td colspan="2">
  1049. <input type="text" name="rpt_freq" id="entry_freq" size="4" '
  1050. . 'maxlength="4" value="' . $rpt_freq . '" />&nbsp;&nbsp;&nbsp;&nbsp;
  1051. <label id="weekdays_only"><input type="checkbox" '
  1052. . 'name="weekdays_only" value="y" '
  1053. . ( empty ( $weekdays_only ) ? '' : $checked ) . ' />'
  1054. . translate ( 'Weekdays Only' )
  1055. . '</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  1056. <span id="rptwkst">
  1057. <select name="wkst">';
  1058. for ( $i = 0; $i < 7; $i++ ) {
  1059. echo '
  1060. <option value="' . $byday_names[$i] . '" '
  1061. . ( $wkst ==$byday_names[$i] ? $selected : '' )
  1062. . '>' . translate ( $byday_names[$i] ) . '</option>';
  1063. }
  1064. echo '
  1065. </select>&nbsp;&nbsp;<label for="rptwkst">'
  1066. . translate ( 'Week Start' ) . '</label>
  1067. </span>
  1068. </td>
  1069. </tr>
  1070. <tr>
  1071. <td colspan="4"></td>
  1072. </tr>
  1073. <tr id="rptbydayextended" style="visibility:hidden;" title="'
  1074. . tooltip ( 'repeat-bydayextended-help' ) . '">
  1075. <td class="tooltip"><label>' . translate ( 'ByDay' ) . ':</label></td>
  1076. <td colspan="2" class="boxall">
  1077. <input type="hidden" name="bydayList" value="'
  1078. . ( empty ( $bydayStr ) ? '' : $bydayStr ) . '" />
  1079. <input type="hidden" name="bymonthdayList" value="'
  1080. . ( empty ( $bymonthdayStr ) ? '' : $bymonthdayStr ) . '" />
  1081. <input type="hidden" name="bysetposList" value="'
  1082. . ( empty ( $bysetposStr ) ? '' : $bysetposStr ) . '" />
  1083. <table class="byxxx" cellpadding="2" cellspacing="2" '
  1084. . 'border="1" summary="">
  1085. <tr>
  1086. <td></td>';
  1087. // Display byday extended selection.
  1088. // We use BUTTONS in a triple state configuration, and store the values in
  1089. // a javascript array until form submission. We then set the hidden field
  1090. // bydayList to the string value of the array.
  1091. for ( $rpt_byday_label = $WEEK_START;
  1092. $rpt_byday_label <= ( $WEEK_START + 6); $rpt_byday_label++ ) {
  1093. $rpt_byday_mod = $rpt_byday_label %7;
  1094. $class = ( is_weekend ( $rpt_byday_mod ) ? ' class="weekend" ' : '' );
  1095. echo '
  1096. <th width="50px"' .$class . '><label>'
  1097. . translate ( $weekday_names[$rpt_byday_mod] ) . '</label></th>';
  1098. }
  1099. echo '
  1100. </tr>
  1101. <tr>
  1102. <th>' . translate ( 'All' ) . '</th>';
  1103. for ( $rpt_byday_single = $WEEK_START;
  1104. $rpt_byday_single <= ( $WEEK_START + 6); $rpt_byday_single++ ) {
  1105. $rpt_byday_mod = $rpt_byday_single %7;
  1106. echo '
  1107. <td><input type="checkbox" name="bydayAll[]" id="'
  1108. . $byday_names[$rpt_byday_mod] . '" value="'
  1109. . "$byday_names[$rpt_byday_mod]\""
  1110. . ( in_array ( $byday_names[$rpt_byday_mod], $byday ) ? $checked : '' )
  1111. . ' /></td>';
  1112. }
  1113. echo '
  1114. </tr>
  1115. <tr id="rptbydayln" style="visibility:hidden;">';
  1116. for ( $loop_ctr = 1; $loop_ctr < 6; $loop_ctr++ ) {
  1117. echo '
  1118. <th><label>' . $loop_ctr . '/' . ( $loop_ctr - 6 )
  1119. . '</label></th>';
  1120. for ( $rpt_byday = $WEEK_START;
  1121. $rpt_byday <= ( $WEEK_START + 6); $rpt_byday++ ) {
  1122. $rpt_byday_mod = $rpt_byday %7;
  1123. $buttonvalue = ( in_array ( $loop_ctr
  1124. . $byday_names[$rpt_byday_mod], $byday )
  1125. ? $loop_ctr . translate ( $byday_names[$rpt_byday_mod] )
  1126. : ( in_array ( ( $loop_ctr - 6 )
  1127. . $byday_names[$rpt_byday_mod], $byday )
  1128. ? ( $loop_ctr - 6 )
  1129. . translate ( $byday_names[$rpt_byday_mod] ) : ' ' ) );
  1130. echo '
  1131. <td><input type="button" name="byday" id="_' . $loop_ctr
  1132. . $rpt_byday_mod . '" value="' . $buttonvalue
  1133. . '" onclick="toggle_byday( this )" /></td>';
  1134. }
  1135. echo '
  1136. </tr>';
  1137. if ( $loop_ctr < 5 )
  1138. echo '
  1139. <tr id="rptbydayln' . $loop_ctr . '" style="visibility:hidden;">';
  1140. }
  1141. echo '
  1142. </table>
  1143. </td>
  1144. </tr>
  1145. <tr>
  1146. <td colspan="4"></td>
  1147. </tr>
  1148. <tr id="rptbymonth" style="visibility:hidden;" title="'
  1149. . tooltip ( 'repeat-month-help' ) . '">
  1150. <td class="tooltip">' . translate ( 'ByMonth' ) . ':&nbsp;</td>
  1151. <td colspan="2" class="boxall">'
  1152. /* Display bymonth selection. */ . '
  1153. <table cellpadding="5" cellspacing="0" summary="">
  1154. <tr>';
  1155. for ( $rpt_month = 1; $rpt_month < 13; $rpt_month++ ) {
  1156. echo '
  1157. <td><label><input type="checkbox" name="bymonth[]" value="'
  1158. . $rpt_month . '"' . ( in_array ( $rpt_month, $bymonth ) ? $checked : '' )
  1159. . ' />&nbsp;' . translate (
  1160. date ( 'M', mktime ( 0, 0, 0, $rpt_month, 1 ) ) )
  1161. . '</label></td>' . ( $rpt_month == 6 ? '
  1162. </tr>
  1163. <tr>' : '' );
  1164. }
  1165. echo '
  1166. </tr>
  1167. </table>
  1168. </td>
  1169. </tr>
  1170. <tr>
  1171. <td colspan="4"></td>
  1172. </tr>
  1173. <tr id="rptbysetpos" style="visibility:hidden;" title="'
  1174. . tooltip ( 'repeat-bysetpos-help' ) . '">
  1175. <td class="tooltip" id="BySetPoslabel">' . translate ( 'BySetPos' )
  1176. . ':&nbsp;</td>
  1177. <td colspan="2" class="boxall">'
  1178. /* Display bysetpos selection. */ . '
  1179. <table class="byxxx" cellpadding="2" cellspacing="0" '
  1180. . 'border="1" summary="">
  1181. <tr>
  1182. <td></td>';
  1183. for ( $rpt_bysetpos_label = 1; $rpt_bysetpos_label < 11;
  1184. $rpt_bysetpos_label++ ) {
  1185. echo '
  1186. <th width="37px"><label>' . $rpt_bysetpos_label
  1187. . '</label></th>';
  1188. }
  1189. echo '
  1190. </tr>
  1191. <tr>';
  1192. for ( $loop_ctr = 1; $loop_ctr < 32; $loop_ctr++ ) {
  1193. $buttonvalue = ( in_array ( $loop_ctr, $bysetpos )
  1194. ? ( $loop_ctr ) : ( in_array ( ( $loop_ctr -32 ), $bysetpos )
  1195. ? ( $loop_ctr -32 ) : ' ' ) );
  1196. echo ( $loop_ctr == 1 || $loop_ctr == 11 || $loop_ctr == 21 ? '
  1197. <th><label>' . $loop_ctr . '-' . ( $loop_ctr + 9 )
  1198. . '</label></th>' : '' ) . ( $loop_ctr == 31 ? '
  1199. <th><label>31</label></th>' : '' ) . '
  1200. <td><input type="button" name="bysetpos" id="bysetpos'
  1201. . $loop_ctr . '" value="' . $buttonvalue
  1202. . '" onclick="toggle_bysetpos( this )" /></td>'
  1203. . ( $loop_ctr % 10 == 0 ? '
  1204. </tr>
  1205. <tr>' : '' );
  1206. }
  1207. echo '
  1208. </tr>
  1209. </table>
  1210. </td>
  1211. </tr>
  1212. <tr>
  1213. <td colspan="4"></td>
  1214. </tr>
  1215. <tr id="rptbymonthdayextended" style="visibility:hidden;" title="'
  1216. . tooltip ( 'repeat-bymonthdayextended-help' ) . '">
  1217. <td class="tooltip" id="ByMonthDaylabel">' . translate ( 'ByMonthDay' )
  1218. . ':&nbsp;</td>
  1219. <td colspan="2" class="boxall">

Large files files are truncated, but you can click here to view the full file