2 /* This file is part of Syj, Copyright (c) 2010-2011 Arnaud Renevier,
3 and is published under the AGPL license. */
5 class PendingController extends Zend_Controller_Action
8 public function init() {
9 $this->view->headLink()->appendStylesheet('css/generic.css', 'all');
10 $this->view->headLink()->appendStylesheet('css/form.css', 'all');
11 $this->view->headLink()->appendStylesheet('css/pending.css', 'all');
14 public function indexAction() {
15 $request = $this->getRequest();
16 $response = $this->getResponse();
17 $hash = $request->idx;
19 $pendingMapper = new Syj_Model_PendingMapper();
20 $pending = $pendingMapper->fetchByHash($hash);
21 if (!isset($pending)) {
22 throw new Syj_Exception_NotFound('Not Found', 404);
25 $formData = $request->getPost();
27 switch ($pending->action) {
28 case 'validate_creation':
29 if (array_key_exists('pending_validate', $formData)) {
30 if (!$pending->run()) {
31 throw new Syj_Exception();
33 $title = $this->view->translate("account validated");
34 $this->_helper->ViewRenderer->setViewScriptPathSpec(':controller/creation_validate.:suffix');
36 } else if (array_key_exists('pending_cancel', $formData)) {
37 if (!$pending->cancel()) {
38 throw new Syj_Exception();
40 $title = $this->view->translate("account deleted");
41 $this->_helper->ViewRenderer->setViewScriptPathSpec(':controller/creation_cancel.:suffix');
43 $this->view->form = new Syj_Form_Pending_ValidateCreation($pending, array('name' => 'pendingform'));
44 $title = $this->view->translate('account creation validation');
47 case 'reset_password':
48 if (array_key_exists('pending_validate', $formData)) {
49 if (!$pending->run()) {
50 throw new Syj_Exception();
52 $this->view->newpwd = $pending->newpwd;
54 $title = $this->view->translate("password changed");
55 $this->_helper->ViewRenderer->setViewScriptPathSpec(':controller/password_validate.:suffix');
56 $this->_helper->SyjUserManager->logout();
58 } else if (array_key_exists('pending_cancel', $formData)) {
59 if (!$pending->cancel()) {
60 throw new Syj_Exception();
62 $title = $this->view->translate("request canceled");
63 $this->_helper->ViewRenderer->setViewScriptPathSpec(':controller/password_cancel.:suffix');
65 $this->view->form = new Syj_Form_Pending_ResetPassword($pending, array('name' => 'pendingform'));
66 $title = $this->view->translate('password reset validation');
70 throw new Syj_Exception_Request();
74 $this->view->headTitle($title);