This file is part of poMMo (http://www.pommo.org) poMMo is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or any later version. poMMo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with program; see the file docs/LICENSE. If not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
Example #1
0
$view = new Pommo_Template();
$view->assign('returnStr', _('Groups Page'));
// Initialize page state with default values overriden by those held in $_REQUEST
$state =& Pommo_Api::stateInit('groups_edit', array('group' => 0), $_REQUEST);
$groups = Pommo_Groups::get();
$fields = Pommo_Fields::get();
$group =& $groups[$state['group']];
if (empty($group)) {
    Pommo::redirect('subscribers_groups.php');
}
$rules = Pommo_Sql::sortRules($group['rules']);
$rules['and'] = Pommo_Sql::sortLogic($rules['and']);
$rules['or'] = Pommo_Sql::sortLogic($rules['or']);
foreach ($rules as $key => $a) {
    if ($key == 'include' || $key == 'exclude') {
        foreach ($a as $k => $gid) {
            $rules[$key][$k] = $groups[$gid]['name'];
        }
    }
}
$view->assign('fields', $fields);
$view->assign('legalFieldIDs', Pommo_Rules::getLegal($group, $fields));
$view->assign('legalGroups', Pommo_Rules::getLegalGroups($group, $groups));
$view->assign('group', $group);
$view->assign('logicNames', Pommo_Rules::getEnglish());
$view->assign('rules', $rules);
$view->assign('tally', Pommo_Groups::tally($group));
$view->assign('ruleCount', count($rules['and']) + count($rules['or']) + count($rules['include']) + count($rules['exclude']));
$view->assign('getURL', $_SERVER['PHP_SELF'] . '?group_id=' . $group['id']);
$view->assign('t_include', Pommo::_T('INCLUDE'));
$view->display('admin/subscribers/groups_edit');
Example #2
0
     $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;
         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:
Example #3
0
 function addFieldRule(&$group, &$field, &$logic, &$values, $type = 0)
 {
     global $pommo;
     $dbo =& Pommo::$_dbo;
     $type = $type == 'or' ? 1 : 0;
     // remove previous filters
     Pommo_Rules::deleteRule($group, $field, $logic);
     // get the field
     require_once Pommo::$_baseDir . 'classes/Pommo_Fields.php';
     $field = current(Pommo_Fields::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 = Pommo_Helper::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);
 }
Example #4
0
$smarty->assign('returnStr', Pommo::_T('Groups Page'));
// Initialize page state with default values overriden by those held in $_REQUEST
$state =& Pommo_Api::stateInit('groups_edit', array('group' => 0), $_REQUEST);
$groups =& Pommo_Groups::get();
$fields =& Pommo_Fields::get();
$group =& $groups[$state['group']];
if (empty($group)) {
    Pommo::redirect('subscribers_groups.php');
}
$rules = Pommo_Sql::sortRules($group['rules']);
$rules['and'] = Pommo_Sql::sortLogic($rules['and']);
$rules['or'] = Pommo_Sql::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', Pommo_Rules::getLegal($group, $fields));
$smarty->assign('legalGroups', Pommo_Rules::getLegalGroups($group, $groups));
$smarty->assign('group', $group);
$smarty->assign('logicNames', Pommo_Rules::getEnglish());
$smarty->assign('rules', $rules);
$smarty->assign('tally', Pommo_Groups::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();