本文整理汇总了PHP中Horde::callHook方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde::callHook方法的具体用法?PHP Horde::callHook怎么用?PHP Horde::callHook使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde
的用法示例。
在下文中一共展示了Horde::callHook方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkMailbox
/**
* Checks whether a mailbox exists and is set up properly.
*
* @param string $user The name of the mailbox to check.
* @param string $domain The mailbox' domain.
*
* @return boolean True if the mailbox exists.
* @throws Vilma_Exception if the mailbox doesn't exist.
*/
public function checkMailbox($user, $domain)
{
try {
return Horde::callHook('checkMailbox', array($user, $domain), 'vilma');
} catch (Exception $e) {
throw new Vilma_Exception($e);
}
}
示例2: _validate
protected function _validate($certificate)
{
try {
return Horde::callHook('x509_validate', array($certificate));
} catch (Horde_Exception_HookNotSet $e) {
}
return true;
}
示例3: _content
/**
*/
protected function _content()
{
$memo = $this->_getNote();
$html = '<div id="noteBody' . $memo['memo_id'] . '" class="noteBody">';
$body = $GLOBALS['injector']->getInstance('Horde_Core_Factory_TextFilter')->filter($memo['body'], 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO));
try {
$body = Horde::callHook('format_description', array($body), 'mnemo', $body);
} catch (Horde_Exception_HookNotSet $e) {
}
$html .= $body . '</div>';
$GLOBALS['injector']->getInstance('Horde_Core_Factory_Imple')->create('Mnemo_Ajax_Imple_EditNote', array('dataid' => $this->_params['note_uid'], 'id' => 'noteBody' . $memo['memo_id'], 'rows' => substr_count($memo['body'], "\n")));
return $html;
}
示例4: __construct
/**
*/
public function __construct($vars, $ticket, $title = '')
{
parent::__construct($vars, $title);
$date_params = array($GLOBALS['prefs']->getValue('date_format'));
$fields = array('summary', 'queue', 'version', 'type', 'state', 'priority', 'owner', 'requester', 'created', 'due', 'updated', 'assigned', 'resolved');
try {
$attributes = $ticket->addAttributes();
} catch (Whups_Exception $e) {
$attributes = array();
}
foreach ($attributes as $attribute) {
$fields[] = 'attribute_' . $attribute['id'];
}
$grouped_fields = array($fields);
$grouped_hook = false;
try {
$grouped_fields = Horde::callHook('group_fields', array($ticket->get('type'), $fields), 'whups');
$grouped_hook = true;
} catch (Horde_Exception_HookNotSet $e) {
} catch (Horde_Exception $e) {
Horde::log($e, 'ERR');
}
foreach ($grouped_fields as $header => $fields) {
if ($grouped_hook) {
$this->addVariable($header, null, 'header', false);
}
foreach ($fields as $field) {
switch ($field) {
case 'summary':
$this->addVariable(_("Summary"), 'summary', 'text', true);
break;
case 'queue':
if ($vars->get('queue_link')) {
$this->addVariable(_("Queue"), 'queue_link', 'link', true, false, null, array(array('url' => $vars->get('queue_link'), 'text' => $vars->get('queue_name'))));
} else {
$this->addVariable(_("Queue"), 'queue_name', 'text', true);
}
break;
case 'version':
if ($vars->get('version_name')) {
if ($vars->get('version_link')) {
$this->addVariable(_("Queue Version"), 'version_name', 'link', true, false, null, array(array('url' => $vars->get('version_link'), 'text' => $vars->get('version_name'))));
} else {
$this->addVariable(_("Queue Version"), 'version_name', 'text', true);
}
}
break;
case 'type':
$this->addVariable(_("Type"), 'type_name', 'text', true);
break;
case 'state':
$this->addVariable(_("State"), 'state_name', 'text', true);
break;
case 'priority':
$this->addVariable(_("Priority"), 'priority_name', 'text', true);
break;
case 'owner':
$owner = $this->addVariable(_("Owners"), 'user_id_owner', 'email', false, false, null, array(true, true));
$owner->setDefault(_("Unassigned"));
break;
case 'requester':
$this->addVariable(_("Requester"), 'user_id_requester', 'email', false, false, null, array(false, true));
break;
case 'created':
$this->addVariable(_("Created"), 'timestamp', 'date', false, false, null, $date_params);
break;
case 'due':
$this->addVariable(_("Due"), 'due', 'datetime', false, false, null, $date_params);
break;
case 'updated':
$this->addVariable(_("Updated"), 'date_updated', 'date', false, false, null, $date_params);
break;
case 'assigned':
$this->addVariable(_("Assigned"), 'date_assigned', 'date', false, false, null, $date_params);
break;
case 'resolved':
$this->addVariable(_("Resolved"), 'date_resolved', 'date', false, false, null, $date_params);
break;
default:
if (substr($field, 0, 10) == 'attribute_' && isset($attributes[substr($field, 10)])) {
$attribute = $attributes[substr($field, 10)];
if (!$attribute['params']) {
$attribute['params'] = array();
}
$this->attributes[$attribute['id']] = $this->addVariable($attribute['human_name'], 'attribute_' . $attribute['id'], $attribute['type'], $attribute['required'], $attribute['readonly'], $attribute['desc'], $attribute['params']);
$this->attributes[$attribute['id']]->setDefault($attribute['value']);
}
break;
}
}
}
}
示例5: getProfile
/**
* Get user profile
*
* @param string $user Username
*/
public function getProfile($user = null)
{
static $profiles;
if ($user == null) {
$user = $GLOBALS['registry']->getAuth();
}
if (empty($user)) {
return PEAR::raiseError(sprintf(_("User \"%s\" does not exists."), $user));
}
if (isset($profiles[$user])) {
return $profiles[$user];
}
$profile = $GLOBALS['cache']->get('folksProfile' . $user, $GLOBALS['conf']['cache']['default_lifetime']);
if ($profile || $GLOBALS['registry']->isAdmin() && Horde_Util::getGet('debug')) {
$profile = unserialize($profile);
} else {
// Load profile
$profile = $this->_getProfile($user);
if ($profile instanceof PEAR_Error) {
return $profile;
}
// Filter description
$filters = array('text2html', 'bbcode', 'highlightquotes', 'emoticons');
$filters_params = array(array('parselevel' => Horde_Text_Filter_Text2html::MICRO), array(), array(), array());
if (($hasBBcode = strpos($profile['user_description'], '[')) !== false && strpos($profile['user_description'], '[/', $hasBBcode) !== false) {
$filters_params[0]['parselevel'] = Horde_Text_Filter_Text2html::NOHTML;
}
$profile['user_description'] = $GLOBALS['injector']->getInstance('Horde_Core_Factory_TextFilter')->filter(trim($profile['user_description']), $filters, $filters_params);
// Get user last external data
foreach ($profile as $key => $value) {
if (substr($key, 0, 6) != 'count_') {
continue;
}
$service = substr($key, 6);
if ($GLOBALS['conf']['services']['countcron']) {
if (empty($value)) {
continue;
}
} else {
try {
$profile['count_' . $service] = Horde::callHook('countService', array($service, $user), 'folks');
} catch (Horde_Exception_HookNotSet $e) {
}
if (empty($profile['count_' . $service])) {
continue;
}
}
try {
$profile['count_' . $service . '_list'] = Horde::callHook('getService', array($service, $user), 'folks');
} catch (Horde_Exception_HookNotSet $e) {
}
if (empty($profile['count_' . $service . '_list'])) {
$profile['count_' . $service] = 0;
}
}
// Cache profile
// cache profile
$GLOBALS['cache']->set('folksProfile' . $user, serialize($profile));
}
$profiles[$user] = $profile;
return $profile;
}
示例6: _changePassword
/**
* @param string $backend_key Backend key.
*/
private function _changePassword($backend_key)
{
global $conf, $injector, $notification, $registry;
// Check for users that cannot change their passwords.
if (in_array($this->_userid, $conf['user']['refused'])) {
$notification->push(sprintf(_("You can't change password for user %s"), $userid), 'horde.error');
return;
}
// We must be passed the old (current) password.
if (!isset($this->_vars->oldpassword)) {
$notification->push(_("You must give your current password"), 'horde.warning');
return;
}
if (!isset($this->_vars->newpassword0)) {
$notification->push(_("You must give your new password"), 'horde.warning');
return;
}
if (!isset($this->_vars->newpassword1)) {
$notification->push(_("You must verify your new password"), 'horde.warning');
return;
}
if ($this->_vars->newpassword0 != $this->_vars->newpassword1) {
$notification->push(_("Your new passwords didn't match"), 'horde.warning');
return;
}
if ($this->_vars->newpassword0 == $this->_vars->oldpassword) {
$notification->push(_("Your new password must be different from your current password"), 'horde.warning');
return;
}
$b_ptr = $this->_backends[$backend_key];
try {
Horde_Auth::checkPasswordPolicy($this->_vars->newpassword0, isset($b_ptr['policy']) ? $b_ptr['policy'] : array());
} catch (Horde_Auth_Exception $e) {
$notification->push($e, 'horde.warning');
return;
}
// Do some simple strength tests, if enabled in the config file.
if (!empty($conf['password']['strengthtests'])) {
try {
Horde_Auth::checkPasswordSimilarity($this->_vars->newpassword0, array($this->_userid, $this->_vars->oldpassword));
} catch (Horde_Auth_Exception $e) {
$notification->push($e, 'horde.warning');
return;
}
}
try {
$driver = $injector->getInstance('Passwd_Factory_Driver')->create($backend_key);
} catch (Passwd_Exception $e) {
Horde::log($e);
$notification->push(_("Password module is not properly configured"), 'horde.error');
return;
}
try {
$driver->changePassword($this->_userid, $this->_vars->oldpassword, $this->_vars->newpassword0);
} catch (Exception $e) {
$notification->push(sprintf(_("Failure in changing password for %s: %s"), $b_ptr['name'], $e->getMessage()), 'horde.error');
return;
}
$notification->push(sprintf(_("Password changed on %s."), $b_ptr['name']), 'horde.success');
try {
Horde::callHook('password_changed', array($this->_userid, $this->_vars->oldpassword, $this->_vars->newpassword0), 'passwd');
} catch (Horde_Exception_HookNotSet $e) {
}
if (!empty($b_ptr['logout'])) {
$logout_url = $registry->getLogoutUrl(array('msg' => _("Your password has been succesfully changed. You need to re-login to the system with your new password."), 'reason' => Horde_Auth::REASON_MESSAGE));
$registry->clearAuth();
$logout_url->redirect();
}
if ($this->_vars->return_to) {
$url = new Horde_Url($return_to);
$url->redirect();
}
}
示例7: setcookie
setcookie('folks_login_code', '', $_SERVER['REQUEST_TIME'] - 1000, $conf['cookie']['path'], $conf['cookie']['domain']);
$folks_driver->deleteOnlineUser($GLOBALS['registry']->getAuth());
@session_destroy();
if (!empty($_GET['redirect'])) {
header('Location: ' . $_GET['redirect']);
} else {
$page = $registry->getInitialPage('folks');
header('Location: ' . (empty($page) ? '/' : $page));
}
exit;
}
/*
* Special login for apps (gollem, imp)?
*/
if ($conf['login']['prelogin'] && $GLOBALS['registry']->getAuth() && ($app = Horde_Util::getGet('app'))) {
Horde::callHook('prelogin', array($app), 'folks');
}
/*
* Login parameters
*/
$url_param = Horde_Util::getFormData('url');
$login_url = $registry->getServiceLink('login', 'folks')->add('url', $url_param);
/*
* We are already logged in?
*/
if ($registry->isAuthenticated()) {
if (empty($url_param)) {
$url_param = Folks::getUrlFor('user', $GLOBALS['registry']->getAuth());
}
header('Location: ' . $url_param);
exit;
示例8: deleteDomain
/**
* Deletes a domain and all the users and virtuals within it.
*
* @param integer $domain_id The id of the domain to delete.
*
* @throws Vilma_Exception
*/
public function deleteDomain($domain_id)
{
$domain_record = $this->getDomain($domain_id);
$users = $this->getUsers($domain_record['domain_name']);
foreach ($users as $user) {
$this->deleteUser($user['user_id']);
}
$this->_deleteDomain($domain_id);
try {
Horde::callHook('deleteDomain', array($domain_record['domain_name']), 'vilma');
} catch (Horde_Exception_HookNotSet $e) {
}
}
示例9: isOldEnough
/**
* Check user age limtation
*
* @return boolean
*/
public function isOldEnough()
{
global $session;
if ($GLOBALS['registry']->getAuth() && $this->get('owner') == $GLOBALS['registry']->getAuth() || empty($GLOBALS['conf']['ages']['limits']) || !$this->get('age')) {
return true;
}
// Do we have the user age already cheked?
if (!$session->exists('ansel', 'user_age')) {
$session->set('ansel', 'user_age', 0);
$user_age = 0;
} else {
$user_age = $session->get('ansel', 'user_age');
if ($user_age >= $this->get('age')) {
return true;
}
}
// Can we hook user's age?
if ($GLOBALS['conf']['ages']['hook'] && $GLOBALS['registry']->isAuthenticated()) {
try {
$result = Horde::callHook('user_age', array(), 'ansel');
} catch (Horde_Exception_HookNotSet $e) {
}
if (is_int($result)) {
$session->set('ansel', 'user_age', $result);
$user_age = $result;
}
}
return $user_age >= $this->get('age');
}
示例10: __construct
public function __construct(&$vars, &$ticket, $title = '')
{
global $whups_driver;
parent::__construct($vars, $title);
$type = $vars->get('type');
$start_year = date('Y');
if (is_numeric($d = $vars->get('due'))) {
$start_year = min($start_year, date('Y', $d));
}
$fields = array('summary');
$qinfo = $whups_driver->getQueue($vars->get('queue'));
if (!empty($qinfo['versioned'])) {
$fields[] = 'version';
}
$fields = array_merge($fields, array('state', 'priority', 'due'));
try {
$attributes = $ticket->addAttributes();
} catch (Whups_Exception $e) {
$attributes = array();
}
foreach ($attributes as $attribute) {
$fields[] = 'attribute_' . $attribute['id'];
}
$fields = array_merge($fields, array('owner', 'attachments', 'comment'));
$grouped_fields = array($fields);
$grouped_hook = false;
try {
$grouped_fields = Horde::callHook('group_fields', array($ticket->get('type'), $fields), 'whups');
$grouped_hook = true;
} catch (Horde_Exception_HookNotSet $e) {
} catch (Horde_Exception $e) {
Horde::log($e, 'ERR');
}
$this->addHidden('', 'id', 'int', true, true);
$this->addHidden('', 'type', 'int', true, true);
foreach ($grouped_fields as $header => $fields) {
if ($grouped_hook) {
$this->addVariable($header, null, 'header', false);
}
foreach ($fields as $field) {
switch ($field) {
case 'summary':
$this->addVariable(_("Summary"), 'summary', 'text', true);
break;
case 'version':
$versions = $whups_driver->getVersions($vars->get('queue'));
if (count($versions) == 0) {
$vtype = 'invalid';
$v_params = array(_("This queue requires that you specify a version, but there are no versions associated with it. Until versions are created for this queue, you will not be able to create tickets."));
} else {
$vtype = 'enum';
$v_params = array($versions);
}
$this->addVariable(_("Queue Version"), 'version', $vtype, true, false, null, $v_params);
break;
case 'state':
$this->addVariable(_("State"), 'state', 'enum', true, false, null, array($whups_driver->getStates($type)));
break;
case 'priority':
$this->addVariable(_("Priority"), 'priority', 'enum', true, false, null, array($whups_driver->getPriorities($type)));
break;
case 'due':
$this->addVariable(_("Due Date"), 'due', 'datetime', false, false, null, array($start_year));
break;
case 'owner':
if (Whups::hasPermission($vars->get('queue'), 'queue', 'assign')) {
$groups = $GLOBALS['injector']->getInstance('Horde_Group');
$mygroups = $groups->listAll($GLOBALS['conf']['prefs']['assign_all_groups'] ? null : $GLOBALS['registry']->getAuth());
asort($mygroups);
$f_users = array();
$users = $whups_driver->getQueueUsers($vars->get('queue'));
foreach ($users as $user) {
$f_users['user:' . $user] = Whups::formatUser($user);
}
$f_groups = array();
if ($mygroups) {
foreach (array_keys($mygroups) as $id) {
$f_groups['group:' . $id] = $groups->getName($id);
}
}
if (count($f_users)) {
asort($f_users);
$this->addVariable(_("Owners"), 'owners', 'multienum', false, false, null, array($f_users));
}
if (count($f_groups)) {
asort($f_groups);
$this->addVariable(_("Group Owners"), 'group_owners', 'multienum', false, false, null, array($f_groups));
}
}
break;
case 'attachments':
$this->addVariable(_("Attachment"), 'newattachment', 'file', false);
break;
case 'comment':
$cvar = $this->addVariable(_("Comment"), 'newcomment', 'longtext', false);
/* Form replies. */
try {
$replies = Whups::permissionsFilter($whups_driver->getReplies($type), 'reply');
} catch (Whups_Exception $e) {
$replies = array();
//.........这里部分代码省略.........
示例11: postBatchUpload
/**
* Notify Ansel that a group of images has just been uploaded. Used for when
* the postupload hook should be called with a group of recently
* uploaded images, as opposed to calling it once after each image is saved.
*
* @param array $image_ids An array of image ids.
*/
public function postBatchUpload(array $image_ids)
{
try {
Horde::callHook('postupload', array($image_ids), 'ansel');
} catch (Horde_Exception_HookNotSet $e) {
}
}
示例12: mapUser
/**
* Converts the current user's name, optionally removing the domain part or
* applying any configured hooks.
*
* @param string|boolean $hordeauth Defines how to use the authenticated
* Horde username. If set to 'full',
* will initialize the username to
* contain the @realm part. Otherwise,
* the username will initialize as a
* simple login.
*
* @return string The converted username.
*/
public static function mapUser($hordeauth)
{
$uid = $GLOBALS['registry']->getAuth($hordeauth === 'full' ? null : 'bare');
try {
return Horde::callHook('username', array($uid), 'sam');
} catch (Horde_Exception_HookNotSet $e) {
return $uid;
}
}
示例13: array
if ($addForm->isValid() && $vars->get('formname') == 'adduser') {
$addForm->getInfo($vars, $info);
if (empty($info['user_name'])) {
$notification->push(_("You must specify the username to add."), 'horde.error');
} else {
$credentials = array('password' => $info['password']);
if (isset($info['extra'])) {
foreach ($info['extra'] as $field => $value) {
$credentials[$field] = $value;
}
}
if (is_a($ret = $auth->addUser($info['user_name'], $credentials), 'PEAR_Error')) {
$notification->push(sprintf(_("There was a problem adding '%s' to the system: %s"), $info['user_name'], $ret->getMessage()), 'horde.error');
} else {
if (isset($info['extra'])) {
$result = Horde::callHook('_horde_hook_signup_addextra', array($info['user_name'], $info['extra']));
if (is_a($result, 'PEAR_Error')) {
$notification->push(sprintf(_("Added '%s' to the system, but could not add additional signup information: %s."), $info['user_name'], $result->getMessage()), 'horde.warning');
}
}
if (Util::getFormData('removeQueuedSignup')) {
$signup->removeQueuedSignup($info['user_name']);
}
$notification->push(sprintf(_("Successfully added '%s' to the system."), $info['user_name']), 'horde.success');
$addForm->unsetVars($vars);
}
}
}
break;
case 'remove_f':
$f_user_name = Util::getFormData('user_name');
示例14: handleLegacy
/**
* Handle uploads from non-js browsers
*/
public function handleLegacy()
{
global $conf, $notification, $page_output, $browser;
$vars = Horde_Variables::getDefaultVariables();
$form = new Ansel_Form_Upload($vars, _("Upload photos"));
// Output the carousel JS in case we are here because the user
// explicitly selected the old uploader.
$js = $this->_doCarouselSetup();
if (!empty($js)) {
$page_output->addInlineScript($js, true);
}
if ($form->validate($vars)) {
$valid = true;
$uploaded = 0;
$form->getInfo($vars, $info);
// Remember the ids of the images we uploaded so we can autogen
$image_ids = array();
for ($i = 0; $i <= $conf['image']['num_uploads'] + 1; ++$i) {
if (empty($info['file' . $i]['file'])) {
continue;
}
try {
$GLOBALS['browser']->wasFileUploaded('file' . $i);
} catch (Horde_Browser_Exception $e) {
if (!empty($info['file' . $i]['error'])) {
$notification->push(sprintf(_("There was a problem uploading the photo: %s"), $info['file' . $i]['error']), 'horde.error');
} elseif (!filesize($info['file' . $i]['file'])) {
$notification->push(_("The uploaded file appears to be empty. It may not exist on your computer."), 'horde.error');
}
$valid = false;
continue;
}
// Check for a compressed file.
if (in_array($info['file' . $i]['type'], array('x-extension/zip', 'application/x-compressed', 'application/x-zip-compressed', 'application/zip')) || Horde_Mime_Magic::filenameToMime($info['file' . $i]['name']) == 'application/zip') {
$this->_handleZip($info['file' . $i]['name']);
} else {
// Read in the uploaded data.
$data = file_get_contents($info['file' . $i]['file']);
// Try and make sure the image is in a recognizeable
// format.
if (getimagesize($info['file' . $i]['file']) === false) {
$notification->push(_("The file you uploaded does not appear to be a valid photo."), 'horde.error');
continue;
}
// Add the image to the gallery
$image_data = array('image_filename' => $info['file' . $i]['name'], 'image_caption' => $vars->get('image' . $i . '_desc'), 'image_type' => $info['file' . $i]['type'], 'data' => $data, 'tags' => isset($info['image' . $i . '_tags']) ? explode(',', $info['image' . $i . '_tags']) : array());
try {
$image_ids[] = $this->_gallery->addImage($image_data, (bool) $vars->get('image' . $i . '_default'));
++$uploaded;
} catch (Ansel_Exception $e) {
$notification->push(sprintf(_("There was a problem saving the photo: %s"), $e->getMessage()), 'horde.error');
$valid = false;
}
}
}
// Try to autogenerate some views and tell the user what happened.
if ($uploaded) {
$qtask = new Ansel_Queue_ProcessThumbs($image_ids);
$queue = $GLOBALS['injector']->getInstance('Horde_Queue_Storage');
$queue->add($qtask);
// postupload hook if needed
try {
Horde::callHook('postupload', array($image_ids), 'ansel');
} catch (Horde_Exception_HookNotSet $e) {
}
$notification->push(sprintf(ngettext("%d photo was uploaded.", "%d photos were uploaded.", $uploaded), $uploaded), 'horde.success');
} elseif ($vars->get('submitbutton') != _("Cancel")) {
$notification->push(_("You did not select any photos to upload."), 'horde.error');
}
if ($valid) {
// Return to the gallery view.
Ansel::getUrlFor('view', array('gallery' => $this->_gallery->id, 'slug' => $this->_gallery->get('slug'), 'view' => 'Gallery', 'page' => $page), true)->redirect();
exit;
}
}
Horde::startBuffer();
include ANSEL_TEMPLATES . '/image/upload.inc';
return ($this->_forceNoScript ? '' : '<noscript>') . Horde::endBuffer() . ($this->_forceNoScript ? '' : '</noscript>');
}
示例15: changePassword
/**
* Changes the user's password.
*
* @param string $user The user for which to change the password.
* @param string $oldpass The old (current) user password.
* @param string $newpass The new user password to set.
*
* @throws Passwd_Exception
*/
public function changePassword($user, $oldpass, $newpass)
{
try {
$user = Horde::callHook('username', array($user, $this), 'passwd');
} catch (Horde_Exception_HookNotSet $e) {
}
$this->_changePassword($user, $oldpass, $newpass);
}