if ($state['order'] != 'asc' && $state['order'] != 'desc') {
    $state['order'] = 'asc';
}
if (!is_numeric($state['sort']) && $state['sort'] != 'email' && $state['sort'] != 'ip' && $state['sort'] != 'time_registered' && $state['sort'] != 'time_touched') {
    $state['sort'] = 'email';
}
if (!is_numeric($state['status'])) {
    $state['status'] = 1;
}
if (!is_numeric($state['group']) && $state['group'] != 'all') {
    $state['group'] = 'all';
}
if (isset($_REQUEST['searchClear'])) {
    $state['search'] = false;
} elseif (isset($_REQUEST['searchField']) && (is_numeric($_REQUEST['searchField']) || $_REQUEST['searchField'] == 'email' || $_REQUEST['searchField'] == 'ip' || $_REQUEST['searchField'] == 'time_registered' || $_REQUEST['searchField'] == 'time_touched')) {
    $_REQUEST['searchString'] = trim($_REQUEST['searchString']);
    $state['search'] = empty($_REQUEST['searchString']) ? false : array('field' => $_REQUEST['searchField'], 'string' => trim($_REQUEST['searchString']));
}
/**********************************
	DISPLAY METHODS
*********************************/
// Get the *empty* group [no member IDs. 3rd arg is set TRUE]
$group = new PommoGroup($state['group'], $state['status'], $state['search']);
// Calculate and Remember number of pages for this group/status combo
$state['pages'] = is_numeric($group->_tally) && $group->_tally > 0 ? ceil($group->_tally / $state['limit']) : 0;
$smarty->assign('state', $state);
$smarty->assign('tally', $group->_tally);
$smarty->assign('groups', PommoGroup::get());
$smarty->assign('fields', PommoField::get());
$smarty->display('admin/subscribers/subscribers_manage.tpl');
Pommo::kill();
Beispiel #2
0
 function add(&$in)
 {
     global $pommo;
     $dbo =& $pommo->_dbo;
     if (!PommoGroup::validate($in)) {
         return false;
     }
     $query = "\n\t\tINSERT INTO " . $dbo->table['groups'] . "\n\t\tSET\n\t\tgroup_name='%s'";
     $query = $dbo->prepare($query, @array($in['name']));
     return $dbo->lastId($query);
 }
Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/fields.php');
Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/groups.php');
$pommo->init();
$logger =& $pommo->_logger;
$dbo =& $pommo->_dbo;
$pommo->toggleEscaping(TRUE);
$state =& PommoAPI::stateInit('subscribers_manage');
$fields = PommoField::get();
$ids = FALSE;
if (!empty($_POST['ids'])) {
    $ids = explode(',', $_POST['ids']);
}
// ====== CSV EXPORT ======
if ($_POST['type'] == 'csv') {
    if (!$ids) {
        $group = new PommoGroup($state['group'], $state['status']);
        $subscribers = $group->members();
    } else {
        $subscribers = PommoSubscriber::get(array('id' => $ids));
    }
    // supply headers
    $o = '"' . Pommo::_T('Email') . '"';
    if (!empty($_POST['registered'])) {
        $o .= ',"' . Pommo::_T('Date Registered') . '"';
    }
    if (!empty($_POST['ip'])) {
        $o .= ',"' . Pommo::_T('IP Address') . '"';
    }
    foreach ($fields as $f) {
        $o .= ",\"{$f['name']}\"";
    }
$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();
$json = new PommoJSON(false);
// do not toggle escaping
// EXAMINE CALL
switch ($_REQUEST['call']) {
    case 'notice':
        foreach ($mailingIDS as $id) {
            $logger->AddMsg('<br /><br />###' . sprintf(Pommo::_T('Displaying notices for mailing %s'), PommoMailing::getSubject($id)) . ' ###<br /><br />');
            $notices = PommoMailing::getNotices($id);
            $logger->AddMsg($notices);
        }
        break;
    case 'reload':
        Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/groups.php');
        $mailing = current(PommoMailing::get(array('id' => $_REQUEST['mailings'])));
        // change group name to ID
        $groups = PommoGroup::getNames();
        $gid = 'all';
        foreach ($groups as $group) {
            if ($group['name'] == $mailing['group']) {
                $gid = $group['id'];
            }
        }
        PommoAPI::stateReset(array('mailing'));
        // if this is a plain text mailing, switch body + altbody.
        if ($mailing['ishtml'] == 'off') {
            $mailing['altbody'] = $mailing['body'];
            $mailing['body'] = null;
        }
        // Initialize page state with default values overriden by those held in $_REQUEST
        $state =& PommoAPI::stateInit('mailing', array('fromname' => $mailing['fromname'], 'fromemail' => $mailing['fromemail'], 'frombounce' => $mailing['frombounce'], 'list_charset' => $mailing['charset'], 'mailgroup' => $gid, 'subject' => $mailing['subject'], 'body' => $mailing['body'], 'altbody' => $mailing['altbody']));
        Pommo::redirect($pommo->_baseUrl . 'admin/mailings/mailings_start.php');
Beispiel #6
0
        $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:
        die('invalid request passed to ' . __FILE__);
        break;
}
die;
Beispiel #7
0
 function groupSQL(&$group, $tally = false, $status = 1, $filter = false)
 {
     // used to prevent against group include/exclude recursion
     static $groups;
     if (!isset($groups[$group['id']])) {
         $groups[$group['id']] = TRUE;
     }
     global $pommo;
     $dbo =& $pommo->_dbo;
     /*
     		SELECT count(subscriber_id)
     from subscribers 
     where 
     status ='1' 
     AND ( // base group
     subscriber_id in 
     	(select subscriber_id from subscriber_data  where  field_id =3 and value IN ('on'))
     AND subscriber_id in 
     	(select subscriber_id from subscriber_data  where  field_id =4 and value NOT IN ('lemur'))
     OR subscriber_id in
     	(select subscriber_id from subscriber_data  where  field_id =5 and value NOT IN ('on'))
     )
     AND subscriber_ID NOT IN(  // exclude group
     	SELECT subscriber_id from subscribers where status ='1' AND (
     		subscriber_id in
     			(select ... zzz)
     		AND subsriber_id in
     			(select ... zzz)
     		OR subscriber_id in
     			(select ... zzz)
     	)
     )
     OR subscriber_ID IN(  // include group
     	SELECT subscriber_id from subscribers where status ='1' AND (
     		subscriber_id in
     			(select ... zzz)
     		AND subsriber_id in
     			(select ... zzz)
     		OR subscriber_id in
     			(select ... zzz)
     	)
     )
     */
     $rules = PommoSQL::sortRules($group['rules']);
     $ands = PommoSQL::getSubQueries(PommoSQL::sortLogic($rules['and']));
     $ors = empty($rules['or']) ? array() : PommoSQL::getSubQueries(PommoSQL::sortLogic($rules['or']));
     $sql = $tally ? 'SELECT count(subscriber_id) ' : 'SELECT subscriber_id ';
     $sql .= "\n\t\t\tFROM {$dbo->table['subscribers']}\n\t\t\tWHERE status=" . intval($status);
     $q = FALSE;
     if (!empty($ands)) {
         $sql .= " AND (\n";
         foreach ($ands as $k => $s) {
             if ($k != 0) {
                 $sql .= "\n AND ";
             }
             $sql .= $s;
         }
         foreach ($ors as $s) {
             $sql .= "\n OR {$s}";
         }
         $sql .= "\n)";
         $q = TRUE;
     }
     foreach ($rules['exclude'] as $gid) {
         if (!isset($groups[$gid])) {
             $sql .= "\nAND subscriber_id NOT IN (\n";
             $sql .= PommoSQL::groupSQL(current(PommoGroup::get(array('id' => $gid))));
             $sql .= "\n)";
         }
         $q = TRUE;
     }
     foreach ($rules['include'] as $gid) {
         if (!isset($groups[$gid])) {
             $sql .= "\n" . ($q ? 'OR' : 'AND') . " subscriber_id IN (\n";
             $sql .= PommoSQL::groupSQL(current(PommoGroup::get(array('id' => $gid))));
             $sql .= "\n)";
         }
         $q = TRUE;
     }
     // If a filter/search is requested, perform a match
     if (is_array($filter) && !empty($filter['field']) && !empty($filter['string'])) {
         // make MySQL LIKE() compliant
         $filter['string'] = mysql_real_escape_string(addcslashes($filter['string'], '%_'));
         $sql .= is_numeric($filter['field']) ? "\n AND subscriber_id in (select subscriber_id from {$dbo->table['subscriber_data']} WHERE field_id = " . (int) $filter['field'] . " AND value LIKE '%{$filter['string']}%')" : "\n AND " . mysql_real_escape_string($filter['field']) . " LIKE '%{$filter['string']}%'";
     }
     return $sql;
 }
 * 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.
 */
/**********************************
	INITIALIZATION METHODS
*********************************/
require '../../../bootstrap.php';
Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/groups.php');
$pommo->init();
$logger =& $pommo->_logger;
$dbo =& $pommo->_dbo;
// Remember the Page State
$state =& PommoAPI::stateInit('subscribers_manage');
// Fetch group + member IDs
$group = new PommoGroup($state['group'], $state['status'], $state['search']);
/**********************************
	JSON OUTPUT INITIALIZATION
 *********************************/
Pommo::requireOnce($pommo->_baseDir . 'inc/classes/json.php');
$json = new PommoJSON();
/**********************************
	PAGINATION AND ORDERING
*********************************/
// Get and Remember the requested number of rows
if (!empty($_REQUEST['page']) && (is_numeric($_REQUEST['rows']) && ($_REQUEST['rows'] > 0 && $_REQUEST['rows'] <= 1000))) {
    $state['limit'] = $_REQUEST['rows'];
}
// Get and Remember the requested page
if (!empty($_REQUEST['page']) && (is_numeric($_REQUEST['page']) && $_REQUEST['page'] <= $state['pages'])) {
    $state['page'] = $_REQUEST['page'];