/** * 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); } }
protected function _validate($certificate) { try { return Horde::callHook('x509_validate', array($certificate)); } catch (Horde_Exception_HookNotSet $e) { } return true; }
/** */ 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; }
/** */ 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; } } } }
/** * 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; }
/** * @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(); } }
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;
/** * 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) { } }
/** * 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'); }
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:'******'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(); } if (count($replies)) { $params = array(); foreach ($replies as $key => $reply) { $params[$key] = $reply['reply_name']; } $rvar = $this->addVariable(_("Form Reply:"), 'reply', 'enum', false, false, null, array($params, true)); $rvar->setAction(Horde_Form_Action::factory('reload')); if ($vars->get('reply')) { $reply = $vars->get('newcomment'); if (strlen($reply)) { $reply .= "\n\n"; } $reply .= $replies[$vars->get('reply')]['reply_text']; $vars->set('newcomment', $reply); $vars->remove('reply'); } } /* Comment permissions. */ $groups = $GLOBALS['injector']->getInstance('Horde_Group'); $mygroups = $groups->listGroups($GLOBALS['registry']->getAuth()); if ($mygroups) { foreach (array_keys($mygroups) as $gid) { $grouplist[$gid] = $groups->getName($gid, true); } asort($grouplist); $grouplist = array(0 => _("This comment is visible to everyone")) + $grouplist; $this->addVariable(_("Make this comment visible only to members of a group?"), 'group', 'enum', false, false, null, array($grouplist)); } break; default: /* Ticket attributes. */ if ($ticket && substr($field, 0, 10) == 'attribute_' && isset($attributes[substr($field, 10)])) { $attribute = $attributes[substr($field, 10)]; $var = $this->addVariable($attribute['human_name'], 'attribute_' . $attribute['id'], $attribute['type'], $attribute['required'], $attribute['readonly'], $attribute['desc'], $attribute['params']); $var->setDefault($attribute['value']); } } } } }
/** * 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) { } }
/** * 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; } }
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');
/** * 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>'); }
/** * 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); }
$view = $injector->createInstance('Horde_View'); $view->formInput = Horde_Util::formInput(); $view->id = $memo_id; $view->listid = $memolist_id; $view->modify = $actionID == 'modify_memo'; $view->passphrase = $show_passphrase; $view->title = $title; $view->url = Horde::url('memo.php'); if (!$view->modify || !$view->passphrase) { $injector->getInstance('Horde_Core_Factory_Imple')->create('Mnemo_Ajax_Imple_TagAutoCompleter', array('id' => 'memo_tags')); $view->body = $memo_body; $view->count = sprintf(_("%s characters"), '<span id="mnemo-count">' . Horde_String::length(str_replace(array("\r", "\n"), '', $memo_body)) . '</span>'); $view->encrypted = $memo_encrypted; $view->encryption = $storage->encryptionSupported(); try { $view->help = Horde::callHook('description_help', array(), 'mnemo', ''); } catch (Horde_Exception_HookNotSet $e) { } $view->loadingImg = Horde::img('loading.gif', _("Loading...")); $view->notepads = array(); if (!$prefs->isLocked('default_notepad')) { foreach (Mnemo::listNotepads(false, Horde_Perms::SHOW) as $id => $notepad) { if (!$notepad->hasPermission($user, Horde_Perms::EDIT)) { continue; } $view->notepads[] = array('id' => $id, 'selected' => $id == $memolist_id, 'label' => Mnemo::getLabel($notepad)); } } $view->tags = implode(', ', $memo_tags); if ($memo_id && $mnemo_shares->getShare($memolist_id)->hasPermission($user, Horde_Perms::DELETE)) { $view->delete = Horde::url('memo.php')->add(array('memo' => $memo_id, 'memolist' => $memolist_id, 'actionID' => 'delete_memos'));
/** * Creates a user in the backend. * * @param array $info The user information to save. * * @return array The user information. * @throws Vilma_Exception */ protected function _createUser($info) { // Bind with appropriate dn to give update access. $res = ldap_bind($this->_ldap, $this->_params['ldap']['binddn'], $this->_params['ldap']['bindpw']); if (!$res) { throw new Vilma_Exception(_("Unable to bind to the LDAP server. Check authentication credentials.")); } // Prepare data. $entry['cn'] = $info['user_full_name']; // sn is not used operationally but we make an effort to be // something sensical. No guarantees, though. $entry['sn'] = array_pop(explode(' ', $info['user_full_name'])); $entry['mail'] = $info['user_name'] . '@' . $info['domain']; // uid must match mail or SMTP auth fails. $entry['uid'] = $entry['mail']; $entry['homeDirectory'] = '/srv/vhost/mail/' . $info['domain'] . '/' . $info['user_name']; $entry['qmailUID'] = $entry['qmailGID'] = 8; $entry['objectclass'] = array('top', 'person', 'organizationalPerson', 'inetOrgPerson', 'hordePerson', 'qmailUser'); $entry['accountstatus'] = $info['user_enabled']; // FIXME: Allow choice of hash $entry['userPassword'] = Horde_Auth::getCryptedPassword($info['password'], '', 'ssha', true); // Stir in any site-local custom LDAP attributes. try { $entry = Horde::callHook('getLDAPAttrs', array($entry), 'vilma'); } catch (Horde_Exception_HookNotSet $e) { } $rdn = 'mail=' . $entry['mail']; $dn = $rdn . ',' . $this->_params['ldap']['basedn']; $res = @ldap_add($this->_ldap, $dn, $entry); if ($res === false) { throw new Vilma_Exception(sprintf(_("Error adding account to LDAP: %s"), @ldap_error($this->_ldap))); } return $dn; }
/** * Format the description - link URLs, etc. * * @return string */ public function getFormattedDescription() { $desc = $GLOBALS['injector']->getInstance('Horde_Core_Factory_TextFilter')->filter($this->desc, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO)); try { return Horde::callHook('format_description', array($desc), 'nag'); } catch (Horde_Exception_HookNotSet $e) { return $desc; } }
/** * Goes through a list of built-up changes and commits them to the * backend. * * This will send email updates by default, update the ticket log, etc. * * @see change() * * @param string $user The Horde user of the changes to be made. * Defaults to the current user. * @param integer $transaction The transaction these changes are part of. * Defaults to a new transaction. * @param boolean $notify Send ticket notifications? */ public function commit($user = null, $transaction = null, $notify = true) { global $conf, $whups_driver; if (!count($this->_changes)) { return; } if (is_null($user)) { $user = $GLOBALS['registry']->getAuth(); } $author_email = isset($this->_changes['comment-email']['to']) ? $this->_changes['comment-email']['to'] : null; if (is_null($transaction)) { // Get a new transaction id from the backend. $transaction = $whups_driver->newTransaction($user, $author_email); } // If this is a guest update, the comment id is going to map to the // requester pseudo-username. if ($user === false) { $user = '******' . $transaction . '_transaction'; } // Run hook before setting the dates. try { $this->_changes = Horde::callHook('ticket_update', array($this, $this->_changes), 'whups'); } catch (Horde_Exception_HookNotSet $e) { } // Update cached dates. $timestamp = time(); $this->_changes['date_updated'] = array('to' => $timestamp); if (isset($this->_changes['state'])) { $state = $whups_driver->getState($this->_changes['state']['to']); if ($state['category'] == 'assigned') { $this->_changes['date_assigned'] = array('to' => $timestamp); $this->_changes['date_resolved'] = array('to' => null); } elseif ($state['category'] == 'resolved') { $this->_changes['date_resolved'] = array('to' => $timestamp); } else { $this->_changes['date_resolved'] = array('to' => null); } } $updates = array(); foreach ($this->_changes as $detail => $values) { $value = $values['to']; switch ($detail) { case 'owners': // Fetch $oldOwners list; then loop through $value adding and // deleting as needed. if ($owners = $whups_driver->getOwners($this->_id)) { $oldOwners = reset($owners); } else { $oldOwners = array(); } $this->_changes['oldowners'] = $oldOwners; foreach ($value as $owner) { if (!$oldOwners || array_search($owner, $oldOwners) === false) { $whups_driver->addTicketOwner($this->_id, $owner); $whups_driver->updateLog($this->_id, $user, array('assign' => $owner), $transaction); } else { // Remove $owner from the old owners list; anyone left // in $oldOwners will be removed. unset($oldOwners[array_search($owner, $oldOwners)]); } } // Delete removed owners and log the removals. if (is_array($oldOwners)) { foreach ($oldOwners as $owner) { $whups_driver->deleteTicketOwner($this->_id, $owner); $whups_driver->updateLog($this->_id, $user, array('unassign' => $owner), $transaction); } } break; case 'comment': $commentId = $whups_driver->addComment($this->_id, $value, $user, $author_email); // Store the comment id in the updates array for the log. $updates['comment'] = $commentId; if (!empty($this->_changes['comment-perms'])) { $this->addCommentPerms($commentId, $this->_changes['comment-perms']['to']); } break; case 'comment-email': case 'comment-perms': // Skip these, handled in the comment case. break; case 'message': if (isset($conf['vfs']['type'])) { $updates['message'] = $this->addMessage($value); } break; case 'delete-message': if (isset($conf['vfs']['type'])) { $this->deleteMessage($value); // Store the deleted message id in the updates array for the // log. $updates['delete-message'] = $value; } break; case 'attachment': $this->addAttachment($value['name'], $value['tmp_name']); // Store the new file name in the updates array for the // log. $updates['attachment'][] = $value['name']; break; case 'attachments': foreach ($value as $attachment) { $this->addAttachment($attachment['name'], $attachment['tmp_name']); // Store the new file name in the updates array for the // log. $updates['attachment'][] = $attachment['name']; } break; case 'delete-attachment': $this->deleteAttachment($value); // Store the deleted file name in the updates array for // the log. $updates['delete-attachment'] = $value; break; case 'queue': // Reset version if new queue is not versioned. $newqueue = $whups_driver->getQueue($value); if (empty($newqueue['queue_versioned'])) { $updates['version'] = 0; } $updates['queue'] = $value; break; default: if (strpos($detail, 'attribute_') === 0 && !is_string($value)) { $value = Horde_Serialize::Serialize($value, Horde_Serialize::JSON); } $updates[$detail] = $value; break; } } if (count($updates)) { $whups_driver->updateTicket($this->_id, $updates); $whups_driver->updateLog($this->_id, $user, $updates, $transaction); } // Reload $this->_details to make sure we have the latest information. // // @todo Only touch the db if we have to. $details = $whups_driver->getTicketDetails($this->_id); $this->_details = array_merge($this->_details, $details); // Send notification emails to all ticket listeners. if ($notify) { $this->notify($user, false); } // Reset the changes array. $this->_changes = array(); }
/** * Const'r * * @param Horde_Form_Variables $vars The form variables. * @param string $title The form title. * * @return Nag_Form_Task */ public function __construct($vars, $title = '') { global $injector, $nag_shares, $prefs, $registry; parent::__construct($vars, $title); $user = $registry->getAuth(); $tasklist_enums = array(); foreach (Nag::listTasklists(false, Horde_Perms::SHOW, false) as $tl_id => $tl) { if (!$tl->hasPermission($user, Horde_Perms::EDIT)) { continue; } $tasklist_enums[$tl_id] = Nag::getLabel($tl); } $tasklist = $vars->get('tasklist_id'); if (empty($tasklist)) { reset($tasklist_enums); $tasklist = key($tasklist_enums); } $priorities = array(1 => '1 ' . _("(highest)"), 2 => 2, 3 => 3, 4 => 4, 5 => '5 ' . _("(lowest)")); $this->addHidden('', 'mobile', 'boolean', false); $this->addHidden('', 'task_id', 'text', false); $this->addHidden('', 'old_tasklist', 'text', false); $this->addHidden('', 'url', 'text', false); $this->addHidden('', 'uid', 'text', false); $this->addHidden('', 'owner', 'text', false); $this->addHidden('', 'list', 'text', false); $this->addHidden('', 'tab_name', 'text', false); $this->setSection(self::SECTION_GENERAL, _("General")); $this->addVariable(_("Name"), 'name', 'text', true); if (!$prefs->isLocked('default_tasklist') && count($tasklist_enums) > 1) { $v = $this->addVariable(_("Task List"), 'tasklist_id', 'enum', true, false, false, array($tasklist_enums)); if (!$vars->get('mobile')) { $v->setAction(Horde_Form_Action::factory('reload')); } } if (!$vars->get('mobile')) { $tasks = Nag::listTasks(array('tasklists' => array($tasklist), 'complete' => Nag::VIEW_FUTURE_INCOMPLETE, 'include_history' => false)); $task_enums = array('' => _("No parent task")); $tasks->reset(); while ($task = $tasks->each()) { if ($vars->get('task_id') == $task->id) { continue; } $task_enums[htmlspecialchars($task->id)] = str_repeat(' ', $task->indent * 4) . htmlspecialchars($task->name); } $v = $this->addVariable(_("Parent task"), 'parent', 'enum', false, false, false, array($task_enums)); $v->setOption('htmlchars', true); } $this->addVariable(_("Tags"), 'tags', 'Nag:NagTags', false); // Only display the delete button if this is an existing task and the // user has HORDE_PERMS::DELETE $share = $nag_shares->getShare($tasklist); $delete = $share->hasPermission($registry->getAuth(), Horde_Perms::DELETE) && $vars->get('task_id'); if (!$vars->get('mobile')) { $users = $share->listUsers(Horde_Perms::READ); $groups = $share->listGroups(Horde_Perms::READ); if (count($groups)) { $horde_group = $injector->getInstance('Horde_Group'); foreach ($groups as $group) { $users = array_merge($users, $horde_group->listUsers($group)); } } if (empty($GLOBALS['conf']['assignees']['allow_external'])) { $users = array_flip($users); if (count($users)) { foreach (array_keys($users) as $user) { $identity = $injector->getInstance('Horde_Core_Factory_Identity')->create($user); $fullname = $identity->getValue('fullname'); $users[$user] = strlen($fullname) ? $fullname : $user; } } $this->addVariable(_("Assignee"), 'assignee', 'enum', false, false, null, array($users, _("None"))); } else { $this->addVariable(_("Assignee"), 'assignee', 'Nag:NagContact', false); } } $this->addVariable(_("Private?"), 'private', 'boolean', false); $this->addVariable(_("Due By"), 'due', 'Nag:NagDue', false); if (!$vars->get('mobile')) { $this->addVariable(_("Delay Start Until"), 'start', 'Nag:NagStart', false); } $this->addVariable(_("Alarm"), 'alarm', 'Nag:NagAlarm', false); if (!$vars->get('mobile')) { $v = $this->addVariable(_("Notification"), 'methods', 'Nag:NagMethod', false); $v->setAction(Horde_Form_Action::factory('reload')); $v = $this->addVariable(_("Priority"), 'priority', 'enum', false, false, false, array($priorities)); $v->setDefault(3); $this->addVariable(_("Estimated Time"), 'estimate', 'number', false); $this->addVariable(_("Actual Time"), 'actual', 'number', false); $this->_completedVar = $this->addVariable(_("Completed?"), 'completed', 'boolean', false); $this->setSection(self::SECTION_RECUR, _("Recurrence")); $this->addVariable(_("Recurrence"), 'recurrence', 'Nag:NagRecurrence', false); } $this->setSection(self::SECTION_DESC, _("Description")); try { $description = Horde::callHook('description_help', array(), 'nag'); } catch (Horde_Exception_HookNotSet $e) { $description = ''; } $this->addVariable(_("Description"), 'desc', 'longtext', false, false, $description); $buttons = array(array('value' => _("Save"))); if ($delete) { $buttons[] = array('value' => _("Delete"), 'name' => 'deletebutton', 'class' => 'horde-delete'); } if (!$vars->get('task_id')) { $buttons[] = array('value' => _("Save and New"), 'name' => 'savenewbutton', 'class' => 'horde-create'); } if (Horde_Util::getFormData('have_search')) { $buttons[] = array('value' => _("Return to Search Results"), 'name' => 'search_return', 'class' => 'horde-button'); } $this->setButtons($buttons); }
} else { $notification->push(_("This note has been encrypted, and cannot be decrypted without a secure web connection"), 'horde.error'); $memo['body'] = ''; } } else { $notification->push($memo['body'], 'horde.error'); $memo['body'] = ''; } } $share = $mnemo_shares->getShare($memolist_id); $url = Horde::url('memo.php')->add(array('memo' => $memo_id, 'memolist' => $memolist_id)); $body = $injector->getInstance('Horde_Core_Factory_TextFilter')->filter($memo['body'], 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO)); $view = $injector->createInstance('Horde_View'); $view->assign($memo); try { $view->body = Horde::callHook('format_description', array($body), 'mnemo', $body); } catch (Horde_Exception_HookNotSet $e) { $view->body = $body; } $view->id = $memo_id; $view->listid = $memolist_id; $view->passphrase = $show_passphrase; $view->pdfurl = Horde::url('note/pdf.php')->add(array('note' => $memo_id, 'notepad' => $memolist_id)); $view->tags = implode(', ', $memo['tags']); if ($share->hasPermission($registry->getAuth(), Horde_Perms::DELETE)) { $view->delete = Horde::widget(array('url' => $url->add('actionID', 'delete_memos'), 'class' => 'mnemo-delete', 'id' => 'mnemo-delete', 'title' => _("_Delete"))); } if ($share->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { $view->edit = Horde::widget(array('url' => $url->add('actionID', 'modify_memo'), 'class' => 'mnemo-edit', 'title' => _("_Edit"))); } if (isset($memo['created'])) {