Pommo_Groups::getNames PHP Method

getNames() public static method

returns an array of group names. Array key(s) correlates to group ID.
public static getNames ( $id = null )
    public static function getNames($id = null)
    {
        $dbo =& Pommo::$_dbo;
        $o = array();
        $query = "\n            SELECT group_id, group_name\n            FROM " . $dbo->table['groups'] . "\n            WHERE\n                1\n                [AND group_id IN(%C)]\n            ORDER BY group_name";
        $query = $dbo->prepare($query, array($id));
        while ($row = $dbo->getRows($query)) {
            $o[$row['group_id']] = $row['group_name'];
        }
        return $o;
    }

Usage Example

Example #1
0
$json = new Pommo_Json(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'), Pommo_Mailing::getSubject($id)) . ' ###<br /><br />');
            $notices = Pommo_Mailing::getNotices($id);
            $logger->AddMsg($notices);
        }
        break;
    case 'reload':
        require_once Pommo::$_baseDir . 'classes/Pommo_Groups.php';
        $mailing = current(Pommo_Mailing::get(array('id' => $_REQUEST['mailings'])));
        // change group name to ID
        $groups = Pommo_Groups::getNames();
        $gid = 'all';
        foreach ($groups as $group) {
            if ($group['name'] == $mailing['group']) {
                $gid = $group['id'];
            }
        }
        Pommo_Api::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 =& Pommo_Api::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 . 'mailings_start.php');
All Usage Examples Of Pommo_Groups::getNames