* JSON Encoding Methods authored by Jack Sleight (below);
----------------------------------------------------------------------
Version 0.5
Copyright Jack Sleight - www.reallyshiny.com
This script is licensed under the:
Creative Commons Attribution-ShareAlike 2.5 License
----------------------------------------------------------------------
public encode ( $input ) |
$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'); break; case 'delete': $deleted = Pommo_Mailing::delete($mailingIDS); $logger->addMsg(Pommo::_T('Please Wait') . '...'); $params = $json->encode(array('ids' => $mailingIDS)); $view->assign('callbackFunction', 'deleteMailing'); $view->assign('callbackParams', $params); break; default: $logger->AddErr('invalid call'); break; } $view->display('admin/rpc');
// 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'); break; case 'delete': $currentUser = Pommo::$_auth->_username; // We dont want to delete the current user $key = array_search($currentUser, $_GET['users']); if ($key !== false) { unset($_GET['users'][$key]); } require_once Pommo::$_baseDir . 'classes/Pommo_User.php'; $pu = new Pommo_User(); $deleted = $pu->delete($_GET['users']); $logger->addMsg(Pommo::_T('Please Wait') . '...'); $params = $json->encode(array('users' => $_GET['users'])); $view->assign('callbackFunction', 'deleteUser'); $view->assign('callbackParams', $params); break; case 'add': require_once Pommo::$_baseDir . 'classes/Pommo_User.php'; $pu = new Pommo_User(); if ($pu->save($_POST['user'], $_POST['password'])) { echo $_POST['user']; return; } break; default: $logger->AddErr('invalid call'); break; }