]> dev.renevier.net Git - syj.git/blob - application/controllers/PendingController.php
add mapquest layer back
[syj.git] / application / controllers / PendingController.php
1 <?php
2 /*  This file is part of Syj, Copyright (c) 2010-2011 Arnaud Renevier,
3     and is published under the AGPL license. */
4
5 class PendingController extends Zend_Controller_Action
6 {
7
8     public function init() {
9         $this->_helper->SyjMedias->addStyleSheets('pending');
10     }
11
12     public function indexAction() {
13         $request = $this->getRequest();
14         $response = $this->getResponse();
15         $hash = $request->idx;
16
17         $pendingMapper = new Syj_Model_PendingMapper();
18         $pending = $pendingMapper->fetchByHash($hash);
19         if (!isset($pending)) {
20             throw new Syj_Exception_NotFound('Not Found', 404);
21         }
22
23         $formData = $request->getPost();
24
25         switch ($pending->action) {
26             case 'validate_creation':
27             if (array_key_exists('pending_validate', $formData)) {
28                     if (!$pending->run()) {
29                         throw new Syj_Exception();
30                     }
31                     $title = $this->view->translate("account validated");
32                     $this->_helper->ViewRenderer->setViewScriptPathSpec(':controller/creation_validate.:suffix');
33
34                 } else if (array_key_exists('pending_cancel', $formData)) {
35                     if (!$pending->cancel()) {
36                         throw new Syj_Exception();
37                     }
38                     $title = $this->view->translate("account deleted");
39                     $this->_helper->ViewRenderer->setViewScriptPathSpec(':controller/creation_cancel.:suffix');
40                 } else {
41                     $this->view->form = new Syj_Form_Pending_ValidateCreation($pending, array('name' => 'pendingform'));
42                     $title = $this->view->translate('account creation validation');
43                 }
44             break;
45             case 'reset_password':
46                 if (array_key_exists('pending_validate', $formData)) {
47                     if (!$pending->run()) {
48                         throw new Syj_Exception();
49                     }
50                     $this->view->newpwd = $pending->newpwd;
51
52                     $title = $this->view->translate("password changed");
53                     $this->_helper->ViewRenderer->setViewScriptPathSpec(':controller/password_validate.:suffix');
54                     $this->_helper->SyjUserManager->logout();
55
56                 } else if (array_key_exists('pending_cancel', $formData)) {
57                     if (!$pending->cancel()) {
58                         throw new Syj_Exception();
59                     }
60                     $title = $this->view->translate("request canceled");
61                     $this->_helper->ViewRenderer->setViewScriptPathSpec(':controller/password_cancel.:suffix');
62                 } else {
63                     $this->view->form = new Syj_Form_Pending_ResetPassword($pending, array('name' => 'pendingform'));
64                     $title = $this->view->translate('password reset validation');
65                 }
66             break;
67             default:
68                 throw new Syj_Exception_Request();
69             break;
70         }
71
72         $this->view->headTitle($title);
73     }
74
75 }