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->_helper->SyjMedias->addStyleSheets('pending');
12 public function indexAction() {
13 $request = $this->getRequest();
14 $response = $this->getResponse();
15 $hash = $request->idx;
17 $pendingMapper = new Syj_Model_PendingMapper();
18 $pending = $pendingMapper->fetchByHash($hash);
19 if (!isset($pending)) {
20 throw new Syj_Exception_NotFound('Not Found', 404);
23 $formData = $request->getPost();
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();
31 $title = $this->view->translate("account validated");
32 $this->_helper->ViewRenderer->setViewScriptPathSpec(':controller/creation_validate.:suffix');
34 } else if (array_key_exists('pending_cancel', $formData)) {
35 if (!$pending->cancel()) {
36 throw new Syj_Exception();
38 $title = $this->view->translate("account deleted");
39 $this->_helper->ViewRenderer->setViewScriptPathSpec(':controller/creation_cancel.:suffix');
41 $this->view->form = new Syj_Form_Pending_ValidateCreation($pending, array('name' => 'pendingform'));
42 $title = $this->view->translate('account creation validation');
45 case 'reset_password':
46 if (array_key_exists('pending_validate', $formData)) {
47 if (!$pending->run()) {
48 throw new Syj_Exception();
50 $this->view->newpwd = $pending->newpwd;
52 $title = $this->view->translate("password changed");
53 $this->_helper->ViewRenderer->setViewScriptPathSpec(':controller/password_validate.:suffix');
54 $this->_helper->SyjUserManager->logout();
56 } else if (array_key_exists('pending_cancel', $formData)) {
57 if (!$pending->cancel()) {
58 throw new Syj_Exception();
60 $title = $this->view->translate("request canceled");
61 $this->_helper->ViewRenderer->setViewScriptPathSpec(':controller/password_cancel.:suffix');
63 $this->view->form = new Syj_Form_Pending_ResetPassword($pending, array('name' => 'pendingform'));
64 $title = $this->view->translate('password reset validation');
68 throw new Syj_Exception_Request();
72 $this->view->headTitle($title);