public function checkAction() { if ($this->getRequest()->isPost()) { $admin_can_publish = $this->getSession()->getAdmin()->canPublishThemself(); $errors = $this->getApplication()->isAvailableForPublishing($admin_can_publish); if (!empty($errors)) { $message = $this->_('In order to publish your application, we need:<br />- '); $message .= join('<br />- ', $errors); $html = array('message' => $message, 'message_button' => 1, 'message_loader' => 1); } else { if (Siberian_Version::TYPE == "MAE") { $backoffice_email = null; $system = new System_Model_Config(); if ($system->getValueFor("support_email")) { $backoffice_email = $system->getValueFor("support_email"); } else { $user = new Backoffice_Model_User(); $backoffice_user = $user->findAll(array(), "user_id ASC", array("limit" => 1))->current(); if ($backoffice_user) { $backoffice_email = $backoffice_user->getEmail(); } } $layout = $this->getLayout()->loadEmail('application', 'publish_app'); $layout->getPartial('content_email')->setApp($this->getApplication())->setAdmin($this->getAdmin())->setBackofficeEmail($backoffice_email); $content = $layout->render(); $sender = $backoffice_email; $mail = new Zend_Mail('UTF-8'); $mail->setBodyHtml($content); $mail->setFrom($sender); $mail->addTo($backoffice_email); $mail->setSubject($this->_('%s – Publication request', $this->getApplication()->getName())); $mail->send(); $html = array('success_message' => $this->_("Your app will be published"), 'message_button' => 0, 'message_loader' => 0, 'message_timeout' => 3); } else { if (Siberian_Version::TYPE == "PE") { $url = $this->getUrl('subscription/application/create'); $html = array('url' => $url); } } } $this->getResponse()->setBody(Zend_Json::encode($html))->sendResponse(); die; } }
public function deleteAction() { if ($user_id = $this->getRequest()->getParam('user_id')) { try { $user = new Backoffice_Model_User(); $users = $user->findAll(); if ($users->count() == 1) { throw new Exception($this->_("This account can't be deleted, it's the only one")); } $user->find($user_id); if (!$user->getId()) { throw new Exception($this->_("This administrator does not exist")); } $user->delete(); $html = array('success' => 1, 'user_id' => $user_id); } catch (Exception $e) { $html = array('error' => 1, 'message' => $e->getMessage()); } $this->_sendHtml($html); } }
public function deleteAction() { if ($data = Zend_Json::decode($this->getRequest()->getRawBody())) { try { if (empty($data["user_id"])) { throw new Exception($this->_("An error occurred while saving. Please try again later.")); } $user = new Backoffice_Model_User(); $user->find($data["user_id"]); if (!$user->getId()) { throw new Exception($this->_("An error occurred while saving. Please try again later.")); } if ($user->findAll()->count() <= 1) { throw new Exception($this->_("How do you want to access the backoffice if you remove the only user remaining?")); } $user->delete(); $data = array("success" => 1, "message" => $this->_("User successfully deleted")); } catch (Exception $e) { $data = array("error" => 1, "message" => $e->getMessage()); } $this->_sendHtml($data); } }