2 /* This file is part of Syj, Copyright (c) 2010 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');
10 $this->view->headLink()->appendStylesheet('css/pending.css');
13 public function indexAction() {
14 $request = $this->getRequest();
15 $response = $this->getResponse();
16 $hash = $request->idx;
18 $pendingMapper = new Syj_Model_PendingMapper();
19 $pending = $pendingMapper->fetchByHash($hash);
20 if (!isset($pending)) {
21 throw new Syj_Exception_NotFound('Not Found', 404);
24 $formData = $request->getPost();
26 switch ($pending->action) {
27 case 'validate_creation':
28 if (array_key_exists('pending_validate', $formData)) {
29 if (!$pending->run()) {
30 throw new Syj_Exception();
32 $title = $this->view->translate("account validated");
33 $this->_helper->ViewRenderer->setViewScriptPathSpec(':controller/creation_validate.:suffix');
35 } else if (array_key_exists('pending_cancel', $formData)) {
36 if (!$pending->cancel()) {
37 throw new Syj_Exception();
39 $title = $this->view->translate("account deleted");
40 $this->_helper->ViewRenderer->setViewScriptPathSpec(':controller/creation_cancel.:suffix');
42 $this->view->form = new Syj_Form_Pending_ValidateCreation($pending, array('name' => 'pendingform'));
43 $title = $this->view->translate('account creation validation');
46 case 'reset_password':
47 if (array_key_exists('pending_validate', $formData)) {
48 if (!$pending->run()) {
49 throw new Syj_Exception();
51 $this->view->newpwd = $pending->newpwd;
53 $title = $this->view->translate("password changed");
54 $this->_helper->ViewRenderer->setViewScriptPathSpec(':controller/password_validate.:suffix');
55 $this->_helper->SyjSession->logout();
57 } else if (array_key_exists('pending_cancel', $formData)) {
58 if (!$pending->cancel()) {
59 throw new Syj_Exception();
61 $title = $this->view->translate("request canceled");
62 $this->_helper->ViewRenderer->setViewScriptPathSpec(':controller/password_cancel.:suffix');
64 $this->view->form = new Syj_Form_Pending_ResetPassword($pending, array('name' => 'pendingform'));
65 $title = $this->view->translate('password reset validation');
69 throw new Syj_Exception_Request();
73 $this->view->headTitle($title);