当前位置: 首页>>代码示例>>PHP>>正文


PHP Kronolith::addShare方法代码示例

本文整理汇总了PHP中Kronolith::addShare方法的典型用法代码示例。如果您正苦于以下问题:PHP Kronolith::addShare方法的具体用法?PHP Kronolith::addShare怎么用?PHP Kronolith::addShare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Kronolith的用法示例。


在下文中一共展示了Kronolith::addShare方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * @throws Kronolith_Exception
  */
 public function execute()
 {
     $info = array();
     foreach (array('name', 'color', 'description', 'tags', 'system') as $key) {
         $info[$key] = $this->_vars->get($key);
     }
     return Kronolith::addShare($info);
 }
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:11,代码来源:CreateCalendar.php

示例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;
//.........这里部分代码省略.........
开发者ID:kossamums,项目名称:horde,代码行数:101,代码来源:Handler.php

示例3: addCalendar

 /**
  * Create a new calendar for the existing user.
  *
  * @param string $name  The calendar's display name.
  * @param array $param  Any additional parameters. May include:
  *   - color: (string) The color to associate with the calendar.
  *            DEFAULT: none (color will be randomly assigned).
  *   - description:  (string) The calendar description.
  *                   DEFAULT: none (empty description).
  *   - tags:         (array) An array of tags to apply to the new calendar.
  *
  *   - synchronize:   (boolean) If true, add calendar to the list of
  *                             calendars to syncronize.
  *                    DEFAULT: false (do not add to the list of calendars).
  * @return string  The new calendar's UID.
  * @since 4.2.0
  */
 public function addCalendar($name, array $params = array())
 {
     global $prefs;
     $info = array('name' => $name, 'color' => empty($params['color']) ? null : $params['color'], 'description' => empty($params['description']) ? null : $params['description'], 'tags' => empty($params['tags']) ? null : $params['tags']);
     $share = Kronolith::addShare($info);
     if (!empty($params['synchronize'])) {
         $sync = @unserialize($prefs->getValue('sync_calendars'));
         $sync[] = $share->getName();
         $prefs->setValue('sync_calendars', serialize($sync));
     }
     return $share->getName();
 }
开发者ID:horde,项目名称:horde,代码行数:29,代码来源:Api.php


注:本文中的Kronolith::addShare方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。