summaryrefslogtreecommitdiffstats
path: root/application/modules/user/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'application/modules/user/controllers')
-rw-r--r--application/modules/user/controllers/AuthController.php41
-rw-r--r--application/modules/user/controllers/FilterController.php3
-rw-r--r--application/modules/user/controllers/GroupController.php275
-rw-r--r--application/modules/user/controllers/RoleController.php31
4 files changed, 325 insertions, 25 deletions
diff --git a/application/modules/user/controllers/AuthController.php b/application/modules/user/controllers/AuthController.php
index db47f44..5d63b20 100644
--- a/application/modules/user/controllers/AuthController.php
+++ b/application/modules/user/controllers/AuthController.php
@@ -74,6 +74,7 @@ class User_AuthController extends Zend_Controller_Action
$auth = Zend_Auth::getInstance();
$auth->clearIdentity();
Zend_Session::namespaceUnset('userIDs');
+ Zend_Session::forgetMe();
$this->_helper->redirector('login', 'auth');
return;
}
@@ -119,25 +120,31 @@ class User_AuthController extends Zend_Controller_Action
public function deleteAction()
{
- $this->_helper-> viewRenderer-> setNoRender();
- $result = $this->personmapper->findBy('email', Zend_Auth::getInstance()->getIdentity());
- $person = $result[0];
- $personID = $person["personID"];
- if (isset($personID)){
- $this->personmapper = new Application_Model_PersonMapper();
- $person = $this->personmapper->find($personID);
- try {
- $this->personmapper->delete($person);
- }catch(Zend_Exception $e)
- {
- echo "Caught exception: " . get_class($e) . "<br/>";
- echo "Message: " . $e->getMessage() . "<br/>";
+ if($_POST['confirmdelete']) {
+ $auth = Zend_Auth::getInstance();
+ $result = $this->personmapper->findBy('email', $auth->getIdentity());
+ $person = $result[0];
+ $personID = $person["personID"];
+ if (isset($personID)){
+ $this->personmapper = new Application_Model_PersonMapper();
+ $person = $this->personmapper->find($personID);
+ try {
+ $this->personmapper->delete($person);
+ }catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ return;
+ }
+ $auth->clearIdentity();
+ Zend_Session::namespaceUnset('userIDs');
+ Zend_Session::forgetMe();
+ $this->_helper->redirector('login', 'auth');
return;
}
- $auth = Zend_Auth::getInstance();
- $auth->clearIdentity();
- $this->_helper->redirector('login', 'auth');
- return;
+ } else {
+ $deleteconfirmform = new user_Form_ConfirmDeleteAccount();
+ $this->view->deleteconfirmform = $deleteconfirmform;
}
}
diff --git a/application/modules/user/controllers/FilterController.php b/application/modules/user/controllers/FilterController.php
index d49e68f..fd8eaf5 100644
--- a/application/modules/user/controllers/FilterController.php
+++ b/application/modules/user/controllers/FilterController.php
@@ -171,10 +171,9 @@ class User_FilterController extends Zend_Controller_Action
$filtermapper->find($this->_request->getParam('filterID'),$DBfilterentry);
$compareresult = $filtermapper->compare($newfilterentry,$DBfilterentry);
- print_a($compareresult);
if(isset($compareresult['priority']) && count($compareresult) == 1){
$filtermapper->save($newfilterentry);
- #$this->_redirect('/user/filter/index/modifyresult/ok');
+ $this->_redirect('/user/filter/index/modifyresult/ok');
}
else{
$this->_redirect('/user/filter/index/modifyresult/forbidden');
diff --git a/application/modules/user/controllers/GroupController.php b/application/modules/user/controllers/GroupController.php
index 52136af..7a21aa9 100644
--- a/application/modules/user/controllers/GroupController.php
+++ b/application/modules/user/controllers/GroupController.php
@@ -3,20 +3,291 @@
class User_GroupController extends Zend_Controller_Action
{
+ protected $groupMapper = null;
+
+ protected $groupGroupsMapper = null;
+
+ protected $membershipMapper = null;
+
+ protected $groupRequestMapper = null;
+
+ protected $personmapper = null;
+
+ protected $rolemapper = null;
+
+ protected $groupList = null;
+
+ protected $userIDsNamespace = null;
+
public function init()
{
if (Zend_Auth::getInstance()->hasIdentity()) {
-
+ $this->userIDsNamespace = Zend_Session::namespaceGet('userIDs');
+ $this->groupMapper = new Application_Model_GroupMapper();
+ $this->groupGroupsMapper = new Application_Model_GroupGroupsMapper();
+ $this->membershipMapper = new Application_Model_MembershipMapper();
+ $this->groupRequestMapper = new Application_Model_GroupRequestMapper();
+ $this->personmapper = new Application_Model_PersonMapper();
+ $this->rolemapper = new Application_Model_RoleMapper();
+ $this->groupList = $this->groupMapper->fetchAll();
} else {
$this->_helper->redirector('login', 'auth');
+ return;
}
}
public function indexAction()
{
- // action body
+ $this->_helper->redirector('show', 'group');
}
+ public function addAction()
+ {
+ if (!isset($_POST["add"])){
+ $addForm = new user_Form_GroupAdd(array('grouplist' => $this->groupList));
+ } else {
+ $addForm = new user_Form_GroupAdd(array('grouplist' => $this->groupList),$_POST);
+
+ if ($addForm->isValid($_POST)) {
+ $group = new Application_Model_Group($_POST);
+ try {
+ $this->groupMapper->save($group);
+ } catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ return;
+ }
+ if($_POST['superordinatedGroupID'] != -1) {
+ $lastID = $this->groupMapper->getDbTable()->getDefaultAdapter()->lastInsertId();
+ $groupgroups = new Application_Model_GroupGroups();
+ $groupgroups->setParentID($_POST['superordinatedGroupID']);
+ $groupgroups->setGroupID($lastID);
+ try {
+ $this->groupGroupsMapper->save($groupgroups);
+ } catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ return;
+ }
+
+ }
+ $this->_helper->redirector('', 'group');
+ return;
+ }
+ }
+
+ $this->view->addForm = $addForm;
+ }
+
+ public function editAction()
+ {
+ $groupID = $this->_request->getParam('groupID');
+ if(!isset($groupID)) {
+ if(count($this->userIDsNamespace) > 0) {
+ $groupID = $this->userIDsNamespace['groupID'];
+ }
+ }
+ if(!isset($groupID)) {
+ $addForm = new user_Form_GroupAdd(array('grouplist' => $this->groupList));
+ $this->view->addForm = $addForm;
+ return;
+ }
+ if (!isset($_POST["save"])){
+ $group = $this->groupMapper->find($groupID);
+ $_POST['title'] = $group->getTitle();
+ $_POST['description'] = $group->getDescription();
+ $editForm = new user_Form_GroupEdit(array('groupID' => $groupID));
+ } else {
+ $editForm = new user_Form_GroupEdit(array('groupID' => $groupID), $_POST);
+ if ($editForm->isValid($_POST)) {
+ $group = new Application_Model_Group($_POST);
+ $group->setID($this->_request->getParam('groupID'));
+ try {
+ $this->groupMapper->save($group);
+ } catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ return;
+ }
+ $this->_redirect($_SERVER['HTTP_REFERER']);
+ return;
+ }
+ }
+
+ $this->view->editForm = $editForm;
+ }
+
+ public function showAction()
+ {
+ $groupID = $this->_request->getParam('groupID');
+ if(!isset($groupID)) {
+ if(count($this->userIDsNamespace) > 0) {
+ $groupID = $this->userIDsNamespace['groupID'];
+ }
+ }
+ if($groupID) {
+ $groupRequests = $this->groupRequestMapper->findBy('groupID', $groupID);
+ if(isset($groupRequests)) {
+ foreach($groupRequests as $groupRequest) {
+ $person = $this->personmapper->find($groupRequest['personID']);
+ $groupRequestList[] = array(
+ 'grouprequestID' => $groupRequest['grouprequestID'],
+ 'person' => $person
+ );
+ }
+ if(is_array($groupRequestList)) {
+ $this->view->groupRequestList = $groupRequestList;
+ }
+ $this->view->roleList = $this->rolemapper->findBy('groupID', $groupID);
+ }
+ $members = $this->membershipMapper->findBy('groupID', $groupID);
+ if(isset($members)) {
+ foreach($members as $member) {
+ $person = $this->personmapper->find($member['personID']);
+ $membersList[] = array(
+ 'membershipID' => $member['membershipID'],
+ 'person' => $person
+ );
+ }
+ if(is_array($membersList)) {
+ $this->view->membersList = $membersList;
+ }
+ }
+ $groupgroups = $this->groupGroupsMapper->findBy('groupID', $groupID);
+ if(is_object($groupgroups)) {
+ $parentGroup = $this->groupMapper->find($groupgroups->getParentID());
+ $this->view->$parentGroup = $parentGroup;
+ }
+ $group = $this->groupMapper->find($groupID);
+ $this->view->userIDsNamespace = $this->userIDsNamespace;
+ $this->view->group = $group;
+ $this->view->groupID = $groupID;
+ } else {
+ $this->_redirect('/user/');
+ return;
+ }
+ }
+
+ public function linkAction()
+ {
+ if (!isset($_POST["link"])){
+ $linkForm = new user_Form_GroupLink(array('grouplist' => $this->groupList));
+ } else {
+ $linkForm = new user_Form_GroupLink(array('grouplist' => $this->groupList),$_POST);
+
+ if ($linkForm->isValid($_POST)) {
+ $groupgroups = new Application_Model_GroupGroups();
+ $groupgroups->setParentID($_POST['superordinatedGroupID']);
+ $groupgroups->setGroupID($_POST['groupID']);
+ try {
+ $this->groupGroupsMapper->save($groupgroups);
+ } catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ return;
+ }
+ $this->_helper->redirector('', 'group');
+ return;
+ }
+ }
+
+ $this->view->linkForm = $linkForm;
+ }
+
+ public function deleteAction()
+ {
+ $this->_helper->viewRenderer->setNoRender();
+ $groupID = $this->_request->getParam('groupID');
+ if(!isset($groupID)) {
+ if(count($this->userIDsNamespace) > 0) {
+ $groupID = $this->userIDsNamespace['groupID'];
+ }
+ }
+ if (isset($groupID)){
+ $group = $this->groupMapper->find($groupID);
+ try {
+ $this->groupMapper->delete($group);
+ } catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ return;
+ }
+ if(strpos($_SERVER['HTTP_REFERER'], '/user/group/show')) {
+ if(strpos($_SERVER['HTTP_REFERER'], '/groupID/')) {
+ $this->_redirect('/user/group/showall');
+ } else {
+ $this->_helper->redirector('changemembership', 'person');
+ }
+ } else {
+ $this->_helper->redirector('showall', 'group');
+ }
+ return;
+ } else {
+ $this->_redirect('/user/');
+ return;
+ }
+ }
+
+ public function grantpersonAction()
+ {
+ $this->_helper->viewRenderer->setNoRender();
+ if(isset($_POST['grouprequestID']) && isset($_POST['roleID'])) {
+ $groupRequest = $this->groupRequestMapper->find($_POST['grouprequestID']);
+ try {
+ $this->groupRequestMapper->delete($groupRequest);
+ } catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ return;
+ }
+ $membership = new Application_Model_Membership();
+ $membership->setGroupID($groupRequest->getGroupID());
+ $membership->setPersonID($groupRequest->getPersonID());
+ $membership->setRoleID($_POST['roleID']);
+ try {
+ $this->membershipMapper->save($membership);
+ } catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ return;
+ }
+ $this->_redirect("/user/group/show/groupID/" . $groupRequest->getGroupID());
+ }
+ }
+
+ public function revokepersonAction()
+ {
+ $this->_helper->viewRenderer->setNoRender();
+ $membershipID = $this->_request->getParam('membershipID');
+ if(isset($membershipID)) {
+ $membership = $this->membershipMapper->find($membershipID);
+ if(isset($membership)) {
+ try {
+ $this->membershipMapper->delete($membership);
+ } catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ return;
+ }
+ $this->_redirect("/user/group/edit/groupID/" . $membership->getGroupID());
+ }
+
+ } }
+
+ public function showallAction()
+ {
+ $this->view->userIDsNamespace = $this->userIDsNamespace;
+ $this->view->groupList = $this->groupList;
+ }
+
}
diff --git a/application/modules/user/controllers/RoleController.php b/application/modules/user/controllers/RoleController.php
index da65507..0b0cb7d 100644
--- a/application/modules/user/controllers/RoleController.php
+++ b/application/modules/user/controllers/RoleController.php
@@ -2,15 +2,15 @@
class User_RoleController extends Zend_Controller_Action
{
- private $userIDsNamespace;
+ protected $userIDsNamespace;
public function init()
{
if (Zend_Auth::getInstance()->hasIdentity()) {
$this->userIDsNamespace = Zend_Session::namespaceGet('userIDs');
- if($this->userIDsNamespace['groupID'] ==''){
+ if($this->userIDsNamespace['roleID'] ==''){
$pbsNotifier = new Pbs_Notifier();
- echo $pbsNotifier->notify('No groupID set','forbidden');
+ echo $pbsNotifier->notify('No roleID set','forbidden');
}
$this->roleMapper = new Application_Model_RoleMapper();
$this->rightMapper = new Application_Model_RightMapper();
@@ -67,6 +67,11 @@ class User_RoleController extends Zend_Controller_Action
{
$roleID = $this->_request->getParam('roleID');
if(!isset($roleID)) {
+ if(count($this->userIDsNamespace) > 0) {
+ $roleID = $this->userIDsNamespace['roleID'];
+ }
+ }
+ if(!isset($roleID)) {
$addForm = new user_Form_RoleAdd();
$this->view->addForm = $addForm;
return;
@@ -76,10 +81,12 @@ class User_RoleController extends Zend_Controller_Action
$_POST['title'] = $role->getTitle();
$_POST['description'] = $role->getDescription();
$_POST['groupID'] = $role->getGroupID();
+ $_POST['inheritance'] = $role->getInheritance();
$editForm = new user_Form_RoleEdit(array('roleID' => $roleID));
} else {
$editForm = new user_Form_RoleEdit(array('roleID' => $roleID), $_POST);
if ($editForm->isValid($_POST)) {
+
$role = new Application_Model_Role($_POST);
$role->setID($this->_request->getParam('roleID'));
try {
@@ -90,7 +97,7 @@ class User_RoleController extends Zend_Controller_Action
echo "Message: " . $e->getMessage() . "<br/>";
return;
}
- $this->_helper->redirector('', 'role');
+ $this->_redirect($_SERVER['HTTP_REFERER']);
return;
}
}
@@ -100,6 +107,11 @@ class User_RoleController extends Zend_Controller_Action
public function showAction()
{
$roleID = $this->_request->getParam('roleID');
+ if(!isset($roleID)) {
+ if(count($this->userIDsNamespace) > 0) {
+ $roleID = $this->userIDsNamespace['roleID'];
+ }
+ }
if($roleID) {
$rightroles = $this->rightRolesMapper->findBy('roleID', $roleID);
if(count($rightroles) > 0) {
@@ -113,6 +125,7 @@ class User_RoleController extends Zend_Controller_Action
}
$this->view->role = $this->roleMapper->find($roleID);
$this->view->roleID = $roleID;
+ $this->view->userIDsNamespace = $this->userIDsNamespace;
} else {
$this->_helper->redirector('', 'role');
return;
@@ -123,6 +136,11 @@ class User_RoleController extends Zend_Controller_Action
{
$this->_helper->viewRenderer->setNoRender();
$roleID = $this->_request->getParam('roleID');
+ if(!isset($roleID)) {
+ if(count($this->userIDsNamespace) > 0) {
+ $roleID = $this->userIDsNamespace['roleID'];
+ }
+ }
if (isset($roleID)){
$role = $this->roleMapper->find($roleID);
try {
@@ -144,6 +162,11 @@ class User_RoleController extends Zend_Controller_Action
public function linkrightAction()
{
$roleID = $this->_request->getParam('roleID');
+ if(!isset($roleID)) {
+ if(count($this->userIDsNamespace) > 0) {
+ $roleID = $this->userIDsNamespace['roleID'];
+ }
+ }
if(isset($roleID)) {
$rightroles = $this->rightRolesMapper->findBy('roleID', $roleID);
$rights = $this->rightMapper->fetchAll();