function user_permissions_submit()
{
    global $phpcid, $phpc_cal, $vars, $phpcdb, $phpc_script;
    if (!$phpc_cal->can_admin()) {
        return tag('div', __('Permission denied'));
    }
    if (empty($vars['uid'])) {
        return tag('div', __('No users'));
    }
    $users = array();
    foreach ($vars['uid'] as $uid) {
        $perm_names = array('read', 'write', 'readonly', 'modify', 'admin');
        $old_perms = $phpcdb->get_permissions($phpcid, $uid);
        $new_perms = array();
        $different = false;
        foreach ($perm_names as $perm_name) {
            $new_perms[$perm_name] = asbool(!empty($vars["{$perm_name}{$uid}"]));
            if (empty($old_perms[$perm_name]) != empty($vars["{$perm_name}{$uid}"])) {
                $different = true;
            }
        }
        if ($different) {
            $user = $phpcdb->get_user($uid);
            $users[] = $user->get_username();
            $phpcdb->update_permissions($phpcid, $uid, $new_perms);
        }
    }
    if (sizeof($users) == 0) {
        $message = __('No changes to make.');
    } else {
        $message = __('Updated user(s):') . ' ' . implode(', ', $users);
    }
    return message_redirect($message, "{$phpc_script}?action=cadmin&phpcid={$phpcid}");
}
 function modify_event($eid, $subject, $description, $readonly, $catid = false)
 {
     $fmt_readonly = asbool($readonly);
     $query = "UPDATE `" . SQL_PREFIX . "events`\n" . "SET\n" . "`subject`='{$subject}',\n" . "`description`='{$description}',\n" . "`readonly`={$fmt_readonly},\n" . "`mtime`=NOW(),\n" . ($catid !== false ? "`catid`='{$catid}'\n" : "`catid`=NULL\n") . "WHERE eid='{$eid}'";
     $this->dbh->query($query) or $this->db_error(__('Error modifying event.'), $query);
     return $this->dbh->affected_rows > 0;
 }