本文整理汇总了PHP中Kronolith::hasApiPermission方法的典型用法代码示例。如果您正苦于以下问题:PHP Kronolith::hasApiPermission方法的具体用法?PHP Kronolith::hasApiPermission怎么用?PHP Kronolith::hasApiPermission使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kronolith
的用法示例。
在下文中一共展示了Kronolith::hasApiPermission方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _addBaseVars
/**
* Add base javascript variables to the page.
*/
protected function _addBaseVars()
{
global $conf, $injector, $prefs, $registry;
$auth_name = $registry->getAuth();
$has_tasks = Kronolith::hasApiPermission('tasks');
$identity = $injector->getInstance('Horde_Core_Factory_Identity')->create();
$app_urls = $js_vars = array();
if (isset($conf['menu']['apps']) && is_array($conf['menu']['apps'])) {
foreach ($conf['menu']['apps'] as $app) {
$app_urls[$app] = strval(Horde::url($registry->getInitialPage($app), true));
}
}
/* Variables used in core javascript files. */
$js_vars['conf'] = array_filter(array('URI_CALENDAR_EXPORT' => str_replace(array('%23', '%2523', '%7B', '%257B', '%7D', '%257D'), array('#', '#', '{', '{', '}', '}'), strval($registry->downloadUrl('#{calendar}.ics', array('actionID' => 'export', 'all_events' => 1, 'exportID' => Horde_Data::EXPORT_ICALENDAR, 'exportCal' => 'internal_#{calendar}'))->setRaw(true))), 'URI_RESOURCE_EXPORT' => str_replace(array('%23', '%2523', '%7B', '%257B', '%7D', '%257D'), array('#', '#', '{', '{', '}', '}'), strval($registry->downloadUrl('#{calendar}.ics', array('actionID' => 'export', 'all_events' => 1, 'exportID' => Horde_Data::EXPORT_ICALENDAR, 'exportCal' => 'resource_#{calendar}'))->setRaw(true))), 'URI_EVENT_EXPORT' => str_replace(array('%23', '%7B', '%7D'), array('#', '{', '}'), Horde::url('event.php', true)->add(array('view' => 'ExportEvent', 'eventID' => '#{id}', 'calendar' => '#{calendar}', 'type' => '#{type}'))), 'images' => array('alarm' => strval(Horde_Themes::img('alarm-fff.png')), 'attendees' => strval(Horde_Themes::img('attendees-fff.png')), 'exception' => strval(Horde_Themes::img('exception-fff.png')), 'new_event' => strval(Horde_Themes::img('new.png')), 'new_task' => strval(Horde_Themes::img('new_task.png')), 'recur' => strval(Horde_Themes::img('recur-fff.png'))), 'new_event' => $injector->getInstance('Kronolith_View_Sidebar')->newLink . $injector->getInstance('Kronolith_View_Sidebar')->newText . '</a>', 'new_task' => $injector->getInstance('Kronolith_View_SidebarTasks')->newLink . $injector->getInstance('Kronolith_View_SidebarTasks')->newText . '</a>', 'user' => $registry->convertUsername($auth_name, false), 'name' => $identity->getName(), 'email' => strval($identity->getDefaultFromAddress()), 'prefs_url' => strval($registry->getServiceLink('prefs', 'kronolith')->setRaw(true)), 'app_urls' => $app_urls, 'name' => $registry->get('name'), 'has_tasks' => intval($has_tasks), 'has_resources' => intval(!empty($conf['resource']['driver'])), 'login_view' => $prefs->getValue('defaultview') == 'workweek' ? 'week' : $prefs->getValue('defaultview'), 'default_calendar' => 'internal|' . Kronolith::getDefaultCalendar(Horde_Perms::EDIT), 'max_events' => intval($prefs->getValue('max_events')), 'date_format' => Horde_Core_Script_Package_Datejs::translateFormat(Horde_Nls::getLangInfo(D_FMT)), 'time_format' => $prefs->getValue('twentyFour') ? 'HH:mm' : 'hh:mm tt', 'import_file' => Horde_Data::IMPORT_FILE, 'import_url' => Horde_Data::IMPORT_URL, 'show_time' => Kronolith::viewShowTime(), 'default_alarm' => intval($prefs->getValue('default_alarm')), 'status' => array('cancelled' => Kronolith::STATUS_CANCELLED, 'confirmed' => Kronolith::STATUS_CONFIRMED, 'free' => Kronolith::STATUS_FREE, 'tentative' => Kronolith::STATUS_TENTATIVE), 'recur' => array(Horde_Date_Recurrence::RECUR_NONE => 'None', Horde_Date_Recurrence::RECUR_DAILY => 'Daily', Horde_Date_Recurrence::RECUR_WEEKLY => 'Weekly', Horde_Date_Recurrence::RECUR_MONTHLY_DATE => 'Monthly', Horde_Date_Recurrence::RECUR_MONTHLY_WEEKDAY => 'Monthly', Horde_Date_Recurrence::RECUR_YEARLY_DATE => 'Yearly', Horde_Date_Recurrence::RECUR_YEARLY_DAY => 'Yearly', Horde_Date_Recurrence::RECUR_YEARLY_WEEKDAY => 'Yearly'), 'perms' => array('all' => Horde_Perms::ALL, 'show' => Horde_Perms::SHOW, 'read' => Horde_Perms::READ, 'edit' => Horde_Perms::EDIT, 'delete' => Horde_Perms::DELETE, 'delegate' => Kronolith::PERMS_DELEGATE), 'tasks' => $has_tasks ? $registry->tasks->ajaxDefaults() : null));
/* Make sure this value is not optimized out by array_filter(). */
$js_vars['conf']['week_start'] = intval($prefs->getValue('week_start_monday'));
/* Gettext strings. */
$js_vars['text'] = array('alarm' => _("Alarm:"), 'alerts' => _("Notifications"), 'allday' => _("All day"), 'delete_calendar' => _("Are you sure you want to delete this calendar and all the events in it?"), 'delete_tasklist' => _("Are you sure you want to delete this task list and all the tasks in it?"), 'external_category' => _("Other events"), 'fix_form_values' => _("Please enter correct values in the form first."), 'geocode_error' => _("Unable to locate requested address"), 'hidelog' => _("Hide Notifications"), 'import_warning' => _("Importing calendar data. This may take a while..."), 'more' => _("more..."), 'no_assignee' => _("None"), 'no_calendar_title' => _("The calendar title must not be empty."), 'no_parent' => _("No parent task"), 'no_tasklist_title' => _("The task list title must not be empty."), 'no_url' => _("You must specify a URL."), 'prefs' => _("Preferences"), 'searching' => sprintf(_("Events matching \"%s\""), '#{term}'), 'shared' => _("Shared"), 'tasks' => _("Tasks"), 'unknown_resource' => _("Unknown resource."), 'wrong_auth' => _("The authentication information you specified wasn't accepted."), 'wrong_date_format' => sprintf(_("You used an unknown date format \"%s\". Please try something like \"%s\"."), '#{wrong}', '#{right}'), 'wrong_time_format' => sprintf(_("You used an unknown time format \"%s\". Please try something like \"%s\"."), '#{wrong}', '#{right}'));
for ($i = 1; $i <= 12; ++$i) {
$js_vars['text']['month'][$i - 1] = Horde_Nls::getLangInfo(constant('MON_' . $i));
}
for ($i = 1; $i <= 7; ++$i) {
$js_vars['text']['weekday'][$i] = Horde_Nls::getLangInfo(constant('DAY_' . $i));
}
foreach (array_diff(array_keys($js_vars['conf']['recur']), array(Horde_Date_Recurrence::RECUR_NONE)) as $recurType) {
$js_vars['text']['recur'][$recurType] = Kronolith::recurToString($recurType);
}
$js_vars['text']['recur']['exception'] = _("Exception");
// Maps
$js_vars['conf']['maps'] = $conf['maps'];
return $js_vars;
}
示例2: listCalendars
/**
* Returns a list of all calendars.
*/
public function listCalendars()
{
Kronolith::initialize();
$all_external_calendars = $GLOBALS['calendar_manager']->get(Kronolith::ALL_EXTERNAL_CALENDARS);
$result = new stdClass();
$auth_name = $GLOBALS['registry']->getAuth();
// Calendars. Do some twisting to sort own calendar before shared
// calendars.
foreach (array(true, false) as $my) {
foreach ($GLOBALS['calendar_manager']->get(Kronolith::ALL_CALENDARS) as $id => $calendar) {
$owner = $auth_name && $calendar->owner() == $auth_name;
if ($my && $owner || !$my && !$owner) {
$result->calendars['internal'][$id] = $calendar->toHash();
}
}
// Tasklists
if (Kronolith::hasApiPermission('tasks')) {
foreach ($GLOBALS['registry']->tasks->listTasklists($my, Horde_Perms::SHOW, false) as $id => $tasklist) {
if (isset($all_external_calendars['tasks/' . $id])) {
$owner = $auth_name && $tasklist->get('owner') == $auth_name;
if ($my && $owner || !$my && !$owner) {
$result->calendars['tasklists']['tasks/' . $id] = $all_external_calendars['tasks/' . $id]->toHash();
}
}
}
}
}
// Resources
if (!empty($GLOBALS['conf']['resources']['enabled'])) {
foreach (Kronolith::getDriver('Resource')->listResources() as $resource) {
if ($resource->get('isgroup')) {
$rcal = new Kronolith_Calendar_ResourceGroup(array('resource' => $resource));
$result->calendars['resourcegroup'][$resource->getId()] = $rcal->toHash();
} else {
$rcal = new Kronolith_Calendar_Resource(array('resource' => $resource));
$result->calendars['resource'][$resource->get('calendar')] = $rcal->toHash();
}
}
}
// Timeobjects
foreach ($all_external_calendars as $id => $calendar) {
if ($calendar->api() != 'tasks' && $calendar->display()) {
$result->calendars['external'][$id] = $calendar->toHash();
}
}
// Remote calendars
foreach ($GLOBALS['calendar_manager']->get(Kronolith::ALL_REMOTE_CALENDARS) as $url => $calendar) {
$result->calendars['remote'][$url] = $calendar->toHash();
}
// Holidays
foreach ($GLOBALS['calendar_manager']->get(Kronolith::ALL_HOLIDAYS) as $id => $calendar) {
$result->calendars['holiday'][$id] = $calendar->toHash();
}
return $result;
}
示例3: array
<?php
global $prefs, $registry;
$kronolith_webroot = $registry->get('webroot');
$horde_webroot = $registry->get('webroot', 'horde');
$has_tasks = Kronolith::hasApiPermission('tasks');
/* Variables used in core javascript files. */
$code['conf'] = array('images' => array('attendees' => (string) Horde_Themes::img('attendees-fff.png'), 'alarm' => (string) Horde_Themes::img('alarm-fff.png'), 'recur' => (string) Horde_Themes::img('recur-fff.png'), 'exception' => (string) Horde_Themes::img('exception-fff.png')), 'user' => $GLOBALS['registry']->convertUsername($GLOBALS['registry']->getAuth(), false), 'prefs_url' => strval($registry->getServiceLink('prefs', 'kronolith')->setRaw(true)), 'name' => $registry->get('name'), 'has_tasks' => $has_tasks, 'default_calendar' => 'internal|' . Kronolith::getDefaultCalendar(Horde_Perms::EDIT), 'week_start' => (int) $prefs->getValue('week_start_monday'), 'max_events' => (int) $prefs->getValue('max_events'), 'date_format' => str_replace(array('%e', '%d', '%a', '%A', '%m', '%h', '%b', '%B', '%y', '%Y'), array('d', 'dd', 'ddd', 'dddd', 'MM', 'MMM', 'MMM', 'MMMM', 'yy', 'yyyy'), Horde_Nls::getLangInfo(D_FMT)), 'time_format' => $prefs->getValue('twentyFour') ? 'HH:mm' : 'hh:mm tt', 'status' => array('tentative' => Kronolith::STATUS_TENTATIVE, 'confirmed' => Kronolith::STATUS_CONFIRMED, 'cancelled' => Kronolith::STATUS_CANCELLED, 'free' => Kronolith::STATUS_FREE), 'recur' => array(Horde_Date_Recurrence::RECUR_NONE => 'None', Horde_Date_Recurrence::RECUR_DAILY => 'Daily', Horde_Date_Recurrence::RECUR_WEEKLY => 'Weekly', Horde_Date_Recurrence::RECUR_MONTHLY_DATE => 'Monthly', Horde_Date_Recurrence::RECUR_MONTHLY_WEEKDAY => 'Monthly', Horde_Date_Recurrence::RECUR_MONTHLY_LAST_WEEKDAY => 'Monthly', Horde_Date_Recurrence::RECUR_YEARLY_DATE => 'Yearly', Horde_Date_Recurrence::RECUR_YEARLY_DAY => 'Yearly', Horde_Date_Recurrence::RECUR_YEARLY_WEEKDAY => 'Yearly'), 'perms' => array('all' => Horde_Perms::ALL, 'show' => Horde_Perms::SHOW, 'read' => Horde_Perms::READ, 'edit' => Horde_Perms::EDIT, 'delete' => Horde_Perms::DELETE, 'delegate' => Kronolith::PERMS_DELEGATE));
if ($has_tasks) {
$code['conf']['tasks'] = $registry->tasks->ajaxDefaults();
}
// Calendars
foreach (array(true, false) as $my) {
foreach ($GLOBALS['calendar_manager']->get(Kronolith::ALL_CALENDARS) as $id => $calendar) {
$owner = $GLOBALS['registry']->getAuth() && $calendar->owner() == $GLOBALS['registry']->getAuth();
if ($my && $owner || !$my && !$owner) {
$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) {
示例4: _getDisplayExternal
/**
* Return all external calendars selected for display.
*
* @return array
*/
protected function _getDisplayExternal()
{
global $registry, $prefs;
// Make sure all the external calendars still exist.
$_tasklists = $_temp = $this->_displayExternal;
if (Kronolith::hasApiPermission('tasks')) {
try {
$_tasklists = $registry->tasks->getDisplayedTasklists();
} catch (Horde_Exception $e) {
}
}
$this->_displayExternal = array();
foreach ($this->get(Kronolith::ALL_EXTERNAL_CALENDARS) as $id => $calendar) {
if (substr($id, 0, 6) == 'tasks/' && in_array(substr($id, 6), $_tasklists) || in_array($id, $_temp)) {
$this->_displayExternal[] = $id;
}
}
$prefs->setValue('display_external_cals', serialize($this->_displayExternal));
return $this->displayExternal;
}
示例5: _
echo _("Shared Calendars");
?>
</span>
</h3>
<div style="display:none">
<div class="horde-info"><?php
echo _("No items to display");
?>
</div>
<div id="kronolithSharedCalendars" class="horde-resources"></div>
</div>
</div>
<?php
if (Kronolith::hasApiPermission('tasks')) {
?>
<div class="horde-sidebar-split"></div>
<div>
<h3>
<!-- to be added when searching for shared calendars is implemented <a href="#" id="kronolithAddtasklistsshared" class="horde-add">+</a>-->
<span class="horde-expand" title="<?php
echo _("Expand");
?>
"><?php
echo _("Shared Task Lists");
?>
</span>
</h3>
<div style="display:none">
示例6: topbarCreate
/**
*/
public function topbarCreate(Horde_Tree_Renderer_Base $tree, $parent = null, array $params = array())
{
switch ($params['id']) {
case 'menu':
$menus = array(array('new', _("New Event"), 'new.png', Horde::url('new.php')), array('day', _("Day"), 'dayview.png', Horde::url('day.php')), array('work', _("Work Week"), 'workweekview.png', Horde::url('workweek.php')), array('week', _("Week"), 'weekview.png', Horde::url('week.php')), array('month', _("Month"), 'monthview.png', Horde::url('month.php')), array('year', _("Year"), 'yearview.png', Horde::url('year.php')));
if (Kronolith::showAjaxView()) {
if (Kronolith::hasApiPermission('tasks')) {
$menus[] = array('tasks', _("Tasks"), 'tasks.png', $GLOBALS['registry']->get('webroot') . '#tasks');
}
$menus[] = array('agenda', _("Agenda"), 'agenda.png', $GLOBALS['registry']->get('webroot') . '#agenda');
}
// Dynamic view has no dedicated search page.
if (!Kronolith::showAjaxView()) {
$menus[] = array('search', _("Search"), 'search.png', Horde::url('search.php'));
}
foreach ($menus as $menu) {
$tree->addNode(array('id' => $parent . $menu[0], 'parent' => $parent, 'label' => $menu[1], 'expanded' => false, 'params' => array('icon' => Horde_Themes::img($menu[2]), 'url' => $menu[3])));
}
break;
}
}