summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Geiger2011-03-10 22:10:05 +0100
committerBjörn Geiger2011-03-10 22:10:05 +0100
commit7be4355001156faed62c71492234cba2c5bf96b4 (patch)
tree55bb96227ee354cc0c6d6788dc45020bd43d8bba
parentMerge branch 'master' of ssh://git.openslx.org/lsfks/master-teamprojekt/pbs2 (diff)
downloadpbs2-7be4355001156faed62c71492234cba2c5bf96b4.tar.gz
pbs2-7be4355001156faed62c71492234cba2c5bf96b4.tar.xz
pbs2-7be4355001156faed62c71492234cba2c5bf96b4.zip
Benutzervewaltung, Gruppenverwaltung, Membershipverwaltung und noch leerer RoleController
-rw-r--r--.zfproject.xml93
-rw-r--r--application/Bootstrap.php22
-rw-r--r--application/Functions.php32
-rw-r--r--application/controllers/AuthController.php282
-rw-r--r--application/controllers/GroupController.php238
-rw-r--r--application/controllers/PersonController.php157
-rw-r--r--application/controllers/RoleController.php60
-rw-r--r--application/forms/AuthRecoverPassword.php28
-rw-r--r--application/forms/AuthRegister.php2
-rw-r--r--application/forms/GroupAdd.php65
-rw-r--r--application/forms/GroupEdit.php52
-rw-r--r--application/forms/GroupLink.php55
-rw-r--r--application/forms/GroupRequest.php42
-rw-r--r--application/forms/PersonEdit.php117
-rw-r--r--application/layouts/main.phtml13
-rw-r--r--application/models/GroupGroupsMapper.php44
-rw-r--r--application/models/GroupRequestMapper.php4
-rw-r--r--application/models/Person.php2
-rw-r--r--application/views/scripts/auth/delete.phtml4
-rw-r--r--application/views/scripts/auth/index.phtml1
-rw-r--r--application/views/scripts/auth/login.phtml5
-rw-r--r--application/views/scripts/auth/recoverpassword.phtml5
-rw-r--r--application/views/scripts/group/add.phtml4
-rw-r--r--application/views/scripts/group/delete.phtml6
-rw-r--r--application/views/scripts/group/edit.phtml10
-rw-r--r--application/views/scripts/group/grantperson.phtml11
-rw-r--r--application/views/scripts/group/index.phtml35
-rw-r--r--application/views/scripts/group/link.phtml4
-rw-r--r--application/views/scripts/group/revokeperson.phtml6
-rw-r--r--application/views/scripts/group/show.phtml122
-rw-r--r--application/views/scripts/person/edit.phtml4
-rw-r--r--application/views/scripts/person/index.phtml1
-rw-r--r--application/views/scripts/person/leave.phtml6
-rw-r--r--application/views/scripts/person/request.phtml6
-rw-r--r--application/views/scripts/person/show.phtml79
-rw-r--r--application/views/scripts/role/add.phtml1
-rw-r--r--application/views/scripts/role/delete.phtml1
-rw-r--r--application/views/scripts/role/edit.phtml1
-rw-r--r--application/views/scripts/role/index.phtml1
-rw-r--r--application/views/scripts/role/linkright.phtml1
-rw-r--r--application/views/scripts/role/show.phtml1
-rw-r--r--application/views/scripts/role/unlinkright.phtml1
-rw-r--r--tests/application/controllers/GroupControllerTest.php20
-rw-r--r--tests/application/controllers/RoleControllerTest.php20
44 files changed, 1462 insertions, 202 deletions
diff --git a/.zfproject.xml b/.zfproject.xml
index e421904..e0bd2af 100644
--- a/.zfproject.xml
+++ b/.zfproject.xml
@@ -16,12 +16,16 @@
<actionMethod actionName="login"/>
<actionMethod actionName="register"/>
<actionMethod actionName="logout"/>
- <actionMethod actionName="recoverPassword"/>
+ <actionMethod actionName="recoverpassword"/>
<actionMethod actionName="delete"/>
<actionMethod actionName="index"/>
</controllerFile>
<controllerFile controllerName="Person">
<actionMethod actionName="index"/>
+ <actionMethod actionName="show"/>
+ <actionMethod actionName="edit"/>
+ <actionMethod actionName="request"/>
+ <actionMethod actionName="leave"/>
</controllerFile>
<controllerFile controllerName="Filter">
<actionMethod actionName="index"/>
@@ -90,10 +94,28 @@
<actionMethod actionName="getkcl"/>
<actionMethod actionName="getbootmenuentry"/>
</controllerFile>
+ <controllerFile controllerName="Group">
+ <actionMethod actionName="index"/>
+ <actionMethod actionName="add"/>
+ <actionMethod actionName="edit"/>
+ <actionMethod actionName="show"/>
+ <actionMethod actionName="link"/>
+ <actionMethod actionName="delete"/>
+ <actionMethod actionName="grantperson"/>
+ <actionMethod actionName="revokeperson"/>
+ </controllerFile>
+ <controllerFile controllerName="Role">
+ <actionMethod actionName="index"/>
+ <actionMethod actionName="add"/>
+ <actionMethod actionName="edit"/>
+ <actionMethod actionName="show"/>
+ <actionMethod actionName="delete"/>
+ <actionMethod actionName="linkright"/>
+ <actionMethod actionName="unlinkright"/>
+ </controllerFile>
</controllersDirectory>
<formsDirectory>
<formFile formName="AuthLogin"/>
- <formFile formName="AuthDelete"/>
<formFile formName="AuthRegister"/>
<formFile formName="FilterAdd"/>
<formFile formName="FilterEntriesAdd"/>
@@ -111,7 +133,13 @@
<formFile formName="PoolClient"/>
<formFile formName="Client"/>
<formFile formName="Session"/>
+ <formFile formName="AuthRecoverPassword"/>
+ <formFile formName="PersonEdit"/>
+ <formFile formName="GroupRequest"/>
+ <formFile formName="GroupAdd"/>
<formFile formName="FilterEvaluate"/>
+ <formFile formName="GroupLink"/>
+ <formFile formName="GroupEdit"/>
</formsDirectory>
<layoutsDirectory enabled="false"/>
<modelsDirectory>
@@ -209,7 +237,7 @@
<viewScriptFile forActionName="logout"/>
</viewControllerScriptsDirectory>
<viewControllerScriptsDirectory forControllerName="Auth">
- <viewScriptFile forActionName="recoverPassword"/>
+ <viewScriptFile forActionName="recoverpassword"/>
</viewControllerScriptsDirectory>
<viewControllerScriptsDirectory forControllerName="Auth">
<viewScriptFile forActionName="deleteAccount"/>
@@ -319,6 +347,63 @@
<viewControllerScriptsDirectory forControllerName="Auth">
<viewScriptFile forActionName="index"/>
</viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Person">
+ <viewScriptFile forActionName="show"/>
+ </viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Person">
+ <viewScriptFile forActionName="edit"/>
+ </viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Person">
+ <viewScriptFile forActionName="request"/>
+ </viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Person">
+ <viewScriptFile forActionName="leave"/>
+ </viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Group">
+ <viewScriptFile forActionName="index"/>
+ </viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Group">
+ <viewScriptFile forActionName="add"/>
+ </viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Group">
+ <viewScriptFile forActionName="edit"/>
+ </viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Group">
+ <viewScriptFile forActionName="show"/>
+ </viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Group">
+ <viewScriptFile forActionName="link"/>
+ </viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Group">
+ <viewScriptFile forActionName="delete"/>
+ </viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Group">
+ <viewScriptFile forActionName="grantperson"/>
+ </viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Group">
+ <viewScriptFile forActionName="revokeperson"/>
+ </viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Role">
+ <viewScriptFile forActionName="index"/>
+ </viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Role">
+ <viewScriptFile forActionName="add"/>
+ </viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Role">
+ <viewScriptFile forActionName="edit"/>
+ </viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Role">
+ <viewScriptFile forActionName="show"/>
+ </viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Role">
+ <viewScriptFile forActionName="delete"/>
+ </viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Role">
+ <viewScriptFile forActionName="linkright"/>
+ </viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Role">
+ <viewScriptFile forActionName="unlinkright"/>
+ </viewControllerScriptsDirectory>
<viewControllerScriptsDirectory forControllerName="Filter">
<viewScriptFile forActionName="testevaluate"/>
</viewControllerScriptsDirectory>
@@ -384,6 +469,8 @@
<testApplicationControllerFile filesystemName="PoolControllerTest.php"/>
<testApplicationControllerFile filesystemName="BootisoControllerTest.php"/>
<testApplicationControllerFile filesystemName="SessionControllerTest.php"/>
+ <testApplicationControllerFile filesystemName="GroupControllerTest.php"/>
+ <testApplicationControllerFile filesystemName="RoleControllerTest.php"/>
<testApplicationControllerFile filesystemName="ResourceControllerTest.php"/>
</testApplicationControllerDirectory>
</testApplicationDirectory>
diff --git a/application/Bootstrap.php b/application/Bootstrap.php
index f0fe7d3..f06c85b 100644
--- a/application/Bootstrap.php
+++ b/application/Bootstrap.php
@@ -26,24 +26,4 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
->setSeparator(' :: ');
}
}
-function print_a(){
- $numargs = func_num_args();
- if($numargs>1){
- $out = '';
- ob_start();
- echo "<div style='background-color:#FFCC33;border:1px solid black;margin:3px;padding:5px;'>";
- for($a=0;$a<$numargs;$a++)
- print_a(func_get_arg($a));
- echo "</div>";
- $out .= ob_get_contents();
- ob_end_clean();
- echo $out;
- }else{
- echo "<pre style='background-color:#FFDF80;border:1px solid #000;margin:3px;padding:5px;'>";
- $a = func_get_arg(0);
- $a = (is_bool($a))?(($a)?'true':'false'):$a;
- print_r($a);
- echo "</pre>";
- }
-}
-
+include 'Functions.php'; \ No newline at end of file
diff --git a/application/Functions.php b/application/Functions.php
new file mode 100644
index 0000000..3ffc39b
--- /dev/null
+++ b/application/Functions.php
@@ -0,0 +1,32 @@
+<?php
+function random($name_laenge) {
+ $zeichen = "abcedfghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRTSUVWXYZ0123456789";
+ $name_neu = "";
+
+ mt_srand ((double) microtime() * 1000000);
+ for ($i = 0; $i < $name_laenge; $i++ ) {
+ $name_neu .= $zeichen{mt_rand (0,strlen($zeichen))};
+ }
+ return $name_neu;
+}
+
+function print_a(){
+ $numargs = func_num_args();
+ if($numargs>1){
+ $out = '';
+ ob_start();
+ echo "<div style='background-color:#FFCC33;border:1px solid black;margin:3px;padding:5px;'>";
+ for($a=0;$a<$numargs;$a++)
+ print_a(func_get_arg($a));
+ echo "</div>";
+ $out .= ob_get_contents();
+ ob_end_clean();
+ echo $out;
+ }else{
+ echo "<pre style='background-color:#FFDF80;border:1px solid #000;margin:3px;padding:5px;'>";
+ $a = func_get_arg(0);
+ $a = (is_bool($a))?(($a)?'true':'false'):$a;
+ print_r($a);
+ echo "</pre>";
+ }
+} \ No newline at end of file
diff --git a/application/controllers/AuthController.php b/application/controllers/AuthController.php
index 8ccb25c..097417b 100644
--- a/application/controllers/AuthController.php
+++ b/application/controllers/AuthController.php
@@ -2,136 +2,168 @@
class AuthController extends Zend_Controller_Action
{
+ protected $personmapper;
private $db = null;
- public function init()
- {
- $this->db = Zend_Db_Table::getDefaultAdapter();
- }
-
- public function indexAction()
- {
- $this->_redirect('/auth/login');
- }
-
- public function loginAction()
- {
- if (Zend_Auth::getInstance()->hasIdentity()) {
- print_a('bereits angemeldet');
- }
- if (!isset($_POST["login"])){
- $loginForm = new Application_Form_AuthLogin();
- } else {
- $loginForm = new Application_Form_AuthLogin($_POST);
-
- if ($loginForm->isValid($_POST)) {
-
- $auth = Zend_Auth::getInstance();
-
- $adapter = new Zend_Auth_Adapter_DbTable(
- $this->db,
+
+ public function init()
+ {
+ $this->db = Zend_Db_Table::getDefaultAdapter();
+ $this->personmapper = new Application_Model_PersonMapper();
+ }
+
+ public function indexAction()
+ {
+ $this->_helper->redirector('login', 'auth');
+ }
+
+ public function loginAction()
+ {
+ if (Zend_Auth::getInstance()->hasIdentity()) {
+ print_a('Already logged in.');
+ } else {
+ if (!isset($_POST["login"])){
+ $loginForm = new Application_Form_AuthLogin();
+ } else {
+ $loginForm = new Application_Form_AuthLogin($_POST);
+
+ if ($loginForm->isValid($_POST)) {
+
+ $auth = Zend_Auth::getInstance();
+
+ $adapter = new Zend_Auth_Adapter_DbTable(
+ $this->db,
'pbs_person',
'email',
'password',
'MD5(CONCAT(?, password_salt))'
);
-
-
- $adapter->setIdentity($loginForm->getValue('email'));
- $adapter->setCredential($loginForm->getValue('password'));
-
- $result = $auth->authenticate($adapter);
-
- // TODO: erweiterte fehlerbeschreibung des Users
-
- if ($result->isValid()) {
- $this->_redirect('/auth/login');
- return;
- } else {
- echo "Falsche Email oder Passwort";
- }
- }
- }
-
- $this->view->loginForm = $loginForm;
- }
-
- public function registerAction()
- {
- if (Zend_Auth::getInstance()->hasIdentity()) {
- print_a('bereits angemeldet');
+
+
+ $adapter->setIdentity($loginForm->getValue('email'));
+ $adapter->setCredential($loginForm->getValue('password'));
+
+ $result = $auth->authenticate($adapter);
+
+ // TODO: erweiterte fehlerbeschreibung des Users
+
+ if ($result->isValid()) {
+ $this->personmapper = new Application_Model_PersonMapper();
+ $result = $this->personmapper->findBy('email', Zend_Auth::getInstance()->getIdentity());
+ $person = new Application_Model_Person($result[0]);
+ $person->setID($result[0]['personID']);
+ $date = new DateTime();
+ $person->setLogindate($date->getTimestamp());
+ $this->personmapper->save($person);
+ $this->_redirect('/');
+ return;
+ } else {
+ echo "Wrong Email or Password.";
+ }
+ }
+ }
+
+ $this->view->loginForm = $loginForm;
+ }
+ }
+
+ public function registerAction()
+ {
+ if (Zend_Auth::getInstance()->hasIdentity()) {
+ print_a('Already logged in.');
+ } else {
+ if (!isset($_POST["register"])){
+ $registerForm = new Application_Form_AuthRegister();
+ } else {
+ $registerForm = new Application_Form_AuthRegister($_POST);
+
+ if ($registerForm->isValid($_POST)) {
+
+ $person = new Application_Model_Person($_POST);
+ $this->personmapper = new Application_Model_PersonMapper();
+
+ $date = new DateTime();
+ $person->setRegisterdate($date->getTimestamp());
+ $person->setPasswordSalt(MD5($date->getTimestamp()));
+ $person->setPassword(MD5($person->getPassword() . $person->getPasswordSalt()));
+ print_a($person);
+ 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;
+ }
+ echo "Successfully registered. <br/>";
+ echo "Continue to Login: <a href=\""."/auth/login"."\">Login</a>";
+ $this->_helper->redirector('login', 'auth');
+ return;
+ }
+ }
+
+ $this->view->registerForm = $registerForm;
+ }
+ }
+
+ public function logoutAction()
+ {
+ $auth = Zend_Auth::getInstance();
+ $auth->clearIdentity();
+ $this->_helper->redirector('login', 'auth');
+ }
+
+ public function recoverpasswordAction()
+ {
+ if (!isset($_POST["recoverPassword"])){
+ $recoverPasswordForm = new Application_Form_AuthRecoverPassword();
+ } else {
+ $recoverPasswordForm = new Application_Form_AuthRecoverPassword($_POST);
+ # Wiederherstellung funktioniert noch nicht!!!
+ /*if ($recoverPasswordForm->isValid($_POST)) {
+ $recoverPasswordForm->getView()->url();
+ $person = new Application_Model_Person($_POST);
+ $this->personmapper = new Application_Model_PersonMapper();
+
+ $result = $this->personmapper->findBy('email', $_POST['email']);
+ $email = $result[0]['email'];
+ $name = $result[0]['firstname'] . ' ' . $result[0]['name'];
+ $url = $this->getRequest()->getScheme() . '://' . $this->getRequest()->getHttpHost() . $this->view->url();
+ $recoverid = $this->random(100);
+ $mailbody = 'Um das Passwort zu ändern klicken Sie auf folgenden Link<br /><br /><a href="'. $url . '/auth/recoverpassword/?recoverid='. $recoverid . '">Passwort ändern</a>';
+ $mail = new Zend_Mail();
+ $mail->setBodyHtml($mailbody, 'utf8');
+ $mail->getBodyHtml()->getContent();
+ $mail->setFrom('admin@local', 'Admin');
+ $mail->addTo($email, $name);
+ $mail->setSubject('Password Wiederherstellung Preboot Server');
+ $mail->send();
+ }
+ */
}
- if (!isset($_POST["register"])){
- $registerForm = new Application_Form_AuthRegister();
- } else {
- $registerForm = new Application_Form_AuthRegister($_POST);
-
- if ($registerForm->isValid($_POST)) {
-
- $person = new Application_Model_Person($_POST);
- $personmapper = new Application_Model_PersonMapper();
-
- $date = new DateTime();
- $person->setRegisterdate($date->getTimestamp());
- $person->setPasswordSalt(MD5($date->getTimestamp()));
- $person->setPassword(MD5($person->getPassword() . $person->getPasswordSalt()));
- print_a($person);
- try {
- $personmapper->save($person);
- }catch(Zend_Exception $e)
- {
- echo "Caught exception: " . get_class($e) . "<br/>";
- echo "Message: " . $e->getMessage() . "<br/>";
- echo "Email Adresse bereits vorhanden.";
- return;
- }
- echo "Erfolgreich registriert. <br/>";
- echo "Weiter zum Login: <a href=\""."/auth/login"."\">Login</a>";
- $this->_redirect('/auth/login');
- return;
- }
- }
-
- $this->view->registerForm = $registerForm;
- }
-
- public function logoutAction()
- {
- // action body
- }
-
- public function recoverPasswordAction()
- {
- // action body
- }
-
- public function deleteAction()
- {
- if (!isset($_POST["delete"])){
- $deleteForm = new Application_Form_AuthDelete();
- } else {
- $deleteForm = new Application_Form_AuthDelete($_POST);
-
- if ($deleteForm->isValid($_POST)) {
-
- $person = new Application_Model_Person($_POST);
- $personmapper = new Application_Model_PersonMapper();
-
-
- $personmapper->delete($person);
- }
- }
-
- $this->view->deleteForm = $deleteForm;
- }
-
-
-
-}
-
-
-
-
-
-
-
+ $this->view->recoverPasswordForm = $recoverPasswordForm;
+ }
+
+ public function deleteAction()
+ {
+ $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/>";
+ return;
+ }
+ $auth = Zend_Auth::getInstance();
+ $auth->clearIdentity();
+ $this->_helper->redirector('login', 'auth');
+ }
+ }
+} \ No newline at end of file
diff --git a/application/controllers/GroupController.php b/application/controllers/GroupController.php
new file mode 100644
index 0000000..1de9207
--- /dev/null
+++ b/application/controllers/GroupController.php
@@ -0,0 +1,238 @@
+<?php
+
+class GroupController extends Zend_Controller_Action
+{
+ protected $groupMapper;
+ protected $groupGroupsMapper;
+ protected $membershipMapper;
+ protected $groupRequestMapper;
+ protected $personmapper;
+ protected $rolemapper;
+ protected $groupList;
+
+ public function init()
+ {
+ $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();
+ }
+
+ public function indexAction()
+ {
+ $this->view->groupList = $this->groupList;
+ }
+
+ public function addAction()
+ {
+ if (!isset($_POST["add"])){
+ $addForm = new Application_Form_GroupAdd(array('grouplist' => $this->groupList));
+ } else {
+ $addForm = new Application_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;
+ }
+
+ }
+ echo "Group successfully added. <br/>";
+ }
+ }
+
+ $this->view->addForm = $addForm;
+ }
+
+ public function editAction()
+ {
+ if(!isset($_POST['groupID'])) {
+ $addForm = new Application_Form_GroupAdd(array('grouplist' => $this->groupList));
+ $this->view->addForm = $addForm;
+ return;
+ }
+ if (!isset($_POST["save"])){
+ $group = $this->groupMapper->find($_POST['groupID']);
+ $_POST['title'] = $group->getTitle();
+ $_POST['description'] = $group->getDescription();
+ $editForm = new Application_Form_GroupEdit();
+ } else {
+ $editForm = new Application_Form_GroupEdit($_POST);
+ if ($editForm->isValid($_POST)) {
+ $group = new Application_Model_Group($_POST);
+ try {
+ $this->groupMapper->save($group);
+ } catch(Zend_Exception $e)
+ {
+ echo "Email Address already existing.";
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ return;
+ }
+ echo "Successfully saved. <br/>";
+ }
+ }
+
+ $this->view->editForm = $editForm;
+ }
+
+ public function showAction()
+ {
+ if($_POST['groupID']) {
+ $groupRequests = $this->groupRequestMapper->findBy('groupID', $_POST['groupID']);
+ if(isset($groupRequests)) {
+ foreach($groupRequests as $groupRequest) {
+ $person = $this->personmapper->find($groupRequest['personID']);
+ $groupRequestList[] = array(
+ 'grouprequestID' => $groupRequest['grouprequestID'],
+ 'person' => $person
+ );
+ }
+ $this->view->groupRequestList = $groupRequestList;
+ $this->view->roleList = $this->rolemapper->findBy('groupID', $_POST['groupID']);
+ }
+ $members = $this->membershipMapper->findBy('groupID', $_POST['groupID']);
+ if(isset($members)) {
+ foreach($members as $member) {
+ $person = $this->personmapper->find($member['personID']);
+ $membersList[] = array(
+ 'membershipID' => $member['membershipID'],
+ 'person' => $person
+ );
+ }
+ $this->view->memberslist = $membersList;
+ }
+ $groupgroups = $this->groupGroupsMapper->findBy('groupID', $_POST['groupID']);
+ if(is_object($groupgroups)) {
+ $parentGroup = $this->groupMapper->find($groupgroups->getParentID());
+ $this->view->$parentGroup = $parentGroup;
+ }
+ $group = $this->groupMapper->find($_POST['groupID']);
+ $this->view->group = $group;
+ }
+ }
+
+ public function linkAction()
+ {
+ if (!isset($_POST["link"])){
+ $linkForm = new Application_Form_GroupLink(array('grouplist' => $this->groupList));
+ } else {
+ $linkForm = new Application_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;
+ }
+ echo "Groups successfully linked. <br/>";
+ }
+ }
+
+ $this->view->linkForm = $linkForm;
+ }
+
+ public function deleteAction()
+ {
+ if (isset($_POST["groupID"])){
+ $group = $this->groupMapper->find($_POST["groupID"]);
+ try {
+ $this->groupMapper->delete($group);
+ } catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ return;
+ }
+ echo "Group successfully deleted. <br/>";
+ }
+ }
+
+ public function grantpersonAction()
+ {
+ 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;
+ }
+ echo "Chosen Person has been successfully added to the chosen group. <br />";
+ }
+ }
+
+ public function revokepersonAction()
+ {
+ if(isset($_POST['membershipID'])) {
+ $membership = $this->membershipMapper->find($_POST['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;
+ }
+ echo "Chosen Person has been successfully removed from the chosen group. <br />";
+ }
+
+ }
+ }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/application/controllers/PersonController.php b/application/controllers/PersonController.php
index 986117a..0b6db2e 100644
--- a/application/controllers/PersonController.php
+++ b/application/controllers/PersonController.php
@@ -1,27 +1,154 @@
<?php
class PersonController extends Zend_Controller_Action
-{
-
- public function preDispatch()
- {
-
- if (!Zend_Auth::getInstance()->hasIdentity()) {
- // TODO: quick hack fixxen
- $this->_redirect('/Auth/login');
+{
+ protected $person;
+ protected $personmapper;
+ protected $membershipMapper;
+ protected $memberships;
+ protected $groupMapper;
+ protected $groups;
+ protected $groupRequestMapper;
+
+ public function init() {
+ if (Zend_Auth::getInstance()->hasIdentity()) {
+ $this->personmapper = new Application_Model_PersonMapper();
+ $result = $this->personmapper->findBy('email', Zend_Auth::getInstance()->getIdentity());
+ $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();
+ $this->memberships = $this->membershipMapper->findBy("personID",$this->person->getID());
+ if(isset($this->memberships)) {
+ foreach($this->memberships as $membership) {
+ $group = $this->groupMapper->find($membership['groupID']);
+ $this->groups[] = array (
+ 'id' => $group->getID(),
+ 'title' => $group->getTitle()
+ );
+ }
+ }
+ } else {
+ $this->_helper->redirector('login', 'auth');
}
- }
+ }
+
+ public function indexAction()
+ {
+ $this->_helper->redirector('show', 'person');
+ }
- public function indexAction()
- {
- echo 'case2';
- // action body
- }
+ public function showAction()
+ {
+ $this->view->person = $this->person;
+ $this->view->groups = $this->groups;
+ }
+
+ public function editAction()
+ {
+ $this->view->person = $this->person;
+ if (!isset($_POST["save"])){
+ $editForm = new Application_Form_PersonEdit();
+ } else {
+ $editForm = new Application_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;
+ }
+ echo "Successfully saved. <br/>";
+ }
+ }
-
+ $this->view->editForm = $editForm;
+ }
+ public function requestAction()
+ {
+ $this->view->person = $this->person;
+ $allgroups = $this->groupMapper->fetchAll();
+ $groupRequests = $this->groupRequestMapper->findBy('personID', $this->person->getID());
+ $count = 0;
+ foreach($allgroups as $group) {
+ foreach($groupRequests as $groupRequest) {
+ if($groupRequest['groupID'] == $group->getID()) {
+ unset($allgroups[$count]);
+ }
+ }
+ $count++;
+ }
+ if (!isset($_POST["request"])){
+ if(count($allgroups) <= 0) {
+ echo "No Groups to choose.";
+ }
+ $requestForm = new Application_Form_GroupRequest(array('grouplist' => $allgroups));
+ } else {
+ $requestForm = new Application_Form_GroupRequest(array('grouplist' => $allgroups), $_POST);
+ if ($requestForm->isValid($_POST)) {
+ $groupRequestMapper = new Application_Model_GroupRequestMapper();
+ $groupRequest = new Application_Model_GroupRequest();
+ $groupRequest->setGroupID($_POST['groupID']);
+ $date = new DateTime();
+ $groupRequest->setTime($date->getTimestamp());
+ $groupRequest->setPersonID($this->person->getID());
+ try {
+ $groupRequestMapper->save($groupRequest);
+ } catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ return;
+ }
+ echo "Successfully requested. <br />";
+ }
+ }
+ $this->view->requestForm = $requestForm;
+ }
+ public function leaveAction()
+ {
+ $this->view->person = $this->person;
+ if(isset($_POST['groupID'])) {
+ if(isset($this->memberships)) {
+ foreach($this->memberships as $membership) {
+ if($membership['groupID'] == $_POST['groupID']) {
+ $membershipObject = $this->membershipMapper->find($membership['membershipID']);
+ try {
+ $this->membershipMapper->delete($membershipObject);
+ } catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ return;
+ }
+ echo "You have been successfully removed from the chosen group. <br />";
+ }
+ }
+ }
+ }
+ }
}
+
+
+
+
+
+
+
+
diff --git a/application/controllers/RoleController.php b/application/controllers/RoleController.php
new file mode 100644
index 0000000..f5e436b
--- /dev/null
+++ b/application/controllers/RoleController.php
@@ -0,0 +1,60 @@
+<?php
+
+class RoleController extends Zend_Controller_Action
+{
+
+ public function init()
+ {
+
+ }
+
+ public function indexAction()
+ {
+
+ }
+
+ public function addAction()
+ {
+
+ }
+
+ public function editAction()
+ {
+
+ }
+
+ public function showAction()
+ {
+
+ }
+
+ public function deleteAction()
+ {
+
+ }
+
+ public function linkrightAction()
+ {
+ // action body
+ }
+
+ public function unlinkrightAction()
+ {
+ // action body
+ }
+
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/application/forms/AuthRecoverPassword.php b/application/forms/AuthRecoverPassword.php
new file mode 100644
index 0000000..fc9478b
--- /dev/null
+++ b/application/forms/AuthRecoverPassword.php
@@ -0,0 +1,28 @@
+<?php
+
+class Application_Form_AuthRecoverPassword extends Zend_Form
+{
+
+ public function init()
+ {
+ $this->setName("RecoverPassword");
+ $this->setMethod('post');
+
+ $this->addElement('text', 'email', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 30)),
+ ),
+ 'required' => true,
+ 'label' => 'Email:',
+ ));
+ $this->addElement('submit', 'recoverPassword', array(
+ 'required' => false,
+ 'ignore' => true,
+ 'label' => 'Recover Password',
+ ));
+ }
+
+
+}
+
diff --git a/application/forms/AuthRegister.php b/application/forms/AuthRegister.php
index 773f020..ae6e766 100644
--- a/application/forms/AuthRegister.php
+++ b/application/forms/AuthRegister.php
@@ -93,7 +93,7 @@ class Application_Form_AuthRegister extends Zend_Form
$this->addElement('submit', 'register', array(
'required' => false,
'ignore' => true,
- 'label' => 'Login',
+ 'label' => 'Register',
));
diff --git a/application/forms/GroupAdd.php b/application/forms/GroupAdd.php
new file mode 100644
index 0000000..7df3af5
--- /dev/null
+++ b/application/forms/GroupAdd.php
@@ -0,0 +1,65 @@
+<?php
+
+class Application_Form_GroupAdd extends Zend_Form
+{
+ private $grouplist;
+
+ public function setGrouplist($grouplist){
+ $this->grouplist = $grouplist;
+
+ }
+
+
+ public function init()
+ {
+ $this->setName("GroupAdd");
+ $this->setMethod('post');
+
+ $this->addElement('text', 'title', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'Title:',
+ ));
+
+ $this->addElement('text', 'description', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 140)),
+ ),
+ 'required' => false,
+ 'label' => 'Description:',
+ ));
+
+ $groupfield = $this->createElement('select','superordinatedGroupID');
+ $groupfield ->setLabel('superordinated Group:');
+
+ $groupfield->addMultiOption('-1', '---- none ----');
+
+ if(count($this->grouplist)>0){
+ foreach($this->grouplist as $group => $g){
+ $groupfield->addMultiOption($g->getID(), $g->getTitle());
+ }
+ }
+ $groupfield->setRegisterInArrayValidator(false);
+ $this->addElement($groupfield);
+
+ $this->addElement('submit', 'add', array(
+ 'required' => false,
+ 'ignore' => true,
+ 'label' => 'Add',
+ ));
+
+ $this->addElement('button', 'cancel', array(
+ 'required' => false,
+ 'ignore' => true,
+ 'label' => 'Cancel',
+ 'onclick' => 'location.href="/group/show"',
+ ));
+ }
+
+
+}
+
diff --git a/application/forms/GroupEdit.php b/application/forms/GroupEdit.php
new file mode 100644
index 0000000..ef38d83
--- /dev/null
+++ b/application/forms/GroupEdit.php
@@ -0,0 +1,52 @@
+<?php
+
+class Application_Form_GroupEdit extends Zend_Form
+{
+
+
+ public function init()
+ {
+ $this->setName("GroupEdit");
+ $this->setMethod('post');
+
+ $this->addElement('text', 'title', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'Title:',
+ 'value' => $_POST['title'],
+ ));
+
+ $this->addElement('text', 'description', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 140)),
+ ),
+ 'required' => false,
+ 'label' => 'Description:',
+ 'value' => $_POST['description'],
+ ));
+
+ $this->addElement('hidden', 'groupID', array(
+ 'value' => $_POST['groupID'],
+ ));
+
+ $this->addElement('submit', 'save', array(
+ 'required' => false,
+ 'ignore' => true,
+ 'label' => 'Save',
+ ));
+
+ $this->addElement('button', 'cancel', array(
+ 'required' => false,
+ 'ignore' => true,
+ 'label' => 'Cancel',
+ 'onclick' => 'location.href="/group/show"',
+ ));
+ }
+
+
+}
+
diff --git a/application/forms/GroupLink.php b/application/forms/GroupLink.php
new file mode 100644
index 0000000..231c4a7
--- /dev/null
+++ b/application/forms/GroupLink.php
@@ -0,0 +1,55 @@
+<?php
+
+class Application_Form_GroupLink extends Zend_Form
+{
+ private $grouplist;
+
+ public function setGrouplist($grouplist){
+ $this->grouplist = $grouplist;
+
+ }
+
+ public function init()
+ {
+ $this->setName("GroupLink");
+ $this->setMethod('post');
+
+ $groupfield = $this->createElement('select','groupID');
+ $groupfield ->setLabel('Group:');
+
+ if(count($this->grouplist)>0){
+ foreach($this->grouplist as $group => $g){
+ $groupfield->addMultiOption($g->getID(), $g->getTitle());
+ }
+ }
+ $groupfield->setRegisterInArrayValidator(false);
+ $this->addElement($groupfield);
+
+ $groupfield1 = $this->createElement('select','superordinatedGroupID');
+ $groupfield1 ->setLabel('superordinated Group:');
+
+ if(count($this->grouplist)>0){
+ foreach($this->grouplist as $group => $g){
+ $groupfield1->addMultiOption($g->getID(), $g->getTitle());
+ }
+ }
+ $groupfield1->setRegisterInArrayValidator(false);
+ $this->addElement($groupfield1);
+
+ $this->addElement('submit', 'link', array(
+ 'required' => false,
+ 'ignore' => true,
+ 'label' => 'Link',
+ ));
+
+ $this->addElement('button', 'cancel', array(
+ 'required' => false,
+ 'ignore' => true,
+ 'label' => 'Cancel',
+ 'onclick' => 'location.href="/group/show"',
+ ));
+ }
+
+
+}
+
diff --git a/application/forms/GroupRequest.php b/application/forms/GroupRequest.php
new file mode 100644
index 0000000..ec717de
--- /dev/null
+++ b/application/forms/GroupRequest.php
@@ -0,0 +1,42 @@
+<?php
+
+class Application_Form_GroupRequest extends Zend_Form
+{
+ private $grouplist;
+
+ public function setGrouplist($grouplist){
+ $this->grouplist = $grouplist;
+
+ }
+
+ public function getGrouplist(){
+ return $this->grouplist;
+ }
+
+ public function init()
+ {
+ $this->setName("GroupRequest");
+ $this->setMethod('post');
+
+ $groupfield = $this->createElement('select','groupID');
+ $groupfield ->setLabel('Group:');
+
+ if(count($this->grouplist)>0){
+ foreach($this->grouplist as $group => $g){
+ $groupfield->addMultiOption($g->getID(), $g->getTitle());
+ }
+ }
+
+ $groupfield->setRegisterInArrayValidator(false);
+ $this->addElement($groupfield);
+
+ $this->addElement('submit', 'request', array(
+ 'required' => false,
+ 'ignore' => true,
+ 'label' => 'Request Membership',
+ ));
+
+ }
+
+}
+
diff --git a/application/forms/PersonEdit.php b/application/forms/PersonEdit.php
new file mode 100644
index 0000000..664daac
--- /dev/null
+++ b/application/forms/PersonEdit.php
@@ -0,0 +1,117 @@
+<?php
+
+class Application_Form_PersonEdit extends Zend_Form
+{
+
+ public function init()
+ {
+ $this->setName("PersonEdit");
+ $this->setMethod('post');
+
+ $this->addElement('text', 'title', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'Title:',
+ 'value' => $this->getView()->person->getTitle(),
+ ));
+
+
+ $this->addElement('text', 'name', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'Name:',
+ 'value' => $this->getView()->person->getName(),
+ ));
+
+ $this->addElement('text', 'firstname', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'Firstname:',
+ 'value' => $this->getView()->person->getFirstname(),
+ ));
+
+ $this->addElement('text', 'street', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'Street:',
+ 'value' => $this->getView()->person->getStreet(),
+ ));
+
+ $this->addElement('text', 'housenumber', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'Housenumber:',
+ 'value' => $this->getView()->person->getHousenumber(),
+ ));
+
+ $this->addElement('text', 'city', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'City:',
+ 'value' => $this->getView()->person->getCity(),
+ ));
+
+ $this->addElement('text', 'postalcode', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'Postalcode:',
+ 'value' => $this->getView()->person->getPostalcode(),
+ ));
+
+ $this->addElement('text', 'email', array(
+ 'filters' => array('StringTrim', 'StringToLower'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'Email:',
+ 'value' => $this->getView()->person->getEmail(),
+ ));
+
+ $this->addElement('password', 'newpassword', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => false,
+ 'label' => 'Neues Password:',
+ ));
+
+ $this->addElement('submit', 'save', array(
+ 'required' => false,
+ 'ignore' => true,
+ 'label' => 'Save',
+ ));
+
+ $this->addElement('button', 'cancel', array(
+ 'required' => false,
+ 'ignore' => true,
+ 'label' => 'Cancel',
+ 'onclick' => 'location.href="/person/show"',
+ ));
+ }
+
+
+}
+
diff --git a/application/layouts/main.phtml b/application/layouts/main.phtml
index 57d09c7..202a684 100644
--- a/application/layouts/main.phtml
+++ b/application/layouts/main.phtml
@@ -21,6 +21,9 @@ echo $this->headScript()."\n";
<div id='nav'>
<ul>
<li>Controller:</li>
+ <li><a href='/person'>Person</a></li>
+ <li><a href='/group'>Group</a></li>
+ <li><a href='/role'>Role</a></li>
<li><a href='/bootiso'>BootIso</a></li>
<li><a href='/bootmenu'>BootMenu</a></li>
<li><a href='/config'>Config</a></li>
@@ -29,10 +32,18 @@ echo $this->headScript()."\n";
<li><a href='/filter'>Filter</a></li>
<li><a href='/pool'>Pool</a></li>
<li><a href='/session'>Session</a></li>
+ <?php if (!Zend_Auth::getInstance()->hasIdentity()) {?>
<li><a href='/auth/login'>Login</a></li>
<li><a href='/auth/register'>Register</a></li>
+ <?php
+ } else {?>
+ <li><a href='/auth/delete'>Account Löschen</a></li>
+ <li><a href='/auth/logout'>Logout</a></li>
+ <?php
+ }
+ ?>
</ul>
- </div>
+</div>
<div id='innerwrapper'>
<?php echo $this->layout()->content; ?>
<div class='clear footer'><?php
diff --git a/application/models/GroupGroupsMapper.php b/application/models/GroupGroupsMapper.php
index d7f5095..181d12d 100644
--- a/application/models/GroupGroupsMapper.php
+++ b/application/models/GroupGroupsMapper.php
@@ -2,23 +2,23 @@
class Application_Model_GroupGroupsMapper
{
-
+
protected $_dbTable;
- public function findBy($criteria, $value)
- {
- try{
+ public function findBy($criteria, $value)
+ {
+ try{
$db = Zend_Db_Table::getDefaultAdapter();
- $select = $this->getDbTable()->select()
- ->from($this->_dbTable)
- ->where($criteria . ' = ?', $value);
+ $select = $this->getDbTable()->select()
+ ->from($this->_dbTable)
+ ->where($criteria . ' = ?', $value);
$stmt = $select->query();
$result = $stmt->fetchAll();
return $result;
- }catch (Zend_Exception $e) {
- echo "Error message 2: " . $e->getMessage() . "\n";
+ }catch (Zend_Exception $e) {
+ echo "Error message 2: " . $e->getMessage() . "\n";
}
- }
+ }
public function setDbTable($dbTable)
{
@@ -31,7 +31,7 @@ class Application_Model_GroupGroupsMapper
}
$this->_dbTable = $dbTable;
-
+
return $this;
}
@@ -40,23 +40,19 @@ class Application_Model_GroupGroupsMapper
if (null === $this->_dbTable) {
$this->setDbTable('Application_Model_DbTable_GroupGroups');
}
-
+
return $this->_dbTable;
}
public function save(Application_Model_GroupGroups $groupgroups)
{
-
+
$data = array('parentID'=> $groupgroups->getParentID() ,'groupID'=> $groupgroups->getGroupID() );
- if (null === ($id = $groupgroups->getID()) ) {
- unset($data['groupgroupsID']);
- $this->getDbTable()->insert($data);
- } else {
- $this->getDbTable()->update($data, array('groupgroupsID = ?' => $id));
- }
+ #Noch zu prüfen ob Eintrag schon vorhanden
+ $this->getDbTable()->insert($data);
}
-
+
public function delete(Application_Model_GroupGroups $groupgroups)
{
if (null === ($id = $groupgroups->getID()) ) {
@@ -74,7 +70,7 @@ class Application_Model_GroupGroupsMapper
}
$row = $result->current();
-
+
$groupgroups->setParentID($row->parentID)->setGroupID($row->groupID);
}
@@ -84,8 +80,8 @@ class Application_Model_GroupGroupsMapper
$entries = array();
foreach ($resultSet as $row) {
$entry = new Application_Model_GroupGroups();
-
- $entry->setParentID($row->parentID)->setGroupID($row->groupID);
+
+ $entry->setParentID($row->parentID)->setGroupID($row->groupID);
$entries[] = $entry;
}
@@ -93,6 +89,6 @@ class Application_Model_GroupGroupsMapper
}
-
+
}
diff --git a/application/models/GroupRequestMapper.php b/application/models/GroupRequestMapper.php
index aa83095..98143dd 100644
--- a/application/models/GroupRequestMapper.php
+++ b/application/models/GroupRequestMapper.php
@@ -66,7 +66,7 @@ class Application_Model_GroupRequestMapper
}
}
- public function find($id, Application_Model_GroupRequest $grouprequest)
+ public function find($id)
{
$result = $this->getDbTable()->find($id);
if (0 == count($result)) {
@@ -75,7 +75,9 @@ class Application_Model_GroupRequestMapper
$row = $result->current();
+ $grouprequest = new Application_Model_GroupRequest();
$grouprequest->setID($row->grouprequestID)->setGroupID($row->groupID)->setPersonID($row->personID)->setTime($row->time);
+ return $grouprequest;
}
public function fetchAll()
diff --git a/application/models/Person.php b/application/models/Person.php
index b4545e9..aea348d 100644
--- a/application/models/Person.php
+++ b/application/models/Person.php
@@ -45,6 +45,8 @@ class Application_Model_Person
public function setOptions(array $options)
{
$methods = get_class_methods($this);
+ $options['passwordSalt'] = $options['password_salt'];
+ unset($options['password_salt']);
foreach ($options as $key => $value) {
$method = 'set' . ucfirst($key);
if (in_array($method, $methods)) {
diff --git a/application/views/scripts/auth/delete.phtml b/application/views/scripts/auth/delete.phtml
index 8f269a0..e69de29 100644
--- a/application/views/scripts/auth/delete.phtml
+++ b/application/views/scripts/auth/delete.phtml
@@ -1,4 +0,0 @@
-<?php
-$this->deleteForm->setAction($this->url());
-echo $this->deleteForm;
-?>
diff --git a/application/views/scripts/auth/index.phtml b/application/views/scripts/auth/index.phtml
index 4a9f827..e69de29 100644
--- a/application/views/scripts/auth/index.phtml
+++ b/application/views/scripts/auth/index.phtml
@@ -1 +0,0 @@
-<br /><br /><center>View script for controller <b>Auth</b> and script/action name <b>index</b></center> \ No newline at end of file
diff --git a/application/views/scripts/auth/login.phtml b/application/views/scripts/auth/login.phtml
index 0242bc6..4e642a3 100644
--- a/application/views/scripts/auth/login.phtml
+++ b/application/views/scripts/auth/login.phtml
@@ -1,8 +1,5 @@
<?php
$this->loginForm->setAction($this->url());
echo $this->loginForm;
-
-
-
?>
-
+<div><button onclick="location.href='/auth/recoverpassword'">Recover Password</button></div> \ No newline at end of file
diff --git a/application/views/scripts/auth/recoverpassword.phtml b/application/views/scripts/auth/recoverpassword.phtml
index e133420..881e00e 100644
--- a/application/views/scripts/auth/recoverpassword.phtml
+++ b/application/views/scripts/auth/recoverpassword.phtml
@@ -1 +1,4 @@
-<br /><br /><center>View script for controller <b>Auth</b> and script/action name <b>recoverPassword</b></center> \ No newline at end of file
+<?php
+$this->recoverPasswordForm->setAction($this->url());
+echo $this->recoverPasswordForm;
+?>
diff --git a/application/views/scripts/group/add.phtml b/application/views/scripts/group/add.phtml
new file mode 100644
index 0000000..4f96cf0
--- /dev/null
+++ b/application/views/scripts/group/add.phtml
@@ -0,0 +1,4 @@
+<?php
+$this->addForm->setAction($this->url());
+echo $this->addForm;
+?> \ No newline at end of file
diff --git a/application/views/scripts/group/delete.phtml b/application/views/scripts/group/delete.phtml
new file mode 100644
index 0000000..fc96431
--- /dev/null
+++ b/application/views/scripts/group/delete.phtml
@@ -0,0 +1,6 @@
+<?php
+if(!isset($_POST['groupID'])) {
+ ?>
+<div>No group has been chosen.</div>
+ <?php
+} \ No newline at end of file
diff --git a/application/views/scripts/group/edit.phtml b/application/views/scripts/group/edit.phtml
new file mode 100644
index 0000000..64dde9d
--- /dev/null
+++ b/application/views/scripts/group/edit.phtml
@@ -0,0 +1,10 @@
+<?php
+if(isset($this->addForm)) {
+ $this->addForm->setAction('/group/add');
+ echo $this->addForm;
+}
+else {
+ $this->editForm->setAction($this->url());
+ echo $this->editForm;
+}
+?> \ No newline at end of file
diff --git a/application/views/scripts/group/grantperson.phtml b/application/views/scripts/group/grantperson.phtml
new file mode 100644
index 0000000..f15d08a
--- /dev/null
+++ b/application/views/scripts/group/grantperson.phtml
@@ -0,0 +1,11 @@
+<?php
+if(!isset($_POST['grouprequestID'])) {
+ ?>
+<div>No Request has been chosen.</div>
+ <?php
+}
+if(!isset($_POST['roleID'])) {
+ ?>
+<div>No Role has been chosen.</div>
+ <?php
+} \ No newline at end of file
diff --git a/application/views/scripts/group/index.phtml b/application/views/scripts/group/index.phtml
new file mode 100644
index 0000000..b8178dc
--- /dev/null
+++ b/application/views/scripts/group/index.phtml
@@ -0,0 +1,35 @@
+<table>
+ <tr>
+ <th>Title:</th>
+ <th>Functions:</th>
+ </tr>
+ <?php
+ $count = 0;
+ foreach($this->groupList as $group) {
+ ?>
+ <tr>
+ <td><?php echo $group->getTitle(); ?></td>
+ <td>
+ <form name="show<?php echo $count; ?>" action="/group/show"
+ method="post"><input type="hidden" name="groupID"
+ value="<?php echo $group->getID(); ?>" /><a
+ href="javascript:document.show<?php echo $count; ?>.submit();">Details</a></form>
+ <form name="edit<?php echo $count; ?>" action="/group/edit"
+ method="post"><input type="hidden" name="groupID"
+ value="<?php echo $group->getID(); ?>" /><a
+ href="javascript:document.edit<?php echo $count; ?>.submit();">Edit</a></form>
+ <form name="delete<?php echo $count; ?>" action="/group/delete"
+ method="post"><input type="hidden" name="groupID"
+ value="<?php echo $group->getID(); ?>" /><a
+ href="javascript:document.delete<?php echo $count; ?>.submit();">Delete</a></form>
+ </td>
+ </tr>
+ <?php
+ $count++;
+ }
+ ?>
+</table>
+<br />
+<div>
+<button onclick="location.href='/group/link'">Link Groups</button>
+</div>
diff --git a/application/views/scripts/group/link.phtml b/application/views/scripts/group/link.phtml
new file mode 100644
index 0000000..94ad343
--- /dev/null
+++ b/application/views/scripts/group/link.phtml
@@ -0,0 +1,4 @@
+<?php
+$this->linkForm->setAction($this->url());
+echo $this->linkForm;
+?> \ No newline at end of file
diff --git a/application/views/scripts/group/revokeperson.phtml b/application/views/scripts/group/revokeperson.phtml
new file mode 100644
index 0000000..6af5564
--- /dev/null
+++ b/application/views/scripts/group/revokeperson.phtml
@@ -0,0 +1,6 @@
+<?php
+if(!isset($_POST['membershipID'])) {
+ ?>
+<div>No Membership has been chosen.</div>
+ <?php
+} \ No newline at end of file
diff --git a/application/views/scripts/group/show.phtml b/application/views/scripts/group/show.phtml
new file mode 100644
index 0000000..addf3db
--- /dev/null
+++ b/application/views/scripts/group/show.phtml
@@ -0,0 +1,122 @@
+<?php
+if($_POST['groupID']) {
+ ?>
+<div align="right">
+<form name="editForm" action="/group/edit/" method="post"><input
+ type="hidden" name="groupID"
+ value="<?php echo $this->group->getID(); ?>" /> <input type="submit"
+ name="edit" value="Edit" /></form>
+<form name="deleteForm" action="/group/delete/" method="post"><input
+ type="hidden" name="groupID"
+ value="<?php echo $this->group->getID(); ?>" /> <input type="submit"
+ name="delete" value="Delete" /></form>
+</div>
+<table>
+ <tr>
+ <td><b>Title:</b></td>
+ <td><?php echo $this->group->getTitle(); ?></td>
+ </tr>
+ <tr>
+ <td><b>Description:</b></td>
+ <td><?php echo $this->group->getDescription(); ?></td>
+ </tr>
+ <?php
+ if(isset($parentGroup) && is_object($parentGroup)) {
+ ?>
+ <tr>
+ <td><b>Superordinated Group:</b></td>
+ <td><?php echo $this->parentGroup->getTitle(); ?></td>
+ </tr>
+ <?php
+ }
+ ?>
+</table>
+ <?php
+ if(isset($this->groupRequestList)) {
+ ?>
+<br />
+<div>Grouprequests:</div>
+<br />
+<table>
+ <tr>
+ <th>Firstname:</th>
+ <th>Name:</th>
+ <th>email:</th>
+ <th>city:</th>
+ <th>grant:</th>
+ </tr>
+ <?php
+ foreach($this->groupRequestList as $grouprequest) {
+ $grouprequestID = $grouprequest['grouprequestID'];
+ $person = $grouprequest['person'];
+ ?>
+ <tr>
+ <td><?php echo $person->getFirstname(); ?></td>
+ <td><?php echo $person->getName(); ?></td>
+ <td><?php echo $person->getEmail(); ?></td>
+ <td><?php echo $person->getCity(); ?></td>
+ <td>
+ <form action="/group/grantperson" method="post"><input type="hidden"
+ name="grouprequestID" value="<?php echo $grouprequestID; ?>" /> <?php printRoleSelect($this->roleList); ?>
+ <input type="submit" name="confirm" value="confirm" /></form>
+ </td>
+ </tr>
+ <?php
+ }
+ ?>
+</table>
+ <?php
+ }
+ if(isset($this->memberslist)) {
+ ?>
+<br />
+<div>Members:</div>
+<br />
+<table>
+ <tr>
+ <th>Firstname:</th>
+ <th>Name:</th>
+ <th>email:</th>
+ <th>city:</th>
+ <th></th>
+ </tr>
+
+ <?php
+ foreach($this->memberslist as $member) {
+ $membershipID = $member['membershipID'];
+ $person = $member['person'];
+ ?>
+ <tr>
+ <td><?php echo $person->getFirstname(); ?></td>
+ <td><?php echo $person->getName(); ?></td>
+ <td><?php echo $person->getEmail(); ?></td>
+ <td><?php echo $person->getCity(); ?></td>
+ <td>
+ <form action="/group/revokeperson" method="post"><input type="hidden"
+ name="membershipID" value="<?php echo $membershipID; ?>" /><input
+ type="hidden" name="personID" value="<?php echo $person->getID(); ?>" />
+ <input type="submit" name="revoke" value="revoke" /></form>
+ </td>
+ </tr>
+ <?php
+ }
+ ?>
+</table>
+ <?php
+ }
+} else {
+ ?>
+<div>No Group has been chosen.</div>
+ <?php
+}
+
+function printRoleSelect($roleList) {
+ if(!is_array($roleList)) {
+ return;
+ }
+ echo "<select name=\"roleID\">";
+ foreach($roleList as $role) {
+ echo "<option value=\"" . $role['roleID'] . "\">" . $role['title'] . "</option>";
+ }
+ echo "</select>";
+} \ No newline at end of file
diff --git a/application/views/scripts/person/edit.phtml b/application/views/scripts/person/edit.phtml
new file mode 100644
index 0000000..955ed35
--- /dev/null
+++ b/application/views/scripts/person/edit.phtml
@@ -0,0 +1,4 @@
+<?php
+$this->editForm->setAction($this->url());
+echo $this->editForm;
+?> \ No newline at end of file
diff --git a/application/views/scripts/person/index.phtml b/application/views/scripts/person/index.phtml
index 1ba7791..e69de29 100644
--- a/application/views/scripts/person/index.phtml
+++ b/application/views/scripts/person/index.phtml
@@ -1 +0,0 @@
-<br /><br /><center>View script for controller <b>Person</b> and script/action name <b>index</b></center>
diff --git a/application/views/scripts/person/leave.phtml b/application/views/scripts/person/leave.phtml
new file mode 100644
index 0000000..fc96431
--- /dev/null
+++ b/application/views/scripts/person/leave.phtml
@@ -0,0 +1,6 @@
+<?php
+if(!isset($_POST['groupID'])) {
+ ?>
+<div>No group has been chosen.</div>
+ <?php
+} \ No newline at end of file
diff --git a/application/views/scripts/person/request.phtml b/application/views/scripts/person/request.phtml
new file mode 100644
index 0000000..2da570f
--- /dev/null
+++ b/application/views/scripts/person/request.phtml
@@ -0,0 +1,6 @@
+<?php
+if(count($this->requestForm->getGrouplist())>0) {
+ $this->requestForm->setAction($this->url());
+ echo $this->requestForm;
+}
+?> \ No newline at end of file
diff --git a/application/views/scripts/person/show.phtml b/application/views/scripts/person/show.phtml
new file mode 100644
index 0000000..5386c06
--- /dev/null
+++ b/application/views/scripts/person/show.phtml
@@ -0,0 +1,79 @@
+<div align="right">
+<button onclick="location.href='/person/edit'">Edit</button>
+</div>
+<table>
+ <tr>
+ <td><b>Title:</b></td>
+ <td><?php echo $this->person->getTitle(); ?></td>
+ </tr>
+ <tr>
+ <td><b>Name:</b></td>
+ <td><?php echo $this->person->getName(); ?></td>
+ </tr>
+ <tr>
+ <td><b>Firstname:</b></td>
+ <td><?php echo $this->person->getFirstname(); ?></td>
+ </tr>
+ <tr>
+ <td><b>Street:</b></td>
+ <td><?php echo $this->person->getStreet(); ?></td>
+ </tr>
+ <tr>
+ <td><b>Housenumber:</b></td>
+ <td><?php echo $this->person->getHousenumber(); ?></td>
+ </tr>
+ <tr>
+ <td><b>City:</b></td>
+ <td><?php echo $this->person->getCity(); ?></td>
+ </tr>
+ <tr>
+ <td><b>Postalcode:</b></td>
+ <td><?php echo $this->person->getPostalcode(); ?></td>
+ </tr>
+ <tr>
+ <td><b>Email:</b></td>
+ <td><?php echo $this->person->getEmail(); ?></td>
+ </tr>
+ <tr>
+ <td><b>Last Login Date:</b></td>
+ <td><?php if( $this->person->getLogindate()) echo date ('d. F Y - H:i', $this->person->getLogindate()); ?> Uhr</td>
+ </tr>
+ <tr>
+ <td><b>Register Date:</b></td>
+ <td><?php echo date ('d. F Y - H:i', $this->person->getRegisterdate()); ?> Uhr</td>
+ </tr>
+</table>
+<?php
+if(isset($this->groups)) {
+ ?>
+<br />
+<div>Member in the following Groups:</div>
+<br />
+<table>
+<?php
+foreach($this->groups as $group) {
+ ?>
+ <tr>
+ <th>Title</th>
+ <th>Functions</th>
+ </tr>
+ <tr>
+ <td><?php echo $group['title']; ?></td>
+ <td>
+ <form name="leaveGroup<?php echo $group['id']; ?>"
+ action="/person/leave/" method="post"><input type="hidden"
+ name="groupID" value="<?php echo $group['id']; ?>" /> <a
+ href="javascript:document.leaveGroup<?php echo $group['id']; ?>.submit();">Remove
+ Membership</a></form>
+ </td>
+ </tr>
+ <?php
+}
+}
+?>
+</table>
+<br />
+<div>
+<button onclick="location.href='/person/request'">Add to additional
+Groups</button>
+</div>
diff --git a/application/views/scripts/role/add.phtml b/application/views/scripts/role/add.phtml
new file mode 100644
index 0000000..5277b9d
--- /dev/null
+++ b/application/views/scripts/role/add.phtml
@@ -0,0 +1 @@
+<br /><br /><center>View script for controller <b>Role</b> and script/action name <b>add</b></center> \ No newline at end of file
diff --git a/application/views/scripts/role/delete.phtml b/application/views/scripts/role/delete.phtml
new file mode 100644
index 0000000..6b0ebf1
--- /dev/null
+++ b/application/views/scripts/role/delete.phtml
@@ -0,0 +1 @@
+<br /><br /><center>View script for controller <b>Role</b> and script/action name <b>delete</b></center> \ No newline at end of file
diff --git a/application/views/scripts/role/edit.phtml b/application/views/scripts/role/edit.phtml
new file mode 100644
index 0000000..c30d295
--- /dev/null
+++ b/application/views/scripts/role/edit.phtml
@@ -0,0 +1 @@
+<br /><br /><center>View script for controller <b>Role</b> and script/action name <b>edit</b></center> \ No newline at end of file
diff --git a/application/views/scripts/role/index.phtml b/application/views/scripts/role/index.phtml
new file mode 100644
index 0000000..d30131e
--- /dev/null
+++ b/application/views/scripts/role/index.phtml
@@ -0,0 +1 @@
+<br /><br /><center>View script for controller <b>Role</b> and script/action name <b>index</b></center> \ No newline at end of file
diff --git a/application/views/scripts/role/linkright.phtml b/application/views/scripts/role/linkright.phtml
new file mode 100644
index 0000000..bfba9db
--- /dev/null
+++ b/application/views/scripts/role/linkright.phtml
@@ -0,0 +1 @@
+<br /><br /><center>View script for controller <b>Role</b> and script/action name <b>linkright</b></center> \ No newline at end of file
diff --git a/application/views/scripts/role/show.phtml b/application/views/scripts/role/show.phtml
new file mode 100644
index 0000000..dcd232b
--- /dev/null
+++ b/application/views/scripts/role/show.phtml
@@ -0,0 +1 @@
+<br /><br /><center>View script for controller <b>Role</b> and script/action name <b>show</b></center> \ No newline at end of file
diff --git a/application/views/scripts/role/unlinkright.phtml b/application/views/scripts/role/unlinkright.phtml
new file mode 100644
index 0000000..8c7615d
--- /dev/null
+++ b/application/views/scripts/role/unlinkright.phtml
@@ -0,0 +1 @@
+<br /><br /><center>View script for controller <b>Role</b> and script/action name <b>unlinkright</b></center> \ No newline at end of file
diff --git a/tests/application/controllers/GroupControllerTest.php b/tests/application/controllers/GroupControllerTest.php
new file mode 100644
index 0000000..2a672bd
--- /dev/null
+++ b/tests/application/controllers/GroupControllerTest.php
@@ -0,0 +1,20 @@
+<?php
+
+require_once 'PHPUnit/Framework/TestCase.php';
+
+class GroupControllerTest extends PHPUnit_Framework_TestCase
+{
+
+ public function setUp()
+ {
+ /* Setup Routine */
+ }
+
+ public function tearDown()
+ {
+ /* Tear Down Routine */
+ }
+
+
+}
+
diff --git a/tests/application/controllers/RoleControllerTest.php b/tests/application/controllers/RoleControllerTest.php
new file mode 100644
index 0000000..ee38943
--- /dev/null
+++ b/tests/application/controllers/RoleControllerTest.php
@@ -0,0 +1,20 @@
+<?php
+
+require_once 'PHPUnit/Framework/TestCase.php';
+
+class RoleControllerTest extends PHPUnit_Framework_TestCase
+{
+
+ public function setUp()
+ {
+ /* Setup Routine */
+ }
+
+ public function tearDown()
+ {
+ /* Tear Down Routine */
+ }
+
+
+}
+