Output the javascript needed to call the popup JS function.
public static popupJs ( string | Horde_Url $url, array $options = [] ) : string | ||
$url | string | Horde_Url | The page to load. |
$options | array | Additional options: - height: (integer) The height of the popup window. DEFAULT: 650px - menu: (boolean) Show the browser menu in the popup window? DEFAULT: false - onload: (string) A JS function to call after the popup window is fully loaded. DEFAULT: None - params: (array) Additional parameters to pass to the URL. DEFAULT: None - urlencode: (boolean) URL encode the json string? DEFAULT: false - width: (integer) The width of the popup window. DEFAULT: 700 px |
return | string | The javascript needed to call the popup code. |
/** */ public function display(Horde_Core_Prefs_Ui $ui) { global $injector, $page_output, $prefs, $session; $page_output->addScriptPackage('IMP_Script_Package_Imp'); $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/prefs')); $view->addHelper('Horde_Core_View_Helper_Help'); if (!Horde::isConnectionSecure()) { $view->notsecure = true; } else { $smime_url = IMP_Basic_Smime::url(); $view->has_key = $prefs->getValue('smime_public_key') && $prefs->getValue('smime_private_key'); if ($view->has_key) { $view->viewpublic = Horde::link($smime_url->copy()->add('actionID', 'view_personal_public_key'), _("View Personal Public Certificate"), null, 'view_key'); $view->infopublic = Horde::link($smime_url->copy()->add('actionID', 'info_personal_public_key'), _("Information on Personal Public Certificate"), null, 'info_key'); if ($injector->getInstance('IMP_Crypt_Smime')->getPassphrase()) { $view->passphrase = Horde::link($ui->selfUrl(array('special' => true, 'token' => true))->add('unset_smime_passphrase', 1), _("Unload Passphrase")) . _("Unload Passphrase"); } else { $imple = $injector->getInstance('Horde_Core_Factory_Imple')->create('IMP_Ajax_Imple_PassphraseDialog', array('params' => array('reload' => $ui->selfUrl()->setRaw(true)), 'type' => 'smimePersonal')); $view->passphrase = Horde::link('#', _("Enter Passphrase"), null, null, null, null, null, array('id' => $imple->getDomId())) . _("Enter Passphrase"); } $view->viewprivate = Horde::link($smime_url->copy()->add('actionID', 'view_personal_private_key'), _("View Personal Private Key"), null, 'view_key'); $page_output->addInlineScript(array('$("delete_smime_personal").observe("click", function(e) { if (!window.confirm(' . json_encode(_("Are you sure you want to delete your keypair? (This is NOT recommended!)")) . ')) { e.stop(); } })'), true); } elseif ($session->get('imp', 'file_upload')) { $view->import = true; $page_output->addInlineScript(array('$("import_smime_personal").observe("click", function(e) { ' . Horde::popupJs($smime_url, array('params' => array('actionID' => 'import_personal_certs', 'reload' => base64_encode($ui->selfUrl()->setRaw(true))), 'height' => 275, 'width' => 750, 'urlencode' => true)) . '; e.stop(); })'), true); } } return $view->render('smimeprivatekey'); }
/** */ public function display(Horde_Core_Prefs_Ui $ui) { global $injector, $page_output, $prefs, $session; $page_output->addScriptPackage('IMP_Script_Package_Imp'); $imp_pgp = $injector->getInstance('IMP_Crypt_Pgp'); /* Get list of Public Keys on keyring. */ try { $pubkey_list = $imp_pgp->listPublicKeys(); } catch (Horde_Exception $e) { $pubkey_list = array(); } $pgp_url = IMP_Basic_Pgp::url(); $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/prefs')); $view->addHelper('Horde_Core_View_Helper_Help'); $view->addHelper('Text'); if (!empty($pubkey_list)) { $plist = array(); $self_url = $ui->selfUrl(array('special' => true, 'token' => true)); foreach ($pubkey_list as $val) { $plist[] = array('name' => $val['name'], 'email' => $val['email'], 'view' => Horde::link($pgp_url->copy()->add(array('actionID' => 'view_public_key', 'email' => $val['email'])), sprintf(_("View %s Public Key"), $val['name']), null, 'view_key'), 'info' => Horde::link($pgp_url->copy()->add(array('actionID' => 'info_public_key', 'email' => $val['email'])), sprintf(_("Information on %s Public Key"), $val['name']), null, 'info_key'), 'delete' => Horde::link($self_url->copy()->add(array('delete_pgp_pubkey' => 1, 'email' => $val['email'])), sprintf(_("Delete %s Public Key"), $val['name']), null, null, "window.confirm('" . addslashes(_("Are you sure you want to delete this public key?")) . "')")); } $view->pubkey_list = $plist; } if ($session->get('imp', 'file_upload')) { $view->can_import = true; $view->no_source = !$prefs->getValue('add_source'); if (!$view->no_source) { $page_output->addInlineScript(array('$("import_pgp_public").observe("click", function(e) { ' . Horde::popupJs($pgp_url, array('params' => array('actionID' => 'import_public_key', 'reload' => base64_encode($ui->selfUrl()->setRaw(true))), 'height' => 275, 'width' => 750, 'urlencode' => true)) . '; e.stop(); })'), true); } } return $view->render('pgppublickey'); }
public function __construct($vars, $calendar) { global $conf, $injector, $registry; $this->_calendar = $calendar; $owner = $calendar->get('owner') == $registry->getAuth() || is_null($calendar->get('owner')) && $registry->isAdmin(); parent::__construct($vars, $owner ? sprintf(_("Edit %s"), $calendar->get('name')) : $calendar->get('name')); $this->addHidden('', 'c', 'text', true); $this->addVariable(_("Name"), 'name', 'text', true); if (!$owner) { $v = $this->addVariable(_("Owner"), 'owner', 'text', false); $owner_name = $injector->getInstance('Horde_Core_Factory_Identity')->create($calendar->get('owner'))->getValue('fullname'); if (trim($owner_name) == '') { $owner_name = $calendar->get('owner'); } $v->setDefault($owner_name ? $owner_name : _("System")); } $this->addVariable(_("Color"), 'color', 'colorpicker', false); if ($registry->isAdmin()) { $this->addVariable(_("System Calendar"), 'system', 'boolean', false, false, _("System calendars don't have an owner. Only administrators can change the calendar settings and permissions.")); } $this->addVariable(_("Description"), 'description', 'longtext', false, false, null, array(4, 60)); $this->addVariable(_("Tags"), 'tags', 'Kronolith:KronolithTags', false); /* Display URL. */ $url = Horde::url('month.php', true, -1)->add('display_cal', $calendar->getName()); $this->addVariable(_("Display URL"), '', 'link', false, false, null, array(array('url' => $url, 'text' => $url, 'title' => _("Click or copy this URL to display this calendar"), 'target' => '_blank'))); /* Subscription URLs. */ $url = $registry->get('webroot', 'horde'); if (isset($conf['urls']['pretty']) && $conf['urls']['pretty'] == 'rewrite') { $webdavUrl = $url . '/rpc/kronolith/'; $caldavUrl = $url . '/rpc/calendars/'; $accountUrl = $url . '/rpc/'; } else { $webdavUrl = $url . '/rpc.php/kronolith/'; $caldavUrl = $url . '/rpc.php/calendars/'; $accountUrl = $url . '/rpc.php/'; } try { $accountUrl = Horde::url($accountUrl, true, -1) . 'principals/' . $registry->convertUsername($registry->getAuth(), false) . '/'; $caldavUrl = Horde::url($caldavUrl, true, -1) . $registry->convertUsername($registry->getAuth(), false) . '/' . $injector->getInstance('Horde_Dav_Storage')->getExternalCollectionId($calendar->getName(), 'calendar') . '/'; $this->addVariable(_("CalDAV Subscription URL"), '', 'link', false, false, null, array(array('url' => $caldavUrl, 'text' => $caldavUrl, 'title' => _("Copy this URL to a CalDAV client to subscribe to this calendar"), 'target' => '_blank'))); $this->addVariable(_("CalDAV Account URL"), '', 'link', false, false, null, array(array('url' => $accountUrl, 'text' => $accountUrl, 'title' => _("Copy this URL to a CalDAV client to subscribe to all your calendars"), 'target' => '_blank'))); } catch (Horde_Exception $e) { } $webdavUrl = Horde::url($webdavUrl, true, -1) . ($calendar->get('owner') ? $registry->convertUsername($calendar->get('owner'), false) : '-system-') . '/' . $calendar->getName() . '.ics'; $this->addVariable(_("WebDAV/ICS Subscription URL"), '', 'link', false, false, null, array(array('url' => $webdavUrl, 'text' => $webdavUrl, 'title' => _("Copy this URL to a WebDAV or ICS client to subscribe to this calendar"), 'target' => '_blank'))); /* Feed URL. */ $url = Kronolith::feedUrl($calendar->getName()); $this->addVariable(_("Feed URL"), '', 'link', false, false, null, array(array('url' => $url, 'text' => $url, 'title' => _("Copy this URL to a news feed reader to subscribe to this calendar"), 'target' => '_blank'))); /* Embed code. */ $v = $this->addVariable(_("Embed code"), '', 'longtext', false, false, _("To embed this calendar in another website, use the code above."), array(4, 60)); $v->setHelp('embed'); $v->setDefault(Kronolith::embedCode($calendar->getName())); /* Permissions link. */ if (empty($conf['share']['no_sharing']) && $owner) { $url = Horde::url('perms.php')->add('share', $calendar->getName()); $this->addVariable('', '', 'link', false, false, null, array(array('url' => $url, 'text' => _("Change Permissions"), 'onclick' => Horde::popupJs($url, array('params' => array('urlencode' => true))) . 'return false;', 'class' => 'horde-button', 'target' => '_blank'))); } $this->setButtons(array(_("Save"), array('class' => 'horde-delete', 'value' => _("Delete")), array('class' => 'horde-cancel', 'value' => _("Cancel")))); }
/** */ public function display(Horde_Core_Prefs_Ui $ui) { global $browser, $injector, $page_output, $prefs; $page_output->addScriptPackage('IMP_Script_Package_Imp'); $p_css = new Horde_Themes_Element('prefs.css'); $page_output->addStylesheet($p_css->fs, $p_css->uri); $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/prefs')); $view->addHelper('Horde_Core_View_Helper_Help'); if (!Horde::isConnectionSecure()) { $view->notsecure = true; return $view->render('smimeprivatekey'); } $smime_url = IMP_Basic_Smime::url(); $view->has_key = $prefs->getValue('smime_public_key') && $prefs->getValue('smime_private_key'); $view->has_sign_key = $prefs->getValue('smime_public_sign_key') && $prefs->getValue('smime_private_sign_key'); if ($browser->allowFileUploads()) { $view->import = true; $page_output->addInlineScript(array('$("import_smime_personal").observe("click", function(e) { ' . Horde::popupJs($smime_url, array('params' => array('actionID' => 'import_personal_certs', 'reload' => base64_encode($ui->selfUrl()->setRaw(true))), 'height' => 450, 'width' => 750, 'urlencode' => true)) . '; e.stop(); })'), true); } if (!$view->has_key) { return $view->render('smimeprivatekey'); } $smime = $injector->getInstance('IMP_Smime'); foreach (array('' => false, '_sign' => true) as $suffix => $secondary) { if ($secondary && !$view->has_sign_key) { continue; } $cert = $smime->parseCert($smime->getPersonalPublicKey($secondary)); if (!empty($cert['validity']['notafter'])) { $expired = new Horde_Date($cert['validity']['notafter']); if ($expired->before(time())) { $view->{'expiredate' . $suffix} = $expired->strftime($prefs->getValue('date_format')); $view->{'expiretime' . $suffix} = $expired->strftime($prefs->getValue('time_format')); } } $view->{'viewpublic' . $suffix} = $smime_url->copy()->add('actionID', 'view_personal_public' . $suffix . '_key')->link(array('title' => $secondary ? _("View Secondary Personal Public Certificate") : _("View Personal Public Certificate"), 'target' => 'view_key')) . _("View") . '</a>'; $view->{'infopublic' . $suffix} = $smime_url->copy()->add('actionID', 'info_personal_public' . $suffix . '_key')->link(array('title' => _("Information on Personal Public Certificate"), 'target' => 'info_key')) . _("Details") . '</a>'; if ($smime->getPassphrase($secondary)) { $view->{'passphrase' . $suffix} = $ui->selfUrl(array('special' => true, 'token' => true))->add('unset_smime' . $suffix . '_passphrase', 1)->link(array('title' => _("Unload Passphrase"))) . _("Unload Passphrase") . '</a>'; } else { $imple = $injector->getInstance('Horde_Core_Factory_Imple')->create('IMP_Ajax_Imple_PassphraseDialog', array('params' => array('reload' => $ui->selfUrl()->setRaw(true), 'secondary' => intval($secondary)), 'type' => 'smimePersonal')); $view->{'passphrase' . $suffix} = Horde::link('#', _("Enter Passphrase"), null, null, null, null, null, array('id' => $imple->getDomId())) . _("Enter Passphrase"); } $view->{'viewprivate' . $suffix} = $smime_url->copy()->add('actionID', 'view_personal_private' . $suffix . '_key')->link(array('title' => _("View Secondary Personal Private Key"), 'target' => 'view_key')) . _("View") . '</a>'; $page_output->addInlineScript(array('$("delete_smime_personal' . $suffix . '").observe("click", function(e) { if (!window.confirm(' . json_encode(_("Are you sure you want to delete your keypair? (This is NOT recommended!)")) . ')) { e.stop(); } })'), true); } return $view->render('smimeprivatekey'); }
public function __construct($vars, Horde_Share_Object $addressbook) { global $conf, $injector, $registry; $this->_addressbook = $addressbook; $owner = $addressbook->get('owner') == $registry->getAuth() || is_null($addressbook->get('owner')) && $registry->isAdmin(); parent::__construct($vars, $owner ? sprintf(_("Edit %s"), $addressbook->get('name')) : $addressbook->get('name')); $this->addHidden('', 'a', 'text', true); $this->addVariable(_("Name"), 'name', 'text', true); if (!$owner) { $v = $this->addVariable(_("Owner"), 'owner', 'text', false); $owner_name = $injector->getInstance('Horde_Core_Factory_Identity')->create($addressbook->get('owner'))->getValue('fullname'); if (trim($owner_name) == '') { $owner_name = $addressbook->get('owner'); } $v->setDefault($owner_name ? $owner_name : _("System")); } $this->addVariable(_("Description"), 'description', 'longtext', false, false, null, array(4, 60)); /* Subscription URLs. */ $url = $registry->get('webroot', 'horde'); if (isset($conf['urls']['pretty']) && $conf['urls']['pretty'] == 'rewrite') { $webdavUrl = $url . '/rpc/turba/'; $carddavUrl = $url . '/rpc/addressbooks/'; $accountUrl = $url . '/rpc/'; } else { $webdavUrl = $url . '/rpc.php/turba/'; $carddavUrl = $url . '/rpc.php/addressbooks/'; $accountUrl = $url . '/rpc.php/'; } try { $accountUrl = Horde::url($accountUrl, true, -1) . 'principals/' . $registry->convertUsername($registry->getAuth(), false) . '/'; if ($addressbook->get('owner')) { $carddavUrl = Horde::url($carddavUrl, true, -1) . $registry->convertUsername($registry->getAuth(), false) . '/' . $injector->getInstance('Horde_Dav_Storage')->getExternalCollectionId($addressbook->getName(), 'contacts') . '/'; $this->addVariable(_("CardDAV Subscription URL"), '', 'link', false, false, null, array(array('url' => $carddavUrl, 'text' => $carddavUrl, 'title' => _("Copy this URL to a CardDAV client to subscribe to this address book"), 'target' => '_blank'))); } $this->addVariable(_("CardDAV Account URL"), '', 'link', false, false, null, array(array('url' => $accountUrl, 'text' => $accountUrl, 'title' => _("Copy this URL to a CarddAV client to subscribe to all your address books"), 'target' => '_blank'))); } catch (Horde_Exception $e) { } $webdavUrl = Horde::url($webdavUrl, true, -1) . ($addressbook->get('owner') ? $registry->convertUsername($addressbook->get('owner'), false) : '-system-') . '/' . $addressbook->getName() . '/'; $this->addVariable(_("WebDAV URL"), '', 'link', false, false, null, array(array('url' => $webdavUrl, 'text' => $webdavUrl, 'title' => _("Copy this URL to a WebDAV client to browse this address book"), 'target' => '_blank'))); /* Permissions link. */ if (empty($conf['share']['no_sharing']) && $owner) { $url = Horde::url($registry->get('webroot', 'horde') . '/services/shares/edit.php')->add(array('app' => 'turba', 'share' => $addressbook->getName())); $this->addVariable('', '', 'link', false, false, null, array(array('url' => $url, 'text' => _("Change Permissions"), 'onclick' => Horde::popupJs($url, array('params' => array('urlencode' => true))) . 'return false;', 'class' => 'horde-button', 'target' => '_blank'))); } $this->setButtons(array(_("Save"), array('class' => 'horde-delete', 'value' => _("Delete")), array('class' => 'horde-cancel', 'value' => _("Cancel")))); }
/** */ public function display(Horde_Core_Prefs_Ui $ui) { global $browser, $conf, $injector, $page_output, $prefs; $page_output->addScriptPackage('IMP_Script_Package_Imp'); $p_css = new Horde_Themes_Element('prefs.css'); $page_output->addStylesheet($p_css->fs, $p_css->uri); $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/prefs')); $view->addHelper('Horde_Core_View_Helper_Help'); if (!Horde::isConnectionSecure()) { $view->notsecure = true; } else { $pgp_url = IMP_Basic_Pgp::url(); $view->has_key = $prefs->getValue('pgp_public_key') && $prefs->getValue('pgp_private_key'); if ($view->has_key) { $view->viewpublic = Horde::link($pgp_url->copy()->add('actionID', 'view_personal_public_key'), _("View Personal Public Key"), null, 'view_key'); $view->infopublic = Horde::link($pgp_url->copy()->add('actionID', 'info_personal_public_key'), _("Information on Personal Public Key"), null, 'info_key'); $view->sendkey = Horde::link($ui->selfUrl(array('special' => true, 'token' => true))->add('send_pgp_key', 1), _("Send Key to Public Keyserver")); if ($injector->getInstance('IMP_Pgp')->getPassphrase('personal')) { $view->passphrase = Horde::link($ui->selfUrl(array('special' => true, 'token' => true))->add('unset_pgp_passphrase', 1), _("Unload Passphrase")) . _("Unload Passphrase"); } else { $imple = $injector->getInstance('Horde_Core_Factory_Imple')->create('IMP_Ajax_Imple_PassphraseDialog', array('params' => array('reload' => $ui->selfUrl()->setRaw(true)), 'type' => 'pgpPersonal')); $view->passphrase = Horde::link('#', _("Enter Passphrase"), null, null, null, null, null, array('id' => $imple->getDomId())) . _("Enter Passphrase"); } $view->viewprivate = Horde::link($pgp_url->copy()->add('actionID', 'view_personal_private_key'), _("View Personal Private Key"), null, 'view_key'); $view->infoprivate = Horde::link($pgp_url->copy()->add('actionID', 'info_personal_private_key'), _("Information on Personal Private Key"), null, 'info_key'); $page_output->addInlineScript(array('$("delete_pgp_privkey").observe("click", function(e) { if (!window.confirm(' . json_encode(_("Are you sure you want to delete your keypair? (This is NOT recommended!)")) . ')) { e.stop(); } })'), true); } else { $page_output->addScriptFile('prefs/pgp.js'); Horde_Core_Ui_JsCalendar::init(); $page_output->addInlineJsVars(array('ImpPgp.months' => Horde_Core_Ui_JsCalendar::months())); $imp_identity = $injector->getInstance('IMP_Identity'); $view->fullname = $imp_identity->getFullname(); $view->fromaddr = $imp_identity->getFromAddress()->bare_address; if (!empty($conf['pgp']['keylength'])) { $view->create_pgp_keypair = true; $page_output->addInlineScript(array('$("create_pgp_key").observe("click", function(e) { if (!window.confirm(' . json_encode(_("Key generation may take a long time to complete. Continue with key generation?")) . ')) { e.stop(); } })'), true); } if ($browser->allowFileUploads()) { $view->import_pgp_private = true; $page_output->addInlineScript(array('$("import_pgp_personal").observe("click", function(e) { ' . Horde::popupJs($pgp_url, array('params' => array('actionID' => 'import_personal_key', 'reload' => base64_encode($ui->selfUrl()->setRaw(true))), 'height' => 300, 'width' => 750, 'urlencode' => true)) . '; e.stop(); })'), true); } } } return $view->render('pgpprivatekey'); }
/** * * @param array $vars * @param Horde_Share_Object $tasklist */ public function __construct($vars, Horde_Share_Object $tasklist) { $this->_tasklist = $tasklist; $owner = $tasklist->get('owner') == $GLOBALS['registry']->getAuth() || is_null($tasklist->get('owner')) && $GLOBALS['registry']->isAdmin(); parent::__construct($vars, $owner ? sprintf(_("Edit %s"), $tasklist->get('name')) : $tasklist->get('name')); $this->addHidden('', 't', 'text', true); $this->addVariable(_("Name"), 'name', 'text', true); if (!$owner) { $v = $this->addVariable(_("Owner"), 'owner', 'text', false); $owner_name = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create($tasklist->get('owner'))->getValue('fullname'); if (trim($owner_name) == '') { $owner_name = $tasklist->get('owner'); } $v->setDefault($owner_name ? $owner_name : _("System")); } $this->addVariable(_("Color"), 'color', 'colorpicker', false); if ($GLOBALS['registry']->isAdmin()) { $this->addVariable(_("System Task List"), 'system', 'boolean', false, false, _("System task lists don't have an owner. Only administrators can change the task list settings and permissions.")); } $this->addVariable(_("Description"), 'description', 'longtext', false, false, null, array(4, 60)); /* Display URL. */ $url = Horde::url('list.php', true, -1)->add('display_tasklist', $tasklist->getName()); $this->addVariable(_("Display URL"), '', 'link', false, false, null, array(array('url' => $url, 'text' => $url, 'title' => _("Click or copy this URL to display this task list"), 'target' => '_blank'))); /* Subscription URLs. */ try { $accountUrl = Nag::getUrl(Nag::DAV_ACCOUNT, $tasklist); $caldavUrl = Nag::getUrl(Nag::DAV_CALDAV, $tasklist); $this->addVariable(_("CalDAV Subscription URL"), '', 'link', false, false, null, array(array('url' => $caldavUrl, 'text' => $caldavUrl, 'title' => _("Copy this URL to a CalDAV client to subscribe to this task list"), 'target' => '_blank'))); $this->addVariable(_("CalDAV Account URL"), '', 'link', false, false, null, array(array('url' => $accountUrl, 'text' => $accountUrl, 'title' => _("Copy this URL to a CalDAV client to subscribe to all your task lists"), 'target' => '_blank'))); } catch (Horde_Exception $e) { } $webdavUrl = Nag::getUrl(Nag::DAV_WEBDAV, $tasklist); $this->addVariable(_("WebDAV/ICS Subscription URL"), '', 'link', false, false, null, array(array('url' => $webdavUrl, 'text' => $webdavUrl, 'title' => _("Copy this URL to a WebDAV or ICS client to subscribe to this task list"), 'target' => '_blank'))); /* Permissions link. */ if (empty($GLOBALS['conf']['share']['no_sharing']) && $owner) { $url = Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/services/shares/edit.php')->add(array('app' => 'nag', 'share' => $tasklist->getName())); $this->addVariable('', '', 'link', false, false, null, array(array('url' => $url, 'text' => _("Change Permissions"), 'onclick' => Horde::popupJs($url, array('params' => array('urlencode' => true))) . 'return false;', 'class' => 'horde-button', 'target' => '_blank'))); } $this->setButtons(array(_("Save"), array('class' => 'horde-delete', 'value' => _("Delete")), array('class' => 'horde-cancel', 'value' => _("Cancel")))); }
public function __construct($vars, $notepad) { $this->_notepad = $notepad; $owner = $notepad->get('owner') == $GLOBALS['registry']->getAuth() || is_null($notepad->get('owner')) && $GLOBALS['registry']->isAdmin(); parent::__construct($vars, $owner ? sprintf(_("Edit %s"), $notepad->get('name')) : $notepad->get('name')); $this->addHidden('', 'n', 'text', true); $this->addVariable(_("Name"), 'name', 'text', true); if (!$owner) { $v = $this->addVariable(_("Owner"), 'owner', 'text', false); $owner_name = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create($notepad->get('owner'))->getValue('fullname'); if (trim($owner_name) == '') { $owner_name = $notepad->get('owner'); } $v->setDefault($owner_name ? $owner_name : _("System")); } $this->addVariable(_("Description"), 'description', 'longtext', false, false, null, array(4, 60)); /* Permissions link. */ if (empty($GLOBALS['conf']['share']['no_sharing']) && $owner) { $url = Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/services/shares/edit.php')->add(array('app' => 'mnemo', 'share' => $notepad->getName())); $this->addVariable('', '', 'link', false, false, null, array(array('url' => $url, 'text' => _("Change Permissions"), 'onclick' => Horde::popupJs($url, array('params' => array('urlencode' => true))) . 'return false;', 'class' => 'horde-button', 'target' => '_blank'))); } $this->setButtons(array(_("Save"), array('class' => 'horde-delete', 'value' => _("Delete")), array('class' => 'horde-cancel', 'value' => _("Cancel")))); }
echo $this->contentTag('a', sprintf(ngettext("%d comment", "%d comments", $this->image->commentCount), $this->image->commentCount), array('href' => strval($this->img_view_url->copy()->setAnchor('messagediv')), 'title' => _("View or leave comments"))); ?> </div> <?php } ?> <?php if ($this->option_select) { ?> <div> <span class="light"> <?php if ($this->option_edit) { ?> <?php echo $this->contentTag('a', _("Properties"), array('href' => $this->image_url->copy()->add(array('actionID' => 'modify')), 'target' => '_blank', 'onclick' => Horde::popupJs(Horde::url($this->image_url), array('height' => 360, 'width' => 500, 'params' => array('actionID' => 'modify', 'urlencode' => true))) . ' return false;')); ?> | <?php echo $this->contentTag('a', _("Edit"), array('href' => $this->image_url->copy()->add('actionID', 'editimage'))); ?> <?php } ?> </span> </div> <?php } ?> </div> </div> <!-- End image tile -->
/** */ public function topbarCreate(Horde_Tree_Renderer_Base $tree, $parent = null, array $params = array()) { switch ($params['id']) { case 'menu': $tree->addNode(array('id' => $parent . '__add', 'parent' => $parent, 'label' => _("Enter Time"), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('hermes.png'), 'url' => Horde::url('entry.php')))); $tree->addNode(array('id' => $parent . '__search', 'parent' => $parent, 'label' => _("Search Time"), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('search.png'), 'url' => Horde::url('search.php')))); break; case 'stopwatch': $tree->addNode(array('id' => $parent . '__start', 'parent' => $parent, 'label' => _("Start Watch"), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('timer-start.png'), 'url' => '#', 'onclick' => Horde::popupJs(Horde::url('start.php'), array('height' => 200, 'width' => 410))))); $timers = Hermes::listTimers(); $entry = Horde::url('entry.php'); foreach ($timers as $i => $timer) { $tree->addNode(array('id' => $parent . '__timer_' . $i, 'parent' => $parent, 'label' => $timer['name'] . sprintf(" (%s)", $timer['elapsed']), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('timer-stop.png'), 'url' => $entry->add('timer', $timer['id'])))); } } }
$config = new Horde_Config($app); if ($config->writePHPConfig($vars, $php)) { Horde::url('admin/config/index.php', true)->redirect(); } else { $notification->push(sprintf(_("Could not save the configuration file %s. You can either use one of the options to save the code back on %s or copy manually the code below to %s."), Horde_Util::realPath($configFile), Horde::link(Horde::url('admin/config/index.php') . '#update', _("Configuration")) . _("Configuration") . '</a>', Horde_Util::realPath($configFile)), 'horde.warning', array('content.raw', 'sticky')); } } elseif ($form->isSubmitted()) { $notification->push(_("There was an error in the configuration form. Perhaps you left out a required field."), 'horde.error'); } $view = new Horde_View(array('templatePath' => HORDE_TEMPLATES . '/admin/config')); $view->addHelper('Text'); $view->php = $php; /* Create the link for the diff popup only if stored in session. */ if ($session->exists('horde', 'config/' . $app)) { $url = Horde::url('admin/config/diff.php', true)->add('app', $app); $view->diff_popup = Horde::link('#', '', '', '', Horde::popupJs($url, array('height' => 480, 'width' => 640, 'urlencode' => true)) . 'return false;') . _("show differences") . '</a>'; } Horde::startBuffer(); require HORDE_TEMPLATES . '/admin/menu.inc'; $menu_output = Horde::endBuffer(); /* Render the configuration form. */ $renderer = $form->getRenderer(); $renderer->setAttrColumnWidth('50%'); /* Buffer the form template */ Horde::startBuffer(); $form->renderActive($renderer, $vars, Horde::url('admin/config/config.php'), 'post'); $view->form = Horde::endBuffer(); /* Send headers */ $page_output->header(array('title' => $title)); /* Output page */ echo $menu_output . $view->render('config');
/** * Build variables needed to output the html. Extracted to this method so * child classes can use this as well. */ protected function _prepare() { global $conf; $this->_page = isset($this->_params['page']) ? $this->_params['page'] : 0; $this->_slug = $this->gallery->get('slug'); $this->_date = $this->gallery->getDate(); $this->_style = empty($this->_params['style']) ? $this->gallery->getStyle() : Ansel::getStyleDefinition($this->_params['style']); // Make sure the screen view is loaded and get the geometry try { $this->_geometry = $this->resource->getDimensions('screen'); } catch (Ansel_Exception $e) { Horde::log($e, 'ERR'); $this->_geometry = $GLOBALS['conf']['screen']; } // Get the image lists $this->_imageList = $this->gallery->listImages(); $this->_revList = array_flip($this->_imageList); // Not needed when being called via api if (empty($this->_params['api'])) { // Build the various urls $imageActionUrl = Horde::url('image.php')->add(array_merge(array('gallery' => $this->gallery->id, 'image' => $this->resource->id, 'page' => $this->_page), $this->_date)); if ($this->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { $this->_urls['prop_popup'] = Horde::popupJs($imageActionUrl, array('urlencode' => true, 'height' => 360, 'width' => 500, 'params' => array('actionID' => 'modify', 'ret' => 'image', 'gallery' => $this->gallery->id, 'image' => $this->resource->id, 'page' => $this->_page))); $this->_urls['edit'] = $imageActionUrl->copy()->add('actionID', 'editimage'); } if ($this->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE)) { $this->_urls['delete'] = $imageActionUrl->copy()->add('actionID', 'delete'); } if (!empty($conf['ecard']['enable'])) { $this->_urls['ecard'] = Horde::url('img/ecard.php')->add(array_merge(array('gallery' => $this->gallery->id, 'image' => $this->resource->id), $this->_date)); } if ($this->gallery->canDownload()) { $this->_urls['download'] = Horde::url('img/download.php', true)->add('image', $this->resource->id); } if ((!$GLOBALS['registry']->getAuth() || $this->gallery->get('owner') != $GLOBALS['registry']->getAuth()) && !empty($GLOBALS['conf']['report_content']['driver']) && ($conf['report_content']['allow'] == 'authenticated' && $GLOBALS['registry']->isAuthenticated() || $conf['report_content']['allow'] == 'all')) { $this->_urls['report'] = Horde::url('report.php')->add(array('gallery' => $this->gallery->id, 'image' => $this->resource->id)); } } // Check for an explicit gallery view url to use if (!empty($this->_params['gallery_view_url'])) { $this->_urls['gallery'] = new Horde_Url(str_replace(array('%g', '%s'), array($this->gallery->id, $this->_slug), urldecode($this->_params['gallery_view_url']))); $this->_urls['gallery']->add($this->_date); } else { $this->_urls['gallery'] = Ansel::getUrlFor('view', array_merge(array('gallery' => $this->gallery->id, 'slug' => $this->_slug, 'page' => $this->_page, 'view' => 'Gallery'), $this->_date), true); } // Get the image src url $this->_urls['imgsrc'] = Ansel::getImageUrl($this->resource->id, 'screen', true, $this->_style); // A self url. Can't use Horde::selfUrl() since that would ignore // pretty urls. $this->_urls['self'] = Ansel::getUrlFor('view', array_merge(array('gallery' => $this->gallery->id, 'slug' => $this->_slug, 'image' => $this->resource->id, 'view' => 'Image', 'page' => $this->_page), $this->_date)); }
function _renderVarInput_obrowser($form, $var, $vars) { $varname = $var->getVarName(); $varvalue = $vars->get($varname); $fieldId = 'obrowser_' . uniqid(mt_rand()); $html = ' <script type="text/javascript"> var obrowserWindowName; function obrowserCallback(name, oid) { if (name == obrowserWindowName) { document.getElementById(\'' . $fieldId . '\').value = oid; return false; } else { return "Invalid window name supplied"; } } </script> '; $html .= sprintf('<input type="hidden" name="%s" id="%s"%s value="%s" />', $varname, $fieldId, $this->_getActionScripts($form, $var), $varvalue); if (!empty($varvalue)) { $html .= $varvalue; } if ($GLOBALS['browser']->hasFeature('javascript')) { $imgId = $varname . 'goto'; $html .= '<div id="goto" class="headerbox" style="position:absolute;visibility:hidden;padding:0"></div>'; $html .= Horde::link('#', Horde_Model_Translation::t("Select an object"), '', '', 'obrowserWindow = ' . Horde::popupJs($GLOBALS['registry']->get('webroot', 'horde') . '/services/obrowser/') . 'obrowserWindowName = obrowserWindow.name; return false;') . Horde::img('tree/leaf.png', Horde_Model_Translation::t("Object"), 'id="' . $imgId . '" align="middle"') . "</a>\n"; } return $html; }
/** * @throws IMP_Exception */ protected function _init() { global $injector, $notification, $page_output; if (!$this->indices) { throw new IMP_Exception(_("No message index given.")); } $page_output->addScriptFile('message.js'); $page_output->addScriptFile('external/CustomElements.js'); $page_output->addScriptFile('external/time-elements.js'); $page_output->addScriptFile('textarearesize.js', 'horde'); $page_output->addScriptFile('toggle_quotes.js', 'horde'); $page_output->addScriptPackage('IMP_Script_Package_Imp'); $page_output->addThemeStylesheet('message.css'); $page_output->addThemeStylesheet('message_view.css'); $js_vars = array(); switch ($this->vars->actionID) { case 'strip_attachment': try { $this->indices = new IMP_Indices_Mailbox($this->indices->mailbox, $this->indices->stripPart($this->vars->id)); $js_vars['-ImpMessage.strip'] = 1; $notification->push(_("Attachment successfully stripped."), 'horde.success'); } catch (IMP_Exception $e) { $notification->push($e); } break; } try { $show_msg = new IMP_Contents_Message($this->indices); $msg_res = $show_msg->showMessage(); } catch (IMP_Exception $e) { $notification->notify(array('listeners' => array('status', 'audio'))); echo Horde::wrapInlineScript(array('parent.close()')); exit; } /* Add 'maillog' and 'poll' data to the AJAX queue. */ $ajax_queue = $injector->getInstance('IMP_Ajax_Queue'); $ajax_queue->maillog($this->indices); $ajax_queue->poll($this->indices->mailbox); list(, $buid) = $this->indices->buids->getSingle(); /* Need to be dynamically added, since formatting needs to be applied * via javascript. */ foreach (array('from', 'to', 'cc', 'bcc') as $val) { if ($tmp = $show_msg->getAddressHeader($val)) { $js_vars['ImpMessage.' . $val] = $tmp; } } if ($resent = $show_msg->getResentData()) { $resent_js = array(); foreach ($resent as $val) { $resent_js[] = array('date' => $val['date']->format($val['date']::DATE_LOCAL), 'from' => $show_msg->getAddressHeader($val['from'])); } $js_vars['ImpMessage.resent'] = $resent_js; } if (isset($msg_res['log'])) { $js_vars['ImpMessage.log'] = $msg_res['log']; } $list_info = $show_msg->contents->getListInformation(); if (!empty($list_info['exists'])) { $js_vars['ImpMessage.reply_list'] = true; $this->view->listinfo = Horde::popupJs(IMP_Basic_Listinfo::url(array('buid' => $buid, 'mailbox' => $this->indices->mailbox)), array('urlencode' => true)); } $js_vars['ImpMessage.buid'] = $buid; $js_vars['ImpMessage.mbox'] = $this->indices->mailbox->form_to; if (isset($msg_res['atc'])) { $js_vars['ImpMessage.msg_atc'] = $msg_res['atc']; $this->js_text['atc_downloadall'] = _("Download All (%s)"); } if (isset($msg_res['md'])) { $js_vars['ImpMessage.msg_md'] = $msg_res['md']; } $js_vars['ImpMessage.tasks'] = $injector->getInstance('Horde_Core_Factory_Ajax')->create('imp', $this->vars)->getTasks(); $page_output->addInlineJsVars($js_vars); if (isset($msg_res['js'])) { $page_output->addInlineScript(array_filter($msg_res['js']), true); } $this->_pages[] = 'message'; $subject = $show_msg->getSubject(); $this->view->subject = isset($subject['subjectlink']) ? $subject['subjectlink'] : $subject['subject']; $this->title = $subject['title']; /* Determine if compose mode is disabled. */ if (IMP_Compose::canCompose()) { $this->view->qreply = $injector->getInstance('IMP_Dynamic_Compose_Common')->compose($this, array('title' => _("Message") . ': ' . $subject['subject'])); $this->_pages[] = 'qreply'; $this->js_conf['qreply'] = 1; } $page_output->noDnsPrefetch(); $this->view->show_delete = $this->indices->mailbox->access_deletemsgs; list($real_mbox, ) = $this->indices->getSingle(); $this->view->show_innocent = $real_mbox->innocent_show; $this->view->show_spam = $real_mbox->spam_show; $this->view->show_view_all = empty($msg_res['onepart']); $this->view->show_view_source = $injector->getInstance('Horde_Core_Perms')->hasAppPermission('view_msg_source'); $this->view->save_as = $show_msg->getSaveAs(); if ($date = $show_msg->getDateOb()) { $this->view->datestamp = $date->format($date::DATE_ISO_8601); $this->view->fulldate = $date->format($date::DATE_FORCE); $this->view->localdate = $date->format($date::DATE_LOCAL); $this->view->addHelper('Text'); } if ($this->view->user_hdrs = $show_msg->getUserHeaders()) { $this->view->addHelper('Text'); } $this->view->msgtext = $msg_res['msgtext']; Horde::startBuffer(); $notification->notify(array('listeners' => array('status', 'audio'))); $this->view->status = Horde::endBuffer(); $this->view->title = $this->title; }
/** */ protected function _init() { global $conf, $injector, $notification, $page_output, $prefs, $registry, $session; $mailbox = $this->indices->mailbox; $imp_imap = $mailbox->imp_imap; /* We know we are going to be exclusively dealing with this mailbox, * so select it on the IMAP server (saves some STATUS calls). Open R/W * to clear the RECENT flag. */ $imp_imap->openMailbox($mailbox, Horde_Imap_Client::OPEN_READWRITE); /* Make sure we have a valid index. */ $imp_mailbox = $mailbox->list_ob; $imp_mailbox->setIndex($this->indices); if (!$imp_mailbox->isValidIndex()) { $this->_returnToMailbox(null, 'message_missing'); return; } $imp_flags = $injector->getInstance('IMP_Flags'); $imp_identity = $injector->getInstance('IMP_Identity'); $imp_message = $injector->getInstance('IMP_Message'); $imp_ui = $injector->getInstance('IMP_Message_Ui'); /* Run through action handlers. */ if ($this->vars->actionID) { try { $session->getToken($this->vars->token); } catch (Horde_Exception $e) { $notification->push($e); $this->vars->actionID = null; } } $readonly = $mailbox->readonly; $peek = false; switch ($this->vars->actionID) { case 'blacklist': case 'whitelist': if ($this->vars->actionID == 'blacklist') { $injector->getInstance('IMP_Filter')->blacklistMessage($this->indices); } else { $injector->getInstance('IMP_Filter')->whitelistMessage($this->indices); } break; case 'delete_message': $imp_message->delete($this->indices, array('mailboxob' => $imp_mailbox)); if ($prefs->getValue('mailbox_return')) { $this->_returnToMailbox($imp_mailbox->getIndex()); return; } if ($imp_ui->moveAfterAction($mailbox)) { $imp_mailbox->setIndex(1); } break; case 'undelete_message': $imp_message->undelete($this->indices); break; case 'move_message': case 'copy_message': if (isset($this->vars->targetMbox) && (!$readonly || $this->vars->actionID == 'copy_message')) { if ($this->vars->newMbox) { $targetMbox = IMP_Mailbox::prefFrom($this->vars->targetMbox); $newMbox = true; } else { $targetMbox = IMP_Mailbox::formFrom($this->vars->targetMbox); $newMbox = false; } $imp_message->copy($targetMbox, $this->vars->actionID == 'move_message' ? 'move' : 'copy', $this->indices, array('create' => $newMbox, 'mailboxob' => $imp_mailbox)); if ($prefs->getValue('mailbox_return')) { $this->_returnToMailbox($imp_mailbox->getIndex()); return; } } break; case 'innocent_report': case 'spam_report': $res = $injector->getInstance('IMP_Factory_Spam')->create($this->vars->actionID == 'spam_report' ? IMP_Spam::SPAM : IMP_Spam::INNOCENT)->report($this->indices, array('mailbox' => $imp_mailbox)); switch ($res) { case 1: if ($imp_ui->moveAfterAction($mailbox)) { $imp_mailbox->setIndex(1); } break; } if ($prefs->getValue('mailbox_return')) { $this->_returnToMailbox($imp_mailbox->getIndex()); return; } break; case 'flag_message': if (!$readonly && isset($this->vars->flag) && count($this->indices)) { $peek = true; $flag = $imp_flags->parseFormId($this->vars->flag); $imp_message->flag(array($flag['set'] ? 'add' : 'remove' => array($flag['flag'])), $this->indices); if ($prefs->getValue('mailbox_return')) { $this->_returnToMailbox($imp_mailbox->getIndex()); return; } } break; case 'add_address': try { $contact_link = $injector->getInstance('IMP_Contacts')->addAddress($this->vars->address, $this->vars->name); $notification->push(sprintf(_("Entry \"%s\" was successfully added to the address book"), $contact_link), 'horde.success', array('content.raw')); } catch (Horde_Exception $e) { $notification->push($e); } break; case 'strip_all': case 'strip_attachment': if (!$readonly) { try { $this->indices = new IMP_Indices_Mailbox($this->indices->mailbox, $imp_message->stripPart($this->indices, $this->vars->actionID == 'strip_all' ? null : $this->vars->imapid, array('mailboxob' => $imp_mailbox))); $notification->push(_("Attachment successfully stripped."), 'horde.success'); } catch (Horde_Exception $e) { $notification->push($e); } } break; } /* We may have done processing that has taken us past the end of the * message array, so we will return to the mailbox. */ if (!$imp_mailbox->isValidIndex()) { $this->_returnToMailbox(count($imp_mailbox)); return; } /* Now that we are done processing, get the index and array index of * the current message. */ $msg_index = $imp_mailbox[$imp_mailbox->getIndex()]; /* Parse the message. */ try { $imp_contents = $injector->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($imp_mailbox)); } catch (IMP_Exception $e) { $imp_mailbox->removeMsgs(true); $this->_returnToMailbox(null, 'message_missing'); return; } /* Get envelope/flag/header information. */ try { /* Need to fetch flags before HEADERTEXT, because SEEN flag might * be set before we can grab it. */ $query = new Horde_Imap_Client_Fetch_Query(); $query->flags(); $flags_ret = $imp_imap->fetch($msg_index['m'], $query, array('ids' => $imp_imap->getIdsOb($msg_index['u']))); $query = new Horde_Imap_Client_Fetch_Query(); $query->envelope(); $fetch_ret = $imp_imap->fetch($msg_index['m'], $query, array('ids' => $imp_imap->getIdsOb($msg_index['u']))); } catch (IMP_Imap_Exception $e) { $this->_returnToMailbox(null, 'message_missing'); return; } $envelope = $fetch_ret->first()->getEnvelope(); $flags = $flags_ret->first()->getFlags(); $mime_headers = $peek ? $imp_contents->getHeader() : $imp_contents->getHeaderAndMarkAsSeen(); /* Get the title/mailbox label of the mailbox page. */ $page_label = $mailbox->label; /* Generate the link to ourselves. */ $buid = $imp_mailbox->getBuid($msg_index['m'], $msg_index['u']); $msgindex = $imp_mailbox->getIndex(); $message_url = Horde::url('basic.php')->add('page', 'message'); $token = $session->getToken(); $self_link = self::url(array('buid' => $buid, 'mailbox' => $mailbox))->add(array('token' => $token, 'start' => $msgindex)); /* Develop the list of headers to display. */ $basic_headers = $imp_ui->basicHeaders(); $display_headers = $msgAddresses = array(); $date_ob = new IMP_Message_Date($envelope->date); if ($format_date = $date_ob->format($date_ob::DATE_LOCAL)) { $display_headers['date'] = $format_date; } /* Build From address links. */ $display_headers['from'] = $imp_ui->buildAddressLinks($envelope->from, $self_link); /* Add country/flag image. */ if (!empty($envelope->from)) { $contacts_img = new IMP_Contacts_Image($envelope->from[0]); try { $res = $contacts_img->getImage($contacts_img::FLAG); $display_headers['from'] .= ' ' . Horde_Themes_Image::tag($res['url'], array('alt' => $res['desc'], 'fullsrc' => true)); } catch (IMP_Exception $e) { } } /* Look for Face information. */ if ($face = $mime_headers->getValue('face')) { $display_headers['from'] .= ' <img src="' . Horde_Url_Data::create('image/png', base64_decode($face)) . '">'; } /* Build To/Cc/Bcc links. */ foreach (array('to', 'cc', 'bcc') as $val) { $msgAddresses[] = $mime_headers->getValue($val); if ($val == 'to' || count($envelope->{$val})) { $display_headers[$val] = $imp_ui->buildAddressLinks($envelope->{$val}, $self_link); } } /* Process the subject now. */ if ($subject = $mime_headers->getValue('subject')) { $this->title = sprintf(_("%s: %s"), $page_label, $subject); $shortsub = Horde_String::truncate($subject, 100); } else { $shortsub = _("[No Subject]"); $this->title = sprintf(_("%s: %s"), $page_label, $shortsub); } /* See if the priority has been set. */ switch ($injector->getInstance('IMP_Mime_Headers')->getPriority($mime_headers)) { case 'high': $basic_headers['priority'] = _("Priority"); $display_headers['priority'] = '<div class="iconImg msgflags flagHighpriority" title="' . htmlspecialchars(_("High Priority")) . '"></div> ' . _("High"); break; case 'low': $basic_headers['priority'] = _("Priority"); $display_headers['priority'] = '<div class="iconImg msgflags flagLowpriority" title="' . htmlspecialchars(_("Low Priority")) . '"></div> ' . _("Low"); break; } /* Build Reply-To address link. */ if (!empty($envelope->reply_to) && $envelope->from[0]->bare_address != $envelope->reply_to[0]->bare_address && ($reply_to = $imp_ui->buildAddressLinks($envelope->reply_to, $self_link))) { $display_headers['reply-to'] = $reply_to; } /* Determine if all/list/user-requested headers needed. */ $all_headers = $this->vars->show_all_headers; $user_hdrs = $imp_ui->getUserHeaders(); /* Check for the presence of mailing list information. */ $list_info = $imp_ui->getListInformation($mime_headers); /* Display all headers or, optionally, the user-specified headers for * the current identity. */ $full_headers = array(); if ($all_headers) { $header_array = $mime_headers->toArray(); foreach ($header_array as $head => $val) { $lc_head = strtolower($head); /* Skip the header if we have already dealt with it. */ if (!isset($display_headers[$lc_head]) && (!in_array($lc_head, array('importance', 'x-priority')) || !isset($display_headers['priority']))) { $full_headers[$lc_head] = $val; } } } elseif (!empty($user_hdrs)) { foreach ($user_hdrs as $user_hdr) { $user_val = $mime_headers->getValue($user_hdr); if (!empty($user_val)) { $full_headers[$user_hdr] = $user_val; } } } ksort($full_headers); /* For the self URL link, we can't trust the index in the query string * as it may have changed if we deleted/copied/moved messages. We may * need other stuff in the query string, so we need to do an * add/remove of uid info. */ $selfURL = $mailbox->url(Horde::selfUrlParams()->remove(array('actionID')), $buid)->add('token', $token); $headersURL = $selfURL->copy()->remove(array('show_all_headers')); /* Generate previous/next links. */ $prev_msg = $imp_mailbox[$imp_mailbox->getIndex() - 1]; if ($prev_msg) { $prev_url = self::url(array('buid' => $imp_mailbox->getBuid($prev_msg['m'], $prev_msg['u']), 'mailbox' => $mailbox))->setRaw(true); $page_output->addLinkTag(array('href' => $prev_url, 'id' => 'prev', 'rel' => 'Previous', 'type' => null)); } else { $prev_url = null; } $next_msg = $imp_mailbox[$imp_mailbox->getIndex() + 1]; if ($next_msg) { $next_url = self::url(array('buid' => $imp_mailbox->getBuid($next_msg['m'], $next_msg['u']), 'mailbox' => $mailbox))->setRaw(true); $page_output->addLinkTag(array('href' => $next_url, 'id' => 'next', 'rel' => 'Next', 'type' => null)); } else { $next_url = null; } /* Generate the mailbox link. */ $mailbox_url = $mailbox->url('mailbox')->add('start', $msgindex); /* Everything below here is related to preparing the output. */ $js_vars = array('ImpMessage.text' => array('innocent_report' => _("Are you sure you wish to report this message as innocent?"), 'moveconfirm' => _("Are you sure you want to move the message(s)? (Some message information might get lost, like message headers, text formatting or attachments!)"), 'newmbox' => _("You are copying/moving to a new mailbox.") . "\n" . _("Please enter a name for the new mailbox:") . "\n", 'spam_report' => _("Are you sure you wish to report this message as spam?"), 'target_mbox' => _("You must select a target mailbox first."))); /* Set the status information of the message. */ $msgAddresses[] = $mime_headers->getValue('from'); $identity = $match_identity = $imp_identity->getMatchingIdentity($msgAddresses); if (is_null($identity)) { $identity = $imp_identity->getDefault(); } $flag_parse = $imp_flags->parse(array('flags' => $flags, 'personal' => $match_identity)); $status = ''; foreach ($flag_parse as $val) { if ($val instanceof IMP_Flag_User) { $status .= '<span class="' . $val->css . '" style="' . ($val->bgdefault ? '' : 'background:' . htmlspecialchars($val->bgcolor) . ';') . 'color:' . htmlspecialchars($val->fgcolor) . '">' . htmlspecialchars($val->label) . '</span>'; } else { $status .= $val->span; } } /* If this is a search mailbox, display a link to the parent mailbox * of the message in the header. */ $h_page_label = htmlspecialchars($page_label); $header_label = $h_page_label; if ($mailbox->search) { $header_label .= ' [' . $msg_index['m']->url('mailbox')->link() . $msg_index['m']->display_html . '</a>]'; } /* Prepare the navbar top template. */ $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/basic/message')); $view->addHelper('FormTag'); $view->addHelper('Tag'); $t_view = clone $view; $t_view->buid = $buid; $t_view->message_url = $message_url; $t_view->mailbox = $mailbox->form_to; $t_view->start = $msgindex; $t_view->token = $token; /* Prepare the navbar navigate template. */ $n_view = clone $view; $n_view->readonly = $readonly; $n_view->id = 1; if ($mailbox->access_flags) { $n_view->mailbox = $mailbox->form_to; $args = array('imap' => true, 'mailbox' => $mailbox); $form_set = $form_unset = array(); foreach ($imp_flags->getList($args) as $val) { if ($val->canset) { $form_set[] = array('f' => $val->form_set, 'l' => $val->label); $form_unset[] = array('f' => $val->form_unset, 'l' => $val->label); } } $n_view->flaglist_set = $form_set; $n_view->flaglist_unset = $form_unset; } if ($imp_imap->access(IMP_Imap::ACCESS_FOLDERS)) { $n_view->move = Horde::widget(array('url' => '#', 'class' => 'moveAction', 'title' => _("Move"), 'nocheck' => true)); $n_view->copy = Horde::widget(array('url' => '#', 'class' => 'copyAction', 'title' => _("Copy"), 'nocheck' => true)); $iterator = new IMP_Ftree_IteratorFilter($injector->getInstance('IMP_Ftree')); $iterator->add($iterator::NONIMAP); $n_view->options = new IMP_Ftree_Select(array('heading' => _("This message to"), 'inc_tasklists' => true, 'inc_notepads' => true, 'iterator' => $iterator, 'new_mbox' => true)); } $n_view->back_to = Horde::widget(array('url' => $mailbox_url, 'title' => sprintf(_("Bac_k to %s"), $h_page_label), 'nocheck' => true)); if ($prev_url) { $n_view->prev = Horde::link($prev_url, _("Previous Message")); $n_view->prev_img = 'navleftImg'; } else { $n_view->prev_img = 'navleftgreyImg'; } if ($next_url) { $n_view->next = Horde::link($next_url, _("Next Message")); $n_view->next_img = 'navrightImg'; } else { $n_view->next_img = 'navrightgreyImg'; } /* Prepare the navbar actions template. */ $a_view = clone $view; $compose_params = array('buid' => $buid, 'identity' => $identity, 'mailbox' => IMP_Mailbox::formTo($mailbox)); if (!$prefs->getValue('compose_popup')) { $compose_params['start'] = $msgindex; } if ($msg_index['m']->access_deletemsgs) { if (in_array(Horde_Imap_Client::FLAG_DELETED, $flags)) { $a_view->delete = Horde::widget(array('url' => $self_link->copy()->add('actionID', 'undelete_message'), 'title' => _("Undelete"), 'nocheck' => true)); } else { $a_view->delete = Horde::widget(array('url' => $self_link->copy()->add('actionID', 'delete_message'), 'title' => _("_Delete"), 'nocheck' => true)); if (!$msg_index['m']->is_imap) { $js_vars['ImpMessage.pop3delete'] = _("Are you sure you want to PERMANENTLY delete these messages?"); } } } $disable_compose = !IMP_Compose::canCompose(); if (!$disable_compose) { $clink_ob = new IMP_Compose_Link(); $clink = $clink_ob->link()->add($compose_params); $a_view->reply = Horde::widget(array('url' => $clink->add(array('actionID' => 'reply_auto')), 'class' => 'horde-hasmenu', 'title' => _("_Reply"), 'nocheck' => true)); $a_view->reply_sender = Horde::widget(array('url' => $clink->add(array('actionID' => 'reply')), 'title' => _("To Sender"), 'nocheck' => true)); if ($list_info['reply_list']) { $a_view->reply_list = Horde::widget(array('url' => $clink->add(array('actionID' => 'reply_list')), 'title' => _("To _List"), 'nocheck' => true)); } $addr_ob = clone $envelope->to; $addr_ob->add($envelope->cc); $addr_ob->setIteratorFilter(0, $imp_identity->getAllFromAddresses()); if (count($addr_ob)) { $a_view->show_reply_all = Horde::widget(array('url' => $clink->add(array('actionID' => 'reply_all')), 'title' => _("To _All"), 'nocheck' => true)); } $fwd_locked = $prefs->isLocked('forward_default'); $a_view->forward = Horde::widget(array('url' => $clink->add(array('actionID' => 'forward_auto')), 'class' => $fwd_locked ? '' : ' horde-hasmenu', 'title' => _("Fo_rward"), 'nocheck' => true)); if (!$fwd_locked) { $a_view->forward_attach = Horde::widget(array('url' => $clink->add(array('actionID' => 'forward_attach')), 'title' => _("As Attachment"), 'nocheck' => true)); $a_view->forward_body = Horde::widget(array('url' => $clink->add(array('actionID' => 'forward_body')), 'title' => _("In Body Text"), 'nocheck' => true)); $a_view->forward_both = Horde::widget(array('url' => $clink->add(array('actionID' => 'forward_both')), 'title' => _("Attachment and Body Text"), 'nocheck' => true)); } $a_view->redirect = Horde::widget(array('url' => $clink->add(array('actionID' => 'redirect_compose')), 'title' => _("Redirec_t"), 'nocheck' => true)); $a_view->editasnew = Horde::widget(array('url' => $clink->add(array('actionID' => 'editasnew')), 'title' => _("Edit as New"), 'nocheck' => true)); } if ($mailbox->access_sortthread) { $a_view->show_thread = Horde::widget(array('url' => $mailbox->url(IMP_Basic_Thread::url(), $buid)->add(array('start' => $msgindex)), 'title' => _("_View Thread"), 'nocheck' => true)); } if (!$readonly && $registry->hasMethod('mail/blacklistFrom')) { $a_view->blacklist = Horde::widget(array('url' => $self_link->copy()->add('actionID', 'blacklist'), 'title' => _("_Blacklist"), 'nocheck' => true)); } if (!$readonly && $registry->hasMethod('mail/whitelistFrom')) { $a_view->whitelist = Horde::widget(array('url' => $self_link->copy()->add('actionID', 'whitelist'), 'title' => _("_Whitelist"), 'nocheck' => true)); } if (!empty($conf['user']['allow_view_source'])) { $a_view->view_source = $imp_contents->linkViewJS($imp_contents->getMIMEMessage(), 'view_source', _("_Message Source"), array('css' => '', 'jstext' => _("Message Source"), 'widget' => true)); } if (!$disable_compose && (in_array(Horde_Imap_Client::FLAG_DRAFT, $flags) || $msg_index['m']->drafts)) { $a_view->resume = Horde::widget(array('url' => $clink->add(array('actionID' => 'draft')), 'title' => _("Resume"), 'nocheck' => true)); } $imp_params = $mailbox->urlParams($buid); $a_view->save_as = Horde::widget(array('url' => IMP_Contents_View::downloadUrl($subject, array_merge(array('actionID' => 'save_message'), $imp_params)), 'title' => _("Sa_ve as"), 'nocheck' => true)); if ($msg_index['m']->spam_show) { $a_view->spam = Horde::widget(array('url' => '#', 'class' => 'spamAction', 'title' => _("Report as Spam"), 'nocheck' => true)); } if ($msg_index['m']->innocent_show) { $a_view->innocent = Horde::widget(array('url' => '#', 'class' => 'innocentAction', 'title' => _("Report as Innocent"), 'nocheck' => true)); } if (!$disable_compose) { $a_view->redirect = Horde::widget(array('url' => $clink->add(array('actionID' => 'redirect_compose')), 'title' => _("Redirec_t"), 'nocheck' => true)); } $a_view->headers = Horde::widget(array('url' => '#', 'class' => 'horde-hasmenu', 'title' => _("Headers"), 'nocheck' => true)); if ($all_headers) { $a_view->common_headers = Horde::widget(array('url' => $headersURL, 'title' => _("Show Common Headers"), 'nocheck' => true)); } if (!$all_headers) { $a_view->all_headers = Horde::widget(array('url' => $headersURL->copy()->add('show_all_headers', 1), 'title' => _("Show All Headers"), 'nocheck' => true)); } if ($list_info['exists']) { $a_view->list_headers = Horde::widget(array('onclick' => Horde::popupJs(IMP_Basic_Listinfo::url(array('buid' => $buid, 'mailbox' => $mailbox)), array('urlencode' => true)), 'title' => _("Show Mailing List Information"), 'nocheck' => true)); } $hdrs = array(); /* Prepare the main message template. */ if (!$all_headers) { foreach ($display_headers as $head => $val) { $hdrs[] = array('name' => $basic_headers[$head], 'val' => $val); } } foreach ($full_headers as $head => $val) { if (is_array($val)) { $hdrs[] = array('name' => $head, 'val' => '<ul style="margin:0;padding-left:15px"><li>' . implode("</li>\n<li>", array_map('htmlspecialchars', $val)) . '</li></ul>'); } else { $hdrs[] = array('name' => $head, 'val' => htmlspecialchars($val)); } } /* Determine the fields that will appear in the MIME info entries. */ $part_info = $part_info_display = array('icon', 'description', 'size'); $part_info_action = array('download', 'download_zip', 'img_save', 'strip'); $part_info_bodyonly = array('print'); $show_parts = isset($this->vars->show_parts) ? $this->vars->show_parts : $prefs->getValue('parts_display'); $part_info_display = array_merge($part_info_display, $part_info_action, $part_info_bodyonly); $contents_mask = IMP_Contents::SUMMARY_BYTES | IMP_Contents::SUMMARY_SIZE | IMP_Contents::SUMMARY_ICON | IMP_Contents::SUMMARY_DESCRIP_LINK | IMP_Contents::SUMMARY_DOWNLOAD | IMP_Contents::SUMMARY_DOWNLOAD_ZIP | IMP_Contents::SUMMARY_IMAGE_SAVE | IMP_Contents::SUMMARY_PRINT; /* Do MDN processing now. */ $mdntext = $imp_ui->MDNCheck(new IMP_Indices($msg_index['m'], $buid), $mime_headers, $this->vars->mdn_confirm) ? strval(new IMP_Mime_Status(array(_("The sender of this message is requesting a notification from you when you have read this message."), sprintf(_("Click %s to send the notification message."), Horde::link($selfURL->copy()->add('mdn_confirm', 1)) . _("HERE") . '</a>')))) : ''; /* Build body text. This needs to be done before we build the * attachment list that lives in the header. */ $inlineout = $imp_contents->getInlineOutput(array('mask' => $contents_mask, 'part_info_display' => $part_info_display, 'show_parts' => $show_parts)); /* Build the Attachments menu. */ $show_atc = false; switch ($show_parts) { case 'atc': $a_view->show_parts_all = Horde::widget(array('url' => $headersURL->copy()->add(array('show_parts' => 'all')), 'title' => _("Show All Parts"), 'nocheck' => true)); $show_atc = true; break; case 'all': if ($prefs->getValue('strip_attachments')) { $js_vars['ImpMessage.text']['stripwarn'] = _("Are you sure you wish to PERMANENTLY delete this attachment?"); } break; } if (count($inlineout['atc_parts']) > 2) { $a_view->download_all = Horde::widget(array('url' => $imp_contents->urlView($imp_contents->getMIMEMessage(), 'download_all'), 'title' => _("Download All Attachments (in .zip file)"), 'nocheck' => true)); if ($prefs->getValue('strip_attachments')) { $a_view->strip_all = Horde::widget(array('url' => Horde::selfUrlParams()->add(array('actionID' => 'strip_all', 'token' => $token)), 'class' => 'stripAllAtc', 'title' => _("Strip All Attachments"), 'nocheck' => true)); $js_vars['ImpMessage.text']['stripallwarn'] = _("Are you sure you want to PERMANENTLY delete all attachments?"); } $show_atc = true; } if ($show_atc) { $a_view->atc = Horde::widget(array('url' => '#', 'class' => 'horde-hasmenu', 'title' => _("Attachments"), 'nocheck' => true)); } /* Show attachment information in headers? 'atc_parts' will be empty if * 'parts_display' pref is 'none'. */ if (!empty($inlineout['atc_parts'])) { if ($show_parts == 'all') { $val = $imp_contents->getTree()->getTree(true); } else { $tmp = array(); foreach ($inlineout['atc_parts'] as $id) { $summary = $imp_contents->getSummary($id, $contents_mask); $tmp[] = '<tr>'; foreach ($part_info as $val) { $tmp[] = '<td>' . $summary[$val] . '</td>'; } $tmp[] = '<td>'; foreach ($part_info_action as $val) { $tmp[] = $summary[$val]; } $tmp[] = '</td></tr>'; } $val = '<table>' . implode('', $tmp) . '</table>'; } $hdrs[] = array('class' => 'msgheaderParts', 'name' => $show_parts == 'all' ? _("Parts") : _("Attachments"), 'val' => $val); } $m_view = clone $view; $m_view->label = $shortsub; $m_view->headers = $hdrs; $m_view->msgtext = $mdntext . $inlineout['msgtext']; $subinfo = new IMP_View_Subinfo(array('mailbox' => $mailbox)); $subinfo->label = $header_label; $subinfo->value = sprintf(_("(%d of %d)"), $msgindex, count($imp_mailbox)) . $status; $injector->getInstance('Horde_View_Topbar')->subinfo = $subinfo->render(); /* Output message page now. */ $page_output->addInlineJsVars($js_vars, array('top' => true)); $page_output->addScriptFile('scriptaculous/effects.js', 'horde'); $page_output->addScriptFile('hordecore.js', 'horde'); $page_output->addScriptFile('message.js'); $page_output->addScriptFile('stripe.js', 'horde'); $page_output->addScriptPackage('IMP_Script_Package_Imp'); if (!empty($conf['tasklist']['use_notepad']) || !empty($conf['tasklist']['use_tasklist'])) { $page_output->addScriptPackage('Horde_Core_Script_Package_Dialog'); } $page_output->noDnsPrefetch(); Horde::startBuffer(); foreach ($injector->getInstance('IMP_Maillog')->getLog(new IMP_Maillog_Message($this->indices, array('mdn'))) as $val) { $notification->push($val->message, 'imp.' . $val->action); } $this->output = Horde::endBuffer(); $this->output .= $t_view->render('navbar_top') . $n_view->render('navbar_navigate') . $a_view->render('navbar_actions') . $m_view->render('message') . $a_view->render('navbar_actions'); $n_view->id = 2; $n_view->isbottom = true; $this->output .= $n_view->render('navbar_navigate'); }
} else { $item['link'] = $item['name'] . ' -> ' . $val['link']; } break; default: $mime_type = Horde_Mime_Magic::extToMime($val['type']); // Edit link if possible. if (strpos($mime_type, 'text/') === 0) { $url = $edit_url->copy()->add(array('actionID' => 'edit_file', 'type' => $val['type'], 'file' => $val['name'], 'dir' => Gollem::$backend['dir'], 'driver' => Gollem::$backend['driver'])); $item['edit'] = Horde::link('#', '', '', '_blank', Horde::popupJs($url)); } // We can always download files. $item['dl'] = $registry->downloadUrl($val['name'], array('dir' => Gollem::$backend['dir'], 'backend' => $GLOBALS['session']->get('gollem', 'backend_key')))->link(array('title' => sprintf(_("Download %s"), $val['name']))); // Try a view link. $url = $view_url->copy()->add(array('type' => $val['type'], 'file' => $val['name'], 'dir' => Gollem::$backend['dir'], 'driver' => Gollem::$backend['driver'])); $item['link'] = Horde::link('#', '', '', '_blank', Horde::popupJs($url)) . $name . '</a>'; break; } $entry[] = $item; } /* Set up the variables needed for the header row. */ $sortby = $prefs->getValue('sortby'); $sortdir = $prefs->getValue('sortdir'); if ($total) { // Set start/end items (according to current page) $start = $page * $perpage + 1; $end = min($total, $start + $perpage - 1); $vars->set('page', $page); $pager = new Horde_Core_Ui_Pager('page', $vars, array('num' => $total, 'url' => $refresh_url, 'page_count' => 10, 'perpage' => $perpage)); $page_caption = $pager->render(); }
protected function _renderVarInput_obrowser($form, &$var, &$vars) { $varname = $var->getVarName(); $varvalue = $vars->get($varname); $fieldId = $this->_genID(uniqid(mt_rand()), false) . 'id'; $html = ' <script type="text/javascript"> var obrowserWindowName; function obrowserCallback(name, oid) { if (name == obrowserWindowName) { document.getElementById(\'' . $fieldId . '\').value = oid; return false; } else { return "Invalid window name supplied"; } } </script> '; $html .= sprintf('<input type="hidden" name="%s" id="%s"%s value="%s">', htmlspecialchars($varname), $fieldId, $this->_getActionScripts($form, $var), htmlspecialchars($varvalue)); if (!empty($varvalue)) { $html .= $varvalue; } if ($GLOBALS['browser']->hasFeature('javascript')) { $html .= Horde::link($GLOBALS['registry']->get('webroot', 'horde') . '/services/obrowser/', Horde_Core_Translation::t("Select an object"), '', '_blank', 'obrowserWindow = ' . Horde::popupJs($GLOBALS['registry']->get('webroot', 'horde') . '/services/obrowser/', array('urlencode' => true)) . 'obrowserWindowName = obrowserWindow.name; return false;') . Horde::img('tree/leaf.png', Horde_Core_Translation::t("Object")) . "</a>\n"; } return $html; }
/** * Generates the topbar tree object. * * @return Horde_Tree_Renderer_Base The topbar tree object. */ public function getTree() { if ($this->_generated) { return $this->_tree; } global $injector, $prefs, $registry; $current = $registry->getApp(); $isAdmin = $registry->isAdmin(); $menu = array(); foreach ($registry->listApps(array('active', 'admin', 'noadmin', 'heading', 'link', 'notoolbar', 'topbar'), true, null) as $app => $params) { /* Check if the current user has permisson to see this application, * and if the application is active. Headings are visible to * everyone (but get filtered out later if they have no * children). Administrators always see all applications except * those marked 'inactive'. */ if ($app != 'horde' && (in_array($params['status'], array('heading', 'link')) || in_array($params['status'], array('active', 'admin', 'noadmin', 'topbar')) && !($isAdmin && $params['status'] == 'noadmin') && $registry->hasPermission(!empty($params['app']) ? $params['app'] : $app, Horde_Perms::SHOW))) { $menu[$app] = $params; } } do { $children = array(); foreach ($menu as $params) { if (isset($params['menu_parent'])) { $children[$params['menu_parent']] = true; } } $found = false; foreach (array_keys($menu) as $key) { if ($menu[$key]['status'] == 'heading' && empty($children[$key])) { unset($menu[$key]); $found = true; } } } while ($found); /* Add the administration menu if the user is an admin or has any * admin permissions. */ $perms = $injector->getInstance('Horde_Perms'); $admin_item_count = 0; try { foreach ($registry->callByPackage('horde', 'admin_list') as $method => $val) { if ($isAdmin || $perms->hasPermission('horde:administration:' . $method, $registry->getAuth(), Horde_Perms::SHOW)) { ++$admin_item_count; $menu['administration_' . $method] = array('icon' => $val['icon'], 'menu_parent' => 'administration', 'name' => Horde::stripAccessKey($val['name']), 'status' => 'active', 'url' => Horde::url($registry->applicationWebPath($val['link'], 'horde'))); } } } catch (Horde_Exception $e) { } if ($admin_item_count) { $menu['administration'] = array('name' => Horde_Core_Translation::t("Administration"), 'status' => 'heading', 'menu_parent' => 'settings'); } $menu['settings'] = array('class' => 'horde-settings horde-icon-settings', 'name' => '', 'noarrow' => true, 'status' => 'active'); /* Add preferences. */ if ($registry->showService('prefs') && !$prefs instanceof Horde_Prefs_Session) { $menu['prefs'] = array('icon' => Horde_Themes::img('prefs.png'), 'menu_parent' => 'settings', 'name' => Horde_Core_Translation::t("Preferences"), 'status' => 'active', 'url' => $registry->getServiceLink('prefs', $current)); /* Get a list of configurable applications. */ $prefs_apps = $registry->listApps(array('active', 'admin'), true, Horde_Perms::READ); if (!empty($prefs_apps['horde'])) { $menu['prefs_' . 'horde'] = array('icon' => $registry->get('icon', 'horde'), 'menu_parent' => 'prefs', 'name' => Horde_Core_Translation::t("Global Preferences"), 'status' => 'active', 'url' => $registry->getServiceLink('prefs', 'horde')); unset($prefs_apps['horde']); } uasort($prefs_apps, array($this, '_sortByName')); foreach ($prefs_apps as $app => $params) { $menu['prefs_' . $app] = array('icon' => $registry->get('icon', $app), 'menu_parent' => 'prefs', 'name' => $params['name'], 'status' => 'active', 'url' => $registry->getServiceLink('prefs', $app)); } } /* Add notification log. */ $menu['growlerlog'] = array('icon' => 'info.png', 'menu_parent' => 'settings', 'name' => Horde_Core_Translation::t("Toggle Alerts Log"), 'status' => 'active', 'url' => 'javascript:void(HordeCore.Growler.toggleLog());'); /* Add problem link. */ if ($registry->showService('problem') && ($problem_link = $registry->getServiceLink('problem', $current))) { $menu['problem_' . $current] = array('icon' => 'problem.png', 'menu_parent' => 'settings', 'name' => Horde_Core_Translation::t("Problem"), 'status' => 'active', 'url' => $problem_link); } /* Add help link. */ if ($registry->showService('help') && ($help_link = $registry->getServiceLink('help', $current))) { $menu['help_' . $current] = array('icon' => 'help_index.png', 'menu_parent' => 'settings', 'name' => Horde_Core_Translation::t("Help"), 'onclick' => Horde::popupJs($help_link, array('urlencode' => true)) . 'return false;', 'status' => 'active', 'target' => 'help', 'url' => $help_link); } foreach ($menu as $app => $params) { switch ($params['status']) { case 'topbar': try { $registry->callAppMethod($params['app'], 'topbarCreate', array('args' => array($this->_tree, empty($params['menu_parent']) ? null : $params['menu_parent'], isset($params['topbar_params']) ? $params['topbar_params'] : array()))); } catch (Horde_Exception_PushApp $e) { // Ignore } catch (Horde_Exception $e) { Horde::log($e, 'ERR'); } break; default: /* Need to run the name through Horde's gettext since the * user's locale may not have been loaded when registry.php was * parsed, and the translations of the application names are * not in the Core package. */ $name = strlen($params['name']) ? _($params['name']) : ''; /* Headings have no webroot; they're just containers for other * menu items. */ if (isset($params['url'])) { $url = $params['url']; } elseif ($params['status'] == 'heading' || !isset($params['webroot'])) { $url = ''; } else { $url = Horde::url($registry->getInitialPage($app), false, array('app' => $app)); } $this->_tree->addNode(array('id' => $app, 'parent' => empty($params['menu_parent']) ? null : $params['menu_parent'], 'label' => $name, 'expanded' => false, 'params' => array('icon' => strval(isset($params['icon']) ? $params['icon'] : $registry->get('icon', $app)), 'class' => isset($params['class']) ? $params['class'] : ($app == $current ? 'horde-point-center-active' : 'horde-point-center'), 'noarrow' => !empty($params['noarrow']), 'onclick' => isset($params['onclick']) ? $params['onclick'] : null, 'target' => isset($params['target']) ? $params['target'] : null, 'url' => $url, 'active' => $app == $current))); } } $this->_generated = true; return $this->_tree; }
/** */ public function menu($menu) { global $conf, $injector, $prefs, $registry, $session; $s_categories = $session->get('ingo', 'script_categories'); $vars = $injector->getInstance('Horde_Variables'); $menu->add(Ingo_Basic_Filters::url(), _("Filter _Rules"), 'ingo-rules', null, null, null, $vars->page == 'filters' ? 'current' : '__noselection'); try { if (in_array('Ingo_Rule_System_Whitelist', $s_categories)) { $menu->add(Horde::url($registry->link('mail/showWhitelist')), _("_Whitelist"), 'ingo-whitelist', null, null, null, $vars->page == 'whitelist' ? 'current' : '__noselection'); } } catch (Horde_Exception $e) { Horde::log($e, 'ERR'); } try { if (in_array('Ingo_Rule_System_Blacklist', $s_categories)) { $menu->add(Horde::url($registry->link('mail/showBlacklist')), _("_Blacklist"), 'ingo-blacklist', null, null, null, $vars->page == 'blacklist' ? 'current' : '__noselection'); } } catch (Horde_Exception $e) { Horde::log($e, 'ERR'); } if (in_array('Ingo_Rule_System_Vacation', $s_categories)) { $menu->add(Ingo_Basic_Vacation::url(), _("_Vacation"), 'ingo-vacation', null, null, null, $vars->page == 'vacation' ? 'current' : '__noselection'); } if (in_array('Ingo_Rule_System_Forward', $s_categories)) { $menu->add(Ingo_Basic_Forward::url(), _("_Forward"), 'ingo-forward', null, null, null, $vars->page == 'forward' ? 'current' : '__noselection'); } if (in_array('Ingo_Rule_System_Spam', $s_categories)) { $menu->add(Ingo_Basic_Spam::url(), _("S_pam"), 'ingo-spam', null, null, null, $vars->page == 'spam' ? 'current' : '__noselection'); } if ((!$prefs->isLocked('auto_update') || !$prefs->getValue('auto_update')) && $injector->getInstance('Ingo_Factory_Script')->hasFeature('script_file')) { $menu->add(Ingo_Basic_Script::url(), _("_Script"), 'ingo-script', null, null, null, $vars->page == 'script' ? 'current' : '__noselection'); } if (($shares = $injector->getInstance('Ingo_Shares')) && empty($conf['share']['no_sharing'])) { if ($shares->getShare($session->get('ingo', 'current_share'))->get('owner') == $registry->getAuth()) { $share = $session->get('ingo', 'current_share'); } else { $share = $session->get('ingo', 'backend/id') . ':' . $registry->getAuth(); } $menu->add('#', _("_Permissions"), 'horde-perms', null, '', Horde::popupJs(Horde::url($registry->get('webroot', 'horde') . '/services/shares/edit.php', true), array('params' => array('app' => 'ingo', 'share' => $share), 'urlencode' => true)) . 'return false;'); } }
/** */ public function menu($menu) { $backend_key = Gollem_Auth::getPreferredBackend(); $menu->add(Horde::url('manager.php')->add('dir', Gollem::$backend['home']), _("Start Folder"), 'gollem-home', null, null, null, '__noselection'); if (Gollem::checkPermissions('backend', Horde_Perms::EDIT) && Gollem::checkPermissions('directory', Horde_Perms::EDIT, Gollem::$backend['dir']) && $GLOBALS['session']->get('gollem', 'clipboard', Horde_Session::TYPE_ARRAY)) { $menu->add(Horde::url('clipboard.php')->add('dir', Gollem::$backend['dir']), _("Clipboard"), 'gollem-clipboard'); } if (!empty(Gollem::$backend['quota'])) { if ($GLOBALS['browser']->hasFeature('javascript')) { $quota_url = 'javascript:' . Horde::popupJs(Horde::url('quota.php'), array('params' => array('backend' => $backend_key), 'height' => 300, 'width' => 300, 'urlencode' => true)); } else { $quota_url = Horde::url('quota.php')->add('backend', $backend_key); } $menu->add($quota_url, _("Check Quota"), 'gollem-quota'); } if ($GLOBALS['registry']->isAdmin() && !$GLOBALS['injector']->getInstance('Horde_Perms') instanceof Horde_Perms_Null) { $menu->add(Horde::url('permissions.php')->add('backend', $backend_key), _("_Permissions"), 'horde-perms'); } }
/** * Generate a javascript link to the download/view page. * * @param Horde_Mime_Part $mime_part The MIME part to view. * @param string $actionID The actionID to perform. * @param string $text The ESCAPED (!) link text. * @param array $options Additional options: * - css: (string) The CSS class to use. * - jstext: (string) The javascript link text. * - onload: (string) A JS function to run when popup window is * fully loaded. * - params: (array) A list of any additional parameters that need to be * passed to download/view page. (key = name) * - widget: (boolean) If true use Horde::widget() to generate, * Horde::link() otherwise. * * @return string A HTML href link to the download/view page. */ public function linkViewJS($mime_part, $actionID, $text, $options = array()) { if (empty($options['params'])) { $options['params'] = array(); } if (empty($options['jstext'])) { $options['jstext'] = ($description = $mime_part->getDescription(true)) ? sprintf(_("View %s"), $description) : null; } $url = Horde::popupJs(Horde::url('view.php'), array('menu' => true, 'onload' => empty($options['onload']) ? 'IMP_JS.resizePopup' : $options['onload'], 'params' => $this->_urlViewParams($mime_part, $actionID, isset($options['params']) ? $options['params'] : array()), 'urlencode' => true)); return empty($options['widget']) ? Horde::link('#', $options['jstext'], empty($options['css']) ? null : $options['css'], null, $url) . $text . '</a>' : Horde::widget(array('url' => '#', 'class' => empty($options['css']) ? null : $options['css'], 'onclick' => $url, 'title' => $text)); }
/** * Generates the HTML link that will pop up a help window for the * requested topic. * * @param string $module The name of the current Horde module. * @param string $topic The help topic to be displayed. * * @return string The HTML to create the help link. */ public static function link($module, $topic) { if (!$GLOBALS['registry']->showService('help')) { return ''; } $url = $GLOBALS['registry']->getServiceLink('help', $module)->add('topic', $topic); return $url->link(array('title' => Horde_Core_Translation::t("Help"), 'class' => 'helplink', 'target' => 'hordehelpwin', 'onclick' => Horde::popupJs($url, array('urlencode' => true)) . 'return false;')) . Horde_Themes_Image::tag('help.png', array('alt' => Horde_Core_Translation::t("Help"))) . '</a>'; }
/** * Build the HTML for the widget * * @return string */ public function html() { global $page_output; $view = $GLOBALS['injector']->getInstance('Horde_View'); $view->addTemplatePath(ANSEL_TEMPLATES . '/widgets'); $view->title = _("Location"); $view->background = $this->_style->background; $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage'); $geodata = $ansel_storage->getImagesGeodata($this->_params['images']); $viewType = $this->_view->viewType(); // Exit early? if (count($geodata) == 0 && $viewType != 'Image') { return ''; } // Setup map and javascript includes Horde::initMap(); $page_output->addScriptFile('map.js'); $page_output->addScriptFile('popup.js', 'horde'); $page_output->addScriptFile('widgets/geotag.js'); // Values needed by map javascript $relocate_url = Horde::url('map_edit.php', true); $rtext = _("Relocate this image"); $dtext = _("Delete geotag"); $thisTitleText = _("This image"); $otherTitleText = _("Other images in this gallery"); $geotagUrl = $GLOBALS['registry']->getServiceLink('ajax', 'ansel')->setRaw(true); $geotagUrl->url .= 'imageSaveGeotag'; $permsEdit = (int) $this->_view->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT); $view->haveEdit = $permsEdit; // URL for updating selected layer $layerUrl = $GLOBALS['registry']->getServiceLink('ajax', 'ansel')->setRaw(true); $layerUrl->url .= 'setPrefValue'; // And the current defaultLayer, if any. $defaultLayer = $GLOBALS['prefs']->getValue('current_maplayer'); // Add extra information to the JSON data to be sent: foreach ($geodata as $id => $data) { $geodata[$id]['icon'] = (string) Ansel::getImageUrl($geodata[$id]['image_id'], 'mini', true); $geodata[$id]['markerOnly'] = $viewType == 'Image'; $geodata[$id]['link'] = (string) Ansel::getUrlFor('view', array('view' => 'Image', 'gallery' => $this->_view->gallery->id, 'image' => $geodata[$id]['image_id']), true); } // Image view? $view->isImageView = $viewType == 'Image'; // If this is an image view, get the other gallery images if ($viewType == 'Image' && !empty($geodata)) { $image_id = $this->_view->resource->id; $others = $this->_getGalleryImagesWithGeodata(); foreach ($others as $id => $data) { if ($id != $image_id) { $others[$id]['icon'] = (string) Ansel::getImageUrl($others[$id]['image_id'], 'mini', true); $others[$id]['link'] = (string) Ansel::getUrlFor('view', array('view' => 'Image', 'gallery' => $this->_view->gallery->id, 'image' => $others[$id]['image_id']), true); } else { unset($others[$id]); } } $geodata = array_values(array_merge($geodata, $others)); $view->geodata = $geodata; } if ($permsEdit) { // Image view, but no geotags, provide ability to add it. $addurl = Horde::url('map_edit.php')->add('image', $this->_params['images'][0]); $view->addLink = $addurl->link(array('onclick' => Horde::popupJs(Horde::url('map_edit.php'), array('params' => array('image' => $this->_params['images'][0]), 'urlencode' => true, 'width' => '750', 'height' => '600')) . 'return false;')); $view->imgs = $ansel_storage->getRecentImagesGeodata($GLOBALS['registry']->getAuth()); if (count($view->imgs) > 0) { foreach ($view->imgs as $id => &$data) { if (!empty($data['image_location'])) { $data['title'] = $data['image_location']; } else { $data['title'] = sprintf('%s %s', Ansel::point2Deg($data['image_latitude'], true), Ansel::point2Deg($data['image_longitude'])); } $data['add_link'] = $addurl->link(array('title' => $title, 'onclick' => "Ansel.widgets.geotag.setLocation(" . $image_id . ",'" . $data['image_latitude'] . "', '" . $data['image_longitude'] . "'); return false")); } } } // Build the javascript to handle the map on the gallery/image views. $json = Horde_Serialize::serialize(array_values($geodata), Horde_Serialize::JSON); $js_params = array('smallMap' => 'ansel_map_small', 'mainMap' => 'ansel_map', 'viewType' => $viewType, 'relocateUrl' => strval($relocate_url), 'relocateText' => $rtext, 'markerLayerTitle' => $thisTitleText, 'imageLayerTitle' => $otherTitleText, 'defaultBaseLayer' => $defaultLayer, 'deleteGeotagText' => $dtext, 'hasEdit' => $permsEdit, 'updateEndpoint' => strval($geotagUrl), 'layerUpdateEndpoint' => strval($layerUrl), 'layerUpdatePref' => 'current_maplayer', 'geocoder' => $GLOBALS['conf']['maps']['geocoder']); $js = array('Ansel.widgets = Ansel.widgets || {};', 'Ansel.widgets.geotag = new AnselGeoTagWidget(' . $json . ',' . Horde_Serialize::serialize($js_params, Horde_Serialize::JSON) . ');'); $page_output->addInlineScript($js, true); if (count($geodata)) { $page_output->addInlineScript('Ansel.widgets.geotag.doMap();', true); } return $view->render('geotag'); }
$apps[$i]['vstatus'] = Horde::link($versions[$app]['url'], sprintf(_("Download %s"), $app), '', '_blank') . sprintf(_("A newer version (%s) exists."), $versions[$app]['version']) . '</a> '; } else { $apps[$i]['load'] = $success; $apps[$i]['vstatus'] = _("Module is up-to-date."); } } } /* Sort the apps by name. */ Horde_Array::arraySort($apps, 'sort'); /* Set up any actions that may be offered. */ $actions = array(); $ftpform = ''; if ($session->get('horde', 'config/')) { $url = Horde::url('admin/config/diff.php'); $action = _("Show differences between currently saved and the newly generated configuration."); $actions[] = array('icon' => Horde_Themes_Image::tag('search.png', array('attr' => array('align' => 'middle'))), 'link' => Horde::link('#', '', '', '', Horde::popupJs($url, array('height' => 480, 'width' => 640, 'urlencode' => true)) . 'return false;') . $action . '</a>'); /* Action to download the configuration upgrade PHP script. */ $url = Horde::url('admin/config/scripts.php')->add(array('setup' => 'conf', 'type' => 'php')); $action = _("Download generated configuration as PHP script."); $actions[] = array('icon' => Horde_Themes_Image::tag('download.png', array('attr' => array('align' => 'middle'))), 'link' => Horde::link($url) . $action . '</a>'); /* Action to save the configuration upgrade PHP script. */ $action = _("Save generated configuration as a PHP script to your server's temporary directory."); $actions[] = array('icon' => Horde_Themes_Image::tag('save.png', array('attr' => array('align' => 'middle'))), 'link' => Horde::link($url->add('save', 'tmp')) . $action . '</a>'); /* Set up the form for FTP upload of scripts. */ $vars = Horde_Variables::getDefaultVariables(); $ftpform = new Horde_Form($vars); $ftpform->setButtons(_("Upload"), true); $ftpform->addVariable(_("Username"), 'username', 'text', true, false, null, array('', 20)); $ftpform->addVariable(_("Password"), 'password', 'password', false); if ($ftpform->validate($vars)) { $ftpform->getInfo($vars, $info);
/** * Creates a link to the gollem file selection window. * * The file section window will return a cache ID value which should be * used (along with the selectListResults and returnFromSelectList * functions below) to obtain the data from a list of selected files. * * There MUST be a form field named 'selectlist_selectid' in the calling * form. This field will be populated with the selection ID when the user * completes file selection. * * There MUST be a form parameter named 'actionID' in the calling form. * This form will be populated with the value 'selectlist_process' when * the user completes file selection. The calling form will be submitted * after the window closes (i.e. the calling form must process the * 'selectlist_process' actionID). * * @param string $link_text The text to use in the link. * @param string $link_style The style to use for the link. * @param string $formid The formid of the calling script. * @param boolean $icon Create the link with an icon instead of * text? * @param string $selectid Selection ID. * * @return string The URL string. */ public function selectlistLink($link_text, $link_style, $formid, $icon = false, $selectid = '') { $link = Horde::link('#', $link_text, $link_style, '_blank', Horde::popupJs(Horde::url('selectlist.php'), array('params' => array_filter(array('formid' => $formid, 'cacheid' => $selectid)), 'height' => 500, 'width' => 300, 'urlencode' => true)) . 'return false;'); if ($icon) { $link_text = Horde::img('gollem.png', $link_text); } return '<script type="text/javascript">document.write(\'' . addslashes($link . $link_text) . '<\' + \'/a>\');</script>'; }
/** */ protected function _init() { global $injector, $notification, $page_output, $prefs, $registry, $session; $mailbox = $this->indices->mailbox; /* Call the mailbox redirection hook, if requested. */ try { $redirect = $injector->getInstance('Horde_Core_Hooks')->callHook('mbox_redirect', 'imp', array($mailbox)); if (!empty($redirect)) { Horde::url($redirect, true)->redirect(); } } catch (Horde_Exception_HookNotSet $e) { } $mailbox_url = Horde::url('basic.php')->add('page', 'mailbox'); $mailbox_imp_url = $mailbox->url('mailbox')->add('newmail', 1); $imp_flags = $injector->getInstance('IMP_Flags'); $imp_imap = $mailbox->imp_imap; $imp_search = $injector->getInstance('IMP_Search'); /* Run through the action handlers */ if (($actionID = $this->vars->actionID) && $actionID != 'message_missing') { try { $session->checkToken($this->vars->token); } catch (Horde_Exception $e) { $notification->push($e); $actionID = null; } } /* We know we are going to be exclusively dealing with this mailbox, * so select it on the IMAP server (saves some STATUS calls). Open * R/W to clear the RECENT flag. This call will catch invalid * mailboxes. */ $imp_imap->openMailbox($mailbox, Horde_Imap_Client::OPEN_READWRITE); $imp_mailbox = $mailbox->list_ob; /* Determine if mailbox is readonly. */ $readonly = $mailbox->readonly; switch ($actionID) { case 'change_sort': $mailbox->setSort($this->vars->sortby, $this->vars->sortdir); break; case 'blacklist': $injector->getInstance('IMP_Filter')->blacklistMessage($this->indices); break; case 'whitelist': $injector->getInstance('IMP_Filter')->whitelistMessage($this->indices); break; case 'spam_report': $injector->getInstance('IMP_Factory_Spam')->create(IMP_Spam::SPAM)->report($this->indices); break; case 'innocent_report': $injector->getInstance('IMP_Factory_Spam')->create(IMP_Spam::INNOCENT)->report($this->indices); break; case 'message_missing': $notification->push(_("Requested message not found."), 'horde.error'); break; case 'fwd_digest': case 'redirect_messages': case 'template_edit': if (count($this->indices)) { $compose_actions = array('fwd_digest' => 'fwd_digest', 'redirect_messages' => 'redirect_compose', 'template_edit' => 'template_edit'); $clink = new IMP_Compose_Link($this->vars); $options = array_merge(array('actionID' => $compose_actions[$actionID], 'muid' => strval($this->indices)), $clink->args); if ($prefs->getValue('compose_popup')) { $page_output->addInlineScript(array(Horde::popupJs(IMP_Basic_Compose::url(), array('novoid' => true, 'params' => array_merge(array('popup' => 1), $options)))), true); } else { IMP_Basic_Compose::url()->add($options)->redirect(); } } break; case 'delete_messages': $injector->getInstance('IMP_Message')->delete($this->indices, array('mailboxob' => $imp_mailbox)); break; case 'undelete_messages': $injector->getInstance('IMP_Message')->undelete($this->indices); break; case 'move_messages': case 'copy_messages': if (isset($this->vars->targetMbox) && count($this->indices) && (!$readonly || $actionID == 'copy_messages')) { $targetMbox = IMP_Mailbox::formFrom($this->vars->targetMbox); if (!empty($this->vars->newMbox) && $this->vars->newMbox == 1) { $targetMbox = IMP_Mailbox::get($this->vars->targetMbox)->namespace_append; $newMbox = true; } else { $targetMbox = IMP_Mailbox::formFrom($this->vars->targetMbox); $newMbox = false; } $injector->getInstance('IMP_Message')->copy($targetMbox, $actionID == 'move_messages' ? 'move' : 'copy', $this->indices, array('create' => $newMbox, 'mailboxob' => $imp_mailbox)); } break; case 'flag_messages': if (!$readonly && $this->vars->flag && count($this->indices)) { $flag = $imp_flags->parseFormId($this->vars->flag); $injector->getInstance('IMP_Message')->flag(array($flag['set'] ? 'add' : 'remove' => array($flag['flag'])), $this->indices); } break; case 'filter_messages': if (!$readonly) { $filter = IMP_Mailbox::formFrom($this->vars->filter); $q_ob = null; if (strpos($filter, self::FLAG_FILTER_PREFIX) === 0) { /* Flag filtering. */ $flag_filter = $imp_flags->parseFormId(substr($filter, strpos($filter, "") + 1)); try { $q_ob = $imp_search->createQuery(array(new IMP_Search_Element_Flag($flag_filter['flag'], $flag_filter['set'])), array('mboxes' => array($mailbox), 'type' => IMP_Search::CREATE_QUERY)); } catch (InvalidArgumentException $e) { } } else { /* Pre-defined filters. */ try { $q_ob = $imp_search->applyFilter($filter, array($mailbox)); } catch (InvalidArgumentException $e) { } } if ($q_ob) { IMP_Mailbox::get($q_ob)->url('mailbox')->redirect(); exit; } } break; case 'hide_deleted': $mailbox->setHideDeletedMsgs(!$prefs->getValue('delhide')); break; case 'expunge_mailbox': $injector->getInstance('IMP_Message')->expungeMailbox(array(strval($mailbox) => 1), array('mailboxob' => $imp_mailbox)); break; case 'filter': $mailbox->filter(); break; case 'empty_mailbox': $injector->getInstance('IMP_Message')->emptyMailbox(array(strval($mailbox))); break; case 'view_messages': $mailbox->url(IMP_Basic_Thread::url(), null, false)->add(array('mode' => 'msgview', 'muid' => strval($this->indices)))->redirect(); break; } /* Token to use in requests. */ $token = $session->getToken(); $search_mbox = $mailbox->search; /* Deal with filter options. */ if (!$readonly && IMP_Filter::canApplyFilters() && !$mailbox->filterOnDisplay() && ($mailbox->inbox || $prefs->getValue('filter_any_mailbox') && !$search_mbox)) { $filter_url = $mailbox_imp_url->copy()->add(array('actionID' => 'filter', 'token' => $token)); } /* Generate folder options list. */ if ($imp_imap->access(IMP_Imap::ACCESS_FOLDERS)) { $iterator = new IMP_Ftree_IteratorFilter($injector->getInstance('IMP_Ftree')); $iterator->add($iterator::NONIMAP); $folder_options = new IMP_Ftree_Select(array('heading' => _("Messages to"), 'inc_notepads' => true, 'inc_tasklists' => true, 'iterator' => $iterator, 'new_mbox' => true)); } /* Build the list of messages in the mailbox. */ $pageOb = $imp_mailbox->buildMailboxPage($this->vars->mpage, $this->vars->start); $show_preview = $prefs->getValue('preview_enabled'); $mbox_info = $imp_mailbox->getMailboxArray(range($pageOb['begin'], $pageOb['end']), array('headers' => true, 'preview' => (int) $show_preview, 'type' => $prefs->getValue('atc_flag'))); /* Determine sorting preferences. */ $sortpref = $mailbox->getSort(); $thread_sort = $sortpref->sortby == Horde_Imap_Client::SORT_THREAD; /* Determine if we are going to show the Hide/Purge Deleted Message * links. */ if (!($use_trash = $prefs->getValue('use_trash')) && !$mailbox->vinbox) { $showdelete = array('hide' => true, 'purge' => $mailbox->access_expunge); } else { $showdelete = array('hide' => false, 'purge' => false); } if ($showdelete['hide'] && !$prefs->isLocked('delhide')) { if ($prefs->getValue('delhide')) { $deleted_prompt = _("Show Deleted"); } else { $deleted_prompt = _("Hide Deleted"); } } /* Generate paging links. */ if ($pageOb['pagecount']) { if ($pageOb['page'] == 1) { $url_first = $url_prev = null; $pages_first = 'navfirstgreyImg'; $pages_prev = 'navleftgreyImg'; } else { $url_first = $mailbox_imp_url->copy()->add('mpage', 1); $pages_first = 'navfirstImg'; $url_prev = $mailbox_imp_url->copy()->add('mpage', $pageOb['page'] - 1); $pages_prev = 'navleftImg'; } if ($pageOb['page'] == $pageOb['pagecount']) { $url_last = $url_next = null; $pages_last = 'navlastgreyImg'; $pages_next = 'navrightgreyImg'; } else { $url_next = $mailbox_imp_url->copy()->add('mpage', $pageOb['page'] + 1); $pages_next = 'navrightImg'; $url_last = $mailbox_imp_url->copy()->add('mpage', $pageOb['pagecount']); $pages_last = 'navlastImg'; } } /* Generate RSS link. */ if ($mailbox->inbox) { $rss_box = ''; } else { $ns_info = $mailbox->namespace_info; if (is_null($ns_info)) { $rss_box = null; } else { $rss_box = str_replace(rawurlencode($ns_info->delimiter), '/', rawurlencode($ns_info->delimiter . ($ns_info->type == $ns_info::NS_PERSONAL ? $ns_info->stripNamespace($mailbox) : $mailbox))); } } if (!is_null($rss_box)) { $page_output->addLinkTag(array('href' => Horde::url('rss.php', true, -1) . $rss_box)); } /* If user wants the mailbox to be refreshed, set time here. */ $refresh_url = $mailbox_imp_url->copy()->add('mpage', $pageOb['page']); if (isset($filter_url)) { $filter_url->add('mpage', $pageOb['page']); } /* Determine if we are showing previews. */ $preview_tooltip = $show_preview ? $prefs->getValue('preview_show_tooltip') : false; if (!$preview_tooltip) { $strip_preview = $prefs->getValue('preview_strip_nl'); } $unread = $imp_mailbox->unseenMessages(Horde_Imap_Client::SEARCH_RESULTS_COUNT); $page_output->addInlineJsVars(array('ImpMailbox.pop3' => intval(!$mailbox->is_imap), 'ImpMailbox.text' => array('delete_messages' => _("Are you sure you wish to PERMANENTLY delete these messages?"), 'delete_all' => _("Are you sure you wish to delete all mail in this mailbox?"), 'delete_vfolder' => _("Are you sure you want to delete this Virtual Folder Definition?"), 'innocent_report' => _("Are you sure you wish to report this message as innocent?"), 'moveconfirm' => _("Are you sure you want to move the message(s)? (Some message information might get lost, like message headers, text formatting or attachments!)"), 'newmbox' => _("You are copying/moving to a new mailbox.") . "\n" . _("Please enter a name for the new mailbox:") . "\n", 'no' => _("No"), 'selectone' => _("You must select at least one message first."), 'selectonlyone' => _("You must select only one message for this action."), 'spam_report' => _("Are you sure you wish to report this message as spam?"), 'submit' => _("You must select at least one message first."), 'target_mbox' => _("You must select a target mailbox first.")), 'ImpMailbox.unread' => intval($unread))); $pagetitle = $this->title = $mailbox->label; if ($mailbox->editvfolder) { $query_text = wordwrap($imp_search[$mailbox]->querytext); $pagetitle .= ' [' . Horde::linkTooltip('#', $query_text, '', '', '', $query_text) . _("Virtual Folder") . '</a>]'; $this->title .= ' [' . _("Virtual Folder") . ']'; } elseif ($mailbox->editquery) { $query_text = wordwrap($imp_search[$mailbox]->querytext); $pagetitle = Horde::linkTooltip('#', $query_text, '', '', '', $query_text) . $pagetitle . '</a>'; } else { $pagetitle = $this->title = htmlspecialchars($this->title); } /* Generate mailbox summary string. */ $subinfo = new IMP_View_Subinfo(array('mailbox' => $mailbox)); $subinfo->value = $pagetitle . ' ('; if (empty($pageOb['end'])) { $subinfo->value .= _("No Messages"); } else { $subinfo->value .= $pageOb['pagecount'] > 1 ? sprintf(_("%d Messages"), $pageOb['msgcount']) . ' / ' . sprintf(_("Page %d of %d"), $pageOb['page'], $pageOb['pagecount']) : sprintf(_("%d Messages"), $pageOb['msgcount']); } $subinfo->value .= ')'; $injector->getInstance('Horde_View_Topbar')->subinfo = $subinfo->render(); $page_output->addScriptFile('hordecore.js', 'horde'); $page_output->addScriptFile('mailbox.js'); $page_output->addScriptPackage('Horde_Core_Script_Package_Dialog'); $page_output->metaRefresh($prefs->getValue('refresh_time'), $refresh_url); /* Prepare the header template. */ $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/basic/mailbox')); $view->addHelper('FormTag'); $view->addHelper('Horde_Core_View_Helper_Accesskey'); $view->addHelper('Tag'); $hdr_view = clone $view; $hdr_view->readonly = $readonly; $hdr_view->refresh_url = $refresh_url; if (isset($filter_url)) { $hdr_view->filter_url = $filter_url; } if ($mailbox->access_search) { if (!$search_mbox) { $hdr_view->search_url = $mailbox->url(IMP_Basic_Searchbasic::url()); } else { if ($mailbox->editvfolder) { $edit_search = _("Edit Virtual Folder"); } elseif ($mailbox->query) { if ($mailbox->editquery) { $edit_search = _("Edit Search Query"); } else { /* Basic search results. */ $search_mailbox = IMP_Mailbox::get($imp_search[$mailbox]->mboxes[0]); $hdr_view->search_url = $search_mailbox->url(IMP_Basic_Searchbasic::url()); $hdr_view->searchclose = $search_mailbox->url('mailbox'); } } if (isset($edit_search)) { $hdr_view->edit_search_url = $imp_search->editUrl($mailbox); $hdr_view->edit_search_title = $edit_search; } } } if ($mailbox->access_empty) { $hdr_view->empty = $mailbox_imp_url->copy()->add(array('actionID' => 'empty_mailbox', 'token' => $token)); } $this->output = $hdr_view->render('header'); /* If no messages, exit immediately. */ if (empty($pageOb['end'])) { if ($pageOb['anymsg'] && isset($deleted_prompt)) { /* Show 'Show Deleted' prompt if mailbox has no viewable * message but has hidden, deleted messages. */ $del_view = clone $view; $del_view->hide = Horde::widget(array('url' => $refresh_url->copy()->add(array('actionID' => 'hide_deleted', 'token' => $token)), 'class' => 'hideAction', 'title' => $deleted_prompt)); if ($mailbox->access_expunge) { $del_view->purge = Horde::widget(array('url' => $refresh_url->copy()->add(array('actionID' => 'expunge_mailbox', 'token' => $token)), 'class' => 'purgeAction', 'title' => _("Pur_ge Deleted"))); } $this->output .= $del_view->render('actions_deleted'); } $empty_view = clone $view; $empty_view->search_mbox = $search_mbox; $this->output .= $empty_view->render('empty_mailbox'); return; } $clink_ob = new IMP_Compose_Link(); $clink = $clink_ob->link(); /* Display the navbar and actions if there is at least 1 message in * mailbox. */ if ($pageOb['msgcount']) { /* Prepare the navbar template. */ $n_view = clone $view; $n_view->id = 1; $n_view->readonly = $readonly; $filtermsg = false; if ($mailbox->access_flags) { $args = array('imap' => true, 'mailbox' => $search_mbox ? null : $mailbox); $form_set = $form_unset = array(); foreach ($imp_flags->getList($args) as $val) { if ($val->canset) { $form_set[] = array('f' => $val->form_set, 'l' => $val->label, 'v' => IMP_Mailbox::formTo(self::FLAG_FILTER_PREFIX . $val->form_set)); $form_unset[] = array('f' => $val->form_unset, 'l' => $val->label, 'v' => IMP_Mailbox::formTo(self::FLAG_FILTER_PREFIX . $val->form_unset)); } } $n_view->flaglist_set = $form_set; $n_view->flaglist_unset = $form_unset; if (!$search_mbox && $mailbox->access_search) { $filtermsg = $n_view->flag_filter = true; } } if (!$search_mbox && $mailbox->access_filters) { $filters = array(); $iterator = IMP_Search_IteratorFilter::create(IMP_Search_IteratorFilter::FILTER); foreach ($iterator as $val) { $filters[] = array('l' => $val->label, 'v' => IMP_Mailbox::formTo($val)); } if (!empty($filters)) { $filtermsg = true; $n_view->filters = $filters; } } $n_view->filtermsg = $filtermsg; if ($imp_imap->access(IMP_Imap::ACCESS_FOLDERS)) { $n_view->move = Horde::widget(array('url' => '#', 'class' => 'moveAction', 'title' => _("Move"), 'nocheck' => true)); $n_view->copy = Horde::widget(array('url' => '#', 'class' => 'copyAction', 'title' => _("Copy"), 'nocheck' => true)); $n_view->folder_options = $folder_options; } $n_view->mailbox_url = $mailbox_url; $n_view->mailbox = $mailbox->form_to; if ($pageOb['pagecount'] > 1) { $n_view->multiple_page = true; $n_view->pages_first = $pages_first; $n_view->url_first = $url_first; $n_view->pages_prev = $pages_prev; $n_view->url_prev = $url_prev; $n_view->pages_next = $pages_next; $n_view->url_next = $url_next; $n_view->pages_last = $pages_last; $n_view->url_last = $url_last; $n_view->page_val = $pageOb['page']; $n_view->page_size = Horde_String::length($pageOb['pagecount']); } $this->output .= $n_view->render('navbar'); /* Prepare the actions template. */ $a_view = clone $view; if ($mailbox->access_deletemsgs) { $del_class = $use_trash && $mailbox->trash ? 'permdeleteAction' : 'deleteAction'; $a_view->delete = Horde::widget(array('url' => '#', 'class' => $del_class, 'title' => _("_Delete"))); } if ($showdelete['purge'] || $mailbox->vtrash) { $a_view->undelete = Horde::widget(array('url' => '#', 'class' => 'undeleteAction', 'title' => _("_Undelete"))); } $mboxactions = array(); if ($showdelete['purge']) { $mailbox_link = $mailbox_imp_url->copy()->add('mpage', $pageOb['page']); if (isset($deleted_prompt)) { $mboxactions[] = Horde::widget(array('url' => $mailbox_link->copy()->add(array('actionID' => 'hide_deleted', 'token' => $token)), 'class' => 'hideAction', 'title' => $deleted_prompt)); } $mboxactions[] = Horde::widget(array('url' => $mailbox_link->copy()->add(array('actionID' => 'expunge_mailbox', 'token' => $token)), 'class' => 'purgeAction', 'title' => _("Pur_ge Deleted"))); } if (!$sortpref->sortby_locked && $sortpref->sortby != Horde_Imap_Client::SORT_SEQUENCE) { $mboxactions[] = Horde::widget(array('url' => $mailbox_imp_url->copy()->add(array('sortby' => Horde_Imap_Client::SORT_SEQUENCE, 'actionID' => 'change_sort', 'token' => $token)), 'title' => _("Clear Sort"))); } if ($mailbox->templates) { $a_view->templateedit = Horde::widget(array('url' => '#', 'class' => 'templateeditAction', 'title' => _("Edit Template"))); $mboxactions[] = Horde::widget(array('url' => $clink->copy()->add(array('actionID' => 'template_new')), 'title' => _("Create New Template"))); } $a_view->mboxactions = $mboxactions; if ($registry->hasMethod('mail/blacklistFrom')) { $a_view->blacklist = Horde::widget(array('url' => '#', 'class' => 'blacklistAction', 'title' => _("_Blacklist"))); } if ($registry->hasMethod('mail/whitelistFrom')) { $a_view->whitelist = Horde::widget(array('url' => '#', 'class' => 'whitelistAction', 'title' => _("_Whitelist"))); } if (IMP_Compose::canCompose()) { $a_view->forward = Horde::widget(array('url' => '#', 'class' => 'forwardAction', 'title' => _("Fo_rward"))); $a_view->redirect = Horde::widget(array('url' => '#', 'class' => 'redirectAction', 'title' => _("Redirect"))); } if ($mailbox->spam_show) { $a_view->spam = Horde::widget(array('url' => '#', 'class' => 'spamAction', 'title' => _("Report as Spam"))); } if ($mailbox->innocent_show) { $a_view->innocent = Horde::widget(array('url' => '#', 'class' => 'innocentAction', 'title' => _("Report as Innocent"))); } $a_view->view_messages = Horde::widget(array('url' => '#', 'class' => 'viewAction', 'title' => _("View Messages"))); $this->output .= $a_view->render('actions'); } /* Define some variables now so we don't have to keep redefining in * the foreach loop or the templates. */ $lastMbox = ''; $mh_count = 0; $sortImg = $sortpref->sortdir ? 'sortup' : 'sortdown'; $headers = array(Horde_Imap_Client::SORT_TO => array('id' => 'mboxto', 'stext' => _("Sort by To Address"), 'text' => _("To")), Horde_Imap_Client::SORT_FROM => array('id' => 'mboxfrom', 'stext' => _("Sort by From Address"), 'text' => _("Fro_m")), Horde_Imap_Client::SORT_THREAD => array('id' => 'mboxthread', 'stext' => _("Sort by Thread"), 'text' => _("_Thread")), Horde_Imap_Client::SORT_SUBJECT => array('id' => 'mboxsubject', 'stext' => _("Sort by Subject"), 'text' => _("Sub_ject")), IMP::IMAP_SORT_DATE => array('id' => 'mboxdate', 'stext' => _("Sort by Date"), 'text' => _("Dat_e")), Horde_Imap_Client::SORT_SIZE => array('id' => 'mboxsize', 'stext' => _("Sort by Message Size"), 'text' => _("Si_ze"))); /* If this is the Drafts or Sent-Mail mailbox, sort by To instead of * From. */ if ($mailbox->special_outgoing) { unset($headers[Horde_Imap_Client::SORT_FROM]); } else { unset($headers[Horde_Imap_Client::SORT_TO]); } /* Determine which of Subject/Thread to emphasize. */ if (!$mailbox->access_sortthread || $sortpref->sortby_locked) { unset($headers[Horde_Imap_Client::SORT_THREAD]); if ($sortpref->sortby_locked && $thread_sort) { $sortpref->sortby = Horde_Imap_Client::SORT_SUBJECT; } } else { if ($thread_sort) { $extra = Horde_Imap_Client::SORT_SUBJECT; $standard = Horde_Imap_Client::SORT_THREAD; } else { $extra = Horde_Imap_Client::SORT_THREAD; $standard = Horde_Imap_Client::SORT_SUBJECT; } $headers[$standard]['altsort'] = Horde::widget(array('url' => $mailbox_imp_url->copy()->add(array('actionID' => 'change_sort', 'token' => $token, 'sortby' => $extra)), 'title' => $headers[$extra]['text'])); unset($headers[$extra]); } foreach ($headers as $key => $val) { $ptr =& $headers[$key]; if ($sortpref->sortby == $key) { $csl_icon = '<span class="iconImg ' . $sortImg . '"></span>'; if ($sortpref->sortdir_locked) { $ptr['change_sort_link'] = $csl_icon; $ptr['change_sort_widget'] = Horde::stripAccessKey($val['text']); } else { $tmp = $mailbox_imp_url->copy()->add(array('sortby' => $key, 'sortdir' => intval(!$sortpref->sortdir), 'actionID' => 'change_sort', 'token' => $token)); $ptr['change_sort_link'] = Horde::link($tmp, $val['stext'], null, null, null, $val['stext']) . $csl_icon . '</a>'; $ptr['change_sort_widget'] = Horde::widget(array('url' => $tmp, 'title' => $val['text'])); } } else { $ptr['change_sort_link'] = null; $ptr['change_sort_widget'] = $sortpref->sortby_locked ? Horde::stripAccessKey($val['text']) : Horde::widget(array('url' => $mailbox_imp_url->copy()->add(array('actionID' => 'change_sort', 'token' => $token, 'sortby' => $key)), 'title' => $val['text'])); } $ptr['class'] = 'horde-split-left'; } /* Output the form start. */ $f_view = clone $view; $f_view->mailbox = $mailbox->form_to; $f_view->mailbox_url = $mailbox_url; $f_view->page = $pageOb['page']; $f_view->token = $token; $this->output .= $f_view->render('form_start'); /* Prepare the message headers template. */ $mh_view = clone $view; $mh_view->headers = $headers; if (!$search_mbox) { $mh_view->show_checkbox = !$mh_count++; $this->output .= $mh_view->render('message_headers'); } /* Initialize repetitively used variables. */ $fromlinkstyle = $prefs->getValue('from_link'); $imp_ui = new IMP_Mailbox_Ui($mailbox); /* Display message information. */ $msgs = array(); $search_view = clone $view; $summary_view = clone $view; while (list(, $ob) = each($mbox_info['overview'])) { if ($search_mbox) { if (empty($lastMbox) || $ob['mailbox'] != $lastMbox) { if (!empty($lastMbox)) { $this->_outputSummaries($msgs, $summary_view); $msgs = array(); } $mbox = IMP_Mailbox::get($ob['mailbox']); $search_view->mbox_link = Horde::link($mbox->url($mailbox_url), sprintf(_("View messages in %s"), $mbox->display), 'smallheader') . $mbox->display_html . '</a>'; $this->output .= $search_view->render('searchmbox'); $mh_view->show_checkbox = !$mh_count++; $this->output .= $mh_view->render('message_headers'); } } $lastMbox = $ob['mailbox']; /* Initialize the data fields. */ $msg = array('bg' => '', 'buid' => $imp_mailbox->getBuid($ob['mailbox'], $ob['uid']), 'class' => '', 'date' => $imp_ui->getDate($ob['envelope']->date), 'preview' => '', 'status' => '', 'size' => IMP::sizeFormat($ob['size'])); /* Generate the target link. */ if ($mailbox->drafts || $mailbox->templates) { $clink_copy = clone $clink_ob; $clink_copy->args['buid'] = $msg['buid']; $clink_copy->args['mailbox'] = $mailbox; $target = $clink_copy->link()->add(array('actionID' => $mailbox->drafts ? 'draft' : 'template')); } else { $target = $mailbox->url('message', $msg['buid']); } /* Get all the flag information. */ $flag_parse = $imp_flags->parse(array('flags' => $ob['flags'], 'headers' => $ob['headers'], 'runhook' => $ob, 'personal' => $ob['envelope']->to)); $css_class = $subject_flags = array(); foreach ($flag_parse as $val) { if ($val instanceof IMP_Flag_User) { $subject_flags[] = $val; } else { if (!$val->bgdefault) { $msg['bg'] = $val->bgcolor; } $css_class[] = $val->css; $msg['status'] .= $val->span; } } $msg['class'] = implode(' ', $css_class); /* Show message preview? */ if ($show_preview && isset($ob['preview'])) { if (empty($ob['preview'])) { $ptext = '[[' . _("No Preview Text") . ']]'; } else { $ptext = empty($strip_preview) ? str_replace("\r", '', $ob['preview']) : preg_replace(array('/\\n/', '/(\\s)+/'), array(' ', '$1'), str_replace("\r", "\n", $ob['preview'])); if (!$preview_tooltip) { $ptext = $injector->getInstance('Horde_Core_Factory_TextFilter')->filter($ptext, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::NOHTML)); } $maxlen = $prefs->getValue('preview_maxlen'); if (Horde_String::length($ptext) > $maxlen) { $ptext = Horde_String::truncate($ptext, $maxlen); } elseif (empty($ob['previewcut'])) { $ptext .= '[[' . _("END") . ']]'; } } $msg['preview'] = $ptext; } /* Format the From: Header. */ $getfrom = $imp_ui->getFrom($ob['envelope']); $msg['from'] = htmlspecialchars($getfrom['from'], ENT_QUOTES, 'UTF-8'); switch ($fromlinkstyle) { case 0: $from_tmp = array(); foreach ($getfrom['from_list']->base_addresses as $from_ob) { $from_tmp[] = call_user_func_array(array('Horde', $preview_tooltip ? 'linkTooltip' : 'link'), array($clink->copy()->add(array('actionID' => 'mailto_link', 'to' => strval($from_ob))), sprintf(_("New Message to %s"), $from_ob->label))) . htmlspecialchars($from_ob->label, ENT_QUOTES, 'UTF-8') . '</a>'; } if (!empty($from_tmp)) { $msg['from'] = implode(', ', $from_tmp); } break; default: $from_uri = $mailbox->url('message', $msg['buid']); $msg['from'] = Horde::link($from_uri) . $msg['from'] . '</a>'; break; } /* Format the Subject: Header. */ $msg['subject'] = $imp_ui->getSubject($ob['envelope']->subject, true); $msg['subject'] = $preview_tooltip ? substr(Horde::linkTooltip($target, $msg['preview'], '', '', '', $msg['preview']), 0, -1) . ' class="mboxSubject">' . $msg['subject'] . '</a>' : substr(Horde::link($target, $imp_ui->getSubject($ob['envelope']->subject)), 0, -1) . ' class="mboxSubject">' . $msg['subject'] . '</a>' . (!empty($msg['preview']) ? '<br /><small>' . $msg['preview'] . '</small>' : ''); /* Add subject flags. */ foreach ($subject_flags as $val) { $flag_label = Horde_String::truncate($val->label, 12); $msg['subject'] = '<span class="' . $val->css . '" style="' . ($val->bgdefault ? '' : 'background:' . htmlspecialchars($val->bgcolor) . ';') . 'color:' . htmlspecialchars($val->fgcolor) . '" title="' . htmlspecialchars($val->label) . '">' . htmlspecialchars($flag_label) . '</span>' . $msg['subject']; } /* Set up threading tree now. */ if ($thread_sort) { $t_ob = $imp_mailbox->getThreadOb($ob['idx']); $msg['subject'] = ($sortpref->sortdir ? $t_ob->reverse_img : $t_ob->img) . ' ' . $msg['subject']; } $msgs[$msg['buid']] = $msg; } $this->_outputSummaries($msgs, $summary_view); $this->output .= '</form>'; /* If there are 20 messages or less, don't show the actions/navbar * again. */ if ($pageOb['end'] - $pageOb['begin'] >= 20) { $this->output .= $a_view->render('actions'); $n_view->id = 2; $this->output .= $n_view->render('navbar'); } }
/** * @throws IMP_Exception */ protected function _init() { global $conf, $injector, $notification, $page_output; if (!$this->indices) { throw new IMP_Exception(_("No message index given.")); } $page_output->addScriptFile('message-dimp.js'); $page_output->addScriptFile('textarearesize.js', 'horde'); $page_output->addScriptFile('toggle_quotes.js', 'horde'); $page_output->addScriptPackage('IMP_Script_Package_Imp'); $js_vars = array(); switch ($this->vars->actionID) { case 'strip_attachment': try { $this->indices = new IMP_Indices_Mailbox($this->indices->mailbox, $injector->getInstance('IMP_Message')->stripPart($this->indices, $this->vars->id)); $js_vars['-DimpMessage.strip'] = 1; $notification->push(_("Attachment successfully stripped."), 'horde.success'); } catch (IMP_Exception $e) { $notification->push($e); } break; } try { $show_msg = new IMP_Ajax_Application_ShowMessage($this->indices); $msg_res = $show_msg->showMessage(array('headers' => array_diff(array_keys($injector->getInstance('IMP_Message_Ui')->basicHeaders()), array('subject')), 'preview' => false)); } catch (IMP_Exception $e) { $notification->notify(array('listeners' => array('status', 'audio'))); echo Horde::wrapInlineScript(array('parent.close()')); exit; } $ajax_queue = $injector->getInstance('IMP_Ajax_Queue'); $ajax_queue->poll($this->indices->mailbox); list(, $buid) = $this->indices->buids->getSingle(); foreach (array('from', 'to', 'cc', 'bcc', 'replyTo', 'log') as $val) { if (!empty($msg_res[$val])) { $js_vars['DimpMessage.' . $val] = $msg_res[$val]; } } if (!empty($msg_res['list_info']['exists'])) { $js_vars['DimpMessage.reply_list'] = true; $this->view->listinfo = Horde::popupJs(IMP_Basic_Listinfo::url(array('buid' => $buid, 'mailbox' => $this->indices->mailbox)), array('urlencode' => true)); } $js_vars['DimpMessage.buid'] = $buid; $js_vars['DimpMessage.mbox'] = $this->indices->mailbox->form_to; $js_vars['DimpMessage.tasks'] = $injector->getInstance('Horde_Core_Factory_Ajax')->create('imp', $this->vars)->getTasks(); $page_output->addInlineJsVars($js_vars); if (isset($msg_res['js'])) { $page_output->addInlineScript(array_filter($msg_res['js']), true); } $this->_pages[] = 'message'; /* Determine if compose mode is disabled. */ if (IMP_Compose::canCompose()) { $this->view->qreply = $injector->getInstance('IMP_Dynamic_Compose_Common')->compose($this, array('title' => _("Message") . ': ' . $msg_res['subject'])); $this->_pages[] = 'qreply'; $this->js_conf['qreply'] = 1; } $page_output->noDnsPrefetch(); $this->view->show_delete = $this->indices->mailbox->access_deletemsgs; list($real_mbox, ) = $this->indices->getSingle(); $this->view->show_innocent = $real_mbox->innocent_show; $this->view->show_spam = $real_mbox->spam_show; $this->view->show_view_all = empty($msg_res['onepart']); $this->view->show_view_source = !empty($conf['user']['allow_view_source']); $this->view->save_as = $msg_res['save_as']; $this->view->subject = isset($msg_res['subjectlink']) ? $msg_res['subjectlink'] : $msg_res['subject']; $hdrs = array(); foreach ($msg_res['headers'] as $val) { $hdrs[] = array_filter(array('id' => isset($val['id']) ? 'msgHeader' . $val['id'] : null, 'label' => $val['name'], 'val' => $val['value'])); } $this->view->hdrs = $hdrs; if (isset($msg_res['atc_label'])) { $this->view->atc_label = $msg_res['atc_label']; if (isset($msg_res['atc_list'])) { $this->view->atc_list = $msg_res['atc_list']; } else { $this->view->atc_list = array(); } if (isset($msg_res['atc_download'])) { $this->view->atc_download = $msg_res['atc_download']; } } else { $this->view->atc_list = array(); } $this->view->msgtext = $msg_res['msgtext']; Horde::startBuffer(); $notification->notify(array('listeners' => array('status', 'audio'))); $this->view->status = Horde::endBuffer(); $this->title = $msg_res['title']; $this->view->title = $this->title; }
/** * Save/update image geotag. * * @return object Object with 2 parameters: * - message * - response */ public function imageSaveGeotag() { global $injector, $registry; $type = $this->vars->action; $location = $this->vars->location; $lat = $this->vars->lat; $lng = $this->vars->lng; $img = $this->vars->img; $result = new stdClass(); $result->response = 0; if (empty($img) || $type == 'location' && empty($location) || (empty($type) || $type == 'all') && ($type == 'all' && empty($lat))) { return new Horde_Core_Ajax_Response_Prototypejs($result); } // Get the image and gallery to check perms try { $ansel_storage = $injector->getInstance('Ansel_Storage'); $image = $ansel_storage->getImage((int) $img); $gallery = $ansel_storage->getGallery($image->gallery); } catch (Ansel_Exception $e) { return new Horde_Core_Ajax_Response_Prototypejs($result); } // Bail out if no perms on the image. if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { return new Horde_Core_Ajax_Response_Prototypejs($result); } switch ($type) { case 'geotag': $image->geotag($lat, $lng, !empty($location) ? $location : ''); $result->response = 1; break; case 'location': $image->location = !empty($location) ? urldecode($location) : ''; $image->save(); $result->response = 1; $result->message = htmlentities($image->location); break; case 'untag': $image->geotag('', '', ''); // Now get the "add geotag" stuff $addurl = Horde::url('map_edit.php')->add('image', $img); $addLink = $addurl->link(array('onclick' => Horde::popupJs(Horde::url('map_edit.php'), array('params' => array('image' => $img), 'urlencode' => true, 'width' => '750', 'height' => '600')) . 'return false;')); $imgs = $ansel_storage->getRecentImagesGeodata($registry->getAuth()); if (count($imgs) > 0) { $imgsrc = '<div class="ansel_location_sameas">'; foreach ($imgs as $id => $data) { $title = empty($data['image_location']) ? Ansel::point2Deg($data['image_latitude'], true) . ' ' . Ansel::point2Deg($data['image_longitude']) : $data['image_location']; $imgsrc .= $addurl->link(array('title' => $title, 'onclick' => "Ansel.widgets.geotag.setLocation('" . $data['image_latitude'] . "', '" . $data['image_longitude'] . "');return false")) . '<img src="' . Ansel::getImageUrl($id, 'mini', true) . '" alt="[image]" /></a>'; } $imgsrc .= '</div>'; $result->message = sprintf(_("No location data present. Place using %smap%s or click on image to place at the same location."), $addLink, '</a>') . $imgsrc; } else { $result->message = sprintf(_("No location data present. You may add some %s."), $addLink . _("here") . '</a>'); } $result->response = 1; break; } return new Horde_Core_Ajax_Response_Prototypejs($result); }
/** * Callback for Horde_Url when generating javascript compose links. * * @param Horde_Url $url URL object. * * @return string URL string representation. */ public function composeLinkJsCallback($url) { return 'javascript:' . Horde::popupJs(strval($url), array('urlencode' => true)); }
/** * Helper function for generating the gallery actions selection widget. * * @param Horde_View $view The view object. */ protected function _getGalleryActions(&$view) { global $registry, $conf; $id = $this->_view->gallery->id; $galleryurl = Horde::url('gallery.php')->add('gallery', $id); $selfurl = Horde::selfUrl(true, false, true); $view->count = $count = $this->_view->gallery->countImages(); $date = $this->_view->gallery->getDate(); // Buid the url parameters to the zip link $view_params = array('gallery' => $this->_view->gallery->id, 'view' => 'Gallery', 'slug' => $this->_view->gallery->get('slug'), 'page' => !empty($this->_view->_params['page']) ? $this->_view->_params['page'] : 0); // Append the date information to the parameters if we need it $view_params = array_merge($view_params, $date); // Bookmark link if ($registry->hasMethod('bookmarks/getAddUrl')) { $api_params = array('url' => Ansel::getUrlFor('view', $view_params, true), 'title' => $this->_view->gallery->get('name')); try { $view->bookmark_url = new Horde_Url($registry->bookmarks->getAddUrl($api_params)); } catch (Horde_Exception $e) { } } // Download as ZIP link if (!empty($conf['gallery']['downloadzip']) && $this->_view->gallery->canDownload() && $count && $this->_view->gallery->hasFeature('zipdownload')) { $zip_params = array_merge(array('actionID' => 'downloadzip'), $date); $view->zip_url = $galleryurl->copy()->add($zip_params)->link(array('class' => 'widget')); } // Image upload, subgalleries, captions etc.. if ($this->_view->gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { $view->hasEdit = true; $view->properties_url = $galleryurl->copy()->add(array('actionID' => 'modify', 'url' => $selfurl))->link(array('class' => 'widget')); if ($count) { if ($this->_view->gallery->hasFeature('image_captions')) { $params = array_merge(array('gallery' => $id), $date); $view->captions_url = Horde::url('gallery/captions.php')->add($params)->link(array('class' => 'widget')); } if ($this->_view->gallery->hasFeature('sort_images')) { $view->sort_url = Horde::url('gallery/sort.php')->add(array_merge(array('gallery' => $id), $date))->link(array('class' => 'widget')); $view->resetsort_url = Horde::url('gallery/sort.php')->add(array_merge(array('gallery' => $id, 'action' => 'Reset'), $date))->link(array('class' => 'widget')); } $view->regenerate_url = $galleryurl->copy()->add(array('actionID' => 'generateThumbs'))->link(array('class' => 'widget')); $view->regenerate_all = $galleryurl->copy()->add(array('actionID' => 'deleteCache'))->link(array('class' => 'widget')); if ($conf['faces']['driver'] && $conf['faces']['driver'] !== 'user' && $this->_view->gallery->hasFeature('faces')) { $view->faces_url = Horde::url('faces/gallery.php')->add(array_merge($date, array('gallery' => $id, 'page' => !empty($this->_view->_params['page']) ? $this->_view->_params['page'] : 0)))->link(array('class' => 'widget')); } } if ($this->_view->gallery->hasFeature('stacks')) { $view->gendefault_url = $galleryurl->copy()->add(array('actionID' => 'generateDefault', 'url' => $selfurl))->link(array('class' => 'widget')); } } if ($registry->getAuth() && $this->_view->gallery->get('owner') == $registry->getAuth()) { $url = new Horde_Url('#'); $view->perms_link = $url->link(array('class' => 'popup widget', 'onclick' => Horde::popupJs(Horde::url('perms.php'), array('params' => array('cid' => $this->_view->gallery->id), 'urlencode' => true)) . 'return false;')); } elseif (!empty($conf['report_content']['driver']) && ($conf['report_content']['allow'] == 'authenticated' && $registry->isAuthenticated() || $conf['report_content']['allow'] == 'all')) { $view->report_url = Horde::url('report.php')->add('gallery', $id)->link(array('class' => 'widget')); } if ($this->_view->gallery->hasPermission($registry->getAuth(), Horde_Perms::DELETE)) { $view->have_delete = true; $view->deleteall_url = $galleryurl->copy()->add('actionID', 'empty')->link(array('class' => 'widget')); $view->deletegallery_url = $galleryurl->copy()->add('actionID', 'delete')->link(array('class' => 'widget')); } }