Exemplo n.º 1
0
 /**
  * @brief Edits a calendar
  * @param integer $id
  * @param string $name Default: null
  * @param string $components Default: null
  * @param string $timezone Default: null
  * @param integer $order Default: null
  * @param string $color Default: null, format: '#RRGGBB(AA)'
  * @param boolean $bLogActivity 
  * @return boolean
  *
  * Values not null will be set
  */
 public function edit($id, $name = null, $components = null, $timezone = null, $order = null, $color = null, $transparent = null, $bLogActivity = true)
 {
     // Need these ones for checking uri
     $calendar = $this->find($id);
     if ($calendar['userid'] !== $this->userId) {
         $sharedCalendar = $this->shareConnector->getItemSharedWithBySourceCalendar($id);
         if (!$sharedCalendar || !($sharedCalendar['permissions'] & $this->shareConnector->getUpdateAccess())) {
             throw new \Sabre\DAV\Exception\Forbidden('You do not have the permissions to update this calendar.');
         }
     }
     // Keep old stuff
     if (is_null($name)) {
         $name = $calendar['displayname'];
     }
     if (is_null($components)) {
         $components = $calendar['components'];
     }
     if (is_null($timezone)) {
         $timezone = $calendar['timezone'];
     }
     if (is_null($order)) {
         $order = $calendar['calendarorder'];
     }
     if (is_null($color)) {
         $color = $calendar['calendarcolor'];
     }
     if (is_null($transparent)) {
         $transparent = $calendar['transparent'];
     }
     $calendarDB = new CalendarDAO($this->db, $this->userId);
     $bUpdateCalendar = $calendarDB->update($name, $order, $color, $timezone, $components, $transparent, $id);
     if ($bUpdateCalendar === true) {
         \OCP\Util::emitHook('\\OCA\\CalendarPlus', 'editCalendar', $id);
         if ($bLogActivity === true) {
             $link = \OC::$server->getURLGenerator()->linkToRoute('calendarplus.page.index');
             $params = array('mode' => 'edited', 'link' => $link, 'trans_type' => '', 'summary' => $calendar['displayname'], 'cal_user' => $calendar['userid'], 'cal_displayname' => $calendar['displayname']);
             ActivityData::logEventActivity($params, false, true);
         }
         return true;
     } else {
         return null;
     }
 }
Exemplo n.º 2
0
 /**
  * @brief Edits a calendar
  * @param integer $id
  * @param string $name Default: null
  * @param string $components Default: null
  * @param string $timezone Default: null
  * @param integer $order Default: null
  * @param string $color Default: null, format: '#RRGGBB(AA)'
  * @return boolean
  *
  * Values not null will be set
  */
 public static function editCalendar($id, $name = null, $components = null, $timezone = null, $order = null, $color = null, $transparent = null)
 {
     // Need these ones for checking uri
     $calendar = self::find($id);
     $userid = \OCP\User::getUser();
     if ($calendar['userid'] !== $userid) {
         $sharedCalendar = \OCP\Share::getItemSharedWithBySource(App::SHARECALENDAR, App::SHARECALENDARPREFIX . $id);
         if (!$sharedCalendar || !($sharedCalendar['permissions'] & \OCP\PERMISSION_UPDATE)) {
             throw new \Exception(App::$l10n->t('You do not have the permissions to update this calendar.'));
         }
     }
     // Keep old stuff
     if (is_null($name)) {
         $name = $calendar['displayname'];
     }
     if (is_null($components)) {
         $components = $calendar['components'];
     }
     if (is_null($timezone)) {
         $timezone = $calendar['timezone'];
     }
     if (is_null($order)) {
         $order = $calendar['calendarorder'];
     }
     if (is_null($color)) {
         $color = $calendar['calendarcolor'];
     }
     if (is_null($transparent)) {
         $transparent = $calendar['transparent'];
     }
     $dbObject = \OC::$server->getDb();
     $calendarDB = new CalendarDAO($dbObject, $userid);
     $bUpdateCalendar = $calendarDB->update($name, $order, $color, $timezone, $components, $transparent, $id);
     if ($bUpdateCalendar === true) {
         \OCP\Util::emitHook('\\OCA\\CalendarPlus', 'editCalendar', $id);
         $link = \OC::$server->getURLGenerator()->linkToRoute(App::$appname . '.page.index');
         $params = array('mode' => 'edited', 'link' => $link, 'trans_type' => '', 'summary' => $calendar['displayname'], 'cal_user' => $calendar['userid'], 'cal_displayname' => $calendar['displayname']);
         ActivityData::logEventActivity($params, false, true);
         return true;
     } else {
         return null;
     }
 }