summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Geiger2011-04-05 13:44:19 +0200
committerBjörn Geiger2011-04-05 13:44:19 +0200
commitc1b11591a3009d74cec4a56610070e97883d9251 (patch)
tree628a571294b2a83bf41a4086c03118924234b81f
parentweiteres Recht hinzugefügt (diff)
downloadpbs2-c1b11591a3009d74cec4a56610070e97883d9251.tar.gz
pbs2-c1b11591a3009d74cec4a56610070e97883d9251.tar.xz
pbs2-c1b11591a3009d74cec4a56610070e97883d9251.zip
Rights im Personen Controller eingeführt, verwalten von anderen Accounts nun auch möglich
-rw-r--r--.zfproject.xml14
-rw-r--r--application/modules/user/controllers/AuthController.php18
-rw-r--r--application/modules/user/controllers/PersonController.php150
-rw-r--r--application/modules/user/views/scripts/group/show.phtml3
-rw-r--r--application/modules/user/views/scripts/group/showall.phtml4
-rw-r--r--application/modules/user/views/scripts/person/index.phtml23
-rw-r--r--application/modules/user/views/scripts/person/show.phtml48
-rw-r--r--application/modules/user/views/scripts/person/showall.phtml117
-rw-r--r--application/modules/user/views/scripts/role/index.phtml4
-rw-r--r--application/modules/user/views/scripts/role/show.phtml5
10 files changed, 331 insertions, 55 deletions
diff --git a/.zfproject.xml b/.zfproject.xml
index c7a4807..21e4994 100644
--- a/.zfproject.xml
+++ b/.zfproject.xml
@@ -123,6 +123,8 @@
<actionMethod actionName="leave"/>
<actionMethod actionName="selectMembership"/>
<actionMethod actionName="changemembership"/>
+ <actionMethod actionName="showall"/>
+ <actionMethod actionName="show"/>
</controllerFile>
<controllerFile controllerName="Group">
<actionMethod actionName="index"/>
@@ -316,7 +318,7 @@
</viewControllerScriptsDirectory>
<viewControllerScriptsDirectory forControllerName="Preboot">
<viewScriptFile forActionName="index"/>
- </viewControllerScriptsDirectory>
+ </viewControllerScriptsDirectory>
<viewControllerScriptsDirectory forControllerName="Group">
<viewScriptFile forActionName="add"/>
</viewControllerScriptsDirectory>
@@ -332,8 +334,14 @@
<viewControllerScriptsDirectory forControllerName="Group">
<viewScriptFile forActionName="showall"/>
</viewControllerScriptsDirectory>
- <viewHelpersDirectory/>
- <viewFiltersDirectory/>
+ <viewHelpersDirectory/>
+ <viewFiltersDirectory/>
+ <viewControllerScriptsDirectory forControllerName="Person">
+ <viewScriptFile forActionName="showall"/>
+ </viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Person">
+ <viewScriptFile forActionName="show"/>
+ </viewControllerScriptsDirectory>
</viewScriptsDirectory>
</viewsDirectory>
<bootstrapFile filesystemName="Bootstrap.php"/>
diff --git a/application/modules/user/controllers/AuthController.php b/application/modules/user/controllers/AuthController.php
index 7eccc98..8160104 100644
--- a/application/modules/user/controllers/AuthController.php
+++ b/application/modules/user/controllers/AuthController.php
@@ -2,9 +2,7 @@
class User_AuthController extends Zend_Controller_Action
{
-
protected $personmapper = null;
-
private $db = null;
public function init()
@@ -120,11 +118,19 @@ class User_AuthController extends Zend_Controller_Action
public function deleteAction()
{
+ if($this->_request->getParam('personID')) {
+ if(!Pbs_Acl::checkRight('peoa')) {
+ $this->_redirect('/user');
+ }
+ $personID = $this->_request->getParam('personID');
+ } else {
+ if(!Pbs_Acl::checkRight('pdo')) {
+ $this->_redirect('/user');
+ }
+ $userIDsNamespace = Zend_Session::namespaceGet('userIDs');
+ $personID = $userIDsNamespace['personID'];
+ }
if($_POST['confirmdelete']) {
- $auth = Zend_Auth::getInstance();
- $result = $this->personmapper->findBy(array('email' => $auth->getIdentity()),true);
- $person = $result[0];
- $personID = $person["personID"];
if (isset($personID)){
$this->personmapper = new Application_Model_PersonMapper();
$person = $this->personmapper->find($personID);
diff --git a/application/modules/user/controllers/PersonController.php b/application/modules/user/controllers/PersonController.php
index e614b98..08add21 100644
--- a/application/modules/user/controllers/PersonController.php
+++ b/application/modules/user/controllers/PersonController.php
@@ -2,7 +2,6 @@
class user_PersonController extends Zend_Controller_Action
{
-
protected $person = null;
protected $personmapper = null;
protected $membershipMapper = null;
@@ -10,14 +9,20 @@ class user_PersonController extends Zend_Controller_Action
protected $groupMapper = null;
protected $groups = null;
protected $groupRequestMapper = null;
+ protected $userIDsNamespace = null;
public function init()
{
if (Zend_Auth::getInstance()->hasIdentity()) {
$this->personmapper = new Application_Model_PersonMapper();
- $result = $this->personmapper->findBy(array('email' => Zend_Auth::getInstance()->getIdentity()),true);
- $this->person = new Application_Model_Person($result[0]);
- $this->person->setID($result[0]['personID']);
+ $this->userIDsNamespace = Zend_Session::namespaceGet('userIDs');
+ if($this->userIDsNamespace['personID']) {
+ $this->person = $this->personmapper->find($this->userIDsNamespace['personID']);
+ } else {
+ $result = $this->personmapper->findBy(array('email' => Zend_Auth::getInstance()->getIdentity()),true);
+ $this->person = new Application_Model_Person($result[0]);
+ $this->person->setID($result[0]['personID']);
+ }
$this->groupMapper = new Application_Model_GroupMapper();
$this->groupRequestMapper = new Application_Model_GroupRequestMapper();
$this->membershipMapper = new Application_Model_MembershipMapper();
@@ -26,10 +31,10 @@ class user_PersonController extends Zend_Controller_Action
foreach($this->memberships as $membership) {
$group = $this->groupMapper->find($membership['groupID']);
$this->groups[] = array (
- 'groupID' => $group->getID(),
- 'title' => $group->getTitle(),
- 'description' => $group->getDescription(),
- 'membershipID' => $membership['membershipID']
+ 'groupID' => $group->getID(),
+ 'title' => $group->getTitle(),
+ 'description' => $group->getDescription(),
+ 'membershipID' => $membership['membershipID']
);
}
}
@@ -41,12 +46,15 @@ class user_PersonController extends Zend_Controller_Action
public function indexAction()
{
-
if(!Pbs_Acl::checkRight('psod')) {
$this->_redirect('/user');
}
$this->view->person = $this->person;
$this->view->groups = $this->groups;
+ $this->view->groupRequestRight = Pbs_Acl::checkRight('grm');
+ $this->view->editRight = Pbs_Acl::checkRight('peoa');
+ $this->view->leaveRight = Pbs_Acl::checkRight('gl');
+ $this->view->overviewRight = Pbs_Acl::checkRight('pso');
$this->view->userIDsNamespace = Zend_Session::namespaceGet('userIDs');
}
@@ -55,27 +63,54 @@ class user_PersonController extends Zend_Controller_Action
if(!Pbs_Acl::checkRight('peod')) {
$this->_redirect('/user');
}
- $this->view->person = $this->person;
+ if($personID = $this->_request->getParam('personID')) {
+ if(!Pbs_Acl::checkRight('peoa')) {
+ $this->_redirect('/user');
+ }
+ $person = $this->personmapper->find($personID);
+ $this->view->person = $person;
+ } else {
+ $this->view->person = $this->person;
+ }
if (!isset($_POST["save"])){
$editForm = new user_Form_PersonEdit();
} else {
$editForm = new user_Form_PersonEdit($_POST);
if ($editForm->isValid($_POST)) {
- if(isset($_POST['newpassword'])) {
- $date = new DateTime();
- $this->person->setPassword($_POST['newpassword']);
- $this->person->setPasswordSalt(MD5($date->getTimestamp()));
- $this->person->setPassword(MD5($this->person->getPassword() . $this->person->getPasswordSalt()));
- }
- $this->person->setOptions($_POST);
- try {
- $this->personmapper->save($this->person);
- } catch(Zend_Exception $e)
- {
- echo "Caught exception: " . get_class($e) . "<br/>";
- echo "Message: " . $e->getMessage() . "<br/>";
- echo "Email Address already existing.";
- return;
+ if($personID = $this->_request->getParam('personID')) {
+ if(isset($_POST['newpassword'])) {
+ $date = new DateTime();
+ $person->setPassword($_POST['newpassword']);
+ $person->setPasswordSalt(MD5($date->getTimestamp()));
+ $person->setPassword(MD5($person->getPassword() . $this->person->getPasswordSalt()));
+ }
+ $person->setOptions($_POST);
+ try {
+ $this->personmapper->save($person);
+ } catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ echo "Email Address already existing.";
+ return;
+ }
+ } else {
+ if(isset($_POST['newpassword'])) {
+ $date = new DateTime();
+ $this->person->setPassword($_POST['newpassword']);
+ $this->person->setPasswordSalt(MD5($date->getTimestamp()));
+ $this->person->setPassword(MD5($this->person->getPassword() . $this->person->getPasswordSalt()));
+ }
+ $this->person->setOptions($_POST);
+ try {
+ $this->personmapper->save($this->person);
+ } catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ echo "Email Address already existing.";
+ return;
+ }
}
$this->_helper->redirector('', 'person');
return;
@@ -151,10 +186,9 @@ class user_PersonController extends Zend_Controller_Action
public function leaveAction()
{
- // Nicht klar welches Recht geprüft werden soll
- /*if(!Pbs_Acl::checkRight('peod')) {
- $this->_redirect('/user');
- }*/
+ if(!Pbs_Acl::checkRight('gl')) {
+ $this->_redirect('/user');
+ }
$this->_helper-> viewRenderer-> setNoRender();
$this->view->person = $this->person;
$membershipID = $this->_request->getParam('membershipID');
@@ -197,9 +231,9 @@ class user_PersonController extends Zend_Controller_Action
$group = $groupMapper->find($membership['groupID']);
$role = $roleMapper->find($membership['roleID']);
$membershipList[] = array(
- 'membershipID' => $membership['membershipID'],
- 'group' => $group->getTitle(),
- 'role' => $role->getTitle()
+ 'membershipID' => $membership['membershipID'],
+ 'group' => $group->getTitle(),
+ 'role' => $role->getTitle()
);
}
}
@@ -220,6 +254,54 @@ class user_PersonController extends Zend_Controller_Action
return;
}
+ public function showallAction()
+ {
+ if(!Pbs_Acl::checkRight('pso')) {
+ $this->_redirect('/user');
+ }
+ $this->view->showRight = Pbs_Acl::checkRight('psod');
+ $this->view->editRight = Pbs_Acl::checkRight('peoa');
+ $this->view->deleteRight = Pbs_Acl::checkRight('pd');
+ $this->view->showOtherRight = Pbs_Acl::checkRight('psood');
+ $this->view->editOtherRight = Pbs_Acl::checkRight('peoa');
+ $this->view->deleteOtherRight = Pbs_Acl::checkRight('pdo');
+ $this->view->userIDsNamespace = $this->userIDsNamespace;
+ $this->view->personList = $this->personmapper->fetchAll();
+ }
+
+ public function showAction()
+ {
+ if(!Pbs_Acl::checkRight('psood')) {
+ $this->_redirect('/user');
+ }
+ $personID = $this->_request->getParam('personID');
+ if($personID) {
+ $person = $this->personmapper->find($personID);
+ $memberships = $this->membershipMapper->findBy(array("personID" => $person->getID()),true);
+ if(isset($memberships)) {
+ foreach($memberships as $membership) {
+ $group = $this->groupMapper->find($membership['groupID']);
+ $groups[] = array (
+ 'groupID' => $group->getID(),
+ 'title' => $group->getTitle(),
+ 'description' => $group->getDescription(),
+ 'membershipID' => $membership['membershipID']
+ );
+ }
+ }
+ $this->view->person = $person;
+ $this->view->groups = $groups;
+ $this->view->personID = $personID;
+ $this->view->editRight = Pbs_Acl::checkRight('peoa');
+ $this->view->deleteRight = Pbs_Acl::checkRight('pd');
+ $this->view->overviewRight = Pbs_Acl::checkRight('pso');
+ $this->view->userIDsNamespace = Zend_Session::namespaceGet('userIDs');
+ } else {
+ $this->_helper->redirector('', 'person');
+ return;
+ }
+ }
+
}
@@ -237,3 +319,7 @@ class user_PersonController extends Zend_Controller_Action
+
+
+
+
diff --git a/application/modules/user/views/scripts/group/show.phtml b/application/modules/user/views/scripts/group/show.phtml
index d343204..9777b21 100644
--- a/application/modules/user/views/scripts/group/show.phtml
+++ b/application/modules/user/views/scripts/group/show.phtml
@@ -139,6 +139,3 @@ function printRoleSelect($roleList) {
?>
<br />
<br />
-<br />
-<br />
-<br />
diff --git a/application/modules/user/views/scripts/group/showall.phtml b/application/modules/user/views/scripts/group/showall.phtml
index e26e91e..e58e762 100644
--- a/application/modules/user/views/scripts/group/showall.phtml
+++ b/application/modules/user/views/scripts/group/showall.phtml
@@ -1,4 +1,4 @@
-<h1>Groups</h1>
+<h1>Groups Overview</h1>
<?php echo $this->formButton('addgroup', 'Add Group', array(
'onclick' => 'self.location="/user/group/add"',
'class' => 'addbutton'))
@@ -77,3 +77,5 @@
'onclick' => 'self.location="/user/group/link"',
'class' => 'addbutton'))
?>
+<br />
+<br />
diff --git a/application/modules/user/views/scripts/person/index.phtml b/application/modules/user/views/scripts/person/index.phtml
index cdf5c6b..715bd95 100644
--- a/application/modules/user/views/scripts/person/index.phtml
+++ b/application/modules/user/views/scripts/person/index.phtml
@@ -1,5 +1,5 @@
<h1>Person</h1>
-<?php echo $this->formButton('editperson', 'Edit', array(
+<?php if($this->editRight === true) echo $this->formButton('editperson', 'Edit', array(
'onclick' => 'self.location="/user/person/edit/"',
'class' => 'rightbutton'))?>
<br />
@@ -15,18 +15,23 @@
<div class="personColorDiv"><span class="bold">Last Login Date:</span>&nbsp;<?php if( $this->person->getLogindate()) echo date ('d. F Y - H:i', $this->person->getLogindate()) . " Uhr"; ?></div>
<div class="personDiv"><span class="bold">Register Date:</span>&nbsp;<?php echo date ('d. F Y - H:i', $this->person->getRegisterdate()) . ' Uhr'; ?></div>
<?php
+if($this->overviewRight === true) echo $this->formButton('showallperson', 'Show Personlist', array(
+ 'onclick' => 'self.location="/user/person/showall/"',
+ 'class' => 'rightbutton'));
if(isset($this->groups)) {
?>
<br />
<h2>Member in the following Groups:</h2>
- <?php echo $this->formButton('changeGroup', 'Select other Membership', array(
- 'onclick' => 'self.location="/user/person/changemembership"',
- 'class' => 'rightbutton'))?>
<table>
<tr>
<th>Title</th>
<th>Description</th>
+ <?php if($this->leaveRight === true) {
+ ?>
<th>Leave</th>
+ <?php
+ }
+ ?>
</tr>
<?php
foreach($this->groups as $group) {
@@ -35,6 +40,8 @@ if(isset($this->groups)) {
<?php if($group['membershipID'] == $this->userIDsNamespace['membershipID']) echo 'class="selectedEntry"'; else echo 'class="entry"'; ?>>
<td><?php echo $group['title']; ?></td>
<td><?php echo $group['description']; ?></td>
+ <?php if($this->leaveRight === true) {
+ ?>
<td class='action'><a
href="<?php echo $this->url(
array(
@@ -46,12 +53,15 @@ if(isset($this->groups)) {
'default',
true) ?>"> <img src='/media/img/delete.png' alt='Delete Group' /></a>
</td>
+ <?php
+ }
+ ?>
</tr>
<?php
}
?>
</table>
- <?php echo $this->formButton('addtogroup', 'Add to additional
+ <?php if($this->groupRequestRight === true) echo $this->formButton('addtogroup', 'Add to additional
Groups', array(
'onclick' => 'self.location="/user/person/request/"',
'class' => 'addbutton'));
@@ -59,6 +69,3 @@ Groups', array(
?>
<br />
<br />
-<br />
-<br />
-<br />
diff --git a/application/modules/user/views/scripts/person/show.phtml b/application/modules/user/views/scripts/person/show.phtml
new file mode 100644
index 0000000..a380b3c
--- /dev/null
+++ b/application/modules/user/views/scripts/person/show.phtml
@@ -0,0 +1,48 @@
+<h1>Person</h1>
+<?php if($this->editRight === true) echo $this->formButton('editperson', 'Edit', array(
+ 'onclick' => 'self.location="/user/person/edit/personID/' . $this->personID . '"',
+ 'class' => 'rightbutton')) ?>
+<?php if($this->deleteRight === true) echo $this->formButton('deleteperson', 'Delete', array(
+ 'onclick' => 'self.location="/user/auth/delete/personID/' . $this->personID . '"',
+ 'class' => 'rightbutton')) ?>
+<br />
+<br />
+<div class="personColorDiv"><span class="bold">Title:</span>&nbsp;<?php echo $this->person->getTitle(); ?></div>
+<div class="personDiv"><span class="bold">Name:</span>&nbsp;<?php echo $this->person->getName(); ?></div>
+<div class="personColorDiv"><span class="bold">Firstname:</span>&nbsp;<?php echo $this->person->getFirstname(); ?></div>
+<div class="personDiv"><span class="bold">Street:</span>&nbsp;<?php echo $this->person->getStreet(); ?></div>
+<div class="personColorDiv"><span class="bold">Housenumber:</span>&nbsp;<?php echo $this->person->getHousenumber(); ?></div>
+<div class="personDiv"><span class="bold">City:</span>&nbsp;<?php echo $this->person->getCity(); ?></div>
+<div class="personColorDiv"><span class="bold">Postalcode:</span>&nbsp;<?php echo $this->person->getPostalcode(); ?></div>
+<div class="personDiv"><span class="bold">Email:</span>&nbsp;<?php echo $this->person->getEmail(); ?></div>
+<div class="personColorDiv"><span class="bold">Last Login Date:</span>&nbsp;<?php if( $this->person->getLogindate()) echo date ('d. F Y - H:i', $this->person->getLogindate()) . " Uhr"; ?></div>
+<div class="personDiv"><span class="bold">Register Date:</span>&nbsp;<?php echo date ('d. F Y - H:i', $this->person->getRegisterdate()) . ' Uhr'; ?></div>
+<?php
+if($this->overviewRight === true) echo $this->formButton('showallperson', 'Show Personlist', array(
+ 'onclick' => 'self.location="/user/person/showall/"',
+ 'class' => 'rightbutton'));
+if(isset($this->groups)) {
+ ?>
+<br />
+<h2>Member in the following Groups:</h2>
+<table>
+ <tr>
+ <th>Title</th>
+ <th>Description</th>
+ </tr>
+ <?php
+ foreach($this->groups as $group) {
+ ?>
+ <tr class="entry">
+ <td><?php echo $group['title']; ?></td>
+ <td><?php echo $group['description']; ?></td>
+ </tr>
+ <?php
+ }
+ ?>
+</table>
+ <?php
+}
+?>
+<br />
+<br />
diff --git a/application/modules/user/views/scripts/person/showall.phtml b/application/modules/user/views/scripts/person/showall.phtml
new file mode 100644
index 0000000..68e9e7c
--- /dev/null
+++ b/application/modules/user/views/scripts/person/showall.phtml
@@ -0,0 +1,117 @@
+<h1>Persons Overview</h1>
+<br />
+<br />
+<table>
+ <tr>
+ <th>Title</th>
+ <th>Name</th>
+ <th>Firstname</th>
+ <th>Email</th>
+ <?php
+ if($this->showRight === true || $this->editRight === true || $this->deleteRight === true) {
+ ?>
+ <th colspan=3>Actions</th>
+ <?php
+ }
+ ?>
+ </tr>
+ <?php
+ if(count($this->personList) > 0) {
+ foreach($this->personList as $person) {
+ ?>
+ <tr
+ <?php if($person->getID() == $this->userIDsNamespace['personID']) echo 'class="selectedEntry"'; else echo 'class="entry"'; ?>>
+ <td><?php echo $person->getTitle(); ?></td>
+ <td><?php echo $person->getName(); ?></td>
+ <td><?php echo $person->getFirstname(); ?></td>
+ <td><?php echo $person->getEmail(); ?></td>
+ <?php
+ if($person->getID() == $this->userIDsNamespace['personID']) {
+ if($this->showRight === true) {
+ ?>
+ <td class='action'><a
+ href="<?php echo $this->url(
+ array(
+ 'module' => 'user',
+ 'controller' => 'person',
+ 'action' => 'index'
+ ),
+ 'default',
+ true);?>"> <img src='/media/img/show.png' alt='Show Person' /></a></td>
+ <?php
+ }
+ if($this->editRight === true) { ?>
+ <td class='action'><a
+ href="<?php echo $this->url(
+ array(
+ 'module' => 'user',
+ 'controller' => 'person',
+ 'action' => 'edit'
+ ),
+ 'default',
+ true);?>"> <img src='/media/img/edit.png' alt='Edit Person' /></a></td>
+ <?php
+ }
+ if($this->deleteRight === true) { ?>
+ <td class='action'><a
+ href="<?php echo $this->url(
+ array(
+ 'module' => 'user',
+ 'controller' => 'auth',
+ 'action' => 'delete'
+ ),
+ 'default',
+ true);?>"> <img src='/media/img/delete.png' alt='Delete Account' /></a></td>
+ <?php
+ }
+ } else {
+ if($this->showOtherRight === true) {
+ ?>
+ <td class='action'><a
+ href=" <?php echo $this->url(
+ array(
+ 'module' => 'user',
+ 'controller' => 'person',
+ 'action' => 'show',
+ 'personID' => $person->getID()
+ ),
+ 'default',
+ true); ?>"> <img src='/media/img/show.png' alt='Show Person' /></a></td>
+ <?php
+ }
+ if($this->editOtherRight === true) {
+ ?>
+ <td class='action'><a
+ href=" <?php echo $this->url(
+ array(
+ 'module' => 'user',
+ 'controller' => 'person',
+ 'action' => 'edit',
+ 'personID' => $person->getID()
+ ),
+ 'default',
+ true); ?>"> <img src='/media/img/edit.png' alt='Edit Person' /></a></td>
+ <?php
+ }
+ if($this->deleteOtherRight === true) {
+ ?>
+ <td class='action'><a
+ href=" <?php echo $this->url(
+ array(
+ 'module' => 'user',
+ 'controller' => 'auth',
+ 'action' => 'delete',
+ 'personID' => $person->getID()
+ ),
+ 'default',
+ true); ?>"> <img src='/media/img/delete.png' alt='Delete Account' /></a></td>
+ <?php
+ }
+ }
+ ?>
+ </tr>
+ <?php
+ }
+ }
+ ?>
+</table>
diff --git a/application/modules/user/views/scripts/role/index.phtml b/application/modules/user/views/scripts/role/index.phtml
index db20aa2..a0b4284 100644
--- a/application/modules/user/views/scripts/role/index.phtml
+++ b/application/modules/user/views/scripts/role/index.phtml
@@ -56,4 +56,6 @@ if($this->userIDsNamespace['groupID']) {
</table>
<?php
}
-?> \ No newline at end of file
+?>
+<br />
+<br />
diff --git a/application/modules/user/views/scripts/role/show.phtml b/application/modules/user/views/scripts/role/show.phtml
index 6c6f8f5..6769336 100644
--- a/application/modules/user/views/scripts/role/show.phtml
+++ b/application/modules/user/views/scripts/role/show.phtml
@@ -88,4 +88,7 @@ if($this->roleID) {
</center>
<?php
}
-} \ No newline at end of file
+}
+?>
+<br />
+<br />