Пример #1
0
 function addFieldRule(&$group, &$field, &$logic, &$values, $type = 0)
 {
     global $pommo;
     $dbo =& $pommo->_dbo;
     $type = $type == 'or' ? 1 : 0;
     // remove previous filters
     PommoRules::deleteRule($group, $field, $logic);
     // get the field
     Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/fields.php');
     $field = current(PommoField::get(array('id' => $field)));
     foreach ($values as $value) {
         // if this is a date type field, convert the values from human readable date
         //  strings to timestamps appropriate for matching
         if ($field['type'] == 'date') {
             $value = PommoHelper::timeFromStr($value);
         }
         $v[] = $dbo->prepare("(%i,%i,'%s','%s',%i)", array($group, $field['id'], $logic, $value, $type));
     }
     $query = "\n\t\t\tINSERT INTO " . $dbo->table['group_rules'] . "\n\t\t\t(group_id, field_id, logic, value, type)\n\t\t\tVALUES " . implode(',', $v);
     return $dbo->affected($query);
 }
Пример #2
0
$smarty->assign('returnStr', Pommo::_T('Groups Page'));
// Initialize page state with default values overriden by those held in $_REQUEST
$state =& PommoAPI::stateInit('groups_edit', array('group' => 0), $_REQUEST);
$groups =& PommoGroup::get();
$fields =& PommoField::get();
$group =& $groups[$state['group']];
if (empty($group)) {
    Pommo::redirect('subscribers_groups.php');
}
$rules = PommoSQL::sortRules($group['rules']);
$rules['and'] = PommoSQL::sortLogic($rules['and']);
$rules['or'] = PommoSQL::sortLogic($rules['or']);
foreach ($rules as $key => $a) {
    if ($key == 'include' || $key == 'exclude') {
        foreach ($a as $k => $gid) {
            $rules[$key][$k] = $groups[$gid]['name'];
        }
    }
}
$smarty->assign('fields', $fields);
$smarty->assign('legalFieldIDs', PommoRules::getLegal($group, $fields));
$smarty->assign('legalGroups', PommoRules::getLegalGroups($group, $groups));
$smarty->assign('group', $group);
$smarty->assign('logicNames', PommoRules::getEnglish());
$smarty->assign('rules', $rules);
$smarty->assign('tally', PommoGroup::tally($group));
$smarty->assign('ruleCount', count($rules['and']) + count($rules['or']) + count($rules['include']) + count($rules['exclude']));
$smarty->assign('getURL', $_SERVER['PHP_SELF'] . '?group_id=' . $group['id']);
$smarty->assign('t_include', Pommo::_T('INCLUDE'));
$smarty->display('admin/subscribers/groups_edit.tpl');
Pommo::kill();
Пример #3
0
     $json->serve();
     break;
 case 'updateRule':
     Pommo::requireOnce($pommo->_baseDir . 'inc/classes/sql.gen.php');
     $group =& current(PommoGroup::get(array('id' => $state['group'])));
     $rules = PommoSQL::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.'));
             }
             PommoRules::changeType($group['id'], $_REQUEST['fieldID'], $_REQUEST['logic'], $_REQUEST['type']);
             break;
         case 'delete':
             PommoRules::deleteRule($group['id'], $_REQUEST['fieldID'], $_REQUEST['logic']);
             break;
     }
     $json->add('callbackFunction', 'redirect');
     $json->add('callbackParams', $pommo->_baseUrl . 'admin/subscribers/groups_edit.php');
     $json->serve();
     break;
 case 'renameGroup':
     if (!empty($_REQUEST['group_name'])) {
         if (PommoGroup::nameChange($state['group'], $_REQUEST['group_name'])) {
             $json->success(Pommo::_T('Group Renamed'));
         }
     }
     $json->fail('invalid group name');
     break;
 default: