本文整理汇总了PHP中Kronolith::readPermsForm方法的典型用法代码示例。如果您正苦于以下问题:PHP Kronolith::readPermsForm方法的具体用法?PHP Kronolith::readPermsForm怎么用?PHP Kronolith::readPermsForm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kronolith
的用法示例。
在下文中一共展示了Kronolith::readPermsForm方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveCalendar
/**
* TODO
*/
public function saveCalendar()
{
global $calendar_manager, $injector, $notification, $prefs, $registry, $session;
$calendar_id = $this->vars->calendar;
$result = new stdClass();
switch ($this->vars->type) {
case 'internal':
$info = array();
foreach (array('name', 'color', 'description', 'tags', 'system') as $key) {
$info[$key] = $this->vars->{$key};
}
// Create a calendar.
if (!$calendar_id) {
if (!$registry->getAuth() || $prefs->isLocked('default_share')) {
return $result;
}
try {
$calendar = Kronolith::addShare($info);
Kronolith::readPermsForm($calendar);
if ($calendar->hasPermission($registry->getAuth(), Horde_Perms::SHOW)) {
$wrapper = new Kronolith_Calendar_Internal(array('share' => $calendar));
$result->saved = true;
$result->id = $calendar->getName();
$result->calendar = $wrapper->toHash();
}
} catch (Exception $e) {
$notification->push($e, 'horde.error');
return $result;
}
$notification->push(sprintf(_("The calendar \"%s\" has been created."), $info['name']), 'horde.success');
break;
}
// Update a calendar.
try {
$calendar = $injector->getInstance('Kronolith_Shares')->getShare($calendar_id);
$original_name = $calendar->get('name');
$original_owner = $calendar->get('owner');
Kronolith::updateShare($calendar, $info);
Kronolith::readPermsForm($calendar);
if (!$info['system'] && $calendar->get('owner') != $original_owner || $info['system'] && !is_null($original_owner)) {
$result->deleted = true;
}
if ($calendar->hasPermission($registry->getAuth(), Horde_Perms::SHOW) || is_null($calendar->get('owner')) && $registry->isAdmin()) {
$wrapper = new Kronolith_Calendar_Internal(array('share' => $calendar));
$result->saved = true;
$result->id = $calendar->getName();
$result->calendar = $wrapper->toHash();
}
} catch (Exception $e) {
$notification->push($e, 'horde.error');
return $result;
}
if ($calendar->get('name') != $original_name) {
$notification->push(sprintf(_("The calendar \"%s\" has been renamed to \"%s\"."), $original_name, $calendar->get('name')), 'horde.success');
} else {
$notification->push(sprintf(_("The calendar \"%s\" has been saved."), $original_name), 'horde.success');
}
break;
case 'tasklists':
$calendar = array();
foreach (array('name', 'color', 'description') as $key) {
$calendar[$key] = $this->vars->{$key};
}
// Create a task list.
if (!$calendar_id) {
if (!$registry->getAuth() || $prefs->isLocked('default_share')) {
return $result;
}
try {
$tasklistId = $registry->tasks->addTasklist($calendar['name'], $calendar['description'], $calendar['color']);
$tasklists = $registry->tasks->listTasklists(true);
if (!isset($tasklists[$tasklistId])) {
$notification->push(_("Added task list not found."), 'horde.error');
return $result;
}
$tasklist = $tasklists[$tasklistId];
Kronolith::readPermsForm($tasklist);
if ($tasklist->hasPermission($registry->getAuth(), Horde_Perms::SHOW)) {
$wrapper = new Kronolith_Calendar_External_Tasks(array('api' => 'tasks', 'name' => $tasklistId, 'share' => $tasklist));
// Update external calendars caches.
$all_external = $session->get('kronolith', 'all_external_calendars');
$all_external[] = array('a' => 'tasks', 'n' => $tasklistId, 'd' => $tasklist->get('name'));
$session->set('kronolith', 'all_external_calendars', $all_external);
$display_external = $calendar_manager->get(Kronolith::DISPLAY_EXTERNAL_CALENDARS);
$display_external[] = 'tasks/' . $tasklistId;
$calendar_manager->set(Kronolith::DISPLAY_EXTERNAL_CALENDARS, $display_external);
$prefs->setValue('display_external_cals', serialize($display_external));
$all_external = $calendar_manager->get(Kronolith::ALL_EXTERNAL_CALENDARS);
$all_external['tasks/' . $tasklistId] = $wrapper;
$calendar_manager->set(Kronolith::ALL_EXTERNAL_CALENDARS, $all_external);
$result->saved = true;
$result->id = 'tasks/' . $tasklistId;
$result->calendar = $wrapper->toHash();
}
} catch (Exception $e) {
$notification->push($e, 'horde.error');
return $result;
//.........这里部分代码省略.........
示例2: catch
break;
case 'editform':
$session->checkToken($vars->token);
try {
$share = $shares->getShareById($vars->cid);
} catch (Horde_Share_Exception $e) {
$notification->push(_("Attempt to edit a non-existent share."), 'horde.error');
}
if (empty($share)) {
break;
}
if (!$registry->getAuth() || !$registry->isAdmin() && $registry->getAuth() != $share->get('owner')) {
throw new Horde_Exception_PermissionDenied();
}
try {
$errors = Kronolith::readPermsForm($share);
if ($errors) {
foreach ($errors as $error) {
$notification->push($error, 'horde.error');
}
} elseif ($vars->save_and_finish) {
echo Horde::wrapInlineScript(array('window.close();'));
exit;
}
$notification->push(sprintf(_("Updated \"%s\"."), $share->get('name')), 'horde.success');
} catch (Exception $e) {
$notification->push($e, 'horde.error');
}
$perm = $share->getPermission();
break;
}