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; } }
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'); } }
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())); } }
public function parseCsvAction() { Am_Controller::ajaxResponse(array_map('str_getcsv', array_map('trim', explode("\n", $this->getParam('csv', ''))))); }
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); }
function optionsAction() { return Am_Controller::ajaxResponse($this->getTable()->getOptions()); }
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; }