Ejemplo n.º 1
0
 /**
  * @brief Gets the data of one calendar
  * @param integer $id
  * @return associative array
  */
 public function find($id)
 {
     $this->setUserId(\OCP\User::getUser());
     $calendarDB = new CalendarDAO($this->db, $this->userId);
     $calendarInfo = $calendarDB->find($id);
     if ($calendarInfo !== null) {
         if ($calendarInfo['userid'] !== $this->userId) {
             $userExists = \OC::$server->getUserManager()->userExists($this->userId);
             if (!$userExists) {
                 $sharedCalendar = $this->shareConnector->getItemSharedWithByLinkCalendar($id, $calendarInfo['userid']);
             } else {
                 $sharedCalendar = $this->shareConnector->getItemSharedWithBySourceCalendar($id);
             }
             if (!$sharedCalendar || !(isset($sharedCalendar['permissions']) && $sharedCalendar['permissions'] & $this->shareConnector->getReadAccess())) {
                 return $calendarInfo;
                 // I have to return the row so e.g. Object::getowner() works.
             }
             $calendarInfo['permissions'] = $sharedCalendar['permissions'];
         } else {
             $calendarInfo['permissions'] = $this->shareConnector->getAllAccess();
         }
         return $calendarInfo;
     } else {
         return null;
     }
 }
Ejemplo n.º 2
0
 /**
  * @brief Gets the data of one calendar
  * @param integer $id
  * @return associative array
  */
 public static function find($id)
 {
     $user = \OCP\User::getUser();
     $dbObject = \OC::$server->getDb();
     $calendarDB = new CalendarDAO($dbObject, $user);
     $calendarInfo = $calendarDB->find($id);
     if ($calendarInfo !== null) {
         if ($calendarInfo['userid'] !== $user) {
             $userExists = \OC::$server->getUserManager()->userExists($user);
             if (!$userExists) {
                 $sharedCalendar = \OCP\Share::getItemSharedWithByLink(App::SHARECALENDAR, App::SHARECALENDARPREFIX . $id, $calendarInfo['userid']);
             } else {
                 $sharedCalendar = \OCP\Share::getItemSharedWithBySource(App::SHARECALENDAR, App::SHARECALENDARPREFIX . $id);
             }
             if (!$sharedCalendar || !(isset($sharedCalendar['permissions']) && $sharedCalendar['permissions'] & \OCP\PERMISSION_READ)) {
                 return $calendarInfo;
                 // I have to return the row so e.g. Object::getowner() works.
             }
             $calendarInfo['permissions'] = $sharedCalendar['permissions'];
         } else {
             $calendarInfo['permissions'] = \OCP\PERMISSION_ALL;
         }
         return $calendarInfo;
     } else {
         return null;
     }
 }