if (!empty($_REQUEST['sord']) && ($_REQUEST['sord'] == 'asc' || $_REQUEST['sord'] == 'desc')) { $state['order'] = $_REQUEST['sord']; } // Calculate the offset $start = $state['limit'] * $state['page'] - $state['limit']; if ($start < 0) { $start = 0; } /********************************** RECORD RETREVIAL *********************************/ // normalize sort to database column if ($state['sort'] == 'start') { $state['sort'] = 'started'; } // Fetch Mailings for this Page $mailings = PommoMailing::get(array('noBody' => TRUE, 'sort' => $state['sort'], 'order' => $state['order'], 'limit' => $state['limit'], 'offset' => $start)); /********************************** OUTPUT FORMATTING *********************************/ $records = array(); foreach ($mailings as $o) { $row = array('id' => $o['id'], 'subject' => $o['subject'], 'start' => $o['start']); if ($o['status'] == 0) { // only return "complete" mailings array_push($records, $row); } } // format for JSON output to jqGrid $json->add(array('page' => $state['page'], 'total' => $state['pages'], 'records' => PommoMailing::tally(), 'rows' => $records)); $json->serve();
$input['subject'] = PommoHelperPersonalizeTitle::replace($input['subject'], $subscriber, $pSubject); } } $smarty->assign($input); $smarty->display('inc/mailing.tpl'); Pommo::kill(); } } /********************************** VALIDATION ROUTINES *********************************/ if (!is_numeric($state['limit']) || $state['limit'] < 10 || $state['limit'] > 200) { $state['limit'] = 100; } if ($state['order'] != 'asc' && $state['order'] != 'desc') { $state['order'] = 'asc'; } if ($state['sort'] != 'start' && $state['sort'] != 'subject') { $state['sort'] = 'start'; } /********************************** DISPLAY METHODS *********************************/ // Calculate and Remember number of pages $tally = PommoMailing::tally(); $state['pages'] = is_numeric($tally) && $tally > 0 ? ceil($tally / $state['limit']) : 0; $smarty->assign('state', $state); $smarty->assign('tally', $tally); $smarty->assign('mailings', $mailings); $smarty->display('user/mailings.tpl'); Pommo::kill();