本文整理汇总了PHP中Kronolith::updateShare方法的典型用法代码示例。如果您正苦于以下问题:PHP Kronolith::updateShare方法的具体用法?PHP Kronolith::updateShare怎么用?PHP Kronolith::updateShare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kronolith
的用法示例。
在下文中一共展示了Kronolith::updateShare方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateCalendar
/**
* Update an internal calendar's information.
*
* @param string $id The calendar id.
* @param array $info An array of calendar information.
* @see self::addCalendar()
* @since 4.2.0
*/
public function updateCalendar($id, array $info)
{
$calendar = $this->getCalendar(null, $id);
// Prevent wiping tags if they were not passed.
if (!array_key_exists('tags', $info)) {
$info['tags'] = Kronolith::getTagger()->getTags($id, Kronolith_Tagger::TYPE_CALENDAR);
}
Kronolith::updateShare($calendar->share(), $info);
}
示例2: 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;
//.........这里部分代码省略.........
示例3: execute
/**
* @throws Kronolith_Exception
*/
public function execute()
{
switch ($this->_vars->submitbutton) {
case _("Save"):
$info = array();
foreach (array('name', 'color', 'description', 'tags', 'system') as $key) {
$info[$key] = $this->_vars->get($key);
}
Kronolith::updateShare($this->_calendar, $info);
break;
case _("Delete"):
Horde::url('calendars/delete.php')->add('c', $this->_vars->c)->redirect();
break;
case _("Cancel"):
Horde::url($GLOBALS['prefs']->getValue('defaultview') . '.php', true)->redirect();
break;
}
}