Kronolith::updateShare PHP Метод

updateShare() публичный статический Метод

Updates an existing share.
public static updateShare ( &$calendar, array $info )
$info array Hash with calendar information.
    public static function updateShare(&$calendar, $info)
    {
        if (!$GLOBALS['registry']->getAuth() || $calendar->get('owner') != $GLOBALS['registry']->getAuth() && (!is_null($calendar->get('owner')) || !$GLOBALS['registry']->isAdmin())) {
            throw new Kronolith_Exception(_("You are not allowed to change this calendar."));
        }
        $calendar->set('name', $info['name']);
        $calendar->set('color', $info['color']);
        $calendar->set('desc', $info['description']);
        $calendar->set('owner', empty($info['system']) ? $GLOBALS['registry']->getAuth() : null);
        try {
            $calendar->save();
        } catch (Horde_Share_Exception $e) {
            throw new Kronolith_Exception(sprintf(_("Unable to save calendar \"%s\": %s"), $info['name'], $e->getMessage()));
        }
        $tagger = self::getTagger();
        $tagger->replaceTags($calendar->getName(), $info['tags'], $calendar->get('owner'), Kronolith_Tagger::TYPE_CALENDAR);
    }

Usage Example

Пример #1
0
 /**
  * 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);
 }
All Usage Examples Of Kronolith::updateShare