예제 #1
0
function calendar_delete()
{
    global $vars, $phpcdb, $phpc_script;
    $html = tag('div', attributes('class="phpc-container"'));
    if (empty($vars["cid"])) {
        $html->add(tag('p', __('No calendar selected.')));
        return $html;
    }
    $id = $vars["cid"];
    $calendar = $phpcdb->get_calendar($id);
    if (empty($calendar)) {
        soft_error(__("Invalid calendar ID."));
    }
    if (empty($vars["confirm"])) {
        $html->add(tag('p', __('Confirm you want to delete calendar:') . $calendar->get_title()));
        $html->add(" [ ", create_action_link(__('Confirm'), "calendar_delete", array("cid" => $id, "confirm" => "1")), " ] ");
        $html->add(" [ ", create_action_link(__('Deny'), "display_month"), " ] ");
        return $html;
    }
    if (!$calendar->can_admin()) {
        $html->add(tag('p', __("You do not have permission to remove calendar") . ": {$id}"));
        return $html;
    }
    if ($phpcdb->delete_calendar($id)) {
        $html->add(tag('p', __("Removed calendar") . ": {$id}"));
    } else {
        $html->add(tag('p', __("Could not remove calendar") . ": {$id}"));
    }
    return message_redirect($html, "{$phpc_script}?action=admin");
}
예제 #2
0
function user_list()
{
    global $phpc_script, $phpcdb;
    $tbody = tag('tbody');
    $tbody->add(tag('tr', tag('th', __("Username")), tag('th', __("Groups")), tag('th', __("Edit Groups")), tag('th', __("Action"))));
    foreach ($phpcdb->get_users() as $user) {
        $group_list = array();
        foreach ($user->get_groups() as $group) {
            $group_list[] = $group['name'];
        }
        $groups = implode(', ', $group_list);
        $tbody->add(tag('tr', tag('th', $user->username), tag('td', $groups), tag('td', create_action_link(__("Edit Groups"), "user_groups", array("uid" => $user->uid))), tag('td', create_action_link(__("Delete"), "user_delete", array("uid" => $user->uid)))));
    }
    $create_link = create_action_link(__('Create User'), 'user_create');
    return tag('div', attributes('id="phpc-admin-users"'), tag('table', attributes('class="phpc-container"'), tag('caption', __('User List')), $tbody, tag('tfoot', tag('tr', tag('td', attributes('colspan="3"'), $create_link)))));
}
예제 #3
0
function user_list()
{
    global $phpc_script, $phpcdb;
    $tbody = tag('tbody');
    foreach ($phpcdb->get_users() as $user) {
        $group_list = array();
        foreach ($user->get_groups() as $group) {
            $group_list[] = $group['name'];
        }
        $groups = implode(', ', $group_list);
        if (!$user->is_disabled()) {
            $disable_link = create_action_link(__("Disable"), "user_disable", array("uid" => $user->uid));
        } else {
            $disable_link = create_action_link(__("Enable"), "user_enable", array("uid" => $user->uid));
        }
        $tbody->add(tag('tr', tag('td', $user->username), tag('td', $groups), tag('td', create_action_link(__("Edit Groups"), "user_groups", array("uid" => $user->uid))), tag('td', $disable_link)));
    }
    return tag('div', attrs('id="phpc-admin-users"'), tag('div', attrs('class="phpc-sub-title"'), __('User List')), tag('table', attrs('class="phpc-container ui-widget ui-widget-content"'), tag('thead', tag('tr', attrs('class="ui-widget-header"'), tag('th', __("Username")), tag('th', __("Groups")), tag('th', __("Edit Groups")), tag('th', __("Action")))), $tbody), create_action_link(__('Create User'), 'user_create', false, attrs('class="phpc-button"', 'id="phpc-create-user"')));
}
예제 #4
0
function group_delete()
{
    global $vars, $phpcdb, $phpcid, $phpc_script;
    $html = tag('div', attributes('class="phpc-container"'));
    if (empty($vars["gid"])) {
        return message_redirect(__('No group selected.'), "{$phpc_script}?action=cadmin&phpcid={$phpcid}");
    }
    if (is_array($vars["gid"])) {
        $ids = $vars["gid"];
    } else {
        $ids = array($vars["gid"]);
    }
    $groups = array();
    foreach ($ids as $id) {
        $groups[] = $phpcdb->get_group($id);
    }
    if (empty($vars["confirm"])) {
        $list = tag('ul');
        foreach ($groups as $group) {
            $list->add(tag('li', "{$id}: " . $group['name']));
        }
        $html->add(tag('p', __('Confirm you want to delete:')));
        $html->add($list);
        $html->add(" [ ", create_action_link(__('Confirm'), "group_delete", array("gid" => $ids, "confirm" => "1")), " ] ");
        $html->add(" [ ", create_action_link(__('Deny'), "display_month"), " ] ");
        return $html;
    }
    foreach ($groups as $group) {
        if (empty($group['cid']) && !is_admin() || !$phpcdb->get_calendar($group['cid'])->can_admin()) {
            $html->add(tag('p', __("You do not have permission to delete group: ") . $group['gid']));
            continue;
        }
        if ($phpcdb->delete_group($group['gid'])) {
            $html->add(tag('p', __("Removed group: ") . $group['gid']));
        } else {
            $html->add(tag('p', __("Could not remove group: ") . $group['gid']));
        }
    }
    return message_redirect($html, "{$phpc_script}?action=cadmin&phpcid={$phpcid}");
}
예제 #5
0
function calendar_delete()
{
    global $vars, $phpcdb, $phpc_script;
    $html = tag('div', attributes('class="phpc-container"'));
    if (empty($vars["cid"])) {
        $html->add(tag('p', __('No calendar selected.')));
        return $html;
    }
    if (is_array($vars["cid"])) {
        $ids = $vars["cid"];
    } else {
        $ids = array($vars["cid"]);
    }
    if (empty($vars["confirm"])) {
        $list = tag('ul');
        foreach ($ids as $id) {
            $calendar = $phpcdb->get_calendar($id);
            $list->add(tag('li', "{$id}: " . $calendar->get_title()));
        }
        $html->add(tag('p', __('Confirm you want to delete:')));
        $html->add($list);
        $html->add(" [ ", create_action_link(__('Confirm'), "calendar_delete", array("cid" => $ids, "confirm" => "1")), " ] ");
        $html->add(" [ ", create_action_link(__('Deny'), "display_month"), " ] ");
        return $html;
    }
    foreach ($ids as $id) {
        $calendar = $phpcdb->get_calendar($id);
        if (!$calendar->can_admin()) {
            $html->add(tag('p', __("You do not have permission to remove calendar") . ": {$id}"));
            continue;
        }
        if ($phpcdb->delete_calendar($id)) {
            $html->add(tag('p', __("Removed calendar") . ": {$id}"));
        } else {
            $html->add(tag('p', __("Could not remove calendar") . ": {$id}"));
        }
    }
    return message_redirect($html, "{$phpc_script}?action=admin");
}
예제 #6
0
function create_week($from_stamp, $year, $days_events)
{
    $start_day = date("j", $from_stamp);
    $start_month = date("n", $from_stamp);
    $start_year = date("Y", $from_stamp);
    $week_of_year = week_of_year($start_month, $start_day, $start_year);
    // Non ISO, the week should be of this year.
    if (day_of_week_start() != 1) {
        if ($start_year < $year) {
            $week_of_year = 1;
        }
    } else {
        // Use week's year as year for ISO
        $year = $start_year;
    }
    $week_html = tag('tr', tag('th', attrs('class="phpc-date ui-state-default"'), create_action_link($week_of_year, 'display_week', array('week' => $week_of_year, 'year' => $year))));
    for ($day_of_week = 0; $day_of_week < 7; $day_of_week++) {
        $day = $start_day + $day_of_week;
        $week_html->add(create_day($start_month, $day, $start_year, $days_events));
    }
    return $week_html;
}
예제 #7
0
function user_delete()
{
    global $vars, $phpcid, $phpcdb, $phpc_script;
    $html = tag('div', attributes('class="phpc-container"'));
    if (!is_admin()) {
        $html->add(tag('p', __('You must be an admin to delete users.')));
        return $html;
    }
    if (empty($vars["uid"])) {
        $html->add(tag('p', __('No user selected.')));
        return $html;
    }
    if (is_array($vars["uid"])) {
        $ids = $vars["uid"];
    } else {
        $ids = array($vars["uid"]);
    }
    if (empty($vars["confirm"])) {
        $list = tag('ul');
        foreach ($ids as $id) {
            $user = $phpcdb->get_user($id);
            $list->add(tag('li', "{$id}: " . $user->get_username()));
        }
        $html->add(tag('p', __('Confirm you want to delete:')));
        $html->add($list);
        $html->add(" [ ", create_action_link(__('Confirm'), "user_delete", array("uid" => $ids, "confirm" => "1")), " ] ");
        $html->add(" [ ", create_action_link(__('Deny'), "display_month"), " ] ");
        return $html;
    }
    foreach ($ids as $id) {
        if ($phpcdb->delete_user($id)) {
            $html->add(tag('p', __("Removed user: {$id}")));
        } else {
            $html->add(tag('p', __("Could not remove user: {$id}")));
        }
    }
    return message_redirect($html, "{$phpc_script}?action=admin&phpcid={$phpcid}");
}
예제 #8
0
파일: cadmin.php 프로젝트: Godjqb/Php-test
function group_list()
{
    global $phpc_script, $phpcid, $phpc_cal, $vars;
    $groups = $phpc_cal->get_groups();
    $tbody = tag('tbody');
    foreach ($groups as $group) {
        $name = empty($group['name']) ? __('No Name') : $group['name'];
        $id = $group['gid'];
        $tbody->add(tag('tr', tag('th', $name), tag('td', create_action_link(__('Edit'), 'group_form', array('gid' => $id)), " ", create_action_link(__('Delete'), 'group_delete', array('gid' => $id)))));
    }
    $create_link = create_action_link(__('Create group'), 'group_form', array('cid' => $phpcid));
    $table = tag('table', attributes("class=\"phpc-container\""), tag('caption', __('Calendar Groups')), tag('thead', tag('tr', tag('th', __('Name')), tag('th', __('Actions')))), $tbody, tag('tfoot', tag('tr', tag('td', attributes('colspan="2"'), $create_link))));
    return tag('div', attrs('id="phpc-groups"'), $table);
}
예제 #9
0
function menu_item_prepend(&$html, $name, $action, $args = false, $attribs = false)
{
    if (!is_object($html)) {
        soft_error('Html is not a valid Html class.');
    }
    $html->prepend("\n");
    $html->prepend(create_action_link($name, $action, $args, $attribs));
}
예제 #10
0
function create_week($week_of_month, $month, $year, $days_events)
{
    $start_day = 1 + ($week_of_month - 1) * 7 - day_of_week($month, 1, $year);
    $week_of_year = week_of_year($month, $start_day, $year);
    $args = array('week' => $week_of_year, 'year' => $year);
    $click = create_plain_link($week_of_year, 'display_week', false, false, false, false, $args);
    $week_html = tag('tr', tag('th', attrs('class="ui-state-default"', "onclick=\"window.location.href='{$click}'\""), create_action_link($week_of_year, 'display_week', $args)));
    for ($day_of_week = 0; $day_of_week < 7; $day_of_week++) {
        $day = $start_day + $day_of_week;
        $week_html->add(create_day($month, $day, $year, $days_events));
    }
    return $week_html;
}
예제 #11
0
function event_delete()
{
    global $vars, $phpcdb, $phpc_script;
    $html = tag('div', attributes('class="phpc-container"'));
    if (empty($vars["eid"])) {
        $message = __('No event selected.');
        $html->add(tag('div', $message));
        return $html;
    }
    if (is_array($vars["eid"])) {
        $eids = $vars["eid"];
    } else {
        $eids = array($vars["eid"]);
    }
    if (empty($vars["confirm"])) {
        $list = tag('ul');
        foreach ($eids as $eid) {
            $event = new PhpcEvent($phpcdb->get_event_by_eid($eid));
            $list->add(tag('li', "{$eid}: " . $event->get_subject()));
        }
        $html->add(tag('div', __('Confirm you want to delete:')));
        $html->add($list);
        $html->add(" [ ", create_action_link(__('Confirm'), "event_delete", array("eid" => $eids, "confirm" => "1")), " ] ");
        $html->add(" [ ", create_action_link(__('Deny'), "display_month"), " ] ");
        return $html;
    }
    $removed_events = array();
    $unremoved_events = array();
    $permission_denied = array();
    foreach ($eids as $eid) {
        $event = new PhpcEvent($phpcdb->get_event_by_eid($eid));
        if (!$event->can_modify()) {
            $permission_denied[] = $eid;
        } else {
            if ($phpcdb->delete_event($eid)) {
                $removed_events[] = $eid;
            } else {
                $unremoved_events[] = $eid;
            }
        }
    }
    if (sizeof($removed_events) > 0) {
        if (sizeof($removed_events) == 1) {
            $text = __("Removed event");
        } else {
            $text = __("Removed events");
        }
        $text .= ': ' . implode(', ', $removed_events);
        $html->add(tag('div', $text));
    }
    if (sizeof($unremoved_events) > 0) {
        if (sizeof($unremoved_events) == 1) {
            $text = __("Could not remove event");
        } else {
            $text = __("Could not remove events");
        }
        $text .= ': ' . implode(', ', $unremoved_events);
        $html->add(tag('div', $text));
    }
    if (sizeof($permission_denied) > 0) {
        if (sizeof($permission_denied) == 1) {
            $text = __("You do not have permission to remove event");
        } else {
            $text = __("You do not have permission to remove events");
        }
        $text .= ': ' . implode(', ', $permission_denied);
        $html->add(tag('div', $text));
    }
    return message_redirect($html, $phpc_script);
}
예제 #12
0
function field_list()
{
    global $phpc_script, $phpcid, $phpc_cal, $vars;
    $tbody = tag('tbody');
    $have_contents = false;
    foreach ($phpc_cal->get_fields() as $field) {
        $have_contents = true;
        $name = empty($field['name']) ? __('No Name') : $field['name'];
        $fid = $field['fid'];
        $tbody->add(tag('tr', tag('td', $name), tag('td', escape_entities($field['required'])), tag('td', escape_entities($field['format'])), tag('td', create_action_link(__('Edit'), 'field_form', array('fid' => $fid)), " ", create_action_link(__('Delete'), 'field_delete', array('fid' => $fid), attrs('class="phpc-confirm-field"')))));
    }
    if (!$have_contents) {
        $tbody->add(tag('tr', tag('td', attrs('colspan=4'), __('No fields.'))));
    }
    $table = tag('table', attrs('class="phpc-container"'), tag('thead', tag('tr', attrs('class="ui-widget-header"'), tag('th', __('Name')), tag('th', __('Required?')), tag('th', __('Format')), tag('th', __('Actions')))), $tbody);
    $dialog = tag('div', attrs('id="phpc-dialog-field"', 'title="' . __("Confirmation required") . '"'), __("Permanently delete this field?"));
    return tag('div', attrs('id="phpc-fields"'), tag('div', attrs('class="phpc-sub-title"'), __('Calendar Fields')), $dialog, $table, create_action_link(__('Create Field'), 'field_form', array('cid' => $phpcid), attrs('class="phpc-button"')));
}
function occurrence_delete()
{
    global $vars, $phpcdb, $phpcid, $phpc_script;
    $html = tag('div', attributes('class="phpc-container"'));
    if (empty($vars["oid"])) {
        $message = __('No occurrence selected.');
        $html->add(tag('p', $message));
        return $html;
    }
    if (is_array($vars["oid"])) {
        $oids = $vars["oid"];
    } else {
        $oids = array($vars["oid"]);
    }
    if (empty($vars["confirm"])) {
        $list = tag('ul');
        foreach ($oids as $oid) {
            $occur = $phpcdb->get_occurrence_by_oid($oid);
            $list->add(tag('li', "{$oid}: \"" . $occur->get_subject() . "\" " . __("at") . " " . $occur->get_date_string()));
        }
        $html->add(tag('p', __('Confirm you want to delete:')));
        $html->add($list);
        $html->add(" [ ", create_action_link(__('Confirm'), "occurrence_delete", array("oid" => $oids, "confirm" => "1")), " ] ");
        $html->add(" [ ", create_action_link(__('Deny'), "display_month"), " ] ");
        return $html;
    }
    $removed_occurs = array();
    $unremoved_occurs = array();
    $permission_denied = array();
    foreach ($oids as $oid) {
        $occur = $phpcdb->get_occurrence_by_oid($oid);
        if (!$occur->can_modify()) {
            $permission_denied[] = $oid;
        } else {
            if ($phpcdb->delete_occurrence($oid)) {
                $removed_occurs[] = $oid;
                // TODO: Verify that the event still has occurences.
                $eid = $occur->get_eid();
            } else {
                $unremoved_occurs[] = $oid;
            }
        }
    }
    if (sizeof($removed_occurs) > 0) {
        if (sizeof($removed_occurs) == 1) {
            $text = __("Removed occurrence");
        } else {
            $text = __("Removed occurrences");
        }
        $text .= ': ' . implode(', ', $removed_occurs);
        $html->add(tag('p', $text));
    }
    if (sizeof($unremoved_occurs) > 0) {
        if (sizeof($unremoved_occurs) == 1) {
            $text = __("Could not remove occurrence");
        } else {
            $text = __("Could not remove occurrences");
        }
        $text .= ': ' . implode(', ', $unremoved_occurs);
        $html->add(tag('p', $text));
    }
    if (sizeof($permission_denied) > 0) {
        if (sizeof($permission_denied) == 1) {
            $text = __("You do not have permission to remove the occurrence.");
        } else {
            $text = __("You do not have permission to remove occurrences.");
        }
        $text .= ': ' . implode(', ', $permission_denied);
        $html->add(tag('p', $text));
    }
    return message_redirect($html, "{$phpc_script}?action=display_event&phpcid={$phpcid}&eid={$eid}");
}