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_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 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 pre_footer_hide2() { create_checkbox('pre_footer_hide2', ''); }
while ($r = db_rowarr($c)) { if ($old_c != $r[2]) { if ($row < $rows) { echo '<td colspan="' . ($rows - $row) . '"> </td></tr>'; } echo '<tr class="fieldtopic"><td colspan=' . $rows . '><font size=-2>' . $r[2] . '</font></td></tr><tr class="field">'; $row = 1; $old_c = $r[2]; } if ($row >= $rows) { $row = 2; echo '</tr><tr class="field">'; } else { ++$row; } echo '<td>' . create_checkbox('frm_list[' . $r[1] . ']', $r[1], isset($frm_list[$r[1]])) . ' <font size=-2> ' . $r[0] . '</font></td>'; } ?> </tr></table> </td> </tr> <tr class="tutor"> <td colspan="2">All dates are in GMT, current GMT date/time is: <?php echo gmdate('r', __request_timestamp__); ?> </td> </tr> <tr class="field"> <td>Starting Date:</td>
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 create_config_input($element, $default = false) { $name = $element[0]; $text = $element[1]; $type = $element[2]; $value = false; if (isset($element[3])) { $value = $element[3]; } switch ($type) { case PHPC_CHECK: if ($default == false) { $default = $value; } $input = create_checkbox($name, '1', $default, $text); break; case PHPC_TEXT: if ($default == false) { $default = $value; } $input = create_text($name, $default); break; case PHPC_DROPDOWN: $input = create_select($name, $value, $default); break; case PHPC_MULTI_DROPDOWN: $input = create_multi_select($name, $value, $default); break; default: soft_error(__('Unsupported config type') . ": {$type}"); } return $input; }
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')))))); }