configUpdate() static public method

$input must be an array as key:value ([config_name] => config_value)
static public configUpdate ( $input, $force = FALSE )
Example #1
0
        $messages['confirm']['sub'] = $_POST['confirm_sub'];
        $messages['confirm']['msg'] = $_POST['confirm_msg'];
        $messages['activate'] = array();
        $messages['activate']['sub'] = $_POST['activate_sub'];
        $messages['activate']['msg'] = $_POST['activate_msg'];
        $messages['update'] = array();
        $messages['update']['sub'] = $_POST['update_sub'];
        $messages['update']['msg'] = $_POST['update_msg'];
        $notices = array();
        $notices['email'] = $_POST['notify_email'];
        $notices['subject'] = $_POST['notify_subject'];
        $notices['subscribe'] = $_POST['notify_subscribe'];
        $notices['unsubscribe'] = $_POST['notify_unsubscribe'];
        $notices['update'] = $_POST['notify_update'];
        $notices['pending'] = $_POST['notify_pending'];
        $input = array('messages' => serialize($messages), 'notices' => serialize($notices));
        Pommo_Api::configUpdate($input, TRUE);
        $json->success(Pommo::_T('Configuration Updated.'));
    } else {
        // __ FORM NOT VALID
        $json->add('fieldErrors', $smarty->getInvalidFields('messages'));
        $json->fail(Pommo::_T('Please review and correct errors with your submission.'));
    }
}
$smarty->assign('t_subscribe', Pommo::_T('Subscription'));
$smarty->assign('t_unsubscribe', Pommo::_T('Unsubscription'));
$smarty->assign('t_pending', Pommo::_T('Pending'));
$smarty->assign('t_update', Pommo::_T('Update'));
$smarty->assign($_POST);
$smarty->display('admin/setup/config/messages.tpl');
Pommo::kill();
Example #2
0
    $validator->setPost($_POST);
    $validator->addData('list_name', 'Other', false);
    $validator->addData('site_name', 'Other', false);
    $validator->addData('site_url', 'Url', false);
    $validator->addData('site_success', 'Url', true);
    $validator->addData('site_confirm', 'Url', true);
    $validator->addData('list_confirm', 'matchRegex', false, '!^(on|off)$!');
    $validator->addData('list_exchanger', 'matchRegex', false, '!^(sendmail|mail|smtp)$!');
    /**********************************
    		JSON OUTPUT INITIALIZATION
    	 *********************************/
    require_once Pommo::$_baseDir . 'classes/Pommo_Json.php';
    $json = new Pommo_Json();
    if ($result = $validator->checkData()) {
        // __ FORM IS VALID
        Pommo_Api::configUpdate($_POST);
        Pommo::reloadConfig();
        $json->success(Pommo::_T('Configuration Updated.'));
    } else {
        // __ FORM NOT VALID
        $fieldErrors = array();
        $errors = $validator->getErrors();
        foreach ($errors as $key => $val) {
            $fieldErrors[] = array('field' => $key, 'message' => $val);
        }
        $json->add('fieldErrors', $fieldErrors);
        $json->fail(Pommo::_T('Please review and correct errors with your submission.'));
    }
}
$view->assign($_POST);
$view->display('admin/setup/config/general');
Example #3
0
     $sql = 'DROP TABLE IF EXISTS ' . $table;
     $dbo->query($sql);
 }
 if (isset($_REQUEST['debugInstall'])) {
     $dbo->debug(TRUE);
 }
 $install = Pommo_Install::parseSQL();
 if ($install) {
     // installation of DB went OK, set configuration values to user supplied ones
     $pass = $_POST['admin_password'];
     // install configuration
     $_POST['admin_password'] = md5($_POST['admin_password']);
     Pommo_Api::configUpdate($_POST);
     // generate key to uniquely identify this installation
     $key = Pommo_Helper::makeCode(6);
     Pommo_Api::configUpdate(array('key' => $key), TRUE);
     Pommo::reloadConfig();
     // load configuration [depricated?], set message defaults, load templates
     require_once Pommo::$_baseDir . 'classes/Pommo_Helper_Messages.php';
     Pommo_Helper_Messages::resetDefault('all');
     // install templates
     $file = Pommo::$_baseDir . 'sql/sql.templates.php';
     if (!Pommo_Install::parseSQL(false, $file)) {
         $logger->addErr('Error Loading Default Mailing Templates.');
     }
     $logger->addMsg(Pommo::_T('Installation Complete! You may now login and setup poMMo.'));
     $logger->addMsg(Pommo::_T('Login Username: '******'admin');
     $logger->addMsg(Pommo::_T('Login Password: '******'installed', TRUE);
 } else {
     // INSTALL FAILED
Example #4
0
 function perform(&$in)
 {
     global $pommo;
     $dbo =& Pommo::$_dbo;
     $logger =& Pommo::$_logger;
     if (!is_numeric($in['id']) || !is_numeric($in['subscriber_id'])) {
         $logger->addErr('Pommo_Pending::perform() -> invalid pending object sent.');
         return false;
     }
     switch ($in['type']) {
         case 'add':
             // subscribe
             $query = "\n\t\t\t\t\tUPDATE " . $dbo->table['subscribers'] . "\n\t\t\t\t\tSET status=1\n\t\t\t\t\tWHERE subscriber_id=%i";
             $query = $dbo->prepare($query, array($in['subscriber_id']));
             if (!$dbo->query($query)) {
                 $logger->addErr('Pommo_Pending::perform() -> Error updating subscriber.');
                 return false;
             }
             break;
         case 'change':
             // update
             require_once Pommo::$_baseDir . 'classes/Pommo_Subscribers.php';
             $subscriber =& $in['array'];
             if (!Pommo_Subscribers::update($subscriber, 'REPLACE_ACTIVE')) {
                 $logger->addErr('Pommo_Pending::perform() -> Error updating subscriber.');
                 return false;
             }
             break;
         case 'password':
             // change (admin) password
             require_once Pommo::$_baseDir . 'classes/Pommo_Subscribers.php';
             $password = Pommo_Helper::makePassword();
             $config = Pommo_Api::configGet(array('admin_username', 'admin_email'));
             if (!Pommo_Api::configUpdate(array('admin_password' => md5($password)), TRUE)) {
                 $logger->addMsg('Error updating password.');
                 return false;
             }
             $logger->addErr(sprintf(Pommo::_T('You may now %1$s login %2$s with username: %3$s and password: %4$s '), '<a href="' . Pommo::$_baseUrl . 'index.php">', '</a>', '<span style="font-size: 130%">' . $config['admin_username'] . '</span>', '<span style="font-size: 130%">' . $password . '</span>'));
             break;
     }
     $query = "\n\t\t\tDELETE FROM " . $dbo->table['subscriber_pending'] . "\n\t\t\tWHERE pending_id=%i";
     $query = $dbo->prepare($query, array($in['id']));
     if (!$dbo->query($query)) {
         $logger->addErr('Pommo_Pending::perform() -> Error removing pending entry.');
         return false;
     }
     return true;
 }
Example #5
0
 *********************************/
require '../bootstrap.php';
Pommo::init();
$dbo =& Pommo::$_dbo;
/**********************************
	JSON OUTPUT INITIALIZATION
 *********************************/
require_once Pommo::$_baseDir . 'classes/Pommo_Json.php';
$json = new Pommo_Json();
// EXAMINE CALL
switch ($_REQUEST['call']) {
    case 'wysiwyg':
        // update wysiwyg ++ state
        $wysiwyg = isset($_REQUEST['enable']) ? 'on' : 'off';
        Pommo::$_session['state']['mailing']['wysiwyg'] = $wysiwyg;
        Pommo_Api::configUpdate(array('list_wysiwyg' => $wysiwyg), true);
        break;
    case 'savebody':
        Pommo::$_session['state']['mailing']['body'] = $_REQUEST['body'];
        Pommo::$_session['state']['mailing']['altbody'] = $_REQUEST['altbody'];
        break;
    case 'altbody':
        require_once Pommo::$_baseDir . 'lib/lib.html2txt.php';
        $h2t =& new html2text($_REQUEST['body']);
        $json->add('altbody', $h2t->get_text());
        break;
    case 'getTemplateDescription':
        require_once Pommo::$_baseDir . 'classes/Pommo_Mailing_Template.php';
        $template = Pommo_Mailing_Template::getDescriptions(array('id' => $_REQUEST['id']));
        $msg = empty($template[$_REQUEST['id']]) ? 'Unknown' : $template[$_REQUEST['id']];
        die($msg);
Example #6
0
    $input['smtp_' . key($_POST['addSmtpServer'])] = serialize($server);
    Pommo_Api::configUpdate($input, TRUE);
    $update = true;
} elseif (!empty($_POST['updateSmtpServer'])) {
    $key = key($_POST['updateSmtpServer']);
    $server = array('host' => $_POST['host'][$key], 'port' => $_POST['port'][$key], 'auth' => $_POST['auth'][$key], 'user' => $_POST['user'][$key], 'pass' => $_POST['pass'][$key]);
    $input['smtp_' . $key] = serialize($server);
    Pommo_Api::configUpdate($input, TRUE);
    $update = true;
} elseif (!empty($_POST['deleteSmtpServer'])) {
    $input['smtp_' . key($_POST['deleteSmtpServer'])] = '';
    Pommo_Api::configUpdate($input, TRUE);
    $update = true;
} elseif (!empty($_POST['throttle_SMTP'])) {
    $input['throttle_SMTP'] = $_POST['throttle_SMTP'];
    Pommo_Api::configUpdate($input);
    $update = true;
}
if (isset($update)) {
    $smarty->assign('output', $update ? Pommo::_T('Configuration Updated.') : Pommo::_T('Please review and correct errors with your submission.'));
}
// Get the SMTP settings from DB
$smtpConfig = Pommo_Api::configGet(array('smtp_1', 'smtp_2', 'smtp_3', 'smtp_4', 'throttle_SMTP'));
$smtp[1] = unserialize($smtpConfig['smtp_1']);
$smtp[2] = unserialize($smtpConfig['smtp_2']);
$smtp[3] = unserialize($smtpConfig['smtp_3']);
$smtp[4] = unserialize($smtpConfig['smtp_4']);
if (empty($smtp[1])) {
    $smtp[1] = array('host' => 'mail.localhost', 'port' => '25', 'auth' => 'off', 'user' => '', 'pass' => '');
}
// Test the servers
 function resetDefault($section = 'all')
 {
     global $pommo;
     $dbo =& Pommo::$_dbo;
     $messages = array();
     if ($section != 'all') {
         $config = Pommo_Api::configGet(array('messages'));
         $messages = unserialize($config['messages']);
     }
     if ($section == 'all' || $section == 'subscribe') {
         $messages['subscribe'] = array();
         $messages['subscribe']['msg'] = sprintf(Pommo::_T('Welcome to our mailing list. You can always login to update your records or unsubscribe by visiting: %s'), "\n  " . Pommo::$_http . Pommo::$_baseUrl . 'login.php');
         $messages['subscribe']['sub'] = sprintf(Pommo::_T('Welcome to %s'), Pommo::$_config['list_name']);
         $messages['subscribe']['web'] = Pommo::_T('Welcome to our mailing list. Enjoy your stay.');
         $messages['subscribe']['email'] = false;
     }
     if ($section == 'all' || $section == 'unsubscribe') {
         $messages['unsubscribe'] = array();
         $messages['unsubscribe']['sub'] = sprintf(Pommo::_T('Farewell from %s'), Pommo::$_config['list_name']);
         $messages['unsubscribe']['msg'] = Pommo::_T('You have been unsubscribed and will not receive any more mailings from us. Feel free to come back anytime!');
         $messages['unsubscribe']['web'] = Pommo::_T('You have successfully unsubscribed. Enjoy your travels.');
         $messages['unsubscribe']['email'] = false;
     }
     if ($section == 'all' || $section == 'confirm') {
         $messages['confirm'] = array();
         $messages['confirm']['msg'] = sprintf(Pommo::_T('You have requested to subscribe to %s. We would like to validate your email address before adding you as a subscriber. Please click the link below to be added ->'), Pommo::$_config['list_name']) . "\r\n\t[[url]]\r\n\r\n" . Pommo::_T('If you have received this message in error, please ignore it.');
         $messages['confirm']['sub'] = Pommo::_T('Subscription request');
     }
     if ($section == 'all' || $section == 'activate') {
         $messages['activate'] = array();
         $messages['activate']['msg'] = sprintf(Pommo::_T('Someone has requested to access to your records for %s.'), Pommo::$_config['list_name']) . ' ' . Pommo::_T('You may edit your information or unsubscribe by visiting the link below ->') . "\r\n\t[[url]]\r\n\r\n" . Pommo::_T('If you have received this message in error, please ignore it.');
         $messages['activate']['sub'] = sprintf(Pommo::_T('%s: Account Access.'), Pommo::$_config['list_name']);
     }
     if ($section == 'all' || $section == 'password') {
         $messages['password'] = array();
         $messages['password']['msg'] = sprintf(Pommo::_T('You have requested to change your password for %s.'), Pommo::$_config['list_name']) . ' ' . Pommo::_T('Please validate this request by clicking the link below ->') . "\r\n\t[[url]]\r\n\r\n" . Pommo::_T('If you have received this message in error, please ignore it.');
         $messages['password']['sub'] = Pommo::_T('Change Password request');
     }
     if ($section == 'all' || $section == 'update') {
         $messages['update'] = array();
         $messages['update']['msg'] = sprintf(Pommo::_T('You have requested to update your records for %s.'), Pommo::$_config['list_name']) . ' ' . Pommo::_T('Please validate this request by clicking the link below ->') . "\n\n\t[[url]]\n\n" . Pommo::_T('If you have received this message in error, please ignore it.');
         $messages['update']['sub'] = Pommo::_T('Update Records request');
     }
     $input = array('messages' => serialize($messages));
     Pommo_Api::configUpdate($input, TRUE);
     return $messages;
 }