getLegal() 공개 정적인 메소드

returns an array of logics. Array key correlates to field_id.
public static getLegal ( &$group, $fields )
예제 #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');
예제 #2
0
 }
 if ($_REQUEST['ruleType'] == 'field') {
     $field = current(Pommo_Fields::get(array('id' => $_REQUEST['fieldID'])));
     $logic = isset($_REQUEST['logic']) && $_REQUEST['logic'] != "0" ? $_REQUEST['logic'] : false;
     $type = $_REQUEST['type'] == 'or' ? 'or' : 'and';
     $values = array();
     // check to see if we're editing [logic is passed *only* when edit button is clicked]
     if ($logic) {
         foreach ($group['rules'] as $rule) {
             if ($rule['logic'] == $logic && $rule['field_id'] == $_REQUEST['fieldID']) {
                 $values[] = $field['type'] == 'date' ? Pommo_Helper::timeFromStr($rule['value']) : $rule['value'];
             }
         }
     }
     $firstVal = empty($values) ? false : array_shift($values);
     $logic = $logic ? Pommo_Rules::getEnglish(array($logic)) : Pommo_Rules::getEnglish(end(Pommo_Rules::getLegal($group, array($field))));
     $smarty->assign('type', $type);
     $smarty->assign('field', $field);
     $smarty->assign('logic', $logic);
     $smarty->assign('values', $values);
     $smarty->assign('firstVal', $firstVal);
     $smarty->display('ajax/rule.field.tpl');
     Pommo::kill();
 } elseif ($_REQUEST['ruleType'] == 'group') {
     $match = Pommo_Groups::getNames($_REQUEST['fieldID']);
     $key = key($match);
     $smarty->assign('match_name', $match[$key]);
     $smarty->assign('match_id', $key);
     $smarty->display('ajax/rule.group.tpl');
     Pommo::kill();
 }