本文整理汇总了PHP中Am_Controller::ajaxResponse方法的典型用法代码示例。如果您正苦于以下问题:PHP Am_Controller::ajaxResponse方法的具体用法?PHP Am_Controller::ajaxResponse怎么用?PHP Am_Controller::ajaxResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Am_Controller
的用法示例。
在下文中一共展示了Am_Controller::ajaxResponse方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: debugAction
public function debugAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
{
//requires admin to use this tool
$admin = $this->getDi()->authAdmin->getUser();
if (!$admin) {
return;
}
//plugin is not configured
if (!$this->getConfig('datalink_user') || !$this->getConfig('datalink_pass')) {
Am_Controller::ajaxResponse(array('ok' => false, 'msg' => '<font color="red">Ecsuite plugin error: Datalink is not configured!</font>'));
return;
}
$error = $this->sendTest();
if ($request->isXmlHttpRequest()) {
if (empty($error)) {
Am_Controller::ajaxResponse(array('ok' => true));
} else {
Am_Controller::ajaxResponse(array('ok' => false, 'msg' => $error));
}
} else {
echo $error;
}
}
示例2: directAction
public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
{
$user = $this->getDi()->user;
switch ($request->getActionName()) {
case 'c':
$id = $this->getDi()->app->reveal($request->getFiltered('id'));
//actualy it is notification_id
$notification = $this->getDi()->notificationTable->load($id);
$this->getDi()->notificationClickTable->log($user, $notification);
Am_Controller::redirectLocation($notification->url);
break;
case 'get':
if (!$user) {
Am_Controller::ajaxResponse(array());
} else {
$items = $this->getDi()->notificationTable->getNotificationsForUser($this->getDi()->auth->getUser());
$dismiss = $user->data()->getBlob('notification.dismiss');
if (!$dismiss) {
$dismiss = array();
} else {
$dismiss = unserialize($dismiss);
}
$out = array();
foreach ($items as $item) {
$display = $user->data()->get('notification.display.' . $item->pk());
if ($item->limit && $display >= $item->limit) {
continue;
}
if (in_array($item->notification_id, $dismiss)) {
continue;
}
$user->data()->set('notification.display.' . $item->pk(), ++$display);
$n = new stdClass();
$n->id = $this->getDi()->app->obfuscate($item->notification_id);
$n->content = $item->content;
$n->is_custom = $item->is_custom ? true : false;
$n->is_blank = $item->is_blank ? true : false;
$n->link = $item->url;
$out[] = $n;
}
$user->save();
Am_Controller::ajaxResponse($out);
}
break;
case 'js':
$response->setHeader('Content-Type', 'application/x-javascript; charset=utf-8');
echo $this->getJs();
break;
case 'd':
$id = $this->getDi()->app->reveal($request->getFiltered('id'));
if ($user && $id) {
$dismiss = $user->data()->getBlob('notification.dismiss');
if (!$dismiss) {
$dismiss = array();
} else {
$dismiss = unserialize($dismiss);
}
$dismiss[] = $id;
$user->data()->setBlob('notification.dismiss', serialize($dismiss));
$user->data()->update();
}
break;
default:
throw new Am_Exception_InternalError('Unknown Action');
}
}
示例3: changeRebillDateAction
function changeRebillDateAction()
{
$this->getDi()->authAdmin->getUser()->checkPermission('grid_invoice', 'edit');
$invoice_id = $this->_request->getInt('invoice_id');
$form = new Am_Form_Admin();
$form->addDate('rebill_date');
$vals = $form->getValue();
$rebill_date = $vals['rebill_date'];
try {
if (!$invoice_id) {
throw new Am_Exception_InputError('No invoice provided');
}
$invoice = $this->getDi()->invoiceTable->load($invoice_id);
// Invoice must be recurring active and rebills should be controlled by paylsystem,
// otherwise this doesn't make any sence
if ($invoice->status != Invoice::RECURRING_ACTIVE || $invoice->getPaysystem()->getRecurringType() != Am_Paysystem_Abstract::REPORTS_CRONREBILL) {
throw new Am_Exception_InputError('Unable to change rebill_date for this invoice!');
}
$rebill_date = new DateTime($rebill_date);
$old_rebill_date = $invoice->rebill_date;
$invoice->updateQuick('rebill_date', $rebill_date->format('Y-m-d'));
$invoice->data()->set('first_rebill_failure', null)->update();
$this->getDi()->invoiceLogTable->log($invoice_id, null, ___('Rebill Date changed from %s to %s', $old_rebill_date, $invoice->rebill_date));
Am_Controller::ajaxResponse(array('ok' => true, 'msg' => ___('Rebill date has been changed!')));
} catch (Exception $e) {
Am_Controller::ajaxResponse(array('ok' => false, 'msg' => $e->getMessage()));
}
}
示例4: parseCsvAction
public function parseCsvAction()
{
Am_Controller::ajaxResponse(array_map('str_getcsv', array_map('trim', explode("\n", $this->getParam('csv', '')))));
}
示例5: run
public function run()
{
$prefix = $this->fieldName . '-';
$ds = $this->grid->getDataSource();
foreach ($this->grid->getRequest()->getPost() as $k => $v) {
if (strpos($k, $prefix) === false) {
continue;
}
$id = filterId(substr($k, strlen($prefix)));
$record = $ds->getRecord($id);
if (!$record) {
throw new Am_Exception_InputError("Record [{$id}] not found");
}
$ds->updateRecord($record, array($this->fieldName => $v));
$newValue = $v;
$this->log('LiveEdit [' . $this->fieldName . ']');
}
$resp = array('ok' => true, 'message' => ___("Field Updated"), 'newValue' => $newValue);
if ($this->callback) {
$resp['callback'] = $this->callback;
}
Am_Controller::ajaxResponse($resp);
}
示例6: optionsAction
function optionsAction()
{
return Am_Controller::ajaxResponse($this->getTable()->getOptions());
}
示例7: run
public function run()
{
$request = $this->grid->getRequest();
$id = $request->getFiltered('id');
$move_before = $request->getParam('move_before', null);
$move_after = $request->getParam('move_after', null);
$move_item = $request->getParam('move_item');
$resp = array('ok' => true);
if ($this->callback) {
$resp['callback'] = $this->callback;
}
try {
$this->setSortBetween($move_item, $move_after, $move_before);
} catch (Exception $e) {
throw $e;
$resp = array('ok' => false);
}
Am_Controller::ajaxResponse($resp);
exit;
}