From a3fe05f88ef948366d58dbc47b3d55a8b4511df5 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 13 Apr 2011 12:59:17 +0200 Subject: Erster Teil der Rechte in Group Controller --- .../modules/user/views/scripts/group/index.phtml | 79 +++++++++++----------- .../modules/user/views/scripts/group/show.phtml | 60 ++++++++++------ 2 files changed, 81 insertions(+), 58 deletions(-) (limited to 'application/modules/user/views') diff --git a/application/modules/user/views/scripts/group/index.phtml b/application/modules/user/views/scripts/group/index.phtml index 2e376b3..e3b5082 100644 --- a/application/modules/user/views/scripts/group/index.phtml +++ b/application/modules/user/views/scripts/group/index.phtml @@ -6,31 +6,34 @@ ?>
-
Available searchfilter:
-
title
-
description
+
Available searchfilter:
+
title
+
description
-
+groupList)==0) -echo "There are no groups" ?> groupList as $k => $group): ?> +echo "There are no groups" ?> +groupList as $k => $group): ?> getID() == $this->userIDsNamespace['groupID']) $class= 'highlight checked'; ?> -
getID() != $this->userIDsNamespace['groupID']) { +
+ getID() != $this->userIDsNamespace['groupID']) { + ?> +
+
Group
+ +
+ -
-
Group
- -
- - +
+
+
-
getTitle(); ?>
- getDescription()) { - ?> -
getDescription(); ?>
- -
 
-
-
- - -pagination; ?> + pagination; ?> -formButton('linkgroups', 'Link Groups', array( + formButton('linkgroups', 'Link Groups', array( 'onclick' => 'self.location="/user/group/link"', 'class' => 'addbutton')) ?> diff --git a/application/modules/user/views/scripts/group/show.phtml b/application/modules/user/views/scripts/group/show.phtml index f1a14d1..18bc33a 100644 --- a/application/modules/user/views/scripts/group/show.phtml +++ b/application/modules/user/views/scripts/group/show.phtml @@ -1,31 +1,32 @@ -groupID) { - if(isset($this->userIDsNamespace['groupID'])) { - ?> -

Own Group

- formButton('deletegroup', 'Delete', array( +

Groupdetails

+usergroup == $this->requestgroup){ + echo $this->formButton('deletegroup', 'Delete', array( 'onclick' => 'self.location="/user/group/delete/"', 'class' => 'rightbutton')); - echo $this->formButton('editgroup', 'Edit', array( + echo $this->formButton('editgroup', 'Edit', array( 'onclick' => 'self.location="/user/group/edit/"', 'class' => 'rightbutton')); - } else { - ?> -

Group Details

- formButton('deletegroup', 'Delete', array( +} +else{ + echo $this->formButton('deletegroup', 'Delete', array( 'onclick' => 'self.location="/user/group/delete/groupID/' . $this->group->getID() .'"', 'class' => 'rightbutton')); - echo $this->formButton('editgroup', 'Edit', array( + echo $this->formButton('editgroup', 'Edit', array( 'onclick' => 'self.location="/user/group/edit/groupID/' . $this->group->getID() .'"', 'class' => 'rightbutton')); - } - ?> +} +?>
-
Your Group
+ usergroup == $this->requestgroup){ ?> +
Your Group
+ +
Group
+ group->getID(); ?> +
group->getTitle(); ?>
@@ -40,7 +41,7 @@ if($this->groupID) {
groupRequestList)){ @@ -55,12 +56,23 @@ if(isset($this->groupRequestList)){ ?>
+ usergroup == $this->requestgroup && (Pbs_Acl::checkRight('gam') || Pbs_Acl::checkRight('gdm'))){ + ?>
+
roleList); ?>
+ + + TODO +
+
getTitle(); ?> getFirstname(); ?> getName(); ?>
getCity(); ?>
@@ -69,12 +81,14 @@ if(isset($this->groupRequestList)){
- +
membersList)){ +if(isset($this->membersList) && Pbs_Acl::checkRight('gsmg')){ ?>

Members:

@@ -105,6 +119,9 @@ if(count($this->membersList)==0) ?>
+ usergroup == $this->requestgroup) || (Pbs_Acl::checkRight('gdmog') && $this->usergroup != $this->requestgroup)): + ?> Revoke Membership +
getFirstname(); ?> getName(); ?>
Role: getTitle(); ?>
-- cgit v1.2.3-55-g7522 From 85c7d1157407b132a9f0b71840f65d7ce0119abf Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 13 Apr 2011 14:10:26 +0200 Subject: Zweiter Teil der Rechte in Group Controller --- .../modules/user/controllers/GroupController.php | 41 ++++++++++++++-------- .../modules/user/views/scripts/group/show.phtml | 2 +- 2 files changed, 28 insertions(+), 15 deletions(-) (limited to 'application/modules/user/views') diff --git a/application/modules/user/controllers/GroupController.php b/application/modules/user/controllers/GroupController.php index fb0d2a9..d9fd368 100644 --- a/application/modules/user/controllers/GroupController.php +++ b/application/modules/user/controllers/GroupController.php @@ -300,6 +300,10 @@ class User_GroupController extends Zend_Controller_Action public function deleteAction() { + // ACL delete a group + if(!Pbs_Acl::checkRight('gd')) + $this->_redirect('/user'); + $this->_helper->viewRenderer->setNoRender(); $groupID = $this->_request->getParam('groupID'); if(!isset($groupID)) { @@ -335,6 +339,10 @@ class User_GroupController extends Zend_Controller_Action public function grantpersonAction() { + // ACL grant a membership to request + if(!Pbs_Acl::checkRight('gam')) + $this->_redirect('/user'); + $this->_helper->viewRenderer->setNoRender(); if(isset($_POST['grouprequestID']) && isset($_POST['roleID'])) { $groupRequest = $this->groupRequestMapper->find($_POST['grouprequestID']); @@ -369,21 +377,26 @@ class User_GroupController extends Zend_Controller_Action 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) . "
"; - echo "Message: " . $e->getMessage() . "
"; - return; + $rr = $this->membershipMapper->find($membershipID); + + if(($rr->getGroupID() == $this->membership->getGroupID && Pbs_Acl::checkRight('gdmo') ) || ( $rr->getGroupID() != $this->membership->getGroupID && Pbs_Acl::checkRight('gdmog'))){ + 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) . "
"; + echo "Message: " . $e->getMessage() . "
"; + return; + } + $this->_redirect("/user/group/show/groupID/" . $membership->getGroupID()); } - $this->_redirect("/user/group/show/groupID/" . $membership->getGroupID()); - } - - } } + } + } + } } diff --git a/application/modules/user/views/scripts/group/show.phtml b/application/modules/user/views/scripts/group/show.phtml index 18bc33a..b2a85ac 100644 --- a/application/modules/user/views/scripts/group/show.phtml +++ b/application/modules/user/views/scripts/group/show.phtml @@ -1,4 +1,4 @@ -

Groupdetails

+

Groupdetails - group->getTitle();?>

usergroup == $this->requestgroup){ echo $this->formButton('deletegroup', 'Delete', array( -- cgit v1.2.3-55-g7522 From 63b4fb51d481e4376f60f188c171d57970abbd46 Mon Sep 17 00:00:00 2001 From: Björn Geiger Date: Wed, 13 Apr 2011 15:05:53 +0200 Subject: Suspend und Resume Account --- .zfproject.xml | 3 ++ application/models/Person.php | 60 ++++++++++++--------- application/models/PersonMapper.php | 6 +-- .../modules/user/controllers/AuthController.php | 12 +++-- .../modules/user/controllers/PersonController.php | 49 +++++++++++++++++ application/modules/user/forms/PersonEdit.php | 2 +- application/modules/user/forms/Register.php | 2 +- .../modules/user/views/scripts/person/index.phtml | 39 +++++++++++--- .../user/views/scripts/person/owndetails.phtml | 48 ++++++++++------- .../modules/user/views/scripts/person/show.phtml | 29 ++++++---- pbs.sql | 1 + public/media/img/resume.png | Bin 0 -> 355 bytes public/media/img/suspend.png | Bin 0 -> 335 bytes 13 files changed, 184 insertions(+), 67 deletions(-) create mode 100644 public/media/img/resume.png create mode 100644 public/media/img/suspend.png (limited to 'application/modules/user/views') diff --git a/.zfproject.xml b/.zfproject.xml index b90455d..09c216a 100644 --- a/.zfproject.xml +++ b/.zfproject.xml @@ -126,6 +126,7 @@ + @@ -136,6 +137,8 @@ + + diff --git a/application/models/Person.php b/application/models/Person.php index aea348d..6a591cf 100644 --- a/application/models/Person.php +++ b/application/models/Person.php @@ -16,6 +16,7 @@ class Application_Model_Person protected $_login; protected $_password; protected $_password_salt; + protected $_suspended; public function __construct(array $options = null) { @@ -183,39 +184,48 @@ class Application_Model_Person { return $this->_password_salt; } - /** - * Returns current data as associative array using ReflectionClass - * - * @return array Returns associative array containing model data + public function getSuspended() + { + return $this->_suspended; + } + public function setSuspended($_suspended) + { + $this->_suspended = $_suspended; + return $this; + } + /** + * Returns current data as associative array using ReflectionClass + * + * @return array Returns associative array containing model data * If "get"-method not available (our primary keys) the function getID() is called - */ - public function toArray() - { - $reflectionClass = new ReflectionClass($this); - $properties = $reflectionClass->getProperties(); - $result = array(); - foreach ($properties as $property) { - $key = $property->name; - if (substr($key, 0, 1) != '_' && $this->$key !== null) { - $method = 'get' . ucfirst($key); - if ($reflectionClass->hasMethod($method)) { - $result[$key] = $this->$method(); - } else { - $result[$key] = $this->$key; - } - } + */ + public function toArray() + { + $reflectionClass = new ReflectionClass($this); + $properties = $reflectionClass->getProperties(); + $result = array(); + foreach ($properties as $property) { + $key = $property->name; + if (substr($key, 0, 1) != '_' && $this->$key !== null) { + $method = 'get' . ucfirst($key); + if ($reflectionClass->hasMethod($method)) { + $result[$key] = $this->$method(); + } else { + $result[$key] = $this->$key; + } + } elseif(substr($key, 0, 1) == '_' && $this->$key !== null) { $key = substr($key, 1); - $method = 'get' . ucfirst($key); + $method = 'get' . ucfirst($key); if ($reflectionClass->hasMethod($method)) { $result[$key] = $this->$method(); }else{ $result[$key] = $this->getID(); } - + } - } - return $result; - } + } + return $result; + } } diff --git a/application/models/PersonMapper.php b/application/models/PersonMapper.php index 537d862..4093c07 100644 --- a/application/models/PersonMapper.php +++ b/application/models/PersonMapper.php @@ -74,7 +74,7 @@ class Application_Model_PersonMapper public function save(Application_Model_Person $person) { - $data = array('personID'=> $person->getID() ,'title'=> $person->getTitle() ,'name'=> $person->getName() ,'firstname'=> $person->getFirstname() ,'street'=> $person->getStreet() ,'housenumber'=> $person->getHousenumber() ,'city'=> $person->getCity() ,'postalcode'=> $person->getPostalcode() ,'logindate'=> $person->getLogindate() ,'registerdate'=> $person->getRegisterdate() ,'email'=> $person->getEmail() ,'login'=> $person->getLogin() ,'password'=> $person->getPassword() ,'password_salt'=> $person->getPasswordSalt() ); + $data = array('personID'=> $person->getID() ,'title'=> $person->getTitle() ,'name'=> $person->getName() ,'firstname'=> $person->getFirstname() ,'street'=> $person->getStreet() ,'housenumber'=> $person->getHousenumber() ,'city'=> $person->getCity() ,'postalcode'=> $person->getPostalcode() ,'logindate'=> $person->getLogindate() ,'registerdate'=> $person->getRegisterdate() ,'email'=> $person->getEmail() ,'login'=> $person->getLogin() ,'password'=> $person->getPassword() ,'password_salt'=> $person->getPasswordSalt() ,'suspended'=> $person->getSuspended() ); if (null === ($id = $person->getID()) ) { unset($data['personID']); @@ -110,7 +110,7 @@ class Application_Model_PersonMapper $row = $result->current(); - $person->setID($row->personID)->setTitle($row->title)->setName($row->name)->setFirstname($row->firstname)->setStreet($row->street)->setHousenumber($row->housenumber)->setCity($row->city)->setPostalcode($row->postalcode)->setLogindate($row->logindate)->setRegisterdate($row->registerdate)->setEmail($row->email)->setLogin($row->login)->setPassword($row->password)->setPasswordSalt($row->password_salt); + $person->setID($row->personID)->setTitle($row->title)->setName($row->name)->setFirstname($row->firstname)->setStreet($row->street)->setHousenumber($row->housenumber)->setCity($row->city)->setPostalcode($row->postalcode)->setLogindate($row->logindate)->setRegisterdate($row->registerdate)->setEmail($row->email)->setLogin($row->login)->setPassword($row->password)->setPasswordSalt($row->password_salt)->setSuspended($row->suspended); if($return){ return $person; } @@ -123,7 +123,7 @@ class Application_Model_PersonMapper foreach ($resultSet as $row) { $entry = new Application_Model_Person(); - $entry->setID($row->personID)->setTitle($row->title)->setName($row->name)->setFirstname($row->firstname)->setStreet($row->street)->setHousenumber($row->housenumber)->setCity($row->city)->setPostalcode($row->postalcode)->setLogindate($row->logindate)->setRegisterdate($row->registerdate)->setEmail($row->email)->setLogin($row->login)->setPassword($row->password)->setPasswordSalt($row->password_salt); + $entry->setID($row->personID)->setTitle($row->title)->setName($row->name)->setFirstname($row->firstname)->setStreet($row->street)->setHousenumber($row->housenumber)->setCity($row->city)->setPostalcode($row->postalcode)->setLogindate($row->logindate)->setRegisterdate($row->registerdate)->setEmail($row->email)->setLogin($row->login)->setPassword($row->password)->setPasswordSalt($row->password_salt)->setSuspended($row->suspended); $entries[] = $entry; } diff --git a/application/modules/user/controllers/AuthController.php b/application/modules/user/controllers/AuthController.php index d1596ae..a90c8db 100644 --- a/application/modules/user/controllers/AuthController.php +++ b/application/modules/user/controllers/AuthController.php @@ -52,9 +52,14 @@ class User_AuthController extends Zend_Controller_Action $person->setID($result[0]['personID']); $date = new DateTime(); $person->setLogindate($date->getTimestamp()); - $this->personmapper->save($person); - $this->_helper->redirector('selectmembership', 'person'); - return; + if($person->getSuspended()) { + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('Your Account is suspended', 'error'); + } else { + $this->personmapper->save($person); + $this->_helper->redirector('selectmembership', 'person'); + return; + } } else { $pbsNotifier = new Pbs_Notifier(); $this->view->notification = $pbsNotifier->notify('Wrong Email or Password', 'error'); @@ -95,6 +100,7 @@ class User_AuthController extends Zend_Controller_Action $person = new Application_Model_Person($_POST); $this->personmapper = new Application_Model_PersonMapper(); $date = new DateTime(); + $person->setSuspended(0); $person->setRegisterdate($date->getTimestamp()); $person->setPasswordSalt(MD5($date->getTimestamp())); $person->setPassword(MD5($person->getPassword() . $person->getPasswordSalt())); diff --git a/application/modules/user/controllers/PersonController.php b/application/modules/user/controllers/PersonController.php index bbdf232..975b10e 100644 --- a/application/modules/user/controllers/PersonController.php +++ b/application/modules/user/controllers/PersonController.php @@ -63,6 +63,7 @@ class user_PersonController extends Zend_Controller_Action $this->view->showOtherRight = Pbs_Acl::checkRight('psood'); $this->view->editOtherRight = Pbs_Acl::checkRight('peoa'); $this->view->deleteOtherRight = Pbs_Acl::checkRight('pdo'); + $this->view->suspendRight = Pbs_Acl::checkRight('psa'); $this->view->userIDsNamespace = $this->userIDsNamespace; $this->view->personList = $this->personmapper->fetchAll(); @@ -123,6 +124,7 @@ class user_PersonController extends Zend_Controller_Action $this->view->groupRequestRight = true; $this->view->editRight = Pbs_Acl::checkRight('peod'); $this->view->leaveRight = Pbs_Acl::checkRight('gl'); + $this->view->suspendRight = Pbs_Acl::checkRight('psa'); $this->view->userIDsNamespace = Zend_Session::namespaceGet('userIDs'); } @@ -386,6 +388,7 @@ class user_PersonController extends Zend_Controller_Action $this->view->personID = $personID; $this->view->editRight = Pbs_Acl::checkRight('peoa'); $this->view->deleteRight = Pbs_Acl::checkRight('pd'); + $this->view->suspendRight = Pbs_Acl::checkRight('psa'); $this->view->userIDsNamespace = Zend_Session::namespaceGet('userIDs'); } else { $this->_helper->redirector('', 'person'); @@ -409,6 +412,52 @@ class user_PersonController extends Zend_Controller_Action return; } + public function suspendAction() + { + if(!Pbs_Acl::checkRight('psa')) { + $this->_redirect('/user'); + } + $this->_helper->viewRenderer->setNoRender(); + $personID = $this->_request->getParam('personID'); + if(isset($personID)) { + $person = $this->personmapper->find($personID); + $person->setSuspended(1); + if(isset($person)) { + try { + $this->personmapper->save($person); + } catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "
"; + echo "Message: " . $e->getMessage() . "
"; + return; + } + $this->_redirect("/user/person/"); + } + } + } + public function resumeAction() + { + if(!Pbs_Acl::checkRight('psa')) { + $this->_redirect('/user'); + } + $this->_helper->viewRenderer->setNoRender(); + $personID = $this->_request->getParam('personID'); + if(isset($personID)) { + $person = $this->personmapper->find($personID); + $person->setSuspended(0); + if(isset($person)) { + try { + $this->personmapper->save($person); + } catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "
"; + echo "Message: " . $e->getMessage() . "
"; + return; + } + $this->_redirect("/user/person/"); + } + } + } } diff --git a/application/modules/user/forms/PersonEdit.php b/application/modules/user/forms/PersonEdit.php index 7175691..392174c 100644 --- a/application/modules/user/forms/PersonEdit.php +++ b/application/modules/user/forms/PersonEdit.php @@ -92,7 +92,7 @@ class user_Form_PersonEdit extends Zend_Form $this->addElement('password', 'newpassword', array( 'filters' => array('StringTrim'), 'validators' => array( - array('StringLength', false, array(0, 50)), + array('StringLength', false, array(5, 50)), ), 'required' => false, 'label' => 'Neues Password:', diff --git a/application/modules/user/forms/Register.php b/application/modules/user/forms/Register.php index 9c2a42d..1a054c4 100644 --- a/application/modules/user/forms/Register.php +++ b/application/modules/user/forms/Register.php @@ -84,7 +84,7 @@ class user_Form_Register extends Zend_Form $this->addElement('password', 'password', array( 'filters' => array('StringTrim'), 'validators' => array( - array('StringLength', false, array(0, 50)), + array('StringLength', false, array(5, 50)), ), 'required' => true, 'label' => 'Password:', diff --git a/application/modules/user/views/scripts/person/index.phtml b/application/modules/user/views/scripts/person/index.phtml index 1304299..93dfd78 100644 --- a/application/modules/user/views/scripts/person/index.phtml +++ b/application/modules/user/views/scripts/person/index.phtml @@ -15,14 +15,12 @@ $class=''; if($person->getID() == $this->userIDsNamespace['personID']) $class= 'highlight checked'; ?> -
-getID() != $this->userIDsNamespace['personID']) { +
getID() != $this->userIDsNamespace['personID']) { ?> -
-
Person
- -
- +
Person
+
+
@@ -103,6 +101,33 @@ if($person->getID() == $this->userIDsNamespace['personID']) { suspendRight === true) { + if($person->getSuspended() == 1) { + ?> Resume Account + Suspend Account
getTitle(); ?> getFirstname(); ?> getName(); ?>
getEmail(); ?>
diff --git a/application/modules/user/views/scripts/person/owndetails.phtml b/application/modules/user/views/scripts/person/owndetails.phtml index db9221d..dc6e9aa 100644 --- a/application/modules/user/views/scripts/person/owndetails.phtml +++ b/application/modules/user/views/scripts/person/owndetails.phtml @@ -1,27 +1,40 @@

Own Details

editRight === true) echo $this->formButton('editperson', 'Edit', array( 'onclick' => 'self.location="/user/person/edit/"', 'class' => 'rightbutton'))?>
-
-
person->getTitle()." ".$this->person->getFirstname()." ".$this->person->getName(); ?>
-
person->getEmail(); ?>
-
-
person->getStreet(); ?> 
-
person->getHousenumber(); ?> 
-
person->getCity(); ?> 
-
person->getPostalcode(); ?> 
-
person->getEmail(); ?> 
-
person->getLogindate()) echo date ('d. F Y - H:i', $this->person->getLogindate()) . " Uhr"; ?> 
-
person->getRegisterdate()) . ' Uhr'; ?> 
-
-
-
+
+
person->getTitle()." ".$this->person->getFirstname()." ".$this->person->getName(); ?>
+
person->getEmail(); ?>
+
+
person->getStreet(); ?> 
+ +
person->getHousenumber(); ?> 
+ +
person->getCity(); ?> 
+ +
person->getPostalcode(); ?> 
+ +
person->getEmail(); ?> 
+ +
person->getLogindate()) echo date ('d. F Y - H:i', $this->person->getLogindate()) . " Uhr"; ?> 
+ +
person->getRegisterdate()) . ' Uhr'; ?> 
+suspendRight === true) +{ + ?> +
person->getSuspended() == 1) echo "yes"; else echo "no"; ?>
+
+

Member in the following Groups:

@@ -65,8 +78,7 @@ $class= 'highlight checked';
pagination; if(isset($this->groupRequestList)) { - ?> -
+ ?>

Requests:

groupRequestList as $grouprequest) { @@ -103,4 +115,4 @@ foreach($this->groupRequestList as $grouprequest) { ?>
+ ?> \ No newline at end of file diff --git a/application/modules/user/views/scripts/person/show.phtml b/application/modules/user/views/scripts/person/show.phtml index c43bde3..2f2ef56 100644 --- a/application/modules/user/views/scripts/person/show.phtml +++ b/application/modules/user/views/scripts/person/show.phtml @@ -66,7 +66,18 @@
+suspendRight === true) +{ + ?> +
+
+
Suspended: person->getSuspended() == 1) echo "yes"; else echo "no"; ?>
+
+
+

Member in the following Groups:

groups)==0) @@ -105,18 +116,18 @@ foreach($this->groupRequestList as $grouprequest) {
getTitle(); ?>
- getDescription()) { - ?> + getDescription()) { + ?>
getDescription(); ?>
- +
 
-
+
-