function search_form() { global $day, $month, $year, $phpc_script, $month_names, $sort_options, $order_options; $day_sequence = create_sequence(1, 31); $month_sequence = create_sequence(1, 12); $year_sequence = create_sequence(1970, 2037); $html_table = tag('table', attributes('class="phpc-main"'), tag('caption', _('Search')), tag('tfoot', tag('tr', tag('td', attributes('colspan="2"'), create_submit(_('Submit'))))), tag('tr', tag('td', _('Phrase') . ': '), tag('td', tag('input', attributes('type="text"', 'name="searchstring"', 'size="32"')), create_hidden('action', 'search'))), tag('tr', tag('td', _('From') . ': '), tag('td', create_select('sday', $day_sequence, $day), create_select('smonth', $month_names, $month), create_select('syear', $year_sequence, $year))), tag('tr', tag('td', _('To') . ': '), tag('td', create_select('eday', $day_sequence, $day), create_select('emonth', $month_names, $month), create_select('eyear', $year_sequence, $year))), tag('tr', tag('td', _('Sort By') . ': '), tag('td', create_select('sort', $sort_options, false))), tag('tr', tag('td', _('Order') . ': '), tag('td', create_select('order', $order_options, false)))); return tag('form', attributes("action=\"{$phpc_script}\"", 'method="post"'), $html_table); }
function login_form() { global $vars, $phpc_script; $submit_data = tag('td', attributes('colspan="2"'), create_hidden('action', 'login'), create_submit(__('Log in'))); if (!empty($vars['lasturl'])) { $submit_data->prepend(create_hidden('lasturl', escape_entities(urlencode($vars['lasturl'])))); } return tag('form', attributes("action=\"{$phpc_script}\"", 'method="post"'), tag('table', tag('caption', __('Log in')), tag('thead', tag('tr', tag('th', attributes('colspan="2"'), __('You must have cookies enabled to login.')))), tag('tfoot', tag('tr', $submit_data)), tag('tbody', tag('tr', tag('th', __('Username')), tag('td', create_text('username'))), tag('tr', tag('th', __('Password')), tag('td', create_password('password')))))); }
function display_form() { global $phpc_script, $phpc_token; $tbody = tag('tbody'); foreach (get_config_options() as $element) { $text = $element[1]; $input = create_config_input($element); $tbody->add(tag('tr', tag('th', $text), tag('td', $input))); } return tag('form', attributes("action=\"{$phpc_script}\"", 'method="post"'), tag('table', attributes("class=\"phpc-container\""), tag('caption', __('Create Calendar')), tag('tfoot', tag('tr', tag('td', attributes('colspan="2"'), create_hidden('phpc_token', $phpc_token), create_hidden('action', 'calendar_form'), create_hidden('submit_form', 'submit_form'), create_submit(__('Submit'))))), $tbody)); }
function config_form() { global $phpc_script, $phpc_user_tz, $phpc_user_lang, $phpc_token; $tz_input = create_multi_select('timezone', get_timezone_list(), $phpc_user_tz); $languages = array("" => __("Default")); foreach (get_languages() as $lang) { $languages[$lang] = $lang; } $lang_input = create_select('language', $languages, $phpc_user_lang); $form = tag('form', attributes("action=\"{$phpc_script}\"", 'method="post"'), tag('table', attributes("class=\"phpc-container\""), tag('caption', __('Settings')), tag('tfoot', tag('tr', tag('td', attributes('colspan="2"'), create_hidden('phpc_token', $phpc_token), create_hidden('action', 'settings'), create_hidden('phpc_submit', 'settings'), create_submit(__('Submit'))))), tag('tbody', tag('tr', tag('th', __('Timezone')), tag('td', $tz_input)), tag('tr', tag('th', __('Language')), tag('td', $lang_input))))); return tag('div', attrs('id="phpc-config"'), $form); }
function display_form() { global $phpc_script, $phpc_token, $phpcdb; $groups = array(); foreach ($phpcdb->get_groups() as $group) { $groups[$group['gid']] = $group['name']; } $size = sizeof($groups); if ($size > 6) { $size = 6; } return tag('form', attributes("action=\"{$phpc_script}\"", 'method="post"'), tag('table', attributes("class=\"phpc-container\""), tag('caption', __('Create User')), tag('tfoot', tag('tr', tag('td', attributes('colspan="2"'), create_hidden('phpc_token', $phpc_token), create_hidden('action', 'user_create'), create_hidden('submit_form', 'submit_form'), create_submit(__('Submit'))))), tag('tbody', tag('tr', tag('th', __('User Name')), tag('td', create_text('user_name'))), tag('tr', tag('th', __('Password')), tag('td', create_password('password1'))), tag('tr', tag('th', __('Confirm Password')), tag('td', create_password('password2'))), tag('tr', tag('th', __('Make Admin')), tag('td', create_checkbox('make_admin', '1', false, __('Admin')))), tag('tr', tag('th', __('Groups')), tag('td', create_select('groups[]', $groups, false, attrs('multiple', "size=\"{$size}\""))))))); }
function display_form() { global $phpc_script, $phpc_token, $phpcdb, $vars, $phpc_cal; $groups = array(); foreach ($phpc_cal->get_groups() as $group) { $groups[$group['gid']] = $group['name']; } $size = sizeof($groups); if ($size > 6) { $size = 6; } $user = $phpcdb->get_user($vars["uid"]); $user_groups = array(); foreach ($user->get_groups() as $group) { $user_groups[] = $group['gid']; } return tag('form', attributes("action=\"{$phpc_script}\"", 'method="post"'), tag('div', attributes("class=\"phpc-container\""), tag('h2', __('Edit User Groups')), tag('div', create_select('groups[]', $groups, $user_groups, attrs('multiple', "size=\"{$size}\""))), tag('div', create_hidden('phpc_token', $phpc_token), create_hidden('uid', $vars['uid']), create_hidden('action', 'user_groups'), create_hidden('submit_form', 'submit_form'), create_submit(__('Submit'))))); }
function login_form() { global $vars, $phpc_script, $day, $year, $month; $lastaction = empty($vars['lastaction']) ? '' : $vars['lastaction']; $submit_data = tag('td', attributes('colspan="2"'), create_hidden('action', 'login'), create_submit(_('Log in'))); if (!empty($vars['lastaction'])) { $submit_data->prepend(create_hidden('lastaction', $vars['lastaction'])); } if (!empty($vars['day'])) { $submit_data->prepend(create_hidden('day', $day)); } if (!empty($vars['month'])) { $submit_data->prepend(create_hidden('month', $month)); } if (!empty($vars['year'])) { $submit_data->prepend(create_hidden('year', $year)); } return tag('form', attributes("action=\"{$phpc_script}\"", 'method="post"'), tag('table', attributes('class="phpc-main"'), tag('caption', _('Log in')), tag('thead', tag('tr', tag('th', attributes('colspan="2"'), _('You must have cookies enabled to login.')))), tag('tfoot', tag('tr', $submit_data)), tag('tbody', tag('tr', tag('th', _('Username') . ':'), tag('td', create_text('username'))), tag('tr', tag('th', _('Password') . ':'), tag('td', create_password('password')))))); }
function display_day() { global $phpcid, $phpc_cal, $phpc_user, $phpc_script, $phpcdb, $day, $month, $year; $monthname = month_name($month); $results = $phpcdb->get_occurrences_by_date($phpcid, $year, $month, $day); $today_epoch = mktime(0, 0, 0, $month, $day, $year); $have_events = false; $html_table = tag('table', attributes('class="phpc-main"'), tag('caption', "{$day} {$monthname} {$year}"), tag('thead', tag('tr', tag('th', __('Title')), tag('th', __('Time')), tag('th', __('Description'))))); if ($phpc_cal->can_modify()) { $html_table->add(tag('tfoot', tag('tr', tag('td', attributes('colspan="4"'), create_hidden('action', 'event_delete'), create_hidden('day', $day), create_hidden('month', $month), create_hidden('year', $year), create_submit(__('Delete Selected')))))); } $html_body = tag('tbody'); while ($row = $results->fetch_assoc()) { $event = new PhpcOccurrence($row); if (!$event->can_read()) { continue; } $have_events = true; $eid = $event->get_eid(); $oid = $event->get_oid(); $html_subject = tag('td'); if ($event->can_modify()) { $html_subject->add(create_checkbox('eid[]', $eid)); } $html_subject->add(create_occurrence_link(tag('strong', $event->get_subject()), 'display_event', $oid)); if ($event->can_modify()) { $html_subject->add(" ("); $html_subject->add(create_event_link(__('Modify'), 'event_form', $eid)); $html_subject->add(')'); } $html_body->add(tag('tr', $html_subject, tag('td', $event->get_time_span_string()), tag('td', $event->get_desc()))); } $html_table->add($html_body); if ($phpc_cal->can_modify()) { $output = tag('form', attributes("action=\"{$phpc_script}\""), $html_table); } else { $output = $html_table; } if (!$have_events) { $output = tag('h2', __('No events on this day.')); } return tag('', create_day_menu(), $output); }
function config_form() { global $phpc_script, $phpc_user_tz, $phpc_user_lang, $phpc_token, $phpcdb, $phpc_user; $tz_input = create_multi_select('timezone', get_timezone_list(), $phpc_user_tz); $languages = array("" => __("Default")); foreach (get_languages() as $lang) { $languages[$lang] = $lang; } $lang_input = create_select('language', $languages, $phpc_user_lang); $calendars = array("" => __("None")); foreach ($phpcdb->get_calendars() as $calendar) { $calendars[$calendar->get_cid()] = $calendar->get_title(); } $default_input = create_select('default_cid', $calendars, $phpc_user->get_default_cid()); $table = tag('table', attrs('class="phpc-form"')); if (is_user()) { $table->add(tag('tr', tag('th', __('Default Calendar')), tag('td', $default_input))); } $table->add(tag('tr', tag('th', __('Timezone')), tag('td', $tz_input))); $table->add(tag('tr', tag('th', __('Language')), tag('td', $lang_input))); $form = tag('form', attributes("action=\"{$phpc_script}\"", 'method="post"'), tag('div', attrs('class="phpc-sub-title"'), __('Settings')), $table, create_hidden('phpc_token', $phpc_token), create_hidden('action', 'user_settings_submit'), create_submit(__('Submit'))); return tag('div', attrs('id="phpc-config"'), $form); }
function user_list() { global $phpc_script, $phpcid, $phpcdb, $vars; $users = $phpcdb->get_users_with_permissions($phpcid); $tbody = tag('tbody'); foreach ($users as $user) { $phpc_user = new PhpcUser($user); $group_list = array(); foreach ($phpc_user->get_groups() as $group) { if ($group['cid'] == $phpcid) { $group_list[] = $group['name']; } } $groups = implode(', ', $group_list); $tbody->add(tag('tr', tag('th', $user['username'], create_hidden('uid[]', $user['uid'])), tag('td', create_checkbox("read{$user['uid']}", "1", !empty($user['read']), __('Read'))), tag('td', create_checkbox("write{$user['uid']}", "1", !empty($user['write']), __('Write'))), tag('td', create_checkbox("readonly{$user['uid']}", "1", !empty($user['readonly']), __('Read-only'))), tag('td', create_checkbox("modify{$user['uid']}", "1", !empty($user['modify']), __('Modify'))), tag('td', create_checkbox("admin{$user['uid']}", "1", !empty($user['calendar_admin']), __('Admin'))), tag('td', $groups), tag('td', create_action_link(__("Edit Groups"), "user_groups", array("uid" => $user["uid"]))))); } $hidden_div = tag('div', create_hidden('action', 'user_permissions_submit')); if (isset($vars['phpcid'])) { $hidden_div->add(create_hidden('phpcid', $vars['phpcid'])); } $form = tag('form', attributes("action=\"{$phpc_script}\"", 'method="post"'), $hidden_div, tag('table', attributes("class=\"phpc-container\""), tag('caption', __('User Permissions')), tag('tfoot', tag('tr', tag('td', attributes('colspan="8"'), create_submit(__('Submit'))))), tag('thead', tag('tr', tag('th', __('User Name')), tag('th', __('Read')), tag('th', __('Write')), tag('th', __('Can Create Read-Only')), tag('th', __('Modify')), tag('th', __('Admin')), tag('th', __('Groups')), tag('th', __('Edit Groups')))), $tbody)); return tag('div', attrs('id="phpc-users"'), $form); }
function display_day($day, $month, $year) { global $db, $config, $phpc_script; $tablename = date('Fy', mktime(0, 0, 0, $month, 1, $year)); $monthname = month_name($month); $result = get_events_by_date($day, $month, $year); $today_epoch = mktime(0, 0, 0, $month, $day, $year); if ($row = $result->FetchRow()) { $html_table = tag('table', attributes('class="phpc-main"'), tag('caption', "{$day} {$monthname} {$year}"), tag('thead', tag('tr', tag('th', _('Title')), tag('th', _('Time')), tag('th', _('Duration')), tag('th', _('Description'))))); if (is_user() || $config['anon_permission'] >= 2) { $html_table->add(tag('tfoot', tag('tr', tag('td', attributes('colspan="4"'), create_hidden('action', 'event_delete'), create_hidden('day', $day), create_hidden('month', $month), create_hidden('year', $year), create_submit(_('Delete Selected')))))); } $html_body = tag('tbody'); for (; $row; $row = $result->FetchRow()) { $subject = htmlspecialchars(strip_tags(stripslashes($row['subject']))); if (empty($subject)) { $subject = _('(No subject)'); } $desc = parse_desc($row['description']); $time_str = formatted_time_string($row['starttime'], $row['eventtype']); $dur_str = get_duration($row['duration'], $row['eventtype']); $html_subject = tag('td', attributes('class="phpc-list"')); if (check_user($row['uid']) || $config['anon_permission'] >= 2) { $html_subject->add(create_checkbox('id', $row['id'])); } $html_subject->add(create_id_link(tag('strong', $subject), 'display', $row['id'])); if (check_user($row['uid']) || $config['anon_permission'] >= 2) { $html_subject->add(' ('); $html_subject->add(create_id_link(_('Modify'), 'event_form', $row['id'])); $html_subject->add(')'); } $html_body->add(tag('tr', $html_subject, tag('td', attributes('class="phpc-list"'), $time_str), tag('td', attributes('class="phpc-list"'), $dur_str), tag('td', attributes('class="phpc-list"'), $desc))); } $html_table->add($html_body); if (is_user() || $config['anon_permission'] >= 2) { $output = tag('form', attributes("action=\"{$phpc_script}\""), $html_table); } else { $output = $html_table; } } else { $output = tag('h2', _('No events on this day.')); } return $output; }
function event_form() { global $vars, $day, $month, $year, $db, $config, $phpc_script, $month_names, $event_types; if (isset($vars['id'])) { // modifying $id = $vars['id']; $title = sprintf(_('Editing Event #%d'), $id); $row = get_event_by_id($id); $subject = htmlspecialchars(stripslashes($row['subject'])); $desc = htmlspecialchars(stripslashes($row['description'])); $year = $row['year']; $month = $row['month']; $day = $row['day']; $hour = date('H', strtotime($row['starttime'])); $minute = date('i', strtotime($row['starttime'])); $end_year = $row['end_year']; $end_month = $row['end_month']; $end_day = $row['end_day']; $durmin = $row['duration'] % 60; $durhr = floor($row['duration'] / 60); if (!$config['hours_24']) { if ($hour > 12) { $pm = true; $hour = $hour - 12; } elseif ($hour == 12) { $pm = true; } else { $pm = false; } } $typeofevent = $row['eventtype']; $multiday = $year != $end_year || $month != $end_month || $day != $end_day; } else { // case "add": $title = _('Adding event to calendar'); $subject = ''; $desc = ''; if ($day == date('j') && $month == date('n') && $year == date('Y')) { if ($config['hours_24']) { $hour = date('G'); } else { $hour = date('g'); if (date('a') == 'pm') { $pm = true; } else { $pm = false; } } } else { $hour = 6; $pm = true; } $minute = 0; $end_day = $day; $end_month = $month; $end_year = $year; $durhr = 1; $durmin = 0; $typeofevent = 1; $multiday = false; } if ($config['hours_24']) { $hour_sequence = create_sequence(0, 23); } else { $hour_sequence = create_sequence(1, 12); } $minute_sequence = create_sequence(0, 59, 5, 'minute_pad'); $year_sequence = create_sequence(1970, 2037); $html_time = tag('td', create_select('hour', $hour_sequence, $hour), tag('b', ':'), create_select('minute', $minute_sequence, $minute)); if (!$config['hours_24']) { if ($pm) { $value = 1; } else { $value = 0; } $html_time->add(create_select('pm', array(_('AM'), _('PM')), $value)); } if (isset($id)) { $input = create_hidden('id', $id); } else { $input = ''; } $attributes = attributes('class="phpc-main"'); $day_of_month_sequence = create_sequence(1, 31); return tag('form', attributes("action=\"{$phpc_script}\""), tag('table', $attributes, tag('caption', $title), tag('tfoot', tag('tr', tag('td', attributes('colspan="2"'), $input, create_submit(_("Submit Event")), create_hidden('action', 'event_submit')))), tag('tbody', tag('tr', tag('th', _('Date of event')), tag('td', create_select('day', $day_of_month_sequence, $day), create_select('month', $month_names, $month), create_select('year', $year_sequence, $year))), tag('tr', tag('th', _('Multiple day event')), tag('td', create_checkbox('multiday', '1', $multiday))), tag('tr', tag('th', _('End date (Multiple day events only)')), tag('td', create_select('endday', $day_of_month_sequence, $end_day), create_select('endmonth', $month_names, $end_month), create_select('endyear', $year_sequence, $end_year))), tag('tr', tag('th', _('Event type')), tag('td', create_select('typeofevent', $event_types, $typeofevent))), tag('tr', tag('th', _('Time')), $html_time), tag('tr', tag('th', _('Duration')), tag('td', create_select('durationhour', create_sequence(0, 23), $durhr), _('hour(s)') . "\n", create_select('durationmin', $minute_sequence, $durmin), _('minutes') . "\n")), tag('tr', tag('th', _('Subject') . ' (' . $config['subject_max'] . ' ' . _('chars max') . ')'), tag('td', tag('input', attributes('type="text"', "size=\"{$config['subject_max']}\"", "maxlength=\"{$config['subject_max']}\"", 'name="subject"', "value=\"{$subject}\"")))), tag('tr', tag('th', _('Description')), tag('td', tag('textarea', attributes('rows="5"', 'cols="50"', 'name="description"'), $desc)))))); }
function new_user_form() { global $phpc_script; return tag('form', attributes("action=\"{$phpc_script}\"", 'method="post"'), tag('table', attributes('class="phpc-main"'), tag('caption', _('Create/Modify User')), tag('tfoot', tag('tr', tag('td', attributes('colspan="2"'), create_hidden('action', 'new_user_submit'), create_submit(_('Submit'))))), tag('tbody', tag('tr', tag('th', _('User Name') . ':'), tag('td', create_text('user_name'))), tag('tr', tag('th', _('Password') . ':'), tag('td', create_password('password1'))), tag('tr', tag('th', _('Confirm Password') . ':'), tag('td', create_password('password2'))), tag('tr', tag('th', _('Make Admin') . ':'), tag('td', create_checkbox('make_admin', '1')))))); }