Example #1
0
 public function login()
 {
     $auth = $GLOBALS['registry']->getAuth();
     if (!empty($auth)) {
         $this->urlFor(array('controller' => 'index', 'action' => 'index'))->redirect();
     }
     $this->title = _("Login");
     $this->post = $this->urlFor(array('controller' => 'index', 'action' => 'login'));
     if (isset($_POST['horde_user']) && isset($_POST['horde_pass'])) {
         /* Destroy any existing session on login and make sure to use a
          * new session ID, to avoid session fixation issues. */
         $GLOBALS['registry']->getCleanSession();
         if ($this->koward->auth->authenticate(Horde_Util::getPost('horde_user'), array('password' => Horde_Util::getPost('horde_pass')))) {
             $entry = sprintf('Login success for %s [%s] to Horde', $GLOBALS['registry']->getAuth(), $_SERVER['REMOTE_ADDR']);
             Horde::log($entry, 'NOTICE');
             $type = $this->koward->getType();
             if (!empty($type) && isset($this->koward->objects[$type]['default_view'])) {
                 $url = $this->urlFor($this->koward->objects[$type]['default_view']);
             } else {
                 if (isset($this->koward->conf['koward']['default_view'])) {
                     $url = $this->urlFor($this->koward->conf['koward']['default_view']);
                 } else {
                     $url = $this->urlFor(array('controller' => 'index', 'action' => 'index'));
                 }
             }
             $url->redirect();
         }
         $entry = sprintf('FAILED LOGIN for %s [%s] to Horde', Horde_Util::getFormData('horde_user'), $_SERVER['REMOTE_ADDR']);
         Horde::log($entry, 'ERR');
     }
     if ($reason = $this->koward->auth->getLogoutReasonString()) {
         $this->koward->notification->push(str_replace('<br />', ' ', $reason), 'horde.message');
     }
 }
Example #2
0
 /**
  * Any application specific tests that need to be done.
  *
  * @return string  HTML output.
  */
 public function appTests()
 {
     $ret = '<h1>LDAP Support Test</h1>';
     $params = array('server' => Horde_Util::getPost('server'), 'port' => Horde_Util::getPost('port', 389), 'basedn' => Horde_Util::getPost('basedn'), 'user' => Horde_Util::getPost('user'), 'passwd' => Horde_Util::getPost('passwd'), 'filter' => Horde_Util::getPost('filter'), 'proto' => Horde_Util::getPost('proto'));
     if (!empty($params['server']) && !empty($params['basedn']) && !empty($params['filter'])) {
         $ret .= $this->_doConnectionTest($params);
     }
     $self_url = Horde::selfUrl()->add('app', 'turba');
     Horde::startBuffer();
     require TURBA_TEMPLATES . '/test/ldapserver.inc';
     return $ret . Horde::endBuffer();
 }
Example #3
0
 /**
  * Populate this slice from a time entry form.
  * Assumes the values are POSTed.
  */
 public function readForm()
 {
     // Required
     $this->_properties['date'] = Hermes::parseDate(Horde_Util::getPost('start_date'));
     $this->_properties['hours'] = Horde_Util::getPost('hours');
     $this->_properties['description'] = Horde_Util::getPost('description');
     $this->_properties['id'] = Horde_Util::getPost('id', 0);
     $this->_properties['billable'] = Horde_Util::getPost('billable') ? 1 : 0;
     // Optional
     $client = Horde_Util::getPost('client');
     $this->_properties['client'] = empty($client) ? '' : $client;
     $this->_properties['type'] = Horde_Util::getPost('type');
     $this->_properties['costobject'] = Horde_Util::getPost('costobject');
     $this->_properties['note'] = Horde_Util::getPost('notes');
     // Admin only
     if ($GLOBALS['registry']->isAdmin(array('permission' => 'hermes:timeadmin')) || $GLOBALS['injector']->getInstance('Horde_Perms')->hasPermission('hermes:review', $GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
         $this->_properties['employee'] = Horde_Util::getPost('employee');
         if (empty($this->_properties['employee'])) {
             $this->_properties['employee'] = $GLOBALS['registry']->getAuth();
         }
     } else {
         $this->_properties['employee'] = $GLOBALS['registry']->getAuth();
     }
 }
Example #4
0
<?php

/**
 * Copyright 2007-2014 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (LGPL-2). If you
 * did not receive this file, see http://www.horde.org/licenses/lgpl.
 *
 * @author   Jan Schneider <*****@*****.**>
 * @category Horde
 * @license  http://www.horde.org/licenses/lgpl LGPL-2
 * @package  Horde
 */
require_once __DIR__ . '/../lib/Application.php';
Horde_Registry::appInit('horde', array('nologintasks' => true));
$alarm = $injector->getInstance('Horde_Alarm');
$id = Horde_Util::getPost('alarm');
$snooze = Horde_Util::getPost('snooze');
if ($id && $snooze) {
    try {
        $alarm->snooze($id, $registry->getAuth(), (int) $snooze);
    } catch (Horde_Alarm_Exception $e) {
        header('HTTP/1.0 500 ' . $e->getMessage());
    }
} else {
    header('HTTP/1.0 400 Bad Request');
}
Example #5
0
        $notification->push($result);
        break;
    }
    $notification->push(_("Password changed."), 'horde.success');
    // reset credentials so user is not forced to relogin
    if ($registry->getAuthCredential('password') == $info['old']) {
        $registry->setAuthCredential('password', $info['new']);
    }
} while (false);
// update password reminder prefs
if (Horde_Util::getPost('formname') == 'security') {
    if ($prefs->getValue('security_question') != Horde_Util::getPost('security_question')) {
        $prefs->setValue('security_question', Horde_Util::getPost('security_question'));
    }
    if ($prefs->getValue('security_answer') != Horde_Util::getPost('security_answer')) {
        $prefs->setValue('security_answer', Horde_Util::getPost('security_answer'));
    }
    $notification->push(_("Your securiy questions was updated."), 'horde.success');
}
$form_security = new Horde_Form($vars, _("Security question used when reseting password"), 'security');
$form_security->setButtons(_("Continue"), _("Reset"));
if (!$prefs->isLocked('security_question')) {
    $v = $form_security->addVariable(_("Security question"), 'security_question', 'text', true);
    $v->setDefault($prefs->getValue('security_question'));
}
$v = $form_security->addVariable(_("Security answer"), 'security_answer', 'text', true);
$v->setDefault($prefs->getValue('security_answer'));
$page_output->header(array('title' => $title));
require FOLKS_TEMPLATES . '/menu.inc';
echo $tabs->render('password');
$form->renderActive(null, null, null, 'post');
Example #6
0
 /**
  */
 public function update(Horde_Core_Prefs_Ui $ui)
 {
     global $injector, $notification, $registry;
     $auth = $registry->getAuth();
     $state = $injector->getInstance('Horde_ActiveSyncState');
     $state->setLogger($injector->getInstance('Horde_Log_Logger'));
     try {
         if ($ui->vars->wipeid) {
             if (!$state->deviceExists($ui->vars->wipeid, $auth)) {
                 throw new Horde_Exception_PermissionDenied();
             }
             $state->setDeviceRWStatus($ui->vars->wipeid, Horde_ActiveSync::RWSTATUS_PENDING);
             $notification->push(sprintf(_("A remote wipe for device id %s has been initiated. The device will be wiped during the next synchronisation."), $ui->vars->wipe));
         } elseif ($ui->vars->cancelwipe) {
             if (!$state->deviceExists($ui->vars->cancelwipe, $auth)) {
                 throw new Horde_Exception_PermissionDenied();
             }
             $state->setDeviceRWStatus($ui->vars->cancelwipe, Horde_ActiveSync::RWSTATUS_OK);
             $notification->push(sprintf(_("The Remote Wipe for device id %s has been cancelled."), $ui->vars->wipe));
         } elseif ($ui->vars->reset) {
             $devices = $state->listDevices($auth);
             foreach ($devices as $device) {
                 $state->removeState(array('devId' => $device['device_id'], 'user' => $auth));
             }
             $notification->push(_("All state removed for your ActiveSync devices. They will resynchronize next time they connect to the server."));
         } elseif ($ui->vars->removedevice) {
             $state->removeState(array('devId' => $ui->vars->removedevice, 'user' => $auth));
             $notification->push(sprintf(_("The state for device id %s has been reset. It will resynchronize next time it connects to the server."), $ui->vars->removedevice));
         }
     } catch (Horde_ActiveSync_Exception $e) {
         $notification->push(_("There was an error communicating with the ActiveSync server: %s"), $e->getMessage(), 'horde.err');
     }
     $GLOBALS['prefs']->setValue('activesync_identity', Horde_Util::getPost('activesync_identity'));
     return false;
 }
Example #7
0
<?php

require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('nag');
if ($quickText = Horde_Util::getPost('quickText')) {
    try {
        $result = Nag::createTasksFromText($quickText, Nag::getDefaultTasklist(Horde_Perms::EDIT));
    } catch (Nag_Exception $e) {
        $notification->push($e->getMessage());
    }
    if ($result) {
        $notification->push(sprintf(ngettext("Added %d task", "Added %d tasks", count($result)), count($result)), 'horde.success');
    } else {
        $notification->push(_("No tasks have been added."), 'horde.warning');
    }
} else {
    $notification->push(_("No tasks have been added."), 'horde.warning');
}
Horde::url('list.php', true)->redirect();
Example #8
0
 public function handleAction()
 {
     global $notification;
     $page = Wicked_Page::getPage($this->referrer());
     if ($page->allows(Wicked::MODE_EDIT)) {
         $version = Horde_Util::getPost('version');
         if (empty($version)) {
             $notification->push(sprintf(_("Can't revert to an unknown version.")), 'horde.error');
             Wicked::url($this->referrer(), true)->redirect();
         }
         $oldpage = Wicked_Page::getPage($this->referrer(), $version);
         $page->updateText($oldpage->getText(), 'Revert');
         $notification->push(sprintf(_("Reverted to version %s of \"%s\"."), $version, $page->pageName()));
         Wicked::url($page->pageName(), true)->redirect();
     }
     $notification->push(sprintf(_("You don't have permission to edit \"%s\"."), $page->pageName()), 'horde.warning');
     Wicked::url($this->referrer(), true)->redirect();
 }
Example #9
0
 * Copyright 2008-2014 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.horde.org/licenses/gpl.
 *
 * @author Duck <*****@*****.**>
 */
require_once __DIR__ . '/../lib/Application.php';
Horde_Registry::appInit('ansel');
$image_id = (int) Horde_Util::getFormData('image_id');
$gallery_id = (int) Horde_Util::getFormData('gallery_id');
$face_id = (int) Horde_Util::getFormData('face_id');
$url = Horde_Util::getFormData('url');
$page = Horde_Util::getFormData('page', 0);
$back_url = empty($url) ? Horde::url('faces/gallery.php')->add(array('gallery' => $gallery_id, 'page' => $page))->setRaw(true) : new Horde_Url($url);
if (Horde_Util::getPost('submit') == _("Cancel")) {
    $notification->push(_("Changes cancelled."), 'horde.warning');
    $back_url->redirect();
    exit;
}
try {
    $faces = $GLOBALS['injector']->getInstance('Ansel_Faces');
    $result = $faces->saveCustomFace($face_id, $image_id, (int) Horde_Util::getFormData('x1'), (int) Horde_Util::getFormData('y1'), (int) Horde_Util::getFormData('x2'), (int) Horde_Util::getFormData('y2'), Horde_Util::getFormData('name'));
} catch (Ansel_Exception $e) {
    $notification->push($e->getMessage());
    $back_url->redirect();
    exit;
}
if ($face_id == 0) {
    $notification->push(_("Face successfuly created"), 'horde.success');
} else {
Example #10
0
            $device->blocked = true;
            $device->save(false);
            break;
        case 'unblock':
            $device = $state->loadDeviceInfo($deviceID);
            $device->blocked = false;
            $device->save(false);
            break;
    }
}
switch (Horde_Util::getPost('searchBy')) {
    case 'username':
        $devices = $state->listDevices(Horde_Util::getPost('searchInput'));
        break;
    default:
        $devices = $state->listDevices(null, array(Horde_Util::getPost('searchBy') => Horde_Util::getPost('searchInput')));
}
$view = new Horde_View(array('templatePath' => array(HORDE_TEMPLATES . '/admin', HORDE_TEMPLATES . '/activesync')));
$view->addHelper('Tag');
$selfurl = Horde::selfUrl();
$view->reset = $selfurl->copy()->add('reset', 1);
$devs = array();
$js = array();
$collections = array();
foreach (array_values($devices) as $device) {
    $dev = $state->loadDeviceInfo($device['device_id'], $device['device_user']);
    try {
        $dev = $GLOBALS['injector']->getInstance('Horde_Core_Hooks')->callHook('activesync_device_modify', 'horde', array($dev));
    } catch (Horde_Exception_HookNotSet $e) {
    }
    $syncCache = new Horde_ActiveSync_SyncCache($state, $dev->id, $dev->user, $injector->getInstance('Horde_Log_Logger'));
Example #11
0
/**
 * Process an single image (to be called via Ajax)
 *
 * Copyright 2008-2015 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.horde.org/licenses/gpl.
 *
 * @author Duck <*****@*****.**>
 */
require_once __DIR__ . '/../lib/Application.php';
Horde_Registry::appInit('ansel');
$faces = $GLOBALS['injector']->getInstance('Ansel_Faces');
$name = '';
$image_id = (int) Horde_Util::getPost('image');
$reload = (int) Horde_Util::getPost('reload');
$results = $faces->getImageFacesData($image_id);
// Attempt to get faces from the picture if we don't already have results,
// or if we were asked to explicitly try again.
if ($reload || empty($results)) {
    $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($image_id);
    try {
        $image->createView('screen', null, $GLOBALS['prefs']->getValue('watermark_auto') ? $GLOBALS['prefs']->getValue('watermark_text', '') : '');
        $results = $faces->getFromPicture($image_id, true);
    } catch (Ansel_Exception $e) {
        Horde::log($e, 'ERR');
        $results = null;
    }
}
if (!empty($results)) {
    $customurl = Horde::url('faces/custom.php');
Example #12
0
 public function handleAction()
 {
     global $notification, $wicked;
     if (!$this->allows(Wicked::MODE_EDIT)) {
         $notification->push(sprintf(_("You don't have permission to create \"%s\"."), $this->referrer()));
     } else {
         if (!empty($GLOBALS['conf']['wicked']['captcha']) && !$GLOBALS['registry']->getAuth() && Horde_String::lower(Horde_Util::getFormData('wicked_captcha')) != Horde_String::lower(Wicked::getCAPTCHA())) {
             $notification->push(_("Random string did not match."), 'horde.error');
             return;
         }
         $text = Horde_Util::getPost('page_text');
         if (empty($text)) {
             $notification->push(_("Pages cannot be empty."), 'horde.error');
             return;
         }
         try {
             $result = $wicked->newPage($this->referrer(), $text);
             $notification->push(_("Page Created"), 'horde.success');
         } catch (Wicked_Exception $e) {
             $notification->push(sprintf(_("Create Failed: %s"), $e->getMessage()), 'horde.error');
         }
     }
     // Show the newly created page.
     Wicked::url($this->referrer(), true)->redirect();
 }
Example #13
0
    if (empty($url_param)) {
        $url_param = Folks::getUrlFor('user', $_COOKIE['folks_login_user']);
    }
    header('Location: ' . $url_param);
    exit;
}
/*
 * Form
 */
$title = sprintf(_("Login to %s"), $registry->get('name', 'horde'));
$vars = Horde_Variables::getDefaultVariables();
$form = new Folks_Login_Form($vars, $title, 'folks_login');
/*
 * Check time between one login and anther
 */
$username = Horde_String::lower(trim(Horde_Util::getPost('username')));
if ($username && $conf['login']['diff']) {
    $last_try = $cache->get('login_last_try_' . $username, $conf['cache']['default_lifetime']);
    if ($last_try && $_SERVER['REQUEST_TIME'] - $last_try <= $conf['login']['diff']) {
        $notification->push(_("You are entering your data too fast!"));
        header('Location: ' . $login_url);
        exit;
    } else {
        $cache->set('login_last_try_' . $username, $_SERVER['REQUEST_TIME']);
    }
}
/*
 * Process form
 */
if ($form->isSubmitted()) {
    // check password
Example #14
0
 /**
  * Retrieves the form fields and processes the attachment.
  */
 public function handleAction()
 {
     global $notification, $wicked, $registry, $conf;
     // Only allow POST commands.
     $cmd = Horde_Util::getPost('cmd');
     $version = Horde_Util::getFormData('version');
     $is_update = (bool) Horde_Util::getFormData('is_update');
     $filename = Horde_Util::getFormData('filename');
     $change_log = Horde_Util::getFormData('change_log');
     // See if we're supposed to delete an attachment.
     if ($cmd == 'delete' && $filename && $version) {
         if (!$this->allows(Wicked::MODE_REMOVE)) {
             $notification->push(_("You do not have permission to delete attachments from this page."), 'horde.error');
             return;
         }
         try {
             $wicked->removeAttachment($wicked->getPageId($this->referrer()), $filename, $version);
             $notification->push(sprintf(_("Successfully deleted version %s of \"%s\" from \"%s\""), $version, $filename, $this->referrer()), 'horde.success');
         } catch (Wicked_Exception $e) {
             $notification->push($result->getMessage(), 'horde.error');
         }
         return;
     }
     if (empty($filename)) {
         $filename = Horde_Util::dispelMagicQuotes($_FILES['attachment_file']['name']);
     }
     try {
         $GLOBALS['browser']->wasFileUploaded('attachment_file', _("attachment"));
     } catch (Horde_Browser_Exception $e) {
         $notification->push($e, 'horde.error');
         return;
     }
     if (strpos($filename, ' ') !== false) {
         $notification->push(_("Attachments with spaces can't be embedded into a page."), 'horde.warning');
     }
     $data = file_get_contents($_FILES['attachment_file']['tmp_name']);
     if ($data === false) {
         $notification->push(_("Can't read uploaded file."), 'horde.error');
         return;
     }
     if (!$this->allows(Wicked::MODE_EDIT)) {
         $notification->push(sprintf(_("You do not have permission to edit \"%s\""), $this->referrer()), 'horde.error');
         return;
     }
     if ($conf['wicked']['require_change_log'] && empty($change_log)) {
         $notification->push(_("You must enter a change description to attach this file."), 'horde.error');
         return;
     }
     $referrer_id = $wicked->getPageId($this->referrer());
     try {
         $attachments = $wicked->getAttachedFiles($referrer_id);
     } catch (Wicked_Exception $e) {
         $notification->push(sprintf(_("Error retrieving attachments: %s"), $e->getMessage()), 'horde.error');
         return;
     }
     $found = false;
     foreach ($attachments as $attach) {
         if ($filename == $attach['attachment_name']) {
             $found = true;
             break;
         }
     }
     if ($is_update) {
         if (!$found) {
             $notification->push(sprintf(_("Can't update \"%s\": no such attachment."), $filename), 'horde.error');
             return;
         }
     } else {
         if ($found) {
             $notification->push(sprintf(_("There is already an attachment named \"%s\"."), $filename), 'horde.error');
             return;
         }
     }
     $file = array('page_id' => $referrer_id, 'attachment_name' => $filename, 'change_log' => $change_log);
     try {
         $wicked->attachFile($file, $data);
     } catch (Wicked_Exception $e) {
         $notification->push($e);
         Horde::log($e);
         throw $e;
     }
     if ($is_update) {
         $message = sprintf(_("Updated attachment \"%s\" on page \"%s\"."), $filename, $this->referrer());
     } else {
         $message = sprintf(_("New attachment \"%s\" to page \"%s\"."), $filename, $this->referrer());
     }
     $notification->push($message, 'horde.success');
     $url = Wicked::url($this->referrer(), true, -1);
     Wicked::mail($message . ' ' . _("View page: ") . $url . "\n", array('Subject' => '[' . $registry->get('name') . '] attachment: ' . $this->referrer() . ', ' . $filename));
 }
Example #15
0
 * @author   Chuck Hagenbuch <*****@*****.**>
 * @category Horde
 * @license  http://www.horde.org/licenses/lgpl LGPL-2
 * @package  Horde
 */
require_once __DIR__ . '/../lib/Application.php';
Horde_Registry::appInit('horde', array('permission' => array('horde:administration:cmdshell')));
$title = _("Command Shell");
$view = new Horde_View(array('templatePath' => HORDE_TEMPLATES . '/admin'));
$view->addHelper('Horde_Core_View_Helper_Help');
$view->addHelper('Text');
$view->action = Horde::url('admin/cmdshell.php');
$view->command = trim(Horde_Util::getFormData('cmd'));
$view->title = $title;
$view->session = $session;
if ($view->command) {
    $session->checkToken(Horde_Util::getPost('token'));
    $cmds = explode("\n", $view->command);
    $out = array();
    foreach ($cmds as $cmd) {
        $cmd = trim($cmd);
        if (strlen($cmd)) {
            $out[] = shell_exec($cmd);
        }
    }
    $view->out = $out;
}
$page_output->header(array('title' => $title));
require HORDE_TEMPLATES . '/admin/menu.inc';
echo $view->render('cmdshell');
$page_output->footer();
Example #16
0
             $notification->push(_("You must specify the username to update."), 'horde.error');
         } elseif (empty($user_pass_1) || empty($user_pass_2)) {
             // Don't update, but don't complain.
         } elseif ($user_pass_1 != $user_pass_2) {
             $notification->push(_("Passwords must match."), 'horde.error');
         } else {
             try {
                 $auth->updateUser($user_name_1, $user_name_2, array('password' => $user_pass_1));
             } catch (Horde_Auth_Exception $e) {
                 $notification->push(sprintf(_("There was a problem updating \"%s\": %s"), $user_name_1, $e->getMessage()), 'horde.error');
                 break;
             }
         }
     }
     if ($auth->hasCapability('lock')) {
         $user_locked = Horde_Util::getPost('user_locked');
         /* only execute lock/unlock if it would result in a change */
         if ($auth->isLocked($user_name_2) && !$user_locked) {
             $auth->unlockUser($user_name_2);
         } elseif (!$auth->isLocked($user_name_2) && $user_locked) {
             $auth->lockUser($user_name_2);
         }
     }
     $identity = $injector->getInstance('Horde_Core_Factory_Identity')->create($user_name_1);
     $identity->setValue('fullname', $fullname);
     $identity->setValue('from_addr', $email);
     $identity->save();
     $notification->push(sprintf(_("Successfully updated \"%s\""), $user_name_2), 'horde.success');
     break;
 case 'approve_f':
     $thisSignup = $signup->getQueuedSignup($vars->user_name);
Example #17
0
 /**
  * Returns all threads of a forum in a threaded view.
  *
  * @param string  $forum_name     The unique name for the forum.
  * @param boolean $bodies         Whether to include message bodies in the view.
  * @param string  $scope          The application that the specified forum belongs to.
  * @param string  $base_url       An alternate link where edit/delete/reply links
  *                                point to.
  * @param string  $template_file  Template file to use.
  *
  * @return string  The HTML code of the thread view.
  */
 public static function render($forum_name, $scope = 'agora', $base_url = null, $template_file = false)
 {
     $forums = $GLOBALS['injector']->getInstance('Agora_Factory_Driver')->create($scope);
     $forum_id = $forums->getForumId($forum_name);
     if ($forum_id === null) {
         return '';
     }
     $messages = $GLOBALS['injector']->getInstance('Agora_Factory_Driver')->create($scope, $forum_id);
     if ($messages instanceof PEAR_Error) {
         return $messages->getMessage();
     }
     if (($view_bodies = Horde_Util::getPost('bodies')) !== null) {
         $GLOBALS['prefs']->setValue('comments_view_bodies', $view_bodies);
     } else {
         $view_bodies = $GLOBALS['prefs']->getValue('comments_view_bodies');
     }
     if ($messages->_forum['message_count'] == 0) {
         return '';
     }
     $sort_by = Agora::getSortBy('comments');
     $sort_dir = Agora::getSortDir('comments');
     $html = '<div class="header">' . _("Comments") . ' (' . $messages->_forum['message_count'] . ')' . '&nbsp;&nbsp;';
     if (!$GLOBALS['prefs']->isLocked('comments_view_bodies')) {
         $rss = Horde::url('rss/threads.php', true, -1)->add(array('scope' => $scope, 'forum_id' => $forum_id));
         $html .= '<span style="font-size: 0.8em;">';
         $html .= '<form action=' . urldecode($base_url) . ' method="post" name="sorter" style="display: inline;">';
         $html .= _("View") . ' <select name="bodies" onchange="document.sorter.submit()" >';
         $html .= '<option value="2">' . _("Flat") . '</option>';
         $html .= '<option value="1" ' . ($view_bodies == 1 ? 'selected="selected"' : '') . '>' . _("Thread") . '</option>';
         $html .= '</select>';
         if ($view_bodies != '1') {
             $html .= ' ' . _("Sort by") . ' ';
             $html .= '<select name="comments_sortby" onchange="document.sorter.submit()" >';
             $html .= '<option value="message_timestamp" ' . ($sort_by == 'message_timestamp' ? 'selected="selected"' : '') . '>' . _("Date") . '</option>';
             $html .= '<option value="message_author" ' . ($sort_by == 'message_author' ? 'selected="selected"' : '') . '>' . _("Author") . '</option>';
             $html .= '<option value="message_subject" ' . ($sort_by == 'message_subject' ? 'selected="selected"' : '') . '>' . _("Subject") . '</option>';
             $html .= '</select>';
             $html .= ' ' . _("Sort direction") . ' ';
             $html .= '<select name="comments_sortdir" onchange="document.sorter.submit()" >';
             $html .= '<option value="0">' . _("Ascending") . '</option>';
             $html .= '<option value="1" ' . ($sort_dir == 1 ? 'selected="selected"' : '') . '>' . _("Descending") . '</option>';
             $html .= '</select>';
         }
         $html .= '<link rel="alternate" title="' . _("Threads") . '" href="' . $rss . '" type="application/rss+xml" />';
         $html .= ' <a href="' . $rss . '" />RSS</a> ';
         $html .= '</form></span>';
     }
     $html .= '</div>';
     $col_headers = array('message_thread' => _("Subject"), 'message_thread_class_plain' => 'msgThreadPlain', 'message_author' => _("Posted by"), 'message_author_class_plain' => 'msgAuthorPlain', 'message_timestamp' => _("Date"), 'message_timestamp_class_plain' => 'msgTimestampPlain');
     if ($view_bodies == 1) {
         $threads = $messages->getThreads(0, true, 'message_thread', 0, true, '', $base_url);
         $html .= $messages->getThreadsUi($threads, $col_headers, true, $template_file);
     } else {
         $thread_page = Horde_Util::getFormData('comments_page', 0);
         $thread_per_page = $GLOBALS['prefs']->getValue('comments_per_page');
         $thread_start = $thread_page * $thread_per_page;
         if (empty($template_file)) {
             $template_file = 'messages/flat';
         }
         if ($messages->_forum['message_count'] > $thread_per_page && $view_bodies == 2) {
             $vars = new Horde_Variables(array('comments_page' => $thread_page));
             $pager_ob = new Horde_Core_Ui_Pager('comments_page', $vars, array('num' => $messages->_forum['message_count'], 'url' => $base_url, 'perpage' => $thread_per_page));
             $pager_html = $pager_ob->render();
         } else {
             $pager_html = '';
         }
         $threads_list = $messages->getThreads(0, true, $sort_by, $sort_dir, 1, '', $base_url, $thread_start, $thread_per_page);
         if ($threads_list instanceof PEAR_Error) {
             $html .= $threads_list->getDebugInfo();
         } else {
             $html .= $pager_html . $messages->getThreadsUi($threads_list, $col_headers, true, $template_file) . $pager_html;
         }
     }
     return $html;
 }
Example #18
0
<?php

/**
 * Copyright 2001-2015 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.horde.org/licenses/gpl.
 *
 * @author  Jan Schneider <*****@*****.**>
 * @package Kronolith
 */
require_once __DIR__ . '/lib/Application.php';
$app_ob = Horde_Registry::appInit('kronolith');
if (Kronolith::showAjaxView() && !Horde_Util::getPost('import_ajax') || !$conf['menu']['import_export']) {
    Horde::url('', true)->redirect();
}
/* Importable file types. */
$file_types = array('csv' => _("Comma separated values"), 'icalendar' => _("vCalendar/iCalendar"));
/* Templates for the different import steps. */
$templates = array(Horde_Data::IMPORT_CSV => array($registry->get('templates', 'horde') . '/data/csvinfo.inc'), Horde_Data::IMPORT_MAPPED => array($registry->get('templates', 'horde') . '/data/csvmap.inc'), Horde_Data::IMPORT_DATETIME => array($registry->get('templates', 'horde') . '/data/datemap.inc'));
$perms = $GLOBALS['injector']->getInstance('Horde_Core_Perms');
if ($perms->hasAppPermission('max_events') !== true && $perms->hasAppPermission('max_events') <= Kronolith::countEvents()) {
    Horde::permissionDeniedError('kronolith', 'max_events', sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events')));
    $templates[Horde_Data::IMPORT_FILE] = array(KRONOLITH_TEMPLATES . '/data/export.inc');
} else {
    $templates[Horde_Data::IMPORT_FILE] = array(KRONOLITH_TEMPLATES . '/data/import.inc', KRONOLITH_TEMPLATES . '/data/export.inc');
}
/* Initial values. */
$import_step = Horde_Util::getFormData('import_step', 0) + 1;
$actionID = Horde_Util::getFormData('actionID');
$next_step = Horde_Data::IMPORT_FILE;
Example #19
0
 * See the enclosed file LICENSE for license information (ASL).  If you
 * did not receive this file, see http://www.horde.org/licenses/apache.
 *
 * @author Chuck Hagenbuch <*****@*****.**>
 */
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('turba');
$source = Horde_Util::getPost('source');
if ($source === null || !isset($cfgSources[$source])) {
    $notification->push(_("Not found"), 'horde.error');
    Horde::url($prefs->getValue('initial_page'), true)->redirect();
}
$driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
try {
    $contact = $driver->getObject(Horde_Util::getPost('key'));
} catch (Horde_Exception $e) {
    $notification->push($e);
    Horde::url($prefs->getValue('initial_page'), true)->redirect();
}
if (!$contact->isEditable()) {
    $notification->push(_("Permission denied"), 'horde.error');
    Horde::url($prefs->getValue('initial_page'), true)->redirect();
}
$file = Horde_Util::getPost('file');
try {
    $contact->deleteFile($file);
    $notification->push(sprintf(_("The file \"%s\" has been deleted."), $file), 'horde.success');
} catch (Turba_Exception $e) {
    $notification->push($e, 'horde.error');
}
$contact->url('Contact', true)->redirect();
Example #20
0
 public static function galleryActions($actionID)
 {
     global $registry, $notification, $page_output;
     if (self::download($actionID)) {
         return true;
     }
     $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage');
     switch ($actionID) {
         case 'add':
         case 'addchild':
         case 'save':
         case 'modify':
             $view = new Ansel_View_GalleryProperties(array('actionID' => $actionID, 'url' => new Horde_Url(Horde_Util::getFormData('url')), 'gallery' => Horde_Util::getFormData('gallery')));
             $view->run();
             exit;
         case 'downloadzip':
             $galleryId = Horde_Util::getFormData('gallery');
             try {
                 $gallery = $ansel_storage->getGallery($galleryId);
                 if (!$registry->getAuth() || !$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) {
                     $notification->push(_("Access denied downloading photos from this gallery."), 'horde.error');
                     Horde::url('view.php?view=List', true)->redirect();
                     exit;
                 }
                 Ansel::downloadImagesAsZip($gallery);
             } catch (Ansel_Exception $e) {
                 $notification->push($gallery->getMessage(), 'horde.error');
                 Horde::url('view.php?view=List', true)->redirect();
                 exit;
             }
             exit;
         case 'delete':
         case 'empty':
             // Print the confirmation screen.
             $galleryId = Horde_Util::getFormData('gallery');
             if ($galleryId) {
                 try {
                     $gallery = $ansel_storage->getGallery($galleryId);
                     $page_output->header();
                     $notification->notify(array('listeners' => 'status'));
                     require ANSEL_TEMPLATES . '/gallery/delete_confirmation.inc';
                     $page_output->footer();
                     exit;
                 } catch (Ansel_Exception $e) {
                     $notification->push($gallery->getMessage(), 'horde.error');
                 }
             }
             // Return to the gallery list.
             Horde::url(Ansel::getUrlFor('view', array('view' => 'List'), true))->redirect();
             exit;
         case 'do_delete':
         case 'do_empty':
             $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage');
             $galleryId = Horde_Util::getPost('gallery');
             try {
                 $gallery = $ansel_storage->getGallery($galleryId);
             } catch (Ansel_Exception $e) {
                 $notification->push($e->getMessage(), 'horde.error');
                 Ansel::getUrlFor('default_view', array())->redirect();
                 exit;
             }
             switch ($actionID) {
                 case 'do_delete':
                     if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::DELETE)) {
                         $notification->push(_("Access denied deleting this gallery."), 'horde.error');
                     } else {
                         try {
                             $ansel_storage->removeGallery($gallery);
                             $notification->push(sprintf(_("Successfully deleted %s."), $gallery->get('name')), 'horde.success');
                         } catch (Ansel_Exception $e) {
                             $notification->push(sprintf(_("There was a problem deleting %s: %s"), $gallery->get('name'), $e->getMessage()), 'horde.error');
                         } catch (Horde_Exception_NotFound $e) {
                             Horde::log($e, 'err');
                         }
                     }
                     // Return to the default view.
                     Ansel::getUrlFor('default_view', array())->redirect();
                     exit;
                 case 'do_empty':
                     if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::DELETE)) {
                         $notification->push(_("Access denied deleting this gallery."), 'horde.error');
                     } else {
                         $ansel_storage->emptyGallery($gallery);
                         $notification->push(sprintf(_("Successfully emptied \"%s\""), $gallery->get('name')), 'horde.success');
                     }
                     Ansel::getUrlFor('view', array('view' => 'Gallery', 'gallery' => $galleryId, 'slug' => $gallery->get('slug')), true)->redirect();
                     exit;
                 default:
                     Ansel::getUrlFor('view', array('view' => 'Gallery', 'gallery' => $galleryId, 'slug' => $gallery->get('slug')), true)->redirect();
                     exit;
             }
         case 'generateDefault':
             // Re-generate the default pretty gallery image.
             $galleryId = Horde_Util::getFormData('gallery');
             try {
                 $gallery = $ansel_storage->getGallery($galleryId);
                 $gallery->clearStacks();
                 $notification->push(_("The gallery's default photo has successfully been reset."), 'horde.success');
                 Horde::url('view.php', true)->add('gallery', $galleryId)->redirect();
                 exit;
             } catch (Ansel_Exception $e) {
                 $notification->push($e->getMessage(), 'horde.error');
                 Horde::url('index.php', true)->redirect();
                 exit;
             }
         case 'generateThumbs':
             // Re-generate all of this gallery's prettythumbs.
             $galleryId = Horde_Util::getFormData('gallery');
             try {
                 $gallery = $ansel_storage->getGallery($galleryId);
             } catch (Ansel_Exception $e) {
                 $notification->push($gallery->getMessage(), 'horde.error');
                 Horde::url('index.php', true)->redirect();
                 exit;
             }
             $gallery->clearThumbs();
             $notification->push(_("The gallery's thumbnails have successfully been reset."), 'horde.success');
             Horde::url('view.php', true)->add('gallery', $galleryId)->redirect();
             exit;
         case 'deleteCache':
             // Delete all cached image views.
             $galleryId = Horde_Util::getFormData('gallery');
             try {
                 $gallery = $ansel_storage->getGallery($galleryId);
             } catch (Ansel_Exception $e) {
                 $notification->push($gallery->getMessage(), 'horde.error');
                 Horde::url('index.php', true)->redirect();
                 exit;
             }
             $gallery->clearViews();
             $notification->push(_("The gallery's views have successfully been reset."), 'horde.success');
             Horde::url('view.php', true)->add('gallery', $galleryId)->redirect();
             exit;
     }
     return false;
 }
Example #21
0
 if ($select_view == 'mobile_nojs') {
     $nojs = true;
     $select_view = 'mobile';
 } else {
     $nojs = false;
 }
 /* Get the login params from the login screen. */
 $auth_params = array('password' => Horde_Util::getPost('horde_pass'), 'mode' => $select_view);
 try {
     $result = $auth->getLoginParams();
     foreach (array_keys($result['params']) as $val) {
         $auth_params[$val] = Horde_Util::getPost($val);
     }
 } catch (Horde_Exception $e) {
 }
 if ($auth->authenticate(Horde_Util::getPost('horde_user'), $auth_params)) {
     Horde::log(sprintf('Login success for %s to %s (%s)', $registry->getAuth(), $vars->app && $is_auth ? $vars->app : 'horde', $_SERVER['REMOTE_ADDR']), 'NOTICE');
     if (!$is_auth && $nojs) {
         $notification->push(_("JavaScript is either disabled or not available on your browser. You are restricted to the minimal view."));
     }
     if (!empty($url_in)) {
         /* $horde_login_url is used by horde/index.php to redirect to URL
          * without the need to redirect to horde/index.php also. */
         $horde_login_url = Horde::url(_addAnchor($url_in->remove(session_name()), 'url', $vars), true);
     }
     /* Do password change request on initial login only. */
     if (!$is_auth && $registry->passwordChangeRequested()) {
         $notification->push(_("Your password has expired."), 'horde.message');
         if ($auth->hasCapability('update')) {
             Horde::url('services/changepassword.php')->redirect();
         }
Example #22
0
    $gallery = $injector->getInstance('Ansel_Storage')->getGallery($galleryId);
} catch (Ansel_Excception $e) {
    $notification->push(_("There was an error accessing the gallery."), 'horde.error');
    Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect();
    exit;
}
if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
    $notification->push(_("Access denied editing this gallery."), 'horde.error');
    Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect();
}
$style = $gallery->getStyle();
$date = Ansel::getDateParameter();
$gallery->setDate($date);
switch (Horde_Util::getFormData('action')) {
    case 'Sort':
        parse_str(Horde_Util::getPost('order'), $order);
        $order = $order['order'];
        foreach ($order as $pos => $id) {
            $gallery->setImageOrder($id, $pos);
        }
        $notification->push(_("Gallery sorted."), 'horde.success');
        $style = $gallery->getStyle();
        Ansel::getUrlFor('view', array_merge(array('view' => 'Gallery', 'gallery' => $galleryId, 'slug' => $gallery->get('slug')), $date), true)->redirect();
        exit;
    case 'Reset':
        // Reset the sort order by date.
        $images = $injector->getInstance('Ansel_Storage')->listImages(array('gallery_id' => $galleryId, 'sort' => 'image_original_date'));
        $pos = 0;
        foreach ($images as $id) {
            $gallery->setImageOrder($id, $pos++);
        }
Example #23
0
 /**
  */
 protected function _init()
 {
     global $browser, $injector, $notification, $page_output, $prefs, $registry, $session;
     /* Mailto link handler: redirect based on current view. */
     if ($this->vars->actionID == 'mailto_link') {
         switch ($registry->getView()) {
             case Horde_Registry::VIEW_DYNAMIC:
                 IMP_Dynamic_Compose::url()->add($_GET)->redirect();
                 exit;
             case Horde_Registry::VIEW_MINIMAL:
                 IMP_Minimal_Compose::url()->add($_GET)->redirect();
                 exit;
         }
     }
     /* The message headers and text. */
     $header = array();
     $msg = '';
     $redirect = $resume = $spellcheck = false;
     $oldrtemode = $rtemode = null;
     /* Is this a popup window? */
     if ($isPopup = $prefs->getValue('compose_popup') || $this->vars->popup) {
         $page_output->topbar = $page_output->sidebar = false;
     }
     /* Set the current identity. */
     $identity = $injector->getInstance('IMP_Identity');
     if (!$prefs->isLocked('default_identity') && !is_null($this->vars->identity)) {
         $identity->setDefault($this->vars->identity);
     }
     if ($this->vars->actionID) {
         switch ($this->vars->actionID) {
             case 'draft':
             case 'editasnew':
             case 'forward_attach':
             case 'forward_auto':
             case 'forward_body':
             case 'forward_both':
             case 'fwd_digest':
             case 'mailto':
             case 'mailto_link':
             case 'reply':
             case 'reply_all':
             case 'reply_auto':
             case 'reply_list':
             case 'redirect_compose':
             case 'template':
             case 'template_edit':
             case 'template_new':
                 /* These are all safe actions that might be invoked without a
                  * token. */
                 break;
             default:
                 try {
                     $session->checkToken($this->vars->compose_requestToken);
                 } catch (Horde_Exception $e) {
                     $notification->push($e);
                     $this->vars->actionID = null;
                 }
         }
     }
     /* Check for duplicate submits. */
     if ($reload = $this->vars->compose_formToken) {
         try {
             $session->checkNonce($reload);
         } catch (Horde_Exception $e) {
             $notification->push(_("You have already submitted this page."), 'horde.error');
             $this->vars->actionID = null;
         }
     }
     /* Determine if compose mode is disabled. */
     $compose_disable = !IMP_Compose::canCompose();
     /* Determine if mailboxes are readonly. */
     $draft = IMP_Mailbox::getPref(IMP_Mailbox::MBOX_DRAFTS);
     $readonly_drafts = $draft && $draft->readonly;
     $sent_mail = $identity->getValue(IMP_Mailbox::MBOX_SENT);
     if (!$sent_mail) {
         $readonly_sentmail = $save_sent_mail = false;
     } elseif ($sent_mail->readonly) {
         $readonly_sentmail = true;
         $save_sent_mail = false;
     } else {
         $readonly_sentmail = false;
         $save_sent_mail = $reload ? (bool) $this->vars->save_sent_mail : true;
     }
     /* Initialize the IMP_Compose:: object. */
     $imp_compose = $injector->getInstance('IMP_Factory_Compose')->create($this->vars->composeCache);
     /* Init objects. */
     $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
     $imp_ui = new IMP_Compose_Ui();
     /* Determine the composition type - text or HTML.
        $rtemode is null if browser does not support it. */
     if ($session->get('imp', 'rteavail')) {
         if ($prefs->isLocked('compose_html')) {
             $rtemode = $prefs->getValue('compose_html');
         } else {
             $rtemode = $this->vars->rtemode;
             if (is_null($rtemode)) {
                 $rtemode = $prefs->getValue('compose_html');
             } else {
                 $rtemode = intval($rtemode);
                 $oldrtemode = intval($this->vars->oldrtemode);
             }
         }
     }
     /* Update the file attachment information. */
     $attach_upload = $imp_compose->canUploadAttachment();
     if ($attach_upload) {
         /* Only notify if we are reloading the compose screen. */
         $notify = !in_array($this->vars->actionID, array('send_message', 'save_draft'));
         $deleteList = Horde_Util::getPost('delattachments', array());
         /* Update the attachment information. */
         foreach ($imp_compose as $key => $val) {
             if (!in_array($key, $deleteList)) {
                 $val->getPart()->setDescription($this->vars->filter('file_description_' . $key));
                 $imp_compose[$key] = $val;
             }
         }
         /* Delete attachments. */
         foreach ($deleteList as $val) {
             if ($notify) {
                 $notification->push(sprintf(_("Deleted attachment \"%s\"."), $imp_compose[$val]->getPart()->getName(true)), 'horde.success');
             }
             unset($imp_compose[$val]);
         }
         /* Add attachments. */
         for ($i = 1, $fcount = count($_FILES); $i <= $fcount; ++$i) {
             if (isset($_FILES['upload_' . $i]) && strlen($_FILES['upload_' . $i]['name'])) {
                 try {
                     $atc_ob = $imp_compose->addAttachmentFromUpload('upload_' . $i);
                     if ($atc_ob[0] instanceof IMP_Compose_Exception) {
                         throw $atc_ob[0];
                     }
                     if ($notify) {
                         $notification->push(sprintf(_("Added \"%s\" as an attachment."), $atc_ob[0]->getPart()->getName()), 'horde.success');
                     }
                 } catch (IMP_Compose_Exception $e) {
                     /* Any error will cancel the current action. */
                     $this->vars->actionID = null;
                     $notification->push($e, 'horde.error');
                 }
             }
         }
     }
     /* Get message priority. */
     $priority = $this->vars->get('priority', 'normal');
     /* Request read receipt? */
     $request_read_receipt = (bool) $this->vars->request_read_receipt;
     /* Run through the action handlers. */
     $this->title = _("New Message");
     switch ($this->vars->actionID) {
         case 'mailto':
             try {
                 $contents = $this->_getContents();
             } catch (IMP_Exception $e) {
                 $notification->push($e, 'horde.error');
                 break;
             }
             $imp_headers = $contents->getHeader();
             $header['to'] = '';
             if ($this->vars->mailto) {
                 $header['to'] = $imp_headers->getValue('to');
             }
             if (empty($header['to'])) {
                 ($header['to'] = strval($imp_headers->getOb('from'))) || ($header['to'] = strval($imp_headers->getOb('reply-to')));
             }
             break;
         case 'mailto_link':
             $clink = new IMP_Compose_Link($this->vars);
             if (isset($clink->args['body'])) {
                 $msg = $clink->args['body'];
             }
             foreach (array('to', 'cc', 'bcc', 'subject') as $val) {
                 if (isset($clink->args[$val])) {
                     $header[$val] = $clink->args[$val];
                 }
             }
             break;
         case 'draft':
         case 'editasnew':
         case 'template':
         case 'template_edit':
             try {
                 switch ($this->vars->actionID) {
                     case 'draft':
                         $result = $imp_compose->resumeDraft($this->indices);
                         $resume = true;
                         break;
                     case 'editasnew':
                         $result = $imp_compose->editAsNew($this->indices);
                         break;
                     case 'template':
                         $result = $imp_compose->useTemplate($this->indices);
                         break;
                     case 'template_edit':
                         $result = $imp_compose->editTemplate($this->indices);
                         $this->vars->template_mode = true;
                         break;
                 }
                 if (!is_null($rtemode)) {
                     $rtemode = $result['format'] == 'html';
                 }
                 $msg = $result['body'];
                 $header = array_merge($header, $this->_convertToHeader($result));
                 if (!is_null($result['identity']) && $result['identity'] != $identity->getDefault() && !$prefs->isLocked('default_identity')) {
                     $identity->setDefault($result['identity']);
                     $sent_mail = $identity->getValue(IMP_Mailbox::MBOX_SENT);
                 }
                 $priority = $result['priority'];
                 $request_read_receipt = $result['readreceipt'];
             } catch (IMP_Compose_Exception $e) {
                 $notification->push($e);
             }
             break;
         case 'reply':
         case 'reply_all':
         case 'reply_auto':
         case 'reply_list':
             try {
                 $contents = $this->_getContents();
             } catch (IMP_Exception $e) {
                 $notification->push($e, 'horde.error');
                 break;
             }
             $reply_map = array('reply' => IMP_Compose::REPLY_SENDER, 'reply_all' => IMP_Compose::REPLY_ALL, 'reply_auto' => IMP_Compose::REPLY_AUTO, 'reply_list' => IMP_Compose::REPLY_LIST);
             $reply_msg = $imp_compose->replyMessage($reply_map[$this->vars->actionID], $contents, array('to' => $this->vars->to));
             $msg = $reply_msg['body'];
             $header = $this->_convertToHeader($reply_msg);
             $format = $reply_msg['format'];
             switch ($reply_msg['type']) {
                 case IMP_Compose::REPLY_SENDER:
                     $this->vars->actionID = 'reply';
                     $this->title = _("Reply:");
                     break;
                 case IMP_Compose::REPLY_ALL:
                     if ($this->vars->actionID == 'reply_auto') {
                         $recip_list = $imp_compose->recipientList($header);
                         if (!empty($recip_list['list'])) {
                             $replyauto_all = count($recip_list['list']);
                         }
                     }
                     $this->vars->actionID = 'reply_all';
                     $this->title = _("Reply to All:");
                     break;
                 case IMP_Compose::REPLY_LIST:
                     if ($this->vars->actionID == 'reply_auto') {
                         $replyauto_list = true;
                         if (($parse_list = $injector->getInstance('Horde_ListHeaders')->parse('list-id', $contents->getHeader()->getValue('list-id'))) && !is_null($parse_list->label)) {
                             $replyauto_list_id = $parse_list->label;
                         }
                     }
                     $this->vars->actionID = 'reply_list';
                     $this->title = _("Reply to List:");
                     break;
             }
             if (!empty($reply_msg['lang'])) {
                 $reply_lang = array_values($reply_msg['lang']);
             }
             $this->title .= ' ' . $header['subject'];
             if (!is_null($rtemode)) {
                 $rtemode = $rtemode || $format == 'html';
             }
             break;
         case 'replyall_revert':
         case 'replylist_revert':
             try {
                 $reply_msg = $imp_compose->replyMessage(IMP_Compose::REPLY_SENDER, $imp_compose->getContentsOb());
                 $header = $this->_convertToHeader($reply_msg);
             } catch (IMP_Exception $e) {
                 $notification->push($e, 'horde.error');
             }
             break;
         case 'forward_attach':
         case 'forward_auto':
         case 'forward_body':
         case 'forward_both':
             $fwd_map = array('forward_attach' => IMP_Compose::FORWARD_ATTACH, 'forward_auto' => IMP_Compose::FORWARD_AUTO, 'forward_body' => IMP_Compose::FORWARD_BODY, 'forward_both' => IMP_Compose::FORWARD_BOTH);
             try {
                 $fwd_msg = $imp_compose->forwardMessage($fwd_map[$this->vars->actionID], $this->_getContents());
             } catch (IMP_Exception $e) {
                 $notification->push($e, 'horde.error');
                 break;
             }
             $msg = $fwd_msg['body'];
             $header = $this->_convertToHeader($fwd_msg);
             $format = $fwd_msg['format'];
             $rtemode = $rtemode || !is_null($rtemode) && $format == 'html';
             $this->title = $fwd_msg['title'];
             break;
         case 'redirect_compose':
             try {
                 $imp_compose->redirectMessage($this->indices);
                 $redirect = true;
                 $this->title = ngettext("Redirect", "Redirect Messages", count($this->indices));
             } catch (IMP_Compose_Exception $e) {
                 $notification->push($e, 'horde.error');
             }
             break;
         case 'redirect_send':
             try {
                 $num_msgs = $imp_compose->sendRedirectMessage($this->vars->to);
                 $imp_compose->destroy('send');
                 if ($isPopup) {
                     if ($prefs->getValue('compose_confirm')) {
                         $notification->push(ngettext("Message redirected successfully.", "Messages redirected successfully", count($num_msgs)), 'horde.success');
                         $this->_popupSuccess();
                         return;
                     }
                     echo Horde::wrapInlineScript(array('window.close();'));
                 } else {
                     $notification->push(ngettext("Message redirected successfully.", "Messages redirected successfully", count($num_msgs)), 'horde.success');
                     $this->_mailboxReturnUrl()->redirect();
                 }
                 exit;
             } catch (Horde_Exception $e) {
                 $notification->push($e);
                 $this->vars->actionID = 'redirect_compose';
             }
             break;
         case 'auto_save_draft':
         case 'save_draft':
         case 'save_template':
         case 'send_message':
             // Drafts readonly is handled below.
             if ($compose_disable && $this->vars->actionID == 'send_message') {
                 break;
             }
             try {
                 $header['from'] = strval($identity->getFromLine(null, $this->vars->from));
             } catch (Horde_Exception $e) {
                 $header['from'] = '';
                 $notification->push($e);
                 break;
             }
             $header['to'] = $this->vars->to;
             $header['cc'] = $this->vars->cc;
             $header['bcc'] = $this->vars->bcc;
             $header['subject'] = strval($this->vars->subject);
             $message = strval($this->vars->message);
             /* Save the draft. */
             switch ($this->vars->actionID) {
                 case 'auto_save_draft':
                 case 'save_draft':
                 case 'save_template':
                     if (!$readonly_drafts || $this->vars->actionID == 'save_template') {
                         $save_opts = array('html' => $rtemode, 'priority' => $priority, 'readreceipt' => $request_read_receipt);
                         try {
                             switch ($this->vars->actionID) {
                                 case 'save_template':
                                     $result = $imp_compose->saveTemplate($header, $message, $save_opts);
                                     break;
                                 default:
                                     $result = $imp_compose->saveDraft($header, $message, $save_opts);
                                     break;
                             }
                             /* Closing draft if requested by preferences. */
                             switch ($this->vars->actionID) {
                                 case 'save_draft':
                                     if ($isPopup) {
                                         if ($prefs->getValue('close_draft')) {
                                             $imp_compose->destroy('save_draft');
                                             echo Horde::wrapInlineScript(array('window.close();'));
                                             exit;
                                         }
                                         $notification->push($result, 'horde.success');
                                     } else {
                                         $notification->push($result, 'horde.success');
                                         if ($prefs->getValue('close_draft')) {
                                             $imp_compose->destroy('save_draft');
                                             $this->_mailboxReturnUrl()->redirect();
                                         }
                                     }
                                     break;
                                 case 'save_template':
                                     if ($isPopup) {
                                         echo Horde::wrapInlineScript(array('window.close();'));
                                         exit;
                                     }
                                     $notification->push($result, 'horde.success');
                                     $this->_mailboxReturnUrl()->redirect();
                                     break;
                             }
                         } catch (IMP_Compose_Exception $e) {
                             if ($this->vars->actionID == 'save_draft') {
                                 $notification->push($e);
                             }
                         }
                     }
                     if ($this->vars->actionID == 'auto_save_draft') {
                         $r = new stdClass();
                         $r->requestToken = $session->getToken();
                         $r->formToken = $session->getNonce();
                         $response = new Horde_Core_Ajax_Response_HordeCore($r);
                         $response->sendAndExit();
                     }
                     break;
                 default:
                     $header['replyto'] = $identity->getValue('replyto_addr');
                     if ($this->vars->sent_mail) {
                         $sent_mail = IMP_Mailbox::formFrom($this->vars->sent_mail);
                     }
                     try {
                         $imp_compose->buildAndSendMessage($message, $header, $identity, array('encrypt' => $prefs->isLocked('default_encrypt') ? $prefs->getValue('default_encrypt') : $this->vars->encrypt_options, 'html' => $rtemode, 'pgp_attach_pubkey' => $this->vars->pgp_attach_pubkey, 'priority' => $priority, 'save_sent' => $save_sent_mail, 'sent_mail' => $sent_mail, 'signature' => $this->vars->signature, 'strip_attachments' => !$this->vars->save_attachments_select, 'readreceipt' => $request_read_receipt, 'vcard_attach' => $this->vars->vcard ? $identity->getValue('fullname') : null));
                         $imp_compose->destroy('send');
                         if ($isPopup) {
                             if ($prefs->getValue('compose_confirm')) {
                                 $notification->push(_("Message sent successfully."), 'horde.success');
                                 $this->_popupSuccess();
                                 return;
                             }
                             echo Horde::wrapInlineScript(array('window.close();'));
                         } else {
                             $notification->push(_("Message sent successfully."), 'horde.success');
                             $this->_mailboxReturnUrl()->redirect();
                         }
                         exit;
                     } catch (IMP_Compose_Exception $e) {
                         $code = $e->getCode();
                         $notification->push($e->getMessage(), strpos($code, 'horde.') === 0 ? $code : 'horde.error');
                         /* Switch to tied identity. */
                         if (!is_null($e->tied_identity)) {
                             $identity->setDefault($e->tied_identity);
                             $notification->push(_("Your identity has been switched to the identity associated with the current recipient address. The identity will not be checked again during this compose action."));
                         }
                         switch ($e->encrypt) {
                             case 'pgp_symmetric_passphrase_dialog':
                                 $imp_ui->passphraseDialog('pgp_symm', $imp_compose->getCacheId());
                                 break;
                             case 'pgp_passphrase_dialog':
                                 $imp_ui->passphraseDialog('pgp');
                                 break;
                             case 'smime_passphrase_dialog':
                                 $imp_ui->passphraseDialog('smime');
                                 break;
                         }
                     }
                     break;
             }
             break;
         case 'fwd_digest':
             if (count($this->indices)) {
                 try {
                     $res = $imp_compose->forwardMultipleMessages($this->indices);
                     $header['subject'] = $res['subject'];
                     $fwd_msg = array('type' => IMP_Compose::FORWARD_ATTACH);
                 } catch (IMP_Compose_Exception $e) {
                     $notification->push($e, 'horde.error');
                 }
             }
             break;
         case 'cancel_compose':
         case 'discard_compose':
             $imp_compose->destroy($this->vars->actionID == 'cancel_compose' ? 'cancel' : 'discard');
             if ($isPopup) {
                 echo Horde::wrapInlineScript(array('window.close();'));
             } else {
                 $this->_mailboxReturnUrl()->redirect();
             }
             exit;
         case 'template_new':
             $this->vars->template_mode = true;
             break;
     }
     /* Get the message cache ID. */
     $composeCacheID = filter_var($imp_compose->getCacheId(), FILTER_SANITIZE_STRING);
     /* Attach autocompleters to the compose form elements. */
     if ($redirect) {
         $imp_ui->attachAutoCompleter(array('to'));
     } else {
         $imp_ui->attachAutoCompleter(array('to', 'cc', 'bcc'));
         $spellcheck = $imp_ui->attachSpellChecker();
         $page_output->addScriptFile('ieescguard.js', 'horde');
     }
     $max_attach = $imp_compose->additionalAttachmentsAllowed();
     /* Get the URL to use for the cancel action. If the attachments cache
      * is not empty, or this is the resume drafts page, we must reload
      * this page and delete the attachments and/or the draft message. */
     if ($isPopup) {
         if ($resume || count($imp_compose)) {
             $cancel_url = self::url()->setRaw(true)->add(array('actionID' => 'cancel_compose', 'compose_requestToken' => $session->getToken(), 'composeCache' => $composeCacheID, 'popup' => 1));
             $discard_url = clone $cancel_url;
             $discard_url->add('actionID', 'discard_compose');
         } else {
             $cancel_url = $discard_url = '';
         }
     } elseif ($resume || count($imp_compose)) {
         $cancel_url = $this->_mailboxReturnUrl(self::url()->setRaw(true))->setRaw(true)->add(array('actionID' => 'cancel_compose', 'compose_requestToken' => $session->getToken(), 'composeCache' => $composeCacheID));
         $discard_url = clone $cancel_url;
         $discard_url->add('actionID', 'discard_compose');
     } else {
         $cancel_url = $discard_url = $this->_mailboxReturnUrl(false)->setRaw(true);
     }
     /* Grab any data that we were supplied with. */
     if (!strlen($msg)) {
         $msg = $this->vars->get('message', strval($this->vars->body));
         if ($browser->hasQuirk('double_linebreak_textarea')) {
             $msg = preg_replace('/(\\r?\\n){3}/', '$1', $msg);
         }
         $msg = "\n" . $msg;
     }
     if (isset($this->vars->signature)) {
         $signature = $this->vars->signature;
         if ($browser->hasQuirk('double_linebreak_textarea')) {
             $signature = preg_replace('/(\\r?\\n){3}/', '$1', $signature);
         }
         $signatureChanged = $signature != $identity->getSignature($oldrtemode ? 'html' : 'text');
     } else {
         $signatureChanged = false;
     }
     /* Convert from Text -> HTML or vice versa if RTE mode changed. */
     if (!is_null($oldrtemode) && $oldrtemode != $rtemode) {
         $msg = $imp_ui->convertComposeText($msg, $rtemode ? 'html' : 'text');
         if ($signatureChanged) {
             $signature = $imp_ui->convertComposeText($signature, $rtemode ? 'html' : 'text');
         }
     }
     /* If this is the first page load for this compose item, add auto BCC
      * addresses. */
     if (!$reload && !$resume) {
         $header['bcc'] = strval($identity->getBccAddresses());
     }
     foreach (array('to', 'cc', 'bcc') as $val) {
         if (!isset($header[$val])) {
             $header[$val] = $this->vars->{$val};
         }
     }
     if (!isset($header['subject'])) {
         $header['subject'] = $this->vars->subject;
     }
     /* If PGP encryption is set by default, and we have a recipient list
      * on first load, make sure we have public keys for all recipients. */
     $encrypt_options = $prefs->isLocked('default_encrypt') ? $prefs->getValue('default_encrypt') : $this->vars->encrypt_options;
     if ($prefs->getValue('use_pgp') && !$prefs->isLocked('default_encrypt') && $prefs->getValue('pgp_reply_pubkey')) {
         $default_encrypt = $prefs->getValue('default_encrypt');
         if (!$reload && in_array($default_encrypt, array(IMP_Crypt_Pgp::ENCRYPT, IMP_Crypt_Pgp::SIGNENC))) {
             $addrs = $imp_compose->recipientList($header);
             if (!empty($addrs['list'])) {
                 $imp_pgp = $injector->getInstance('IMP_Crypt_Pgp');
                 try {
                     foreach ($addrs['list'] as $val) {
                         $imp_pgp->getPublicKey(strval($val));
                     }
                 } catch (Horde_Exception $e) {
                     $notification->push(_("PGP encryption cannot be used by default as public keys cannot be found for all recipients."), 'horde.warning');
                     $encrypt_options = $default_encrypt == IMP_Crypt_Pgp::ENCRYPT ? IMP::ENCRYPT_NONE : IMP_Crypt_Pgp::SIGN;
                 }
             }
         }
     }
     /* Define some variables used in the javascript code. */
     $js_vars = array('ImpComposeBase.editor_on' => $rtemode, 'ImpCompose.auto_save' => intval($prefs->getValue('auto_save_drafts')), 'ImpCompose.cancel_url' => strval($cancel_url), 'ImpCompose.cursor_pos' => $rtemode ? null : $prefs->getValue('compose_cursor'), 'ImpCompose.discard_url' => strval($discard_url), 'ImpCompose.max_attachments' => $max_attach === true ? null : $max_attach, 'ImpCompose.popup' => intval($isPopup), 'ImpCompose.redirect' => intval($redirect), 'ImpCompose.reloaded' => intval($reload), 'ImpCompose.sm_check' => intval(!$prefs->isLocked(IMP_Mailbox::MBOX_SENT)), 'ImpCompose.spellcheck' => intval($spellcheck && $prefs->getValue('compose_spellcheck')), 'ImpCompose.text' => array('cancel' => _("Cancelling this message will permanently discard its contents.") . "\n" . _("Are you sure you want to do this?"), 'change_identity' => _("You have edited your signature. Change the identity and lose your changes?"), 'discard' => _("Doing so will discard this message permanently."), 'file' => _("File"), 'nosubject' => _("The message does not have a Subject entered.") . "\n" . _("Send message without a Subject?"), 'recipient' => _("You must specify a recipient.")));
     /* Set up the base view now. */
     $view = $injector->createInstance('Horde_View');
     $view->addHelper('FormTag');
     $view->addHelper('Horde_Core_View_Helper_Accesskey');
     $view->addHelper('Horde_Core_View_Helper_Help');
     $view->addHelper('Horde_Core_View_Helper_Image');
     $view->addHelper('Horde_Core_View_Helper_Label');
     $view->addHelper('Tag');
     $view->allow_compose = !$compose_disable;
     $view->post_action = self::url();
     $blank_url = new Horde_Url('#');
     if ($redirect) {
         /* Prepare the redirect template. */
         $view->cacheid = $composeCacheID;
         $view->title = $this->title;
         $view->token = $session->getToken();
         if ($registry->hasMethod('contacts/search')) {
             $view->abook = $blank_url->copy()->link(array('class' => 'widget', 'id' => 'redirect_abook', 'title' => _("Address Book")));
             $js_vars['ImpCompose.redirect_contacts'] = strval(IMP_Basic_Contacts::url()->add(array('to_only' => 1))->setRaw(true));
         }
         $view->input_value = $header['to'];
         $this->output = $view->render('basic/compose/redirect');
     } else {
         /* Prepare the compose template. */
         $view->file_upload = $attach_upload;
         $hidden = array('actionID' => '', 'attachmentAction' => '', 'compose_formToken' => $session->getNonce(), 'compose_requestToken' => $session->getToken(), 'composeCache' => $composeCacheID, 'composeHmac' => $imp_compose->getHmac(), 'oldrtemode' => $rtemode, 'rtemode' => $rtemode, 'user' => $registry->getAuth());
         if ($attach_upload) {
             $hidden['MAX_FILE_SIZE'] = $session->get('imp', 'file_upload');
         }
         foreach (array('page', 'start', 'popup', 'template_mode') as $val) {
             $hidden[$val] = $this->vars->{$val};
         }
         $view->hidden = $hidden;
         $view->tabindex = 1;
         $view->title = $this->title;
         if (!$this->vars->template_mode) {
             $view->send_msg = true;
             $view->save_draft = $imp_imap->access(IMP_Imap::ACCESS_DRAFTS) && !$readonly_drafts;
         }
         $view->resume = $resume;
         $view->di_locked = $prefs->isLocked('default_identity');
         if ($view->di_locked) {
             $view->fromaddr_locked = $prefs->isLocked('from_addr');
             try {
                 $view->from = $identity->getFromLine(null, $this->vars->from);
             } catch (Horde_Exception $e) {
             }
         } else {
             $select_list = $identity->getSelectList();
             $view->last_identity = $identity->getDefault();
             if (count($select_list) > 1) {
                 $view->count_select_list = true;
                 $t_select_list = array();
                 foreach ($select_list as $key => $select) {
                     $t_select_list[] = array('label' => $select, 'selected' => $key == $identity->getDefault(), 'value' => $key);
                 }
                 $view->select_list = $t_select_list;
             } else {
                 $view->identity_default = $identity->getDefault();
                 $view->identity_text = $select_list[0];
             }
         }
         $view->signature = $identity->hasSignature(true);
         $addr_array = array('to' => _("_To"), 'cc' => _("_Cc"), 'bcc' => _("_Bcc"));
         $address_array = array();
         foreach ($addr_array as $val => $label) {
             $address_array[] = array('id' => $val, 'label' => $label, 'val' => $header[$val]);
         }
         $view->addr = $address_array;
         $view->subject = $header['subject'];
         if ($prefs->getValue('set_priority')) {
             $view->set_priority = true;
             $priorities = array('high' => _("High"), 'normal' => _("Normal"), 'low' => _("Low"));
             $priority_option = array();
             foreach ($priorities as $key => $val) {
                 $priority_option[] = array('label' => $val, 'selected' => $priority == $key, 'val' => $key);
             }
             $view->pri_opt = $priority_option;
         }
         $compose_options = array();
         if ($registry->hasMethod('contacts/search')) {
             $compose_options[] = array('url' => $blank_url->copy()->link(array('class' => 'widget', 'id' => 'addressbook_popup')), 'img' => Horde_Themes_Image::tag('addressbook_browse.png'), 'label' => _("Address Book"));
             $js_vars['ImpCompose.contacts_url'] = strval(IMP_Basic_Contacts::url()->setRaw(true));
         }
         if ($spellcheck) {
             $compose_options[] = array('url' => $blank_url->copy()->link(array('class' => 'widget', 'id' => 'spellcheck')), 'img' => '', 'label' => '');
         }
         if ($attach_upload) {
             $url = new Horde_Url('#attachments');
             $compose_options[] = array('url' => $url->link(array('class' => 'widget')), 'img' => Horde_Themes_Image::tag('attachment.png'), 'label' => _("Attachments"));
         }
         $view->compose_options = $compose_options;
         if ($imp_imap->access(IMP_Imap::ACCESS_FOLDERS) && !$prefs->isLocked('save_sent_mail')) {
             $view->ssm = true;
             if ($readonly_sentmail) {
                 $notification->push(sprintf(_("Cannot save sent-mail message to \"%s\" as that mailbox is read-only.", $sent_mail->display), 'horde.warning'));
             }
             $view->ssm_selected = $reload ? $save_sent_mail : $sent_mail && $identity->saveSentmail();
             if ($this->vars->sent_mail) {
                 $sent_mail = IMP_Mailbox::formFrom($this->vars->sent_mail);
             }
             if (!$prefs->isLocked(IMP_Mailbox::MBOX_SENT)) {
                 $iterator = new IMP_Ftree_IteratorFilter($injector->getInstance('IMP_Ftree'));
                 $iterator->add($iterator::NONIMAP);
                 $iterator->mboxes = array('INBOX');
                 $ssm_options = array('abbrev' => false, 'basename' => true, 'iterator' => $iterator, 'selected' => $sent_mail);
                 /* Check to make sure the sent-mail mailbox is created -
                  * it needs to exist to show up in drop-down list. */
                 if ($sent_mail) {
                     $sent_mail->create();
                 }
                 $view->ssm_mboxes = new IMP_Ftree_Select($ssm_options);
             } else {
                 if ($sent_mail) {
                     $sent_mail = '&quot;' . $sent_mail->display_html . '&quot;';
                 }
                 $view->ssm_mbox = $sent_mail;
             }
         }
         $view->rrr_selected = $prefs->isLocked('request_mdn') ? null : $prefs->getValue('request_mdn') == 'always' || $request_read_receipt;
         if (!is_null($rtemode) && !$prefs->isLocked('compose_html')) {
             $view->compose_html = true;
             $view->html_switch = $blank_url->copy()->link(array('id' => 'rte_toggle', 'title' => _("Switch Composition Method")));
             $view->rtemode = $rtemode;
         }
         if (isset($replyauto_all)) {
             $view->replyauto_all = $replyauto_all;
         } elseif (isset($replyauto_list)) {
             $view->replyauto_list = true;
             if (isset($replyauto_list_id)) {
                 $view->replyauto_list_id = $replyauto_list_id;
             }
         }
         if (isset($reply_lang)) {
             $view->reply_lang = implode(',', $reply_lang);
         }
         $view->message = $msg;
         if ($signatureChanged) {
             $view->signatureContent = $signature;
         }
         if ($prefs->getValue('use_pgp') || $prefs->getValue('use_smime')) {
             if ($prefs->isLocked('default_encrypt')) {
                 $view->use_encrypt = false;
             } else {
                 $view->use_encrypt = true;
                 $view->encrypt_options = $imp_ui->encryptList($encrypt_options);
             }
             if ($prefs->getValue('use_pgp') && $prefs->getValue('pgp_public_key')) {
                 $view->pgp_options = true;
                 $view->pgp_attach_pubkey = $reload ? $this->vars->pgp_attach_pubkey : $prefs->getValue('pgp_attach_pubkey');
             }
         }
         if ($registry->hasMethod('contacts/ownVCard')) {
             $view->vcard = true;
             $view->attach_vcard = $this->vars->vcard;
         }
         if ($attach_upload) {
             $view->attach_size = IMP::numberFormat($imp_compose->maxAttachmentSize(), 0);
             $view->maxattachmentnumber = !$max_attach;
             $save_attach = $prefs->getValue('save_attachments');
             if ($view->ssm && !$prefs->isLocked('save_attachments')) {
                 $view->show_link_save_attach = true;
                 $view->attach_options = array(array('label' => _("Save attachments with message in sent-mail mailbox?"), 'name' => 'save_attachments_select', 'val' => $reload ? $this->vars->save_attachments_select : $save_attach == 'always'));
             }
             if (count($imp_compose)) {
                 $view->numberattach = true;
                 $atc = array();
                 $v = $injector->getInstance('IMP_Factory_MimeViewer');
                 foreach ($imp_compose as $data) {
                     $mime = $data->getPart();
                     $type = $mime->getType();
                     $entry = array('name' => $mime->getName(true), 'icon' => $v->getIcon($type), 'number' => $data->id, 'type' => $type, 'size' => $mime->getSize(), 'description' => $mime->getDescription(true));
                     if (!(isset($fwd_msg) && $fwd_msg['type'] != IMP_Compose::FORWARD_BODY) && $type != 'application/octet-stream') {
                         $entry['name'] = $data->viewUrl()->link(array('class' => 'link', 'target' => 'compose_preview_window', 'title' => _("Preview"))) . htmlspecialchars($entry['name']) . '</a>';
                     }
                     $atc[] = $entry;
                 }
                 $view->atc = $atc;
             }
         }
         $this->output = $view->render('basic/compose/compose');
     }
     $page_output->addScriptPackage('IMP_Script_Package_ComposeBase');
     $page_output->addScriptFile('compose.js');
     $page_output->addScriptFile('editor.js');
     $page_output->addScriptFile('imp.js');
     $page_output->addInlineJsVars($js_vars);
     if (!$redirect) {
         $imp_ui->addIdentityJs();
     }
     if ($rtemode && !$redirect) {
         $page_output->addScriptPackage('IMP_Script_Package_Editor');
     }
 }