Pommo_Groups::get PHP Method

get() static public method

returns an array of groups. Array key(s) correlates to group ID.
static public get ( $p = [] )
    static function &get($p = array())
    {
        $defaults = array('id' => null);
        $p = Pommo_Api::getParams($defaults, $p);
        $dbo =& Pommo::$_dbo;
        $o = array();
        $query = "\n            SELECT g.group_id, g.group_name, c.rule_id, c.field_id, c.logic, c.value, c.type\n            FROM " . $dbo->table['groups'] . " g\n            LEFT JOIN " . $dbo->table['group_rules'] . " c\n                ON (g.group_id = c.group_id)\n            WHERE\n                1\n                [AND g.group_id IN(%C)]\n            ORDER BY g.group_name";
        $query = $dbo->prepare($query, array($p['id']));
        while ($row = $dbo->getRows($query)) {
            if (empty($o[$row['group_id']])) {
                $o[$row['group_id']] = Pommo_Groups::makeDB($row);
            }
            if (!empty($row['rule_id'])) {
                $c = array('field_id' => $row['field_id'], 'logic' => $row['logic'], 'value' => $row['value'], 'or' => $row['type'] == 0 ? false : true);
                $o[$row['group_id']]['rules'][$row['rule_id']] = $c;
            }
        }
        return $o;
    }

Usage Example

Example #1
0
 function __construct($groupID = NULL, $status = 1, $filter = FALSE)
 {
     $this->_status = $status;
     if (!is_numeric($groupID)) {
         // exception if no group ID was passed -- group assumes "all subscribers".
         require_once Pommo::$_baseDir . 'classes/Pommo_Subscribers.php';
         $this->_group = array('rules' => array(), 'id' => 0);
         $this->_id = 0;
         $this->_name = Pommo::_T('All Subscribers');
         $this->_memberIDs = is_array($filter) ? Pommo_Groups::getMemberIDs($this->_group, $status, $filter) : null;
         $this->_tally = is_array($filter) ? count($this->_memberIDs) : Pommo_Subscribers::tally($status);
         return;
     }
     $this->_group = current(Pommo_Groups::get(array('id' => $groupID)));
     $this->_id = $groupID;
     $this->_name =& $this->_group['name'];
     $this->_memberIDs = Pommo_Groups::getMemberIDs($this->_group, $status, $filter);
     $this->_tally = count($this->_memberIDs);
     return;
 }
All Usage Examples Of Pommo_Groups::get