Exemple #1
0
 /**
  * Return permission for the specified user for this Resource.
  *
  * @param string $user         The user to check for.
  * @param integer $permission  The permission to check.
  * @param $restrict
  *
  * @return boolean
  */
 public function hasPermission($user, $permission = Horde_Perms::READ, $restrict = null)
 {
     if ($user === null) {
         $user = $GLOBALS['registry']->getAuth();
     }
     return $this->_share->hasPermission($user, $permission);
 }
Exemple #2
0
 /**
  * Encapsulates permissions checking.
  *
  * @param integer $permission  The permission to check for.
  * @param string $user         The user to check permissions for. Defaults
  *                             to the current user.
  * @param string $creator      An event creator, to check for creator
  *                             permissions.
  *
  * @return boolean  Whether the user has the permission on this calendar.
  */
 public function hasPermission($permission, $user = null, $creator = null)
 {
     if ($user === null) {
         $user = $GLOBALS['registry']->getAuth();
     }
     return $this->_share->hasPermission($user, $permission, $creator);
 }
Exemple #3
0
 /**
  * Encapsulates permissions checking.
  *
  * @param integer $permission  The permission to check for.
  * @param string $user         The user to check permissions for. Defaults
  *                             to the current user.
  * @param string $creator      An event creator, to check for creator
  *                             permissions.
  *
  * @return boolean  Whether the user has the permission on this calendar.
  */
 public function hasPermission($permission, $user = null, $creator = null)
 {
     if ($user === null) {
         $user = $GLOBALS['registry']->getAuth();
     }
     if ($this->_share->get('user') == null && $GLOBALS['registry']->isAdmin()) {
         return true;
     }
     return $this->_share->hasPermission($user, $permission, $creator);
 }
Exemple #4
0
 /**
  * Returns a hash representing this calendar.
  *
  * @return array  A simple hash.
  */
 public function toHash()
 {
     global $calendar_manager, $conf, $injector, $registry;
     $owner = $registry->getAuth() && $this->_share->get('owner') == $registry->getAuth();
     $hash = parent::toHash();
     $hash['name'] = Kronolith::getLabel($this->_share);
     $hash['desc'] = (string) $this->_share->get('desc');
     $hash['owner'] = $owner;
     $hash['users'] = Kronolith::listShareUsers($this->_share);
     $hash['fg'] = Kronolith::foregroundColor($this->_share);
     $hash['bg'] = Kronolith::backgroundColor($this->_share);
     $hash['show'] = in_array('tasks/' . $this->_share->getName(), $calendar_manager->get(Kronolith::DISPLAY_EXTERNAL_CALENDARS));
     $hash['edit'] = $this->_share->hasPermission($registry->getAuth(), Horde_Perms::EDIT);
     $hash['caldav'] = $this->caldavUrl();
     $hash['sub'] = Horde::url($registry->get('webroot', 'horde') . ($conf['urls']['pretty'] == 'rewrite' ? '/rpc/nag/' : '/rpc.php/nag/'), true, -1) . ($this->_share->get('owner') ? $registry->convertUsername($this->_share->get('owner'), false) : '-system-') . '/' . $this->_share->getName() . '.ics';
     if ($owner) {
         $hash['perms'] = Kronolith::permissionToJson($this->_share->getPermission(), is_null($this->_share->get('owner')));
     }
     return $hash;
 }
Exemple #5
0
 /**
  * Returns a json representation of this gallery.
  *
  * @param boolean $full  Return all information (subgalleries and images)?
  *
  * @return StdClass  An object describing the gallery
  * <pre>
  * 'id' - gallery id
  * 'p'  - gallery's parent's id (null if top level)
  * 'pn' - gallery's parent's name (null if top level)
  * 'n'  - gallery name
  * 'dc' - date created
  * 'dm' - date modified
  * 'd'  - description
  * 'ki' - key image
  * 'sg' - an object with the following properties:
  *      'n'  - gallery name
  *      'dc' - date created
  *      'dm' - date modified
  *      'd'  - description
  *      'ki' - key image
  *
  *  'imgs' - an array of image objects with the following properties:
  *      'id'  - the image id
  *      'url' - the image url
  * </pre>
  */
 public function toJson($full = false)
 {
     // @TODO: Support date grouped galleries
     $vMode = $this->get('view_mode');
     if ($vMode != 'Normal') {
         $this->_setModeHelper('Normal');
     }
     $style = Ansel::getStyleDefinition('ansel_mobile');
     $json = new StdClass();
     $json->id = $this->id;
     $json->n = $this->get('name');
     $json->dc = $this->get('date_created');
     $json->dm = $this->get('last_modified');
     $json->d = $this->get('desc');
     $json->ki = Ansel::getImageUrl($this->getKeyImage($style), 'thumb', false, $style)->toString(true);
     $json->imgs = array();
     // Parent
     $parents = $this->getParents();
     if (empty($parents)) {
         $json->p = null;
         $json->pn = null;
     } else {
         $p = array_pop($parents);
         $json->p = $p->id;
         $json->pn = $p->get('name');
     }
     if ($full) {
         $json->tiny = $GLOBALS['conf']['image']['tiny'] && ($GLOBALS['conf']['vfs']['src'] == 'direct' || $this->_share->hasPermission('', Horde_Perms::READ));
         $json->sg = array();
         if ($this->hasSubGalleries()) {
             $sgs = $this->getChildren($GLOBALS['registry']->getAuth(), Horde_Perms::READ, false);
             //GLOBALS['injector']->getInstance('Ansel_Storage')->listGalleries(array('parent' => $this->id, 'all_levels' => false));
             foreach ($sgs as $g) {
                 $json->sg[] = $g->toJson();
             }
         }
         $images = $this->getImages();
         foreach ($images as $img) {
             $i = new StdClass();
             $i->id = $img->id;
             $i->url = Ansel::getImageUrl($img->id, 'thumb', false, $style)->toString(true);
             $i->screen = Ansel::getImageUrl($img->id, 'screen', $json->tiny, Ansel::getStyleDefinition('ansel_default'))->toString(true);
             $i->fn = $img->filename;
             $json->imgs[] = $i;
         }
     }
     if ($vMode != 'Normal') {
         $this->_setModeHelper($vMode);
     }
     return $json;
 }