fail() public méthode

public fail ( $msg = false )
if (!SmartyValidate::is_registered_form('exchanger') || empty($_POST)) {
    // ___ USER HAS NOT SENT FORM ___
    SmartyValidate::register_form('exchanger', true);
    SmartyValidate::register_validator('email', 'email', 'isEmail', false, false, false, 'exchanger');
    $vMsg = array();
    $vMsg['email'] = Pommo::_T('Invalid email address');
    $smarty->assign('vMsg', $vMsg);
    $dbvals = array('exchanger' => $exchanger, 'email' => Pommo::$_config['admin_email']);
    $smarty->assign($dbvals);
} else {
    // ___ USER HAS SENT FORM ___
    /**********************************
    		JSON OUTPUT INITIALIZATION
    	 *********************************/
    require_once Pommo::$_baseDir . 'classes/Pommo_Json.php';
    $json = new Pommo_Json();
    if (SmartyValidate::is_valid($_POST, 'exchanger')) {
        // __ FORM IS VALID
        require_once Pommo::$_baseDir . 'classes/Pommo_Helper_Messages.php';
        $msg = Pommo_Helper_Messages::testExchanger($_POST['email'], $exchanger) ? Pommo::_T('Mail Sent.') : Pommo::_T('Error Sending Mail');
        $json->success($msg);
    } else {
        // __ FORM NOT VALID
        $json->addMsg(Pommo::_T('Please review and correct errors with your submission.'));
        $json->add('fieldErrors', $smarty->getInvalidFields('exchanger'));
        $json->fail();
    }
}
$smarty->assign($_POST);
$smarty->display('admin/setup/config/ajax.testexchanger.tpl');
Pommo::kill();
Exemple #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');
Exemple #3
0
Pommo::init();
$logger = Pommo::$_logger;
$dbo = Pommo::$_dbo;
/**********************************
	JSON OUTPUT INITIALIZATION
 *********************************/
require_once Pommo::$_baseDir . 'classes/Pommo_Json.php';
$json = new Pommo_Json();
// EXAMINE CALL
switch ($_REQUEST['call']) {
    case 'addSubscriber':
        $json->setFailMsg(Pommo::_T('Error adding subscriber.'));
        // check if email is valid
        if (!Pommo_Helper::isEmail($_REQUEST['Email'])) {
            echo 1;
            $json->fail(Pommo::_T('Invalid email.'));
        }
        // check if email has unsubscribed
        if (!isset($_REQUEST['force'])) {
            $unsubscribed = Pommo_Subscribers::GetIDByEmail($_REQUEST['Email'], 0);
            if (!empty($unsubscribed)) {
                $json->fail(sprintf(Pommo::_T('%s has already unsubscribed. To
						add the subscriber anyway, check the box to force the
						addition.'), '<strong>' . $_REQUEST['Email'] . '</strong>'));
            }
        }
        // check if duplicate
        if (Pommo_Helper::isDupe($_POST['Email'])) {
            $json->fail(Pommo::_T('Email address already exists. Duplicates are
					not allowed.'));
        }
Exemple #4
0
    $validator->addData('field_prompt', 'Other', false);
    $validator->addData('field_required', 'matchRegex', false, '!^(on|off)$!');
    $validator->addData('field_active', 'matchRegex', false, '!^(on|off)$!');
    if ($result = $validator->checkData()) {
        // __ FORM IS VALID
        // TODO -> Which below logic is better? the computed diff, or send all fields for update?
        /*
        // make a difference between updated & original field
        $update = array_diff_assoc(Pommo_Fields::makeDB($_POST),$field);
        // restore the ID
        $update['id'] = $field['id'];
        */
        // let MySQL do the difference processing
        $update = Pommo_Fields::makeDB($_POST);
        if (!Pommo_Fields::update($update)) {
            $json->fail('error updating field');
        }
        $json->add('callbackFunction', 'updateField');
        $json->add('callbackParams', $update);
        $json->success(Pommo::_T('Settings 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.'));
    }
}
Exemple #5
0
	JSON OUTPUT INITIALIZATION
 *********************************/
require_once Pommo::$_baseDir . 'classes/Pommo_Json.php';
$json = new Pommo_Json();
// EXAMINE CALL
switch ($_REQUEST['call']) {
    case 'updateOrdering':
        $when = '';
        foreach ($_REQUEST['order'] as $order => $fieldID) {
            if (is_numeric($order)) {
                $when .= $dbo->prepare("WHEN %i THEN %i", array($fieldID, $order)) . ' ';
            }
        }
        $query = "\n\t\t\tUPDATE " . $dbo->table['fields'] . "\n\t\t\tSET field_ordering = \n\t\t\t\tCASE field_id " . $when . " ELSE field_ordering END";
        if (!$dbo->query($dbo->prepare($query))) {
            $json->fail('Error Updating Order');
        }
        $json->add('query', $query);
        $json->success(Pommo::_T('Order Updated.'));
        break;
    case 'addOption':
        // validate field ID
        $field = current(Pommo_Fields::get(array('id' => $_REQUEST['field_id'])));
        if ($field['id'] != $_REQUEST['field_id']) {
            die('bad field ID');
        }
        if (!empty($_REQUEST['options'])) {
            $options = Pommo_Fields::optionAdd($field, $_REQUEST['options']);
        }
        if (!options) {
            $json->fail(Pommo::_T('Error with addition.'));
Exemple #6
0
 *
 */
/**********************************
 INITIALIZATION METHODS
*********************************/
require '../bootstrap.php';
Pommo::init();
if ($_POST['bounces_submit']) {
    require_once Pommo::$_baseDir . 'classes/Pommo_Json.php';
    require_once Pommo::$_baseDir . 'classes/Pommo_Setup.php';
    $json = new Pommo_Json();
    $setup = new Pommo_Setup();
    if (!$setup->saveBouncesForm()) {
        $fieldErrors = array();
        $errors = $setup->error['message'];
        foreach ($errors as $key => $val) {
            $fieldErrors[$key] = $val;
        }
        $json->add('fieldErrors', $fieldErrors);
        $json->fail(_('Save failed'));
    } else {
        $json->success(_('Hello'));
    }
    return;
}
/**********************************
 SETUP TEMPLATE, PAGE
*********************************/
require_once Pommo::$_baseDir . 'classes/Pommo_Template.php';
$view = new Pommo_Template();
$view->display('admin/setup/config/bounces');
Exemple #7
0
    	 *********************************/
    require_once Pommo::$_baseDir . 'classes/Pommo_Json.php';
    $json = new Pommo_Json();
    if ($state['tally'] > 0) {
        if ($state['ishtml'] == 'off') {
            $state['body'] = $state['altbody'];
            $state['altbody'] = '';
        }
        $mailing = Pommo_Mailing::make(array(), TRUE);
        $state['status'] = 1;
        $state['current_status'] = 'stopped';
        $state['command'] = 'restart';
        $mailing = Pommo_Helper::arrayIntersect($state, $mailing);
        $code = Pommo_Mailing::add($mailing);
        if (!Pommo_Mail_Ctl::queueMake($memberIDs)) {
            $json->fail('Unable to populate queue');
        }
        if (!Pommo_Mail_Ctl::spawn(Pommo::$_baseUrl . 'ajax/mailings_send4.php?code=' . $code)) {
            $json->fail('Unable to spawn background mailer');
        }
        // clear mailing composistion data from session
        Pommo_Api::stateReset(array('mailing'));
        $json->add('callbackFunction', 'redirect');
        $json->add('callbackParams', Pommo::$_baseUrl . 'mailing_status.php');
    } else {
        $json->fail(Pommo::_T('Cannot send a mailing to 0 subscribers!'));
    }
    $json->serve();
}
$smarty->assign($state);
$smarty->display('admin/mailings/mailing/preview.tpl');
Exemple #8
0
        $group =& current(Pommo_Groups::get(array('id' => $state['group'])));
        $rules = Pommo_Sql::sortRules($group['rules']);
        switch ($_REQUEST['request']) {
            case 'update':
                if ($_REQUEST['type'] == 'or' && count($rules['and']) < 2) {
                    $json->add('callbackFunction', 'resume');
                    $json->success(Pommo::_T('At least 1 "and" rule must exist before an "or" rule takes effect.'));
                }
                Pommo_Rules::changeType($group['id'], $_REQUEST['fieldID'], $_REQUEST['logic'], $_REQUEST['type']);
                break;
            case 'delete':
                Pommo_Rules::deleteRule($group['id'], $_REQUEST['fieldID'], $_REQUEST['logic']);
                break;
        }
        $json->add('callbackFunction', 'redirect');
        $json->add('callbackParams', Pommo::$_baseUrl . 'groups_edit.php');
        $json->serve();
        break;
    case 'renameGroup':
        if (!empty($_REQUEST['group_name'])) {
            if (Pommo_Groups::nameChange($state['group'], $_REQUEST['group_name'])) {
                $json->success(Pommo::_T('Group Renamed'));
            }
        }
        $json->fail('invalid group name');
        break;
    default:
        die('invalid request passed to ' . __FILE__);
        break;
}
die;
Exemple #9
0
if (empty($_POST)) {
    //Initiate Page
    //populate _POST with info from database (fills in form values...)
    $dbVals = Pommo_Api::configGet(array('admin_username'));
    $dbVals['admin_email'] = Pommo::$_config['admin_email'];
    $view->assign($dbVals);
} else {
    // ___ USER HAS SENT FORM ___
    require_once Pommo::$_baseDir . 'classes/Pommo_Json.php';
    $json = new Pommo_Json();
    if (isset($_POST['admin_email'])) {
        //Do inline validation
        require_once Pommo::$_baseDir . 'classes/Pommo_Validate.php';
        $errors = array();
        $validator = new Pommo_Validate();
        $validator->setPost($_POST);
        $validator->addData('admin_email', 'Email', false);
        $result = $validator->checkData();
        $errors = $validator->getErrors();
        //Is result ok?
        if ($result) {
            Pommo_Api::configUpdate($_POST);
            Pommo::reloadConfig();
            $json->success(Pommo::_T('Configuration Updated.'));
        } else {
            $json->fail(Pommo::_T('Invalid email address'));
        }
    }
}
$view->assign($_POST);
$view->display('admin/setup/config/users');