getUrl() public static method

Returns a DAV URL to be used for a task list.
public static getUrl ( integer $type, $tasklist ) : string
$type integer A Nag::DAV_* constant.
return string The task list's URL.
示例#1
0
 /**
  *
  * @param array $vars
  * @param Horde_Share_Object $tasklist
  */
 public function __construct($vars, Horde_Share_Object $tasklist)
 {
     $this->_tasklist = $tasklist;
     $owner = $tasklist->get('owner') == $GLOBALS['registry']->getAuth() || is_null($tasklist->get('owner')) && $GLOBALS['registry']->isAdmin();
     parent::__construct($vars, $owner ? sprintf(_("Edit %s"), $tasklist->get('name')) : $tasklist->get('name'));
     $this->addHidden('', 't', 'text', true);
     $this->addVariable(_("Name"), 'name', 'text', true);
     if (!$owner) {
         $v = $this->addVariable(_("Owner"), 'owner', 'text', false);
         $owner_name = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create($tasklist->get('owner'))->getValue('fullname');
         if (trim($owner_name) == '') {
             $owner_name = $tasklist->get('owner');
         }
         $v->setDefault($owner_name ? $owner_name : _("System"));
     }
     $this->addVariable(_("Color"), 'color', 'colorpicker', false);
     if ($GLOBALS['registry']->isAdmin()) {
         $this->addVariable(_("System Task List"), 'system', 'boolean', false, false, _("System task lists don't have an owner. Only administrators can change the task list settings and permissions."));
     }
     $this->addVariable(_("Description"), 'description', 'longtext', false, false, null, array(4, 60));
     /* Display URL. */
     $url = Horde::url('list.php', true, -1)->add('display_tasklist', $tasklist->getName());
     $this->addVariable(_("Display URL"), '', 'link', false, false, null, array(array('url' => $url, 'text' => $url, 'title' => _("Click or copy this URL to display this task list"), 'target' => '_blank')));
     /* Subscription URLs. */
     try {
         $accountUrl = Nag::getUrl(Nag::DAV_ACCOUNT, $tasklist);
         $caldavUrl = Nag::getUrl(Nag::DAV_CALDAV, $tasklist);
         $this->addVariable(_("CalDAV Subscription URL"), '', 'link', false, false, null, array(array('url' => $caldavUrl, 'text' => $caldavUrl, 'title' => _("Copy this URL to a CalDAV client to subscribe to this task list"), 'target' => '_blank')));
         $this->addVariable(_("CalDAV Account URL"), '', 'link', false, false, null, array(array('url' => $accountUrl, 'text' => $accountUrl, 'title' => _("Copy this URL to a CalDAV client to subscribe to all your task lists"), 'target' => '_blank')));
     } catch (Horde_Exception $e) {
     }
     $webdavUrl = Nag::getUrl(Nag::DAV_WEBDAV, $tasklist);
     $this->addVariable(_("WebDAV/ICS Subscription URL"), '', 'link', false, false, null, array(array('url' => $webdavUrl, 'text' => $webdavUrl, 'title' => _("Copy this URL to a WebDAV or ICS client to subscribe to this task list"), 'target' => '_blank')));
     /* Permissions link. */
     if (empty($GLOBALS['conf']['share']['no_sharing']) && $owner) {
         $url = Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/services/shares/edit.php')->add(array('app' => 'nag', 'share' => $tasklist->getName()));
         $this->addVariable('', '', 'link', false, false, null, array(array('url' => $url, 'text' => _("Change Permissions"), 'onclick' => Horde::popupJs($url, array('params' => array('urlencode' => true))) . 'return false;', 'class' => 'horde-button', 'target' => '_blank')));
     }
     $this->setButtons(array(_("Save"), array('class' => 'horde-delete', 'value' => _("Delete")), array('class' => 'horde-cancel', 'value' => _("Cancel"))));
 }
示例#2
0
 /**
  */
 public function davGetCollections($user)
 {
     global $injector, $nag_shares, $registry;
     $hordeUser = $registry->convertUsername($user, true);
     $shares = $nag_shares->listShares($hordeUser);
     $dav = $injector->getInstance('Horde_Dav_Storage');
     $tasklists = array();
     foreach ($shares as $id => $share) {
         if ($user == '-system-' && $share->get('owner')) {
             continue;
         }
         try {
             $id = $dav->getExternalCollectionId($id, 'tasks') ?: $id;
         } catch (Horde_Dav_Exception $e) {
         }
         $tasklists[] = array('id' => $id, 'uri' => $id, '{' . CalDAV\Plugin::NS_CALENDARSERVER . '}shared-url' => Nag::getUrl(Nag::DAV_CALDAV, $share), 'principaluri' => 'principals/' . $user, '{http://sabredav.org/ns}owner-principal' => 'principals/' . ($share->get('owner') ? $registry->convertUsername($share->get('owner'), false) : '-system-'), '{DAV:}displayname' => Nag::getLabel($share), '{urn:ietf:params:xml:ns:caldav}calendar-description' => $share->get('desc'), '{http://apple.com/ns/ical/}calendar-color' => $share->get('color'), '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Sabre\CalDAV\Property\SupportedCalendarComponentSet(array('VTODO')), '{http://sabredav.org/ns}read-only' => !$share->hasPermission($hordeUser, Horde_Perms::EDIT));
     }
     return $tasklists;
 }