wCMF  3.6
 All Classes Namespaces Files Functions Variables Groups Pages
class.UserController.php
Go to the documentation of this file.
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2014 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of any of the following licenses
7  * at your choice:
8  *
9  * - GNU Lesser General Public License (LGPL)
10  * http://www.gnu.org/licenses/lgpl.html
11  * - Eclipse Public License (EPL)
12  * http://www.eclipse.org/org/documents/epl-v10.php
13  *
14  * See the license.txt file distributed with this work for
15  * additional information.
16  *
17  * $Id: class.UserController.php 1462 2014-02-04 23:52:27Z iherwig $
18  */
19 require_once(BASE."wcmf/lib/presentation/class.Controller.php");
20 require_once(BASE."wcmf/lib/persistence/class.PersistenceFacade.php");
21 require_once(BASE."wcmf/lib/model/class.Node.php");
22 require_once(BASE."wcmf/lib/util/class.ObjectFactory.php");
23 
24 /**
25  * @class UserController
26  * @ingroup Controller
27  * @brief UserController is used to edit data of the current users.
28  *
29  * <b>Input actions:</b>
30  * - @em save Save the new password
31  * - unspecified: Show the change password screen
32  *
33  * <b>Output actions:</b>
34  * - @em edituser In any case
35  *
36  * @param[in] changepassword Must be 'yes' to initiate password change action
37  * @param[in] oldpassword The old password
38  * @param[in] newpassword1 The new password
39  * @param[in] newpassword2 The new password
40  * @param[out] message The message describing the result
41  *
42  * @author ingo herwig <ingo@wemove.com>
43  */
45 {
46  /**
47  * @see Controller::hasView()
48  */
49  function hasView()
50  {
51  return true;
52  }
53  /**
54  * Process action and assign data to View.
55  * @return False (Stop action processing chain).
56  * @see Controller::executeKernel()
57  */
58  function executeKernel()
59  {
60  $rightsManager = &RightsManager::getInstance();
61 
62  // process actions
63 
64  // save changes
65  if ($this->_request->getAction() == 'save')
66  {
67  // password
68  if ($this->_request->getValue('changepassword') == 'yes')
69  {
70  // create UserManager instance
71  $objectFactory = &ObjectFactory::getInstance();
72  $userManager = &$objectFactory->createInstanceFromConfig('implementation', 'UserManager');
73  if ($userManager == null)
74  WCMFException::throwEx($objectFactory->getErrorMsg(), __FILE__, __LINE__);
75 
76  // load model
77  $user = &$rightsManager->getAuthUser();
78  $oid = PersistenceFacade::composeOID(array('type' => UserManager::getUserClassName(), 'id' => $user->getDBID()));
79  $principal = $userManager->getPrincipal($oid);
80 
81  $userManager->startTransaction();
82  $userManager->changePassword($principal->getLogin(), $this->_request->getValue('oldpassword'),
83  $this->_request->getValue('newpassword1'), $this->_request->getValue('newpassword2'));
84  $message .= Message::get("The password was successfully changed.");
85  $userManager->commitTransaction();
86  }
87  }
88  $this->_response->setValue("message", $message);
89 
90  // success
91  $this->_response->setAction('edituser');
92  return false;
93  }
94 }
95 ?>
get($message, $parameters=null, $domain='', $lang='')
throwEx($message, $file='', $line='')
UserController is used to edit data of the current users.
Controller is the base class of all controllers. If a Controller has a view it is expected to reside ...