add() 공개 메소드

beware of key conflicts (especially when passing arrays)!
public add ( $key, $value = false )
예제 #1
0
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();
예제 #2
0
파일: templates.php 프로젝트: soonick/poMMo
Pommo::init();
$logger = Pommo::$_logger;
$dbo = Pommo::$_dbo;
/**********************************
	SETUP TEMPLATE, PAGE
 *********************************/
require_once Pommo::$_baseDir . 'classes/Pommo_Template.php';
$view = new Pommo_Template();
/**********************************
	JSON OUTPUT INITIALIZATION
 *********************************/
require_once Pommo::$_baseDir . 'classes/Pommo_Json.php';
$json = new Pommo_Json();
$success = false;
if (isset($_POST['skip']) || isset($_POST['template']) && !is_numeric($_POST['template'])) {
    $success = true;
} elseif (isset($_POST['load'])) {
    $template = current(Pommo_Mailing_Template::get(array('id' => $_POST['template'])));
    Pommo::$_session['state']['mailing']['body'] = $template['body'];
    Pommo::$_session['state']['mailing']['altbody'] = $template['altbody'];
    $success = true;
} elseif (isset($_POST['delete'])) {
    $msg = Pommo_Mailing_Template::delete($_POST['template']) ? Pommo::_T('Template Deleted') : Pommo::_T('Error with deletion.');
    $json->add('callbackFunction', 'deleteTemplate');
    $json->add('callbackParams', array('id' => $_POST['template'], 'msg' => $msg));
} else {
    $view->assign('templates', Pommo_Mailing_Template::getNames());
    $view->display('admin/mailings/mailing/templates');
    Pommo::kill();
}
$json->serve($success);
예제 #3
0
파일: setup.php 프로젝트: systemfirez/poMMo
    SmartyValidate::register_validator('mailgroup', 'mailgroup:/(all|\\d+)/i', 'isRegExp', false, false, 'trim');
    SmartyValidate::register_validator('list_charset', 'list_charset', 'isCharSet', false, false, 'trim');
    $vMsg = array();
    $vMsg['fromname'] = $vMsg['subject'] = Pommo::_T('Cannot be empty.');
    $vMsg['charset'] = Pommo::_T('Invalid Character Set');
    $vMsg['fromemail'] = $vMsg['frombounce'] = Pommo::_T('Invalid email address');
    $vMsg['ishtml'] = $vMsg['mailgroup'] = Pommo::_T('Invalid Input');
    $smarty->assign('vMsg', $vMsg);
} else {
    // ___ USER HAS SENT FORM ___
    /**********************************
    		JSON OUTPUT INITIALIZATION
    	 *********************************/
    require_once Pommo::$_baseDir . 'classes/Pommo_Json.php';
    $json = new Pommo_Json();
    SmartyValidate::connect($smarty);
    if (SmartyValidate::is_valid($_POST)) {
        // __ FORM IS VALID
        SmartyValidate::disconnect();
        $json->success();
    } else {
        // __ FORM NOT VALID
        $json->add('fieldErrors', $smarty->getInvalidFields());
        $json->fail(Pommo::_T('Please review and correct errors with your submission.'));
    }
}
$mailgroups = explode(',', $state['mailgroup']);
$smarty->assign('mailgroups', $mailgroups);
$smarty->assign('groups', Pommo_Groups::get());
$smarty->assign($state);
$smarty->display('admin/mailings/mailing/setup.tpl');
예제 #4
0
    SmartyValidate::connect($smarty);
    if (SmartyValidate::is_valid($_POST)) {
        // __ 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
        $json->add('fieldErrors', $smarty->getInvalidFields());
        $json->fail(Pommo::_T('Please review and correct errors with your submission.'));
    }
}
$f_text = sprintf(Pommo::_T('%s - Any value will be accepted for text fields. They are useful for collecting names, addresses, etc.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Text') . ')</strong>');
$f_check = sprintf(Pommo::_T('%s - Checkboxes can be toggled ON or OFF. They are useful for opt-ins and agreements.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Checkbox') . ')</strong>');
$f_num = sprintf(Pommo::_T('%s - Only Numeric values will be accepted for number fields.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Number') . ')</strong>');
$f_date = sprintf(Pommo::_T('%s - Only calendar values will be accepted for this field. A date selector (calendar popup) will appear next to the field to aid the subscriber in selecting a date.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Date') . ')</strong>');
$f_mult = sprintf(Pommo::_T('%s - Subscribers will be able to select a value from the options you provide below. Multiple choice fields have reliable values for organizing, and are useful for collecting Country, Interests, etc.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Multiple Choice') . ')</strong>');
$f_comm = sprintf(Pommo::_T('%s -. If a subscriber enters a value for a comment field, it will be mailed to the admin notification email.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Comment') . ')</strong>');
switch ($field['type']) {
예제 #5
0
    $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.'));
    }
}
$f_text = sprintf(Pommo::_T('%s - Any value will be accepted for text fields. They are useful for collecting names, addresses, etc.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Text') . ')</strong>');
$f_check = sprintf(Pommo::_T('%s - Checkboxes can be toggled ON or OFF. They are useful for opt-ins and agreements.'), '<strong>' . $field['name'] . ' (' . Pommo::_T('Checkbox') . ')</strong>');
예제 #6
0
    $vMsg = array();
    $vMsg['site_url'] = $vMsg['site_success'] = $vMsg['site_confirm'] = Pommo::_T('Must be a valid URL');
    $vMsg['list_name'] = $vMsg['site_name'] = Pommo::_T('Cannot be empty.');
    $smarty->assign('vMsg', $vMsg);
    // populate _POST with info from database (fills in form values...)
    $dbVals = Pommo_Api::configGet(array('site_success', 'site_confirm', 'list_exchanger', 'list_confirm'));
    $dbVals['site_url'] = Pommo::$_config['site_url'];
    $dbVals['site_name'] = Pommo::$_config['site_name'];
    $dbVals['list_name'] = Pommo::$_config['list_name'];
    $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, 'general')) {
        // __ FORM IS VALID
        Pommo_Api::configUpdate($_POST);
        Pommo::reloadConfig();
        $json->success(Pommo::_T('Configuration Updated.'));
    } else {
        // __ FORM NOT VALID
        $json->add('fieldErrors', $smarty->getInvalidFields('general'));
        $json->fail(Pommo::_T('Please review and correct errors with your submission.'));
    }
}
$smarty->assign($_POST);
$smarty->display('admin/setup/config/general.tpl');
Pommo::kill();
예제 #7
0
        case 'activate':
            $messages = Pommo_Helper_Messages::resetDefault('activate');
            break;
        case 'unsubscribe':
            $messages = Pommo_Helper_Messages::resetDefault('unsubscribe');
            break;
        case 'confirm':
            $messages = Pommo_Helper_Messages::resetDefault('confirm');
            break;
        case 'update':
            $messages = Pommo_Helper_Messages::resetDefault('update');
            break;
    }
    // reset _POST.
    $_POST = array();
    $json->add('callbackFunction', 'redirect');
    $json->add('callbackParams', Pommo::$_baseUrl . 'setup_configure.php?tab=Messages');
    $json->serve();
}
// ADD CUSTOM VALIDATOR FOR CHARSET
function check_notifyMails($value, $empty, &$params, &$formvars)
{
    $mails = Pommo_Helper::trimArray(explode(',', $value));
    $ret = true;
    foreach ($mails as $mail) {
        if (!empty($mail) && !Pommo_Helper::isEmail($mail)) {
            $ret = false;
        }
    }
    return $ret;
}
예제 #8
0
	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);
    default:
        $json->fail();
        break;
}
$json->success();
예제 #9
0
        }
        $key = Pommo_Subscribers::add($subscriber);
        if (!$key) {
            $json->fail();
        }
        $json->addMsg(sprintf(Pommo::_T('Subscriber %s added!'), '<strong>' . $subscriber['email'] . '</strong>'));
        if ($flag) {
            $json->addErr(Pommo::_T('Subscriber has been flagged for update due
					to invalid or missing information.'));
        }
        // add the subscriber to JSON output
        $data = array('key' => $key, 'email' => $subscriber['email'], 'registered' => $subscriber['registered'], 'touched' => $subscriber['registered'], 'ip' => $subscriber['ip']);
        foreach ($subscriber['data'] as $k => $val) {
            $data['d' . $k] = htmlspecialchars($val);
        }
        $json->add('callbackFunction', 'addSubscriber');
        $json->add('callbackParams', $data);
        break;
    case 'delSubscriber':
        $emails = array();
        if (isset($_REQUEST['emails'])) {
            $in = array_unique(preg_split("/[\\s,]+/", $_REQUEST['emails']));
            foreach ($in as $email) {
                if (Pommo_Helper::isEmail($email)) {
                    array_push($emails, $email);
                }
            }
        }
        if (count($emails) > 0) {
            $ids = Pommo_Subscribers::getIDByEmail($emails, $_REQUEST['status']);
            $msg = sprintf(Pommo::_T('You have removed %s subscribers!'), Pommo_Subscribers::delete($ids));
예제 #10
0
$output['statusText'] = $statusText[$output['status']];
// get last 50 unique notices
$mailingNotices = Pommo_Mailing::getNotices($mailing['id'], 50, true);
$newNotices = array();
foreach ($mailingNotices as $time => $arr) {
    if (!isset($state['notices'][$time])) {
        $newNotices = array_merge($newNotices, $arr);
        continue;
    }
    foreach ($arr as $notice) {
        if (array_search($notice, $arr) === false) {
            $newNotices[] = $notice;
        }
    }
}
$state['notices'] = $mailingNotices;
$output['notices'] = array_reverse($newNotices);
// calculate sent
if ($output['status'] == 4) {
    $output['sent'] = Pommo_Mailing::getSent($mailing['id']);
} else {
    $query = "SELECT count(subscriber_id) FROM {$dbo->table['queue']} WHERE status > 0";
    $output['sent'] = $dbo->query($query, 0);
}
// cleanup session if frozen or finished.
if ($output['status'] > 2) {
    Pommo_Api::stateInit('subscribers_manage');
}
$output['percent'] = $output['status'] == 4 ? 100 : round($output['sent'] * (100 / $mailing['tally']));
$json->add($output);
$json->serve();
예제 #11
0
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.'));
        }
        $json->add('callbackFunction', 'updateOptions');
예제 #12
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');
예제 #13
0
파일: messages.php 프로젝트: soonick/poMMo
        case 'activate':
            $messages = Pommo_Helper_Messages::resetDefault('activate');
            break;
        case 'unsubscribe':
            $messages = Pommo_Helper_Messages::resetDefault('unsubscribe');
            break;
        case 'confirm':
            $messages = Pommo_Helper_Messages::resetDefault('confirm');
            break;
        case 'update':
            $messages = Pommo_Helper_Messages::resetDefault('update');
            break;
    }
    // reset _POST.
    $_POST = array();
    $json->add('callbackFunction', 'redirect');
    $json->add('callbackParams', Pommo::$_baseUrl . 'setup_configure.php?tab=Messages');
    $json->serve();
}
// ADD CUSTOM VALIDATOR FOR CHARSET
function check_notifyMails($value, $empty, &$params, &$formvars)
{
    $mails = Pommo_Helper::trimArray(explode(',', $value));
    $ret = true;
    foreach ($mails as $mail) {
        if (!empty($mail) && !Pommo_Helper::isEmail($mail)) {
            $ret = false;
        }
    }
    return $ret;
}
예제 #14
0
    SmartyValidate::register_validator('maxRuntime', 'maxRuntime', 'isInt', false, false, 'trim', 'mailings');
    $vMsg = array();
    $vMsg['maxRuntime'] = Pommo::_T('Enter a number.');
    $vMsg['list_fromname'] = Pommo::_T('Cannot be empty.');
    $vMsg['list_fromemail'] = $vMsg['list_frombounce'] = Pommo::_T('Invalid email address');
    $smarty->assign('vMsg', $vMsg);
    // populate _POST with info from database (fills in form values...)
    $dbVals = Pommo_Api::configGet(array('list_fromname', 'list_fromemail', 'list_frombounce', 'list_charset', 'public_history', 'maxRuntime'));
    $dbVals['demo_mode'] = !empty(Pommo::$_config['demo_mode']) && Pommo::$_config['demo_mode'] == "on" ? 'on' : 'off';
    $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, 'mailings')) {
        // __ FORM IS VALID
        Pommo_Api::configUpdate($_POST);
        Pommo::reloadConfig();
        $json->success(Pommo::_T('Configuration Updated.'));
    } else {
        // __ FORM NOT VALID
        $json->add('fieldErrors', $smarty->getInvalidFields('mailings'));
        $json->fail(Pommo::_T('Please review and correct errors with your submission.'));
    }
}
$smarty->assign($_POST);
$smarty->display('admin/setup/config/mailings.tpl');
Pommo::kill();
예제 #15
0
}
// Calculate the offset
$start = $state['limit'] * $state['page'] - $state['limit'];
if ($start < 0) {
    $start = 0;
}
/**********************************
	RECORD RETREVIAL
*********************************/
// Normalize sort column to match DB column
if ($state['sort'] == 'registered' || $state['sort'] == 'touched') {
    $state['sort'] = 'time_' . $state['sort'];
} elseif (substr($state['sort'], 0, 1) == 'd') {
    $state['sort'] = substr($state['sort'], 1);
}
// fetch subscribers for this page
$subscribers = $group->members(array('sort' => $state['sort'], 'order' => $state['order'], 'limit' => $state['limit'], 'offset' => $start));
/**********************************
	OUTPUT FORMATTING
*********************************/
// format subscribers for JSON output to jqGrid
$subOut = array();
foreach ($subscribers as $s) {
    $sub = array('id' => $s['id'], 'email' => $s['email'], 'touched' => $s['touched'], 'registered' => $s['registered'], 'ip' => $s['ip']);
    foreach ($s['data'] as $key => $d) {
        $sub['d' . $key] = $d;
    }
    array_push($subOut, $sub);
}
$json->add(array('page' => $state['page'], 'total' => $state['pages'], 'records' => $group->_tally, 'rows' => $subOut));
$json->serve();
예제 #16
0
/**********************************
	OUTPUT FORMATTING
*********************************/
$records = array();
foreach ($mailings as $o) {
    //	If the mailing is not beeing tracked show "not tracked" instead of 0
    if (0 == $o['track']) {
        $o['hits'] = Pommo::_T('Not tracked');
    }
    $row = array('id' => $o['id'], 'subject' => $o['subject'], 'group' => $o['group'] . ' (' . $o['tally'] . ')', 'sent' => $o['sent'], 'start' => $o['start'], 'end' => $o['end'], 'hits' => $o['hits']);
    if ($o['status'] == 0) {
        $o['status'] = Pommo::_T('Complete');
    } elseif ($o['status'] == 1) {
        $o['status'] = Pommo::_T('Processing');
    } else {
        $o['status'] = Pommo::_T('Cancelled');
    }
    $row['status'] = $o['status'];
    // calculate mails per hour
    if (!empty($o['end']) && !empty($o['sent'])) {
        $runtime = strtotime($o['end']) - strtotime($o['start']);
        $mph = $runtime == 0 ? $o['sent'] * 3600 : round($o['sent'] / $runtime * 3600);
    } else {
        $mph = 0;
    }
    $row['end'] .= '<br />' . $mph . ' ' . Pommo::_T('Mails/Hour');
    array_push($records, $row);
}
// format for JSON output to jqGrid
$json->add(array('page' => $state['page'], 'total' => $state['pages'], 'records' => Pommo_Mailing::tally(), 'rows' => $records));
$json->serve();
예제 #17
0
파일: general.php 프로젝트: soonick/poMMo
    $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');
예제 #18
0
             Pommo_Rules::addGroupRule($state['group'], $_REQUEST['field'], $_REQUEST['logic']);
             break;
         case 'true':
         case 'false':
             Pommo_Rules::addBoolRule($state['group'], $_REQUEST['field'], $_REQUEST['logic']);
             break;
         case 'is':
         case 'not':
         case 'less':
         case 'greater':
             $values = array_unique($_REQUEST['match']);
             $type = $_REQUEST['type'] == 'or' ? 'or' : 'and';
             Pommo_Rules::addFieldRule($state['group'], $_REQUEST['field'], $_REQUEST['logic'], $values, $type);
             break;
     }
     $json->add('callbackFunction', 'redirect');
     $json->add('callbackParams', Pommo::$_baseUrl . 'groups_edit.php');
     $json->serve();
     break;
 case 'updateRule':
     require_once Pommo::$_baseDir . 'classes/Pommo_Sql.php';
     $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;