Kronolith::addShare PHP Method

addShare() public static method

Creates a new share.
public static addShare ( array $info ) : Horde_Share
$info array Hash with calendar information.
return Horde_Share The new share.
    public static function addShare($info)
    {
        global $calendar_manager, $injector, $prefs, $registry;
        $kronolith_shares = $injector->getInstance('Kronolith_Shares');
        try {
            $calendar = $kronolith_shares->newShare($registry->getAuth(), strval(new Horde_Support_Randomid()), $info['name']);
        } catch (Horde_Share_Exception $e) {
            throw new Kronolith_Exception($e);
        }
        $calendar->set('color', $info['color']);
        $calendar->set('desc', $info['description']);
        if (!empty($info['system'])) {
            $calendar->set('owner', null);
        }
        $calendar->set('calendar_type', Kronolith::SHARE_TYPE_USER);
        $tagger = self::getTagger();
        $tagger->tag($calendar->getName(), $info['tags'], $calendar->get('owner'), Kronolith_Tagger::TYPE_CALENDAR);
        try {
            $kronolith_shares->addShare($calendar);
        } catch (Horde_Share_Exception $e) {
            throw new Kronolith_Exception($e);
        }
        $all_cals = $calendar_manager->get(Kronolith::ALL_CALENDARS);
        $all_cals[$calendar->getName()] = new Kronolith_Calendar_Internal(array('share' => $calendar));
        $calendar_manager->set(Kronolith::ALL_CALENDARS, $all_cals);
        $display_cals = $calendar_manager->get(Kronolith::DISPLAY_CALENDARS);
        $display_cals[] = $calendar->getName();
        $calendar_manager->set(Kronolith::DISPLAY_CALENDARS, $display_cals);
        $prefs->setValue('display_cals', serialize($display_cals));
        return $calendar;
    }

Usage Example

コード例 #1
0
ファイル: CreateCalendar.php プロジェクト: DSNS-LAB/Dmail
 /**
  * @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);
 }
All Usage Examples Of Kronolith::addShare