permissionToJson() public static method

This methods filters out any permissions for the owner and converts the user name if necessary.
public static permissionToJson ( Horde_Perms_Permission $perm, boolean $systemShare = false ) : array
$perm Horde_Perms_Permission A permission object.
$systemShare boolean Is this from a system share?
return array A hash suitable for json.
Esempio n. 1
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;
 }
Esempio n. 2
0
            $code['conf']['calendars']['internal'][$id] = array('name' => ($owner || !$calendar->owner() ? '' : '[' . $GLOBALS['registry']->convertUsername($calendar->owner(), false) . '] ') . $calendar->name(), 'desc' => $calendar->description(), 'owner' => $owner, 'fg' => $calendar->foreground(), 'bg' => $calendar->background(), 'show' => in_array($id, $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_CALENDARS)), 'edit' => $calendar->hasPermission(Horde_Perms::EDIT), 'feed' => (string) Kronolith::feedUrl($id), 'embed' => Kronolith::embedCode($id));
            if ($owner) {
                $code['conf']['calendars']['internal'][$id]['perms'] = Kronolith::permissionToJson($calendar->share()->getPermission());
            }
        }
    }
    // Tasklists
    if (!$has_tasks) {
        continue;
    }
    foreach ($registry->tasks->listTasklists($my, Horde_Perms::SHOW) as $id => $tasklist) {
        $owner = $GLOBALS['registry']->getAuth() && $tasklist->get('owner') == $GLOBALS['registry']->getAuth();
        if ($my && $owner || !$my && !$owner) {
            $code['conf']['calendars']['tasklists']['tasks/' . $id] = array('name' => Kronolith::getLabel($tasklist), 'desc' => $tasklist->get('desc'), 'owner' => $owner, 'fg' => Kronolith::foregroundColor($tasklist), 'bg' => Kronolith::backgroundColor($tasklist), 'show' => in_array('tasks/' . $id, $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_EXTERNAL_CALENDARS)), 'edit' => $tasklist->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT));
            if ($owner) {
                $code['conf']['calendars']['tasklists']['tasks/' . $id]['perms'] = Kronolith::permissionToJson($tasklist->getPermission());
            }
        }
    }
}
// Timeobjects
foreach ($GLOBALS['calendar_manager']->get(Kronolith::ALL_EXTERNAL_CALENDARS) as $id => $calendar) {
    if ($calendar->api() == 'tasks') {
        continue;
    }
    if (!$calendar->display()) {
        continue;
    }
    $code['conf']['calendars']['external'][$id] = array('name' => $calendar->name(), 'fg' => $calendar->foreground(), 'bg' => $calendar->background(), 'api' => $registry->get('name', $registry->hasInterface($calendar->api())), 'show' => in_array($id, $GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_EXTERNAL_CALENDARS)));
}
// Remote calendars
Esempio n. 3
0
 /**
  * Returns a hash representing this calendar.
  *
  * @return array  A simple hash.
  */
 public function toHash()
 {
     $owner = $GLOBALS['registry']->isAdmin() || $GLOBALS['injector']->getInstance('Horde_Core_Perms')->hasAppPermission('resource_management');
     $hash = parent::toHash();
     $hash['id'] = $this->_resource->getId();
     $hash['name'] = $this->name();
     $hash['owner'] = $owner;
     $hash['show'] = $this->display();
     $hash['edit'] = $this->hasPermission(Horde_Perms::EDIT);
     $hash['sub'] = null;
     $hash['feed'] = null;
     $hash['embed'] = null;
     $hash['response_type'] = $this->_resource->get('response_type');
     if ($owner) {
         $hash['perms'] = Kronolith::permissionToJson($this->_resource->getPermission());
     }
     return $hash;
 }
Esempio n. 4
0
 /**
  * Returns a hash representing this calendar.
  *
  * @return array  A simple hash.
  */
 public function toHash()
 {
     global $calendar_manager, $conf, $injector, $registry;
     $id = $this->_share->getName();
     $owner = $registry->getAuth() && $this->owner() == $registry->getAuth();
     $hash = parent::toHash();
     $hash['name'] = $this->name();
     $hash['owner'] = $owner;
     $hash['users'] = Kronolith::listShareUsers($this->_share);
     $hash['show'] = in_array($id, $calendar_manager->get(Kronolith::DISPLAY_CALENDARS));
     $hash['edit'] = $this->hasPermission(Horde_Perms::EDIT);
     try {
         $hash['caldav'] = Horde::url($registry->get('webroot', 'horde') . ($conf['urls']['pretty'] == 'rewrite' ? '/rpc/calendars/' : '/rpc.php/calendars/'), true, -1) . $registry->getAuth() . '/' . $injector->getInstance('Horde_Dav_Storage')->getExternalCollectionId($id, 'calendar') . '/';
     } catch (Horde_Exception $e) {
     }
     $hash['sub'] = Horde::url($registry->get('webroot', 'horde') . ($conf['urls']['pretty'] == 'rewrite' ? '/rpc/kronolith/' : '/rpc.php/kronolith/'), true, -1) . ($this->owner() ? $this->owner() : '-system-') . '/' . $id . '.ics';
     $hash['feed'] = (string) Kronolith::feedUrl($id);
     $hash['embed'] = Kronolith::embedCode($id);
     $hash['tg'] = array_values(Kronolith::getTagger()->getTags($id, Kronolith_Tagger::TYPE_CALENDAR));
     if ($owner) {
         $hash['perms'] = Kronolith::permissionToJson($this->_share->getPermission());
     }
     return $hash;
 }
Esempio n. 5
0
 /**
  * Returns a hash representing this calendar.
  *
  * @return array  A simple hash.
  */
 public function toHash()
 {
     global $calendar_manager, $conf, $injector, $registry;
     $id = $this->_share->getName();
     $owner = $registry->getAuth() && ($this->owner() == $registry->getAuth() || $this->isSystem() && $registry->isAdmin());
     $hash = parent::toHash();
     $hash['name'] = $this->name();
     $hash['owner'] = $owner;
     $hash['system'] = $this->isSystem();
     $hash['users'] = Kronolith::listShareUsers($this->_share);
     $hash['show'] = in_array($id, $calendar_manager->get(Kronolith::DISPLAY_CALENDARS));
     $hash['edit'] = $this->hasPermission(Horde_Perms::EDIT);
     $hash['delete'] = $this->hasPermission(Horde_Perms::DELETE);
     $hash['caldav'] = $this->caldavUrl();
     $hash['sub'] = Horde::url($registry->get('webroot', 'horde') . ($conf['urls']['pretty'] == 'rewrite' ? '/rpc/kronolith/' : '/rpc.php/kronolith/'), true, -1) . ($this->owner() ? $registry->convertUsername($this->owner(), false) : '-system-') . '/' . $id . '.ics';
     $hash['feed'] = (string) Kronolith::feedUrl($id);
     $hash['embed'] = Kronolith::embedCode($id);
     $hash['tg'] = array_values(Kronolith::getTagger()->getTags($id, Kronolith_Tagger::TYPE_CALENDAR));
     if ($owner) {
         $hash['perms'] = Kronolith::permissionToJson($this->_share->getPermission(), is_null($this->_share->get('owner')));
     }
     return $hash;
 }