$a_template->set('go', _("Go"));
}
-$a_template->set('create_folder', !empty($GLOBALS['conf']['hooks']['permsdenied']) || (IMP::hasPermission('create_folders') && IMP::hasPermission('max_folders')));
+$a_template->set('create_folder', !empty($GLOBALS['conf']['hooks']['permsdenied']) || ($GLOBALS['perms']->hasAppPermission('create_folders') && $GLOBALS['perms']->hasAppPermission('max_folders')));
if ($prefs->getValue('subscribe')) {
$a_template->set('subscribe', true);
$subToggleText = ($showAll) ? _("Hide Unsubscribed") : _("Show Unsubscribed");
);
}
+ /**
+ * Returns the specified permission for the current user.
+ *
+ * @param mixed $allowed The allowed permissions.
+ * @param array $opts Additinal options ('value').
+ *
+ * @return mixed The value of the specified permission.
+ */
+ public function hasPermission($allowed, $opts = array())
+ {
+ if (is_array($allowed)) {
+ switch ($permission) {
+ case 'create_folders':
+ $allowed = (bool)count(array_filter($allowed));
+ break;
+
+ case 'max_folders':
+ case 'max_recipients':
+ case 'max_timelimit':
+ $allowed = max($allowed);
+ break;
+ }
+ }
+
+ if (($permission == 'max_folders') && empty($opts['value'])) {
+ $folder = IMP_Folder::singleton();
+ $allowed = $allowed > count($folder->flist_IMP(array(), false));
+ }
+
+ return $allowed;
+ }
+
/* Horde_Auth_Application methods. */
/**
return;
}
- $timelimit = IMP::hasPermission('max_timelimit');
+ $timelimit = $GLOBALS['perms']->hasAppPermission('max_timelimit');
if ($timelimit !== true) {
if ($conf['sentmail']['driver'] == 'none') {
Horde::logMessage('The permission for the maximum number of recipients per time period has been enabled, but no backend for the sent-mail logging has been configured for IMP.', __FILE__, __LINE__, PEAR_LOG_ERR);
/* Count recipients if necessary. We need to split email groups
* because the group members count as separate recipients. */
if ($exceed) {
- $max_recipients = IMP::hasPermission('max_recipients');
+ $max_recipients = $GLOBALS['perms']->hasAppPermission('max_recipients');
if ($max_recipients !== true) {
$num_recipients = 0;
foreach ($addrlist as $recipient) {
global $conf, $notification;
/* Check permissions. */
- if (!IMP::hasPermission('create_folders')) {
+ if (!$GLOBALS['perms']->hasAppPermission('create_folders')) {
try {
$message = Horde::callHook('perms_denied', array('imp:create_folders'));
} catch (Horde_Exception_HookNotSet $e) {
}
$notification->push($message, 'horde.error', array('content.raw'));
return false;
- } elseif (!IMP::hasPermission('max_folders')) {
+ } elseif (!$GLOBALS['perms']->hasAppPermission('max_folders')) {
try {
$message = Horde::callHook('perms_denied', array('imp:max_folders'));
} catch (Horde_Exception_HookNotSet $e) {
- $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d folders."), IMP::hasPermission('max_folders', true)), ENT_COMPAT, Horde_Nls::getCharset());
+ $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d folders."), $GLOBALS['perms']->hasAppPermission('max_folders', array('opts' => array('value' => true)))), ENT_COMPAT, Horde_Nls::getCharset());
}
$notification->push($message, 'horde.error', array('content.raw'));
return false;
if (!empty($options['new_folder']) &&
(!empty($GLOBALS['conf']['hooks']['permsdenied']) ||
- (self::hasPermission('create_folders') &&
- self::hasPermission('max_folders')))) {
+ ($GLOBALS['perms']->hasAppPermission('create_folders') &&
+ $GLOBALS['perms']->hasAppPermission('max_folders')))) {
$text .= "<option value=\"\" disabled=\"disabled\">- - - - - - - -</option>\n" .
'<option value="*new*">' . _("New Folder") . "</option>\n" .
"<option value=\"\" disabled=\"disabled\">- - - - - - - -</option>\n";
}
/**
- * Returns the specified permission for the current user.
- *
- * @param string $permission A permission.
- * @param boolean $value If true, the method returns the value of a
- * scalar permission, otherwise whether the
- * permission limit has been hit already.
- *
- * @return mixed The value of the specified permission.
- */
- static public function hasPermission($permission, $value = false)
- {
- if (!$GLOBALS['perms']->exists('imp:' . $permission)) {
- return true;
- }
-
- $allowed = $GLOBALS['perms']->getPermissions('imp:' . $permission);
- if (is_array($allowed)) {
- switch ($permission) {
- case 'create_folders':
- $allowed = (bool)count(array_filter($allowed));
- break;
-
- case 'max_folders':
- case 'max_recipients':
- case 'max_timelimit':
- $allowed = max($allowed);
- break;
- }
- }
- if (($permission == 'max_folders') && !$value) {
- $folder = IMP_Folder::singleton();
- $allowed = $allowed > count($folder->flist_IMP(array(), false));
- }
-
- return $allowed;
- }
-
- /**
* Build IMP's list of menu items.
*
* @return Horde_Menu A Horde_Menu object.
$id = Horde_Util::getFormData('rulenumber');
/* Get permissions. */
-$edit_allowed = Ingo::hasPermission('shares', Horde_Perms::EDIT);
-$delete_allowed = Ingo::hasPermission('shares', Horde_Perms::DELETE);
+$edit_allowed = Ingo::hasSharePermission(Horde_Perms::EDIT);
+$delete_allowed = Ingo::hasSharePermission(Horde_Perms::DELETE);
/* Perform requested actions. */
switch ($actionID) {
break;
case 'rule_copy':
- if (!Ingo::hasPermission('allow_rules')) {
+ if (!$GLOBALS['perms']->hasAppPermission('allow_rules')) {
try {
$message = Horde::callHook('perms_denied', array('ingo:allow_rules'));
} catch (Horde_Exception_HookNotSet $e) {
}
$notification->push($message, 'horde.error', array('content.raw'));
break 2;
- } elseif (Ingo::hasPermission('max_rules') !== true &&
- Ingo::hasPermission('max_rules') <= count($filters->getFilterList())) {
+ } elseif ($GLOBALS['perms']->hasAppPermission('max_rules') !== true &&
+ $GLOBALS['perms']->hasAppPermission('max_rules') <= count($filters->getFilterList())) {
try {
$message = Horde::callHook('perms_denied', array('ingo:max_rules'));
} catch (Horde_Exception_HookNotSet $e) {
- $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d rules."), Ingo::hasPermission('max_rules')), ENT_COMPAT, Horde_Nls::getCharset());
+ $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d rules."), $GLOBALS['perms']->hasAppPermission('max_rules')), ENT_COMPAT, Horde_Nls::getCharset());
}
$notification->push($message, 'horde.error', array('content.raw'));
break 2;
/* Create copy link. */
if (!is_null($copyurl) &&
(!empty($conf['hooks']['permsdenied']) ||
- Ingo::hasPermission('max_rules') === true ||
- Ingo::hasPermission('max_rules') > count($filter_list))) {
+ $GLOBALS['perms']->hasAppPermission('max_rules') === true ||
+ $GLOBALS['perms']->hasAppPermission('max_rules') > count($filter_list))) {
$entry['copylink'] = Horde::link($copyurl, sprintf(_("Copy %s"), $name));
$entry['copyimg'] = Horde::img('copy.png', sprintf(_("Copy %s"), $name));
} else {
$actions = $ingo_script->availableActions();
$createrule = (!empty($actions) &&
(!empty($conf['hooks']['permsdenied']) ||
- (Ingo::hasPermission('allow_rules') &&
- (Ingo::hasPermission('max_rules') === true ||
- Ingo::hasPermission('max_rules') > count($filter_list)))));
+ ($GLOBALS['perms']->hasAppPermission('allow_rules') &&
+ ($GLOBALS['perms']->hasAppPermission('max_rules') === true ||
+ $GLOBALS['perms']->hasAppPermission('max_rules') > count($filter_list)))));
$canapply = $ingo_script->canApply();
require INGO_TEMPLATES . '/filters/footer.inc';
if ($on_demand && $edit_allowed) {
}
/**
+ * Returns the specified permission for the current user.
+ *
+ * @param mixed $allowed The allowed permissions.
+ *
+ * @return mixed The value of the specified permission.
+ */
+ public function hasPermission($allowed)
+ {
+ if (is_array($allowed)) {
+ switch ($permission) {
+ case 'allow_rules':
+ $allowed = (bool)count(array_filter($allowed));
+ break;
+
+ case 'max_rules':
+ $allowed = max($allowed);
+ break;
+ }
+ }
+
+ return $allowed;
+ }
+
+ /**
* Generate the menu to use on the prefs page.
*
* @return Horde_Menu A Horde_Menu object.
/* getMenu() cache. */
static private $_menuCache = null;
+ /* hasSharePermission() cache. */
+ static private $_shareCache = null;
+
/**
* Generates a folder widget.
* If an application is available that provides a folderlist method
}
/**
- * Returns the specified permission for the current user.
- *
- * @param string $permission A permission, either 'allow_rules' or
- * 'max_rules'.
- *
- * @return mixed The value of the specified permission.
+ * TODO
*/
- static public function hasPermission($permission, $mask = null)
+ static public function hasSharePermission($mask = null)
{
- if ($permission == 'shares') {
- if (!isset($GLOBALS['ingo_shares'])) {
- return true;
- }
- static $all_perms;
- if (!isset($all_perms)) {
- $all_perms = $GLOBALS['ingo_shares']->getPermissions($_SESSION['ingo']['current_share'], Horde_Auth::getAuth());
- }
- return $all_perms & $mask;
- }
-
- global $perms;
-
- if (!$perms->exists('ingo:' . $permission)) {
+ if (!isset($GLOBALS['ingo_shares'])) {
return true;
}
- $allowed = $perms->getPermissions('ingo:' . $permission);
- if (is_array($allowed)) {
- switch ($permission) {
- case 'allow_rules':
- $allowed = (bool)count(array_filter($allowed));
- break;
-
- case 'max_rules':
- $allowed = max($allowed);
- break;
- }
+ if (is_null(self::$_shareCache)) {
+ self::$_shareCache = $GLOBALS['ingo_shares']->getPermissions($_SESSION['ingo']['current_share'], Horde_Auth::getAuth());
}
- return $allowed;
+ return self::$_shareCache & $mask;
}
/**
require_once dirname(__FILE__) . '/lib/base.php';
/* Check rule permissions. */
-if (!Ingo::hasPermission('allow_rules')) {
+if (!$GLOBALS['perms']->hasAppPermission('allow_rules')) {
try {
$message = Horde::callHook('perms_denied', array('ingo:allow_rules'));
} catch (Horde_Exception_HookNotSet $e) {
case 'rule_save':
case 'rule_update':
case 'rule_delete':
- if (!Ingo::hasPermission('shares', Horde_Perms::EDIT)) {
+ if (!Ingo::hasSharePermission(Horde_Perms::EDIT)) {
$notification->push(_("You do not have permission to edit filter rules."), 'horde.error');
header('Location: ' . Horde::applicationUrl('filters.php', true));
exit;
/* Save the rule. */
if ($actionID == 'rule_save' && $valid) {
if (is_null($edit_number)) {
- if (Ingo::hasPermission('max_rules') !== true &&
- Ingo::hasPermission('max_rules') <= count($filters->getFilterList())) {
+ if ($GLOBALS['perms']->hasAppPermission('max_rules') !== true &&
+ $GLOBALS['perms']->hasAppPermission('max_rules') <= count($filters->getFilterList())) {
header('Location: ' . Horde::applicationUrl('filters.php', true));
exit;
}
header('Location: ' . Horde::applicationUrl('filters.php'));
exit;
} elseif ($actionID == 'rule_delete') {
- if (!Ingo::hasPermission('shares', Horde_Perms::DELETE)) {
+ if (!Ingo::hasSharePermission(Horde_Perms::DELETE)) {
$notification->push(_("You do not have permission to delete filter rules."), 'horde.error');
header('Location: ' . Horde::applicationUrl('filters.php', true));
exit;
break;
default:
- if (!Ingo::hasPermission('shares', Horde_Perms::EDIT)) {
+ if (!Ingo::hasSharePermission(Horde_Perms::EDIT)) {
$notification->push(_("You do not have permission to edit filter rules."), 'horde.error');
header('Location: ' . Horde::applicationUrl('filters.php', true));
exit;
}
if (is_null($edit_number)) {
- if (Ingo::hasPermission('max_rules') !== true &&
- Ingo::hasPermission('max_rules') <= count($filters->getFilterList())) {
+ if ($GLOBALS['perms']->hasAppPermission('max_rules') !== true &&
+ $GLOBALS['perms']->hasAppPermission('max_rules') <= count($filters->getFilterList())) {
try {
$message = Horde::callHook('perms_denied', array('ingo:max_rules'));
} catch (Horde_Exception_HookNotSet $e) {
- $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d rules."), Ingo::hasPermission('max_rules')), ENT_COMPAT, Horde_Nls::getCharset());
+ $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d rules."), $GLOBALS['perms']->hasAppPermission('max_rules')), ENT_COMPAT, Horde_Nls::getCharset());
}
$notification->push($message, 'horde.error', array('content.raw'));
header('Location: ' . Horde::applicationUrl('filters.php', true));
} elseif ($user == Horde_Auth::getAuth() &&
!$share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT, Horde_Auth::getAuth())) {
$notification->push(sprintf(_("You do not have permission to add events to %s."), $share->get('name')), 'horde.warning');
- } elseif (Kronolith::hasPermission('max_events') === true ||
- Kronolith::hasPermission('max_events') > Kronolith::countEvents()) {
+ } elseif ($GLOBALS['perms']->hasAppPermission('max_events') === true ||
+ $GLOBALS['perms']->hasAppPermission('max_events') > Kronolith::countEvents()) {
$event = Kronolith::getDriver(null, $calendar_id)->getEvent();
$event->readForm();
$result = $event->save();
Horde_Data::IMPORT_MAPPED => array($registry->get('templates', 'horde') . '/data/csvmap.inc'),
Horde_Data::IMPORT_DATETIME => array($registry->get('templates', 'horde') . '/data/datemap.inc')
);
-if (Kronolith::hasPermission('max_events') !== true &&
- Kronolith::hasPermission('max_events') <= Kronolith::countEvents()) {
+if ($GLOBALS['perms']->hasAppPermission('max_events') !== true &&
+ $GLOBALS['perms']->hasAppPermission('max_events') <= Kronolith::countEvents()) {
try {
$message = Horde::callHook('perms_denied', array('kronolith:max_events'));
} catch (Horde_Exception_HookNotSet $e) {
- $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), Kronolith::hasPermission('max_events')), ENT_COMPAT, Horde_Nls::getCharset());
+ $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), $GLOBALS['perms']->hasAppPermission('max_events')), ENT_COMPAT, Horde_Nls::getCharset());
}
$notification->push($message, 'horde.warning', array('content.raw'));
$templates[Horde_Data::IMPORT_FILE] = array(KRONOLITH_TEMPLATES . '/data/export.inc');
if (is_array($next_step)) {
$events = array();
$error = false;
- $max_events = Kronolith::hasPermission('max_events');
+ $max_events = $GLOBALS['perms']->hasAppPermission('max_events');
if ($max_events !== true) {
$num_events = Kronolith::countEvents();
}
try {
$message = Horde::callHook('perms_denied', array('kronolith:max_events'));
} catch (Horde_Exception_HookNotSet $e) {
- $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), Kronolith::hasPermission('max_events')), ENT_COMPAT, Horde_Nls::getCharset());
+ $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), $GLOBALS['perms']->hasAppPermission('max_events')), ENT_COMPAT, Horde_Nls::getCharset());
}
$notification->push($message, 'horde.error', array('content.raw'));
break;
function _check_max()
{
- if (Kronolith::hasPermission('max_events') !== true &&
- Kronolith::hasPermission('max_events') <= Kronolith::countEvents()) {
+ if ($GLOBALS['perms']->hasAppPermission('max_events') !== true &&
+ $GLOBALS['perms']->hasAppPermission('max_events') <= Kronolith::countEvents()) {
try {
$message = Horde::callHook('perms_denied', array('kronolith:max_events'));
} catch (Horde_Exception_HookNotSet $e) {
- $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), Kronolith::hasPermission('max_events')), ENT_COMPAT, Horde_Nls::getCharset());
+ $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), $GLOBALS['perms']->hasAppPermission('max_events')), ENT_COMPAT, Horde_Nls::getCharset());
}
$GLOBALS['notification']->push($message, 'horde.error', array('content.raw'));
return false;
}
/**
+ * Returns the specified permission for the current user.
+ *
+ * @param mixed $allowed The allowed permissions.
+ *
+ * @return mixed The value of the specified permission.
+ */
+ public function hasPermission($allowed)
+ {
+ if (is_array($allowed)) {
+ switch ($permission) {
+ case 'max_events':
+ $allowed = max($allowed);
+ break;
+ }
+ }
+
+ return $allowed;
+ }
+
+ /**
* Code to run when viewing prefs for this application.
*
* @param string $group The prefGroup name.
}
/**
- * Returns the specified permission for the current user.
- *
- * @param string $permission A permission, currently only 'max_events'.
- *
- * @return mixed The value of the specified permission.
- */
- public static function hasPermission($permission)
- {
- global $perms;
-
- if (!$perms->exists('kronolith:' . $permission)) {
- return true;
- }
-
- $allowed = $perms->getPermissions('kronolith:' . $permission);
- if (is_array($allowed)) {
- switch ($permission) {
- case 'max_events':
- $allowed = max($allowed);
- break;
- }
- }
-
- return $allowed;
- }
-
- /**
* @param string $tabname
*/
public static function tabs($tabname = null)
$menu->add(Horde::applicationUrl($prefs->getValue('defaultview') . '.php'), _("_Today"), 'today.png', null, null, null, '__noselection');
if (self::getDefaultCalendar(Horde_Perms::EDIT) &&
(!empty($conf['hooks']['permsdenied']) ||
- self::hasPermission('max_events') === true ||
- self::hasPermission('max_events') > self::countEvents())) {
+ $GLOBALS['perms']->hasAppPermission('max_events') === true ||
+ $GLOBALS['perms']->hasAppPermission('max_events') > self::countEvents())) {
$menu->add(Horde_Util::addParameter(Horde::applicationUrl('new.php'), 'url', Horde::selfUrl(true, false, true)), _("_New Event"), 'new.png');
}
if ($browser->hasFeature('dom')) {
$first_row = true;
$addLinks = Kronolith::getDefaultCalendar(Horde_Perms::EDIT) &&
(!empty($GLOBALS['conf']['hooks']['permsdenied']) ||
- Kronolith::hasPermission('max_events') === true ||
- Kronolith::hasPermission('max_events') > Kronolith::countEvents());
+ $GLOBALS['perms']->hasAppPermission('max_events') === true ||
+ $GLOBALS['perms']->hasAppPermission('max_events') > Kronolith::countEvents());
$showLocation = Kronolith::viewShowLocation();
$showTime = Kronolith::viewShowTime();
if (($this->event->isRemote() ||
!$this->event->hasPermission(Horde_Perms::EDIT)) &&
(!empty($GLOBALS['conf']['hooks']['permsdenied']) ||
- Kronolith::hasPermission('max_events') === true ||
- Kronolith::hasPermission('max_events') > Kronolith::countEvents())) {
+ $GLOBALS['perms']->hasAppPermission('max_events') === true ||
+ $GLOBALS['perms']->hasAppPermission('max_events') > Kronolith::countEvents())) {
$buttons[] = '<input type="submit" class="button" name="saveAsNew" value="' . _("Save As New") . '" />';
} else {
if (!$this->event->isRemote()) {
if ($this->event->isInitialized()) {
if (!$this->event->recurs() &&
(!empty($conf['hooks']['permsdenied']) ||
- Kronolith::hasPermission('max_events') === true ||
- Kronolith::hasPermission('max_events') > Kronolith::countEvents())) {
+ $GLOBALS['perms']->hasAppPermission('max_events') === true ||
+ $GLOBALS['perms']->hasAppPermission('max_events') > Kronolith::countEvents())) {
$buttons[] = '<input type="submit" class="button" name="saveAsNew" value="' . _("Save As New") . '" />';
}
}
$twentyFour = $prefs->getValue('twentyFour');
$addLinks = Kronolith::getDefaultCalendar(Horde_Perms::EDIT) &&
(!empty($GLOBALS['conf']['hooks']['permsdenied']) ||
- Kronolith::hasPermission('max_events') === true ||
- Kronolith::hasPermission('max_events') > Kronolith::countEvents());
+ $GLOBALS['perms']->hasAppPermission('max_events') === true ||
+ $GLOBALS['perms']->hasAppPermission('max_events') > Kronolith::countEvents());
if ($sidebyside) {
require KRONOLITH_TEMPLATES . '/month/head_side_by_side.inc';
require dirname(__FILE__) . '/lib/base.php';
/* Check permissions. */
-if (Kronolith::hasPermission('max_events') !== true &&
- Kronolith::hasPermission('max_events') <= Kronolith::countEvents()) {
+if ($GLOBALS['perms']->hasAppPermission('max_events') !== true &&
+ $GLOBALS['perms']->hasAppPermission('max_events') <= Kronolith::countEvents()) {
try {
$message = Horde::callHook('perms_denied', array('kronolith:max_events'));
} catch (Horde_Exception_HookNotSet $e) {
- $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), Kronolith::hasPermission('max_events')), ENT_COMPAT, Horde_Nls::getCharset());
+ $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), $GLOBALS['perms']->hasAppPermission('max_events')), ENT_COMPAT, Horde_Nls::getCharset());
}
$notification->push($message, 'horde.error', array('content.raw'));
$url = Horde_Util::addParameter($prefs->getValue('defaultview') . '.php', array('month' => Horde_Util::getFormData('month'),
<table class="striped" cellspacing="0">
<?php if ($event->recurs() &&
(!empty($conf['hooks']['permsdenied']) ||
- Kronolith::hasPermission('max_events') === true ||
- Kronolith::hasPermission('max_events') > Kronolith::countEvents())): ?>
+ $GLOBALS['perms']->hasAppPermission('max_events') === true ||
+ $GLOBALS['perms']->hasAppPermission('max_events') > Kronolith::countEvents())): ?>
<!-- recurrence editing -->
<tr>
<td></td>
<?php
if (Kronolith::getDefaultCalendar(Horde_Perms::EDIT) &&
(!empty($conf['hooks']['permsdenied']) ||
- Kronolith::hasPermission('max_events') === true ||
- Kronolith::hasPermission('max_events') > Kronolith::countEvents())) {
+ $GLOBALS['perms']->hasAppPermission('max_events') === true ||
+ $GLOBALS['perms']->hasAppPermission('max_events') > Kronolith::countEvents())) {
$addurl = Horde_Util::addParameter('new.php',
array('date' => $day->dateString(),
'url' => $this->link(0, true)));
Horde_Data::IMPORT_MAPPED => array($registry->get('templates', 'horde') . '/data/csvmap.inc'),
Horde_Data::IMPORT_DATETIME => array($registry->get('templates', 'horde') . '/data/datemap.inc')
);
-if (Nag::hasPermission('max_tasks') !== true &&
- Nag::hasPermission('max_tasks') <= Nag::countTasks()) {
+if ($GLOBALS['perms']->hasAppPermission('max_tasks') !== true &&
+ $GLOBALS['perms']->hasAppPermission('max_tasks') <= Nag::countTasks()) {
try {
$message = Horde::callHook('perms_denied', array('nag:max_tasks'));
} catch (Horde_Exception_HookNotSet $e) {
- $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d tasks."), Nag::hasPermission('max_tasks')), ENT_COMPAT, Horde_Nls::getCharset());
+ $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d tasks."), $GLOBALS['perms']->hasAppPermission('max_tasks')), ENT_COMPAT, Horde_Nls::getCharset());
}
$notification->push($message, 'horde.warning', array('content.raw'));
$templates[Horde_Data::IMPORT_FILE] = array(NAG_TEMPLATES . '/data/export.inc');
/* Create a Nag storage instance. */
$storage = Nag_Driver::singleton($_SESSION['import_data']['target']);
- $max_tasks = Nag::hasPermission('max_tasks');
+ $max_tasks = $GLOBALS['perms']->hasAppPermission('max_tasks');
$num_tasks = Nag::countTasks();
$result = null;
foreach ($next_step as $row) {
try {
$message = Horde::callHook('perms_denied', array('nag:max_tasks'));
} catch (Horde_Exception_HookNotSet $e) {
- $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d tasks."), Nag::hasPermission('max_tasks')), ENT_COMPAT, Horde_Nls::getCharset());
+ $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d tasks."), $GLOBALS['perms']->hasAppPermission('max_tasks')), ENT_COMPAT, Horde_Nls::getCharset());
}
$notification->push($message, 'horde.error', array('content.raw'));
break;
}
/**
+ * Returns the specified permission for the current user.
+ *
+ * @param mixed $allowed The allowed permissions.
+ *
+ * @return mixed The value of the specified permission.
+ */
+ public function hasPermission($allowed)
+ {
+ if (is_array($allowed)) {
+ switch ($permission) {
+ case 'max_tasks':
+ $allowed = max($allowed);
+ break;
+ }
+ }
+
+ return $allowed;
+ }
+
+ /**
* Special preferences handling on update.
*
* @param string $item The preference name.
}
/**
- * Returns the specified permission for the current user.
- *
- * @param string $permission A permission, currently only 'max_tasks'.
- *
- * @return mixed The value of the specified permission.
- */
- function hasPermission($permission)
- {
- global $perms;
-
- if (!$perms->exists('nag:' . $permission)) {
- return true;
- }
-
- $allowed = $perms->getPermissions('nag:' . $permission);
- if (is_array($allowed)) {
- switch ($permission) {
- case 'max_tasks':
- $allowed = max($allowed);
- break;
- }
- }
-
- return $allowed;
- }
-
- /**
* Initial app setup code.
*/
function initialize()
$menu->add(Horde::applicationUrl('list.php'), _("_List Tasks"), 'nag.png', null, null, null, basename($_SERVER['PHP_SELF']) == 'index.php' ? 'current' : null);
if (Nag::getDefaultTasklist(Horde_Perms::EDIT) &&
(!empty($conf['hooks']['permsdenied']) ||
- Nag::hasPermission('max_tasks') === true ||
- Nag::hasPermission('max_tasks') > Nag::countTasks())) {
+ $GLOBALS['perms']->hasAppPermission('max_tasks') === true ||
+ $GLOBALS['perms']->hasAppPermission('max_tasks') > Nag::countTasks())) {
$menu->add(Horde::applicationUrl(Horde_Util::addParameter('task.php', 'actionID', 'add_task')), _("_New Task"), 'add.png', null, null, null, Horde_Util::getFormData('task') ? '__noselection' : null);
if ($GLOBALS['browser']->hasFeature('dom')) {
$menu->add('', _("_Quick Add"), 'add.png', null, null, 'Nag.quickAddPanel.show(); $(\'quickText\').focus(); return false;', Horde_Util::getFormData('task') ? 'quickAdd __noselection' : 'quickAdd');
switch ($actionID) {
case 'add_task':
/* Check permissions. */
- if (Nag::hasPermission('max_tasks') !== true &&
- Nag::hasPermission('max_tasks') <= Nag::countTasks()) {
+ if ($GLOBALS['perms']->hasAppPermission('max_tasks') !== true &&
+ $GLOBALS['perms']->hasAppPermission('max_tasks') <= Nag::countTasks()) {
try {
$message = Horde::callHook('perms_denied', array('nag:max_tasks'));
} catch (Horde_Exception_HookNotSet $e) {
- $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d tasks."), Nag::hasPermission('max_tasks')), ENT_COMPAT, Horde_Nls::getCharset());
+ $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d tasks."), $GLOBALS['perms']->hasAppPermission('max_tasks')), ENT_COMPAT, Horde_Nls::getCharset());
}
$notification->push($message, 'horde.error', array('content.raw'));
header('Location: ' . Horde::applicationUrl('list.php', true));
$info['tasklist_id']);
} else {
/* Check permissions. */
- if (Nag::hasPermission('max_tasks') !== true &&
- Nag::hasPermission('max_tasks') <= Nag::countTasks()) {
+ if ($GLOBALS['perms']->hasAppPermission('max_tasks') !== true &&
+ $GLOBALS['perms']->hasAppPermission('max_tasks') <= Nag::countTasks()) {
header('Location: ' . Horde::applicationUrl('list.php', true));
exit;
}