/** * Attempts to determine a files programming language and returns * a parser instance for this language. * * @param Luxor_Files $files An instance of Luxor_Files to use for file * operations and path name resolution. * @param string $pathname The path name of the file to create a * parser for. * * @return mixed The created concrete Luxor_Lang instance, or false * on error. */ function builder($files, $pathname) { global $languages; $languages = Horde::loadConfiguration('languages.php', 'languages', 'luxor'); /* First, check the 'filetype' hash for a matching file extension. */ foreach ($languages['filetype'] as $type) { if (preg_match('/' . $type[1] . '/', $pathname)) { return Luxor_Lang::factory($type[2], $type); } } /* Next, try to detect the shebang line. */ $fh = $files->getFileHandle($pathname); if (!$fh || is_a($fh, 'PEAR_Error')) { return $fh; } $line = fgets($fh); if (!preg_match('/^\\#!\\s*(\\S+)/s', $line, $match)) { return false; } if (isset($languages['interpreters'][$match[1]])) { $lang = $languages['filetype'][$languages['interpreters'][$match[1]]]; return Luxor_Lang::factory($lang[2], $lang); } return false; }
public function create(Horde_Injector $injector) { /* Brings in the $styles array in this scope only */ $styles = Horde::loadConfiguration('styles.php', 'styles', 'ansel'); /* No prettythumbs allowed at all by admin choice */ if (empty($GLOBALS['conf']['image']['prettythumbs'])) { $test = $styles; foreach ($test as $key => $style) { if ($style['thumbstyle'] != 'Thumb') { unset($styles[$key]); } } } /* Check if the browser / server has png support */ if ($GLOBALS['conf']['image']['type'] != 'png') { $test = $styles; foreach ($test as $key => $style) { if (!empty($style['requires_png'])) { if (!empty($style['fallback'])) { $styles[$key] = $styles[$style['fallback']]; } else { unset($styles[$key]); } } } } return $styles; }
/** * Find a list of configured attributes. * * Load the attributes configuration file or uses an already-loaded * cached copy. If loading for the first time, cache it for later use. * * @return array The attributes list. */ public static function getAttributes() { static $_attributes; if (!isset($_attributes)) { $_attributes = Horde::loadConfiguration('attributes.php', '_attributes'); } return $_attributes; }
/** * Returns avaiable countries */ static function getCountries() { try { return Horde::loadConfiguration('countries.php', 'countries', 'folks'); } catch (Horde_Exception $e) { return Horde_Nls::getCountryISO(); } }
public function __construct() { global $registry, $notification, $browser, $conf; $this->registry =& $registry; $this->notification =& $notification; $this->auth = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create(); $this->conf = Horde::loadConfiguration('conf.php', 'conf'); $this->objects = Horde::loadConfiguration('objects.php', 'objects'); $this->attributes = Horde::loadConfiguration('attributes.php', 'attributes'); $this->labels = Horde::loadConfiguration('labels.php', 'labels'); $this->perms = Horde::loadConfiguration('perms.php', 'perms'); $this->order = Horde::loadConfiguration('order.php', 'order'); $this->visible = Horde::loadConfiguration('visible.php', 'visible'); $this->search = Horde::loadConfiguration('search.php', 'search'); }
/** */ protected function _params() { $templates = Horde::loadConfiguration('templates.php', 'templates', 'jonah'); $params['source'] = array('name' => _("Feed"), 'type' => 'enum', 'values' => array()); $channels = $GLOBALS['injector']->getInstance('Jonah_Driver')->getChannels(); foreach ($channels as $channel) { $params['source']['values'][$channel['channel_id']] = $channel['channel_name']; } natcasesort($params['source']['values']); $params['view'] = array('name' => _("View"), 'type' => 'enum', 'values' => array()); foreach ($templates as $key => $template) { $params['view']['values'][$key] = $template['name']; } $params['max'] = array('name' => _("Maximum Stories"), 'type' => 'int', 'default' => 10, 'required' => false); return $params; }
/** * Indexes a file. * * @param string $path The full path name of the file to index. * @param int $fileId The file's unique ID. * * @return mixed A PEAR_Error on error. */ function indexFile($path, $fileId) { global $conf, $index; $typemap = $this->_langmap['typemap']; $languages = Horde::loadConfiguration('languages.php', 'languages', 'luxor'); if (isset($languages['eclangnamemapping'][$this->_language])) { $langforce = $languages['eclangnamemapping'][$this->_language]; } else { $langforce = $this->_language; } $version = shell_exec($conf['paths']['ectags'] . ' --version'); if (!preg_match('/Exuberant ctags +(\\d+)/i', $version, $match) || $match[1] < 5) { return PEAR::raiseError(sprintf(_("Exuberant ctags version 5 or above required, found version %s"), $version)); } if (file_exists($conf['paths']['ectags'])) { /* Call excuberant ctags. */ $ectags = @popen($conf['paths']['ectags'] . ' ' . $languages['ectagsopts'] . ' --excmd=number --language-force=' . $langforce . ' -f - ' . $path, 'r'); if (!$ectags) { return PEAR::raiseError(_("Can't run ectags.")); } while ($fgets = trim(fgets($ectags))) { @(list($sym, $file, $line, $type, $ext) = explode("\t", $fgets)); $line = preg_replace('/;"$/', '', $line); preg_match('/language:(\\w+)/', $ext, $match); $ext = @$match[1]; if (!isset($typemap[$type])) { continue; } $type = $typemap[$type]; if (!empty($ext) && preg_match('/^(struct|union|class|enum):(.*)/', $ext, $match)) { $ext = str_replace('::<anonymous>', '', $match[2]); } else { $ext = ''; } /* Build index. */ $result = $index->index($sym, $fileId, $line, $this->_langmap['langid'], $type); if (is_a($result, 'PEAR_Error')) { pclose($ectags); return $result; } } pclose($ectags); } }
public function run() { $this->_runtime = time(); // See if we need to include the reminders config file. if (filemtime(WHUPS_BASE . '/config/reminders.php') > $this->_filestamp) { $this->_filestamp = $this->_runtime; $this->_reminders = Horde::loadConfiguration('reminders.php', 'reminders', 'whups'); } foreach ($this->_reminders as $reminder) { $ds = new Horde_Scheduler_Cron_Date($reminder['frequency']); if ($ds->scheduledAt($this->_runtime)) { if (!empty($reminder['server_name'])) { $GLOBALS['conf']['server']['name'] = $reminder['server_name']; } $vars = new Horde_Variables($reminder); Whups::sendReminders($vars); } } }
function printfile_raw($pathname) { global $mime_drivers, $mime_drivers_map; $result = Horde::loadConfiguration('mime_drivers.php', array('mime_drivers', 'mime_drivers_map'), 'horde'); extract($result); $result = Horde::loadConfiguration('mime_drivers.php', array('mime_drivers', 'mime_drivers_map'), 'luxor'); if (isset($result['mime_drivers'])) { $mime_drivers = array_replace_recursive($mime_drivers, $result['mime_drivers']); } if (isset($result['mime_drivers_map'])) { $mime_drivers_map = array_replace_recursive($mime_drivers_map, $result['mime_drivers_map']); } $filename = $GLOBALS['files']->toReal($pathname); $data = file_get_contents($filename); $mime_part = new Horde_Mime_Part(Horde_Mime_Magic::filenameToMime($pathname), $data); $mime_part->setName($pathname); $viewer = $GLOBALS['injector']->getInstance('Horde_Core_Factory_MimeViewer')->create($mime_part); if ($viewer->getType() == 'text/plain') { return '<pre class="fixed">' . htmlspecialchars($viewer->render()) . '</pre>'; } else { return $viewer->render(); } }
/** * $registry * $notification * $conf * $criteria * */ public function run() { extract($this->_params, EXTR_REFS); $templates = Horde::loadConfiguration('templates.php', 'templates', 'jonah'); /* Get requested channel. */ try { $channel = $GLOBALS['injector']->getInstance('Jonah_Driver')->getChannel($criteria['feed']); } catch (Exception $e) { Horde::log($e, 'ERR'); $notification->push(_("Invalid channel."), 'horde.error'); Horde::url('delivery/index.php', true)->redirect(); exit; } $title = sprintf(_("HTML Delivery for \"%s\""), $channel['channel_name']); $options = array(); foreach ($templates as $key => $info) { $options[] = '<option value="' . $key . '"' . ($key == $criteria['format'] ? ' selected="selected"' : '') . '>' . $info['name'] . '</option>'; } $template = new Horde_Template(); $template->setOption('gettext', 'true'); $template->set('url', Horde::selfUrl()); $template->set('session', Horde_Util::formInput()); $template->set('channel_id', $criteria['feed']); $template->set('channel_name', $channel['channel_name']); $template->set('format', $criteria['format']); $template->set('options', $options); // @TODO: This is ugly. storage driver shouldn't be rendering any display // refactor this to use individual views possibly with a choice of different templates $template->set('stories', $GLOBALS['injector']->getInstance('Jonah_Driver')->renderChannel($criteria['feed'], $criteria['format'])); // Buffer the notifications and send to the template Horde::startBuffer(); $GLOBALS['notification']->notify(array('listeners' => 'status')); $template->set('notify', Horde::endBuffer()); $GLOBALS['page_output']->header(array('title' => $title)); echo $template->fetch(JONAH_TEMPLATES . '/delivery/html.html'); $GLOBALS['page_output']->footer(); }
public function up() { $this->changeColumn('ansel_shares', 'attribute_style', 'text'); // Create: ansel_hashes $t = $this->createTable('ansel_hashes', array('autoincrementKey' => false)); $t->column('style_hash', 'string', array('limit' => 255)); $t->primaryKey(array('style_hash')); $t->end(); $styles = Horde::loadConfiguration('styles.php', 'styles', 'ansel'); // Migrate existing data $sql = 'SELECT share_id, attribute_style FROM ansel_shares'; $this->announce('Migrating gallery styles.', 'cli.message'); $defaults = array('thumbstyle' => 'Thumb', 'background' => 'none', 'gallery_view' => 'Gallery', 'widgets' => array('Tags' => array('view' => 'gallery'), 'OtherGalleries' => array(), 'Geotag' => array(), 'Links' => array(), 'GalleryFaces' => array(), 'OwnerFaces' => array())); $rows = $this->_connection->selectAll($sql); $update = 'UPDATE ansel_shares SET attribute_style = ? WHERE share_id = ?;'; foreach ($rows as $row) { // Make sure we haven't already migrated if (@unserialize($row['attribute_style']) instanceof Ansel_Style) { $this->announce('Skipping share ' . $row['attribute_style'] . ', already migrated.', 'cli.message'); continue; } if (empty($styles[$row['attribute_style']])) { $newStyle = ''; } else { $properties = array_merge($defaults, $styles[$row['attribute_style']]); // Translate previous generator names: $properties = $this->_translate_generators($properties); $newStyle = serialize(new Ansel_Style($properties)); } $this->announce('Migrating share id: ' . $row['share_id'] . ' from: ' . $row['attribute_style'] . ' to: ' . $newStyle, 'cli.message'); try { $this->_connection->execute($update, array($newStyle, $row['share_id'])); } catch (Horde_Db_Exception $e) { $this->announce('ERROR: ' . $e->getMessage()); } } }
/** * Returns the stories of a channel rendered with the specified template. * * @param integer $channel_id The news channel to get stories from. * @param string $tpl The name of the template to use. * @param integer $max The maximum number of stories to get. If * null, all stories will be returned. * @param integer $from The number of the story to start with. * @param integer $order How to sort the results for internal channels * Possible values are the Jonah::ORDER_* * constants. * * @TODO: This doesn't belong in a storage driver class. Move it to a * view or possible a static method in Jonah::? * * @return string The rendered story listing. */ public function renderChannel($channel_id, $tpl, $max = 10, $from = 0, $order = Jonah::ORDER_PUBLISHED) { $channel = $this->getChannel($channel_id); $templates = Horde::loadConfiguration('templates.php', 'templates', 'jonah'); $escape = !isset($templates[$tpl]['escape']) || !empty($templates[$tpl]['escape']); $template = new Horde_Template(); if ($escape) { $channel['channel_name'] = htmlspecialchars($channel['channel_name']); $channel['channel_desc'] = htmlspecialchars($channel['channel_desc']); } $template->set('channel', $channel, true); /* Get one story more than requested to see if there are more stories. */ if ($max !== null) { $stories = $this->getStories(array('channel_id' => $channel_id, 'published' => true, 'startnumber' => $from, 'limit' => $max), $order); } else { $stories = $this->getStories(array('channel_id' => $channel_id, 'published' => true), $order); $max = count($stories); } if (!$stories) { $template->set('error', _("No stories are currently available."), true); $template->set('stories', false, true); $template->set('image', false, true); $template->set('form', false, true); } else { /* Escape. */ if ($escape) { array_walk($stories, array($this, '_escapeStories')); } /* Process story summaries. */ array_walk($stories, array($this, '_escapeStoryDescriptions')); $template->set('error', false, true); $template->set('story_marker', Horde::img('story_marker.png')); $template->set('image', false, true); $template->set('form', false, true); if ($from) { $template->set('previous', max(0, $from - $max), true); } else { $template->set('previous', false, true); } if ($from && !empty($channel['channel_page_link'])) { $template->set('previous_link', str_replace(array('%25c', '%25n', '%c', '%n'), array('%c', '%n', $channel['channel_id'], max(0, $from - $max)), $channel['channel_page_link']), true); } else { $template->set('previous_link', false, true); } $more = count($stories) > $max; if ($more) { $template->set('next', $from + $max, true); array_pop($stories); } else { $template->set('next', false, true); } if ($more && !empty($channel['channel_page_link'])) { $template->set('next_link', str_replace(array('%25c', '%25n', '%c', '%n'), array('%c', '%n', $channel['channel_id'], $from + $max), $channel['channel_page_link']), true); } else { $template->set('next_link', false, true); } $template->set('stories', $stories, true); } return $template->parse($templates[$tpl]['template']); }
<?php /** * Script to handle requests for html delivery of stories. * * Copyright 2004-2016 Horde LLC (http://www.horde.org/) * * See the enclosed file LICENSE for license information (BSD). If you did not * did not receive this file, see http://cvs.horde.org/co.php/jonah/LICENSE. * * @author Jan Schneider <*****@*****.**> */ require_once __DIR__ . '/lib/Application.php'; $jonah = Horde_Registry::appInit('jonah', array('authentication' => 'none', 'session_control' => 'readonly')); $jonah = Horde_Registry::appInit('jonah'); $templates = Horde::loadConfiguration('templates.php', 'templates', 'jonah'); /* Get the id and format of the feed to display. */ $criteria = Horde_Util::nonInputVar('criteria'); if (empty($criteria['channel_format'])) { // Select the default channel format $criteria['channel_format'] = key($templates); } $options = array(); foreach ($templates as $key => $info) { $options[] = '<option value="' . $key . '"' . ($key == $criteria['channel_format'] ? ' selected="selected"' : '') . '>' . $info['name'] . '</option>'; } if (empty($criteria['channel_id']) && !empty($criteria['feed'])) { $criteria['channel_id'] = $GLOBALS['injector']->getInstance('Jonah_Driver')->getChannelId($criteria['feed']); } if (empty($criteria['channel_id'])) { $notification->push(_("No valid feed name or ID requested."), 'horde.error');
/** * Prints a descriptive blurb at the end of directory listings. * * @param Luxor_File $files An instance of Luxor_File. * @param string $path The directory where to look for a README file. */ function dirDesc($files, $path) { $table_head = '<br /><br /><table width="100%" cellpadding="5"><tr><td class="text"><span class="fixed">'; $table_foot = '</span></td></tr></table>'; if (file_exists($filename = $files->toReal($path . '/README')) || file_exists($filename = $files->toReal($path . '/README.txt'))) { $contents = file_get_contents($filename); return $table_head . $GLOBALS['injector']->getInstance('Horde_Core_Factory_TextFilter')->filter($contents, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO)) . $table_foot; } elseif ($filename = file_exists($files->toReal($path . '/README.html'))) { global $mime_drivers, $mime_drivers_map; $result = Horde::loadConfiguration('mime_drivers.php', array('mime_drivers', 'mime_drivers_map'), 'horde'); extract($result); $result = Horde::loadConfiguration('mime_drivers.php', array('mime_drivers', 'mime_drivers_map'), 'luxor'); $mime_drivers = array_replace_recursive($mime_drivers, $result['mime_drivers']); $mime_drivers_map = array_replace_recursive($mime_drivers_map, $result['mime_drivers_map']); $contents = file_get_contents($filename); $mime_part = new Horde_Mime_Part('text/plain', $contents); $mime_part->setName('README'); return $table_head . $GLOBALS['injector']->getInstance('Horde_Core_Factory_MimeViewer')->create($mime_part)->render() . $table_foot; } }
/** * Loads the Gollem backend configuration from backends.php. * * @param string $backend Returns this labeled entry only. * * @return mixed If $backend is set return this entry; else, return the * entire backends array. Returns false on error. */ public static function getBackend($backend = null) { if (!($backends = self::_getBackends())) { try { $backends = Horde::loadConfiguration('backends.php', 'backends', 'gollem'); if (is_null($backends)) { return false; } } catch (Horde_Exception $e) { Horde::log($e, 'ERR'); return false; } foreach (array_keys($backends) as $key) { if (!empty($backends[$key]['disabled']) || !Gollem::checkPermissions('backend', Horde_Perms::SHOW, $key)) { unset($backends[$key]); } } self::_setBackends($backends); } if (is_null($backend)) { return $backends; } /* Check for the existence of the backend in the config file. */ if (empty($backends[$backend]) || !is_array($backends[$backend])) { $entry = sprintf('Invalid backend key "%s" from client [%s]', $backend, $_SERVER['REMOTE_ADDR']); Horde::log($entry, 'ERR'); return false; } return $backends[$backend]; }
if (!$form->validate()) { break; } $form->getInfo(null, $info); // Check old and new passwords if ($info['old'] == $info['new']) { $notification->push(_("Your new password must be different from your current password"), 'horde.warning'); break; } // Check old password if ($info['old'] == $info['new']) { $notification->push(_("Your old password didn't match"), 'horde.warning'); break; } // Check some password policy $password_policy = Horde::loadConfiguration('password_policy.php', 'password_policy', 'folks'); if (is_array($password_policy)) { // Check max/min lengths if specified in the backend config. if (isset($password_policy['minLength']) && strlen($info['new']) < $password_policy['minLength']) { $notification->push(sprintf(_("Your new password must be at least %d characters long!"), $password_policy['minLength']), 'horde.warning'); break; } if (isset($password_policy['maxLength']) && strlen($info['new']) > $password_policy['maxLength']) { $notification->push(sprintf(_("Your new password is too long; passwords may not be more than %d characters long!"), $password_policy['maxLength']), 'horde.warning'); break; } // Disect the password in a localised way. $classes = array(); $alpha = $alnum = $num = $upper = $lower = $space = $symbol = 0; for ($i = 0; $i < strlen($info['new']); $i++) { $char = substr($info['new'], $i, 1);
/** * Global variables defined: * $chora_conf * $sourceroots */ protected function _init() { global $acts, $conf, $defaultActs, $where, $atdir, $fullname, $sourceroot, $page_output; // TODO: If chora isn't fully/properly setup, init() will throw fatal // errors. Don't want that if this class is being loaded simply to // obtain basic chora application information. $initial_app = $GLOBALS['registry']->initialApp == 'chora'; try { $GLOBALS['sourceroots'] = Horde::loadConfiguration('backends.php', 'sourceroots'); } catch (Horde_Exception $e) { $GLOBALS['sourceroots'] = array(); if (!$initial_app) { return; } $GLOBALS['notification']->push($e); } $sourceroots = Chora::sourceroots(); /** * Variables we wish to propagate across web pages * ha = Hide Attic Files * ord = Sort order * sbt = Sort By Type (name, age, author, etc) * * Obviously, defaults go into $defaultActs :) * TODO: defaults of 1 will not get propagated correctly - avsm * XXX: Rewrite this propagation code, since it sucks - avsm */ $defaultActs = $acts = array('onb' => 0, 'ord' => Horde_Vcs::SORT_ASCENDING, 'rev' => 0, 'rt' => null, 'sa' => 0, 'sbt' => constant($conf['options']['defaultsort']), 'ws' => 1); /* See if any actions have been passed as form variables, and if so, * assign them into the acts array. */ $vars = Horde_Variables::getDefaultVariables(); foreach (array_keys($acts) as $key) { if (isset($vars->{$key})) { $acts[$key] = $vars->{$key}; } } /* Use the value of the 'rt' form value for the sourceroot. If not * present, use the last sourceroot used as the default value if the * user has that preference. Otherwise, use default sourceroot. */ $last_sourceroot = $GLOBALS['prefs']->getValue('last_sourceroot'); if (is_null($acts['rt'])) { if (!empty($last_sourceroot) && !empty($sourceroots[$last_sourceroot]) && is_array($sourceroots[$last_sourceroot])) { $acts['rt'] = $last_sourceroot; } else { foreach ($sourceroots as $key => $val) { if (!isset($acts['rt']) || isset($val['default'])) { $acts['rt'] = $key; break; } } if (is_null($acts['rt'])) { if ($initial_app) { Chora::fatal(new Chora_Exception(_("No repositories found."))); } return; } } } if (!isset($sourceroots[$acts['rt']])) { if ($initial_app) { Chora::fatal(new Chora_Exception(sprintf(_("The repository with the slug '%s' was not found"), $acts['rt']))); } return; } $sourcerootopts = $sourceroots[$acts['rt']]; $sourceroot = $acts['rt']; /* Store last repository viewed */ if ($acts['rt'] != $last_sourceroot) { $GLOBALS['prefs']->setValue('last_sourceroot', $acts['rt']); } // Cache. $cache = empty($conf['caching']) ? null : $GLOBALS['injector']->getInstance('Horde_Cache'); $GLOBALS['chora_conf'] = array('cvsusers' => $sourcerootopts['location'] . '/' . (isset($sourcerootopts['cvsusers']) ? $sourcerootopts['cvsusers'] : ''), 'introText' => CHORA_BASE . '/config/' . (isset($sourcerootopts['intro']) ? $sourcerootopts['intro'] : ''), 'introTitle' => isset($sourcerootopts['title']) ? $sourcerootopts['title'] : '', 'sourceRootName' => $sourcerootopts['name']); $chora_conf =& $GLOBALS['chora_conf']; $GLOBALS['VC'] = Horde_Vcs::factory(Horde_String::ucfirst($sourcerootopts['type']), array('cache' => $cache, 'sourceroot' => $sourcerootopts['location'], 'paths' => array_merge($conf['paths'], array('temp' => Horde::getTempDir())), 'username' => isset($sourcerootopts['username']) ? $sourcerootopts['username'] : '', 'password' => isset($sourcerootopts['password']) ? $sourcerootopts['password'] : '')); if (!$initial_app) { return; } $where = Horde_Util::getFormData('f', '/'); /* Location relative to the sourceroot. */ $where = preg_replace(array('|^/|', '|\\.\\.|'), '', $where); $fullname = $sourcerootopts['location'] . (substr($sourcerootopts['location'], -1) == '/' ? '' : '/') . $where; if ($sourcerootopts['type'] == 'cvs') { $fullname = preg_replace('|/$|', '', $fullname); $atdir = @is_dir($fullname); } else { $atdir = !$where || substr($where, -1) == '/'; } $where = preg_replace('|/$|', '', $where); if ($sourcerootopts['type'] == 'cvs' && !@is_dir($sourcerootopts['location'])) { Chora::fatal(new Chora_Exception(_("Sourceroot not found. This could be a misconfiguration by the server administrator, or the server could be having temporary problems. Please try again later."))); } if (Chora::isRestricted($where)) { Chora::fatal(new Chora_Exception(sprintf(_("%s: Forbidden by server configuration"), $where))); } }
*/ require_once __DIR__ . '/../../lib/base.php'; require_once FOLKS_BASE . '/lib/base.php'; require_once FOLKS_BASE . '/edit/tabs.php'; $title = _("Invite friend"); // Load driver require_once FOLKS_BASE . '/lib/Friends.php'; $friends = Folks_Friends::singleton(); // Manage adding groups $form = new Horde_Form($vars, $title, 'invite'); $form->addVariable(_("Friend's e-mail"), 'email', 'email', true); $v =& $form->addVariable(_("Subject"), 'subject', 'text', true); $v->setDefault(sprintf(_("%s Invited to join %s."), ucfirst($GLOBALS['registry']->getAuth()), $registry->get('name', 'horde'))); $v =& $form->addVariable(_("Body"), 'body', 'longtext', true); try { $body = Horde::loadConfiguration('invite.php', 'body', 'folks'); $body = sprintf($body, $registry->get('name', 'horde'), Folks::getUrlFor('user', $GLOBALS['registry']->getAuth(), true), Horde::url('account/signup.php', true), $GLOBALS['registry']->getAuth()); } catch (Horde_Exception $e) { $body = $body->getMessage(); } $v->setDefault($body); if ($form->validate()) { $form->getInfo(null, $info); $result = Folks::sendMail($info['email'], $info['subject'], $info['body']); if ($result instanceof PEAR_Error) { $notification->push($result); } else { $notification->push(sprintf(_("Friend \"%s\" was invited to join %s."), $info['email'], $registry->get('name', 'horde')), 'horde.success'); } } $page_output->header(array('title' => $title));
/** * @throws Passwd_Exception */ protected function _loadBackends() { if (!is_null($this->_backends)) { return; } $allbackends = Horde::loadConfiguration('backends.php', 'backends', 'passwd'); if (!isset($allbackends) || !is_array($allbackends)) { throw new Passwd_Exception(_("No backends configured in backends.php")); } $backends = array(); foreach ($allbackends as $name => $backend) { if (empty($backend['disabled'])) { /* Make sure the 'params' entry exists. */ if (!isset($backend['params'])) { $backend['params'] = array(); } $backends[$name] = $backend; } } /* Check for valid backend configuration. */ if (empty($backends)) { throw new Passwd_Exception(_("No backend configured for this host")); } $this->_backends = $backends; }
/** * Lists all templates of a given type. * * @param string $type The kind of template ('searchresults', etc.) to * list. * * @return array All templates of the requested type. */ public static function listTemplates($type) { $templates = array(); $_templates = Horde::loadConfiguration('templates.php', '_templates', 'whups'); foreach ($_templates as $name => $info) { if ($info['type'] == $type) { $templates[$name] = $info['name']; } } return $templates; }
/** * Provides a standardised function to call a Horde hook, checking whether * a hook config file exists and whether the function itself exists. If * these two conditions are not satisfied it will return the specified * value (by default a PEAR error). * * @param string $hook The function to call. * @param array $args An array of any arguments to pass to the hook * function. * @param string $app If specified look for hooks in the config directory * of this app. * @param mixed $error What to return if $app/config/hooks.php or $hook * does not exist. If this is the string 'PEAR_Error' * a PEAR error object is returned instead, detailing * the failure. * * @return mixed Either the results of the hook or PEAR error on failure. */ function callHook($hook, $args = array(), $app = 'horde', $error = 'PEAR_Error') { global $registry; static $hooks_loaded = array(); if (!isset($hooks_loaded[$app])) { $success = Horde::loadConfiguration('hooks.php', null, $app); if (is_a($success, 'PEAR_Error')) { Horde::logMessage($success, __FILE__, __LINE__, PEAR_LOG_DEBUG); $hooks_loaded[$app] = false; } else { $hooks_loaded[$app] = true; } } if (function_exists($hook)) { $result = call_user_func_array($hook, $args); if (is_a($result, 'PEAR_Error')) { Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR); } return $result; } if (is_string($error) && strcmp($error, 'PEAR_Error') == 0) { $error = PEAR::raiseError(sprintf('Hook %s in application %s not called.', $hook, $app)); Horde::logMessage($error, __FILE__, __LINE__, PEAR_LOG_DEBUG); } return $error; }
Horde::url('edit/groups.php')->redirect(); } elseif (Horde_Util::getFormData('submitbutton') == _("Rename")) { $new_name = Horde_Util::getFormData('new_name'); $result = $friends->renameGroup($g, $new_name); if ($result instanceof PEAR_Error) { $notification->push($result); } else { $notification->push(sprintf(_("Group \"%s\" has been renamed to \"%s\"."), $groups[$g], $new_name), 'horde.success'); Horde::url('edit/groups.php')->redirect(); } } break; default: // Manage adding groups $form = new Horde_Form($vars, _("Add group"), 'addgroup'); $translated = Horde::loadConfiguration('groups.php', 'groups', 'folks'); asort($translated); $form->addHidden('action', 'action', 'text', 'add'); $form->addVariable(_("Name"), 'translated_name', 'radio', false, false, null, array($translated, true)); $form->addVariable(_("Name"), 'custom_name', 'text', false, false, _("Enter custom name")); if ($form->validate()) { $form->getInfo(null, $info); if (empty($info['custom_name'])) { $name = $info['translated_name']; } else { $name = $info['custom_name']; } $result = $friends->addGroup($name); if ($result instanceof PEAR_Error) { $notification->push($result); } else {
/** * @throws Whups_Exception */ public function download(Horde_Variables $vars) { global $injector, $whups_driver; switch ($vars->actionID) { case 'download_file': // Get the ticket details first. if (empty($vars->ticket)) { exit; } $details = $whups_driver->getTicketDetails($vars->ticket); // Check permissions on this ticket. if (!count(Whups::permissionsFilter($whups_driver->getHistory($vars->ticket), 'comment', Horde_Perms::READ))) { throw new Whups_Exception(sprintf(_("You are not allowed to view ticket %d."), $vars->ticket)); } try { $vfs = $injector->getInstance('Horde_Core_Factory_Vfs')->create(); } catch (Horde_Exception $e) { throw new Whups_Exception(_("The VFS backend needs to be configured to enable attachment uploads.")); } try { return array('data' => $vfs->read(Whups::VFS_ATTACH_PATH . '/' . $vars->ticket, $vars->file), 'name' => $vars->file); } catch (Horde_Vfs_Exception $e) { throw new Whups_Exception(sprintf(_("Access denied to %s"), $vars->file)); } break; case 'report': $_templates = Horde::loadConfiguration('templates.php', '_templates', 'whups'); $tpl = $vars->template; if (empty($_templates[$tpl])) { throw new Whups_Exception(_("The requested template does not exist.")); } if ($_templates[$tpl]['type'] != 'searchresults') { throw new Whups_Exception(_("This is not a search results template.")); } // Fetch all unresolved tickets assigned to the current user. $info = array('id' => explode(',', $vars->ids)); $tickets = $whups_driver->getTicketsByProperties($info); foreach ($tickets as $id => $info) { $tickets[$id]['#'] = $id + 1; $tickets[$id]['link'] = Whups::urlFor('ticket', $info['id'], true, -1); $tickets[$id]['date_created'] = strftime('%x', $info['timestamp']); $tickets[$id]['owners'] = Whups::getOwners($info['id']); $tickets[$id]['owner_name'] = Whups::getOwners($info['id'], false, true); $tickets[$id]['owner_email'] = Whups::getOwners($info['id'], true, false); if (!empty($info['date_assigned'])) { $tickets[$id]['date_assigned'] = strftime('%x', $info['date_assigned']); } if (!empty($info['date_resolved'])) { $tickets[$id]['date_resolved'] = strftime('%x', $info['date_resolved']); } // If the template has a callback function defined for data // filtering, call it now. if (!empty($_templates[$tpl]['callback'])) { array_walk($tickets[$id], $_templates[$tpl]['callback']); } } Whups::sortTickets($tickets, isset($_templates[$tpl]['sortby']) ? $_templates[$tpl]['sortby'] : null, isset($_templates[$tpl]['sortdir']) ? $_templates[$tpl]['sortdir'] : null); $template = $injector->createInstance('Horde_Template'); $template->set('tickets', $tickets); $template->set('now', strftime('%x')); $template->set('values', Whups::getSearchResultColumns(null, true)); return array('data' => $template->parse($_templates[$tpl]['template']), 'name' => isset($_templates[$tpl]['filename']) ? $_templates[$tpl]['filename'] : 'report.html'); } }