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 forgottenpasswordAction() { if ($data = Zend_Json::decode($this->getRequest()->getRawBody())) { try { if (empty($data['email'])) { throw new Exception($this->_('Please enter your email address')); } $user = new Backoffice_Model_User(); $user->find($data['email'], 'email'); if (!$user->getId()) { throw new Exception($this->_("Your email address does not exist")); } $password = Core_Model_Lib_String::generate(8); $user->setPassword($password)->save(); $sender = System_Model_Config::getValueFor("support_email"); $support_name = System_Model_Config::getValueFor("support_name"); $layout = $this->getLayout()->loadEmail('admin', 'forgot_password'); $subject = $this->_('Your new password'); $layout->getPartial('content_email')->setPassword($password); $content = $layout->render(); $mail = new Zend_Mail('UTF-8'); $mail->setBodyHtml($content); $mail->setFrom($sender, $support_name); $mail->addTo($user->getEmail(), $user->getName()); $mail->setSubject($subject); $mail->send(); $data = array("success" => 1, "message" => $this->_('Your new password has been sent to the entered email address')); } catch (Exception $e) { $data = array("error" => 1, "message" => $e->getMessage()); } } $this->_sendHtml($data); }
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); } }
public function saveAction() { if ($data = Zend_Json::decode($this->getRequest()->getRawBody())) { try { if (!Zend_Validate::is($data["email"], "emailAddress")) { throw new Exception($this->_("Please, enter a correct email address.")); } $user = new Backoffice_Model_User(); $dummy = new Backoffice_Model_User(); $dummy->find($data["email"], "email"); $isNew = true; if (!empty($data["id"])) { $user->find($data["id"]); $isNew = !$user->getId(); } $user->addData($data); if ($dummy->getEmail() == $user->getEmail() and $dummy->getId() != $user->getId()) { throw new Exception($this->_("We are sorry but this email address already exists.")); } if ($isNew and empty($data["password"])) { throw new Exception($this->_("Please, enter a password.")); } if (!empty($data["password"]) and $data["password"] != $data["confirm_password"]) { throw new Exception($this->_("Passwords don't match")); } if (!empty($data["password"])) { $user->setPassword($data["password"]); } $user->save(); $data = array("success" => 1, "message" => $this->_("User successfully saved")); } catch (Exception $e) { $data = array("error" => 1, "message" => $e->getMessage()); } $this->_sendHtml($data); } }
public function __construct($params) { $admin = new Backoffice_Model_User(); $admin->find($params['id']); $this->setObject($admin); }
public function forgotpasswordpostAction() { if ($datas = $this->getRequest()->getPost() and !$this->getSession()->isLoggedIn(Core_Model_Session::TYPE_BACKOFFICE)) { try { if (empty($datas['email'])) { throw new Exception($this->_('Please enter your email address')); } $user = new Backoffice_Model_User(); $user->find($datas['email'], 'email'); if (!$user->getId()) { throw new Exception($this->_("Your email address does not exist")); } $password = Core_Model_Lib_String::generate(8); $user->setPassword($password)->save(); $sender = System_Model_Config::getValueFor("support_email"); $support_name = System_Model_Config::getValueFor("support_name"); $layout = $this->getLayout()->loadEmail('admin', 'forgot_password'); $subject = $this->_('Your new password'); $layout->getPartial('content_email')->setPassword($password); $content = $layout->render(); $mail = new Zend_Mail('UTF-8'); $mail->setBodyHtml($content); $mail->setFrom($sender, $support_name); $mail->addTo($user->getEmail(), $user->getName()); $mail->setSubject($subject); $mail->send(); $this->getSession()->addSuccess($this->_('Your new password has been sent to the entered email address')); } catch (Exception $e) { $this->getSession()->addError($e->getMessage()); } } $this->_redirect('backoffice'); return $this; }