From d52a8c277f527c086852459084286900ec260ad6 Mon Sep 17 00:00:00 2001 From: Cliff Ingham Date: Mon, 18 Aug 2014 16:26:14 -0400 Subject: [PATCH] Updated users model and controllers --- blocks/html/users/addUserForm.inc | 54 ------------- blocks/html/users/list.inc | 63 +++++++++++++++ blocks/html/users/updateForm.inc | 58 ++++++++++++++ blocks/html/users/updateUserForm.inc | 55 ------------- blocks/html/users/userList.inc | 57 -------------- html/people/addPerson.php | 33 -------- html/people/home.php | 19 ----- html/people/updatePerson.php | 35 --------- html/people/viewPerson.php | 13 --- html/users/addUser.php | 74 ------------------ html/users/deleteUser.php | 17 ---- html/users/home.php | 20 ----- html/users/updateUser.php | 35 --------- language/en_US.mo | Bin 1906 -> 1856 bytes language/en_US.po | 2 +- templates/html/helpers/ButtonLink.php | 27 +++++++ .../html/helpers/SaveAndCancelButtons.php | 27 +++++++ templates/html/partials/banner.inc | 4 +- templates/html/partials/footer.inc | 14 ++-- templates/html/partials/menubar.inc | 2 +- templates/html/partials/panel-one.inc | 8 +- 21 files changed, 191 insertions(+), 426 deletions(-) delete mode 100644 blocks/html/users/addUserForm.inc create mode 100644 blocks/html/users/list.inc create mode 100644 blocks/html/users/updateForm.inc delete mode 100644 blocks/html/users/updateUserForm.inc delete mode 100644 blocks/html/users/userList.inc delete mode 100644 html/people/addPerson.php delete mode 100644 html/people/home.php delete mode 100644 html/people/updatePerson.php delete mode 100644 html/people/viewPerson.php delete mode 100644 html/users/addUser.php delete mode 100644 html/users/deleteUser.php delete mode 100644 html/users/home.php delete mode 100644 html/users/updateUser.php create mode 100644 templates/html/helpers/ButtonLink.php create mode 100644 templates/html/helpers/SaveAndCancelButtons.php diff --git a/blocks/html/users/addUserForm.inc b/blocks/html/users/addUserForm.inc deleted file mode 100644 index b2a86c6..0000000 --- a/blocks/html/users/addUserForm.inc +++ /dev/null @@ -1,54 +0,0 @@ - - */ -?> -

New User Account

-
-
Login Info - - - - - - - - - - - - - -
-
-
-
- - - -
-
diff --git a/blocks/html/users/list.inc b/blocks/html/users/list.inc new file mode 100644 index 0000000..d6cfb25 --- /dev/null +++ b/blocks/html/users/list.inc @@ -0,0 +1,63 @@ + + * @param Zend\Db\Sql\Select $users + */ +use Application\Models\Person; +use Blossom\Classes\View; +?> +
+

_(['user','users',2]); + + $helper = $this->template->getHelper('buttonLink'); + if (Person::isAllowed('users')) { + echo $helper->buttonLink(BASE_URI.'/users/update', $this->_('create_account'), 'add'); + } + ?> +

+ + + + + + + + + + + + users as $user) { + $editButton = ''; + $deleteButton = ''; + if (Person::isAllowed('users')) { + $editButton = $helper->buttonLink( + BASE_URI.'/users/update?user_id='.$user->getId(), + $this->_('edit_account'), + 'edit' + ); + $deleteButton = $helper->buttonLink( + BASE_URI.'/users/delete?user_id='.$user->getId(), + $this->_('delete_account'), + 'delete' + ); + } + + $name = View::escape($user->getFullname()); + echo " + + + + + + + + "; + } + ?> + +
_('username'); ?>_('name'); ?>_('authenticationMethod'); ?>_('role'); ?>
$editButton{$user->getUsername()}$name{$user->getAuthenticationMethod()}{$user->getRole()}$deleteButton
+
diff --git a/blocks/html/users/updateForm.inc b/blocks/html/users/updateForm.inc new file mode 100644 index 0000000..6f19aab --- /dev/null +++ b/blocks/html/users/updateForm.inc @@ -0,0 +1,58 @@ + + * @param User $this->user + */ +use Application\Models\Person; +use Blossom\Classes\View; + +?> +
+
+
_(['user','users',2]); ?> + + + + + + + + + + + + + + +
+
+
+
+ template->getHelper('saveAndCancelButtons'); + echo $helper->saveAndCancelButtons(BASE_URI.'/users'); + ?> +
+
+
diff --git a/blocks/html/users/updateUserForm.inc b/blocks/html/users/updateUserForm.inc deleted file mode 100644 index 97203c1..0000000 --- a/blocks/html/users/updateUserForm.inc +++ /dev/null @@ -1,55 +0,0 @@ - - * @param User $this->user - */ -?> -

Edit user->getUsername(); ?>

-
-
Login Info - - - - - - - - - - - - - - -
-
-
-
- - -
-
diff --git a/blocks/html/users/userList.inc b/blocks/html/users/userList.inc deleted file mode 100644 index c82af03..0000000 --- a/blocks/html/users/userList.inc +++ /dev/null @@ -1,57 +0,0 @@ - - * @param UserList $this->userList - */ -?> -
-

- Add User Account - - "; - } - ?> - User Accounts -

- - userList as $user) { - $editButton = ''; - $deleteButton = ''; - if (userIsAllowed('Users')) { - $editButton = " - - "; - - $deleteButton = " - - "; - } - - echo " - - - - - - - "; - } - ?> -
$editButton{$user->getUsername()}{$user->getFirstname()} {$user->getLastname()}{$user->getAuthenticationMethod()} - "; - foreach ($user->getRoles() as $role) { - echo "$role "; - } - echo " -
-
diff --git a/html/people/addPerson.php b/html/people/addPerson.php deleted file mode 100644 index 4107951..0000000 --- a/html/people/addPerson.php +++ /dev/null @@ -1,33 +0,0 @@ - - */ -if (!userIsAllowed('Users')) { - $_SESSION['errorMessages'][] = new Exception('noAccessAllowed'); - header('Location: '.BASE_URL); - exit(); -} - -if (isset($_POST['person'])) { - $person = new Person(); - foreach ($_POST['person'] as $field=>$value) { - $set = 'set'.ucfirst($field); - $person->$set($value); - } - - try { - $person->save(); - header('Location: '.BASE_URL.'/people'); - exit(); - } - catch(Exception $e) { - $_SESSION['errorMessages'][] = $e; - } -} - -$template = new Template(); -$template->title = 'Add a person'; -$template->blocks[] = new Block('people/addPersonForm.inc'); -echo $template->render(); diff --git a/html/people/home.php b/html/people/home.php deleted file mode 100644 index 8254c53..0000000 --- a/html/people/home.php +++ /dev/null @@ -1,19 +0,0 @@ - - */ -if (!userIsAllowed('Users')) { - $_SESSION['errorMessages'][] = new Exception('noAccessAllowed'); - header('Location: '.BASE_URL); - exit(); -} - -$personList = new PersonList(); -$personList->find(); - -$template = new Template(); -$template->title = 'People'; -$template->blocks[] = new Block('people/personList.inc',array('personList'=>$personList)); -echo $template->render(); diff --git a/html/people/updatePerson.php b/html/people/updatePerson.php deleted file mode 100644 index f0920da..0000000 --- a/html/people/updatePerson.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @param Request person_id - */ -if (!userIsAllowed('Users')) { - $_SESSION['errorMessages'][] = new Exception('noAccessAllowed'); - header('Location: '.BASE_URL); - exit(); -} - -$person = new Person($_REQUEST['person_id']); - -if (isset($_POST['person'])) { - foreach ($_POST['person'] as $field=>$value) { - $set = 'set'.ucfirst($field); - $person->$set($value); - } - - try { - $person->save(); - header('Location: '.BASE_URL.'/people'); - exit(); - } - catch (Exception $e) { - $_SESSION['errorMessages'][] = $e; - } -} - -$template = new Template(); -$template->title = 'Update a person'; -$template->blocks[] = new Block('people/updatePersonForm.inc',array('person'=>$person)); -echo $template->render(); diff --git a/html/people/viewPerson.php b/html/people/viewPerson.php deleted file mode 100644 index 5fdaeca..0000000 --- a/html/people/viewPerson.php +++ /dev/null @@ -1,13 +0,0 @@ - - * @param GET person_id - */ -$person = new Person($_GET['person_id']); - -$template = new Template(); -$template->title = $person->getFullname(); -$template->blocks[] = new Block('people/personInfo.inc',array('person'=>$person)); -echo $template->render(); diff --git a/html/users/addUser.php b/html/users/addUser.php deleted file mode 100644 index 7031540..0000000 --- a/html/users/addUser.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @param GET person_id - */ -if (!userIsAllowed('Users')) { - $_SESSION['errorMessages'][] = new Exception('noAccessAllowed'); - header('Location: '.BASE_URL); - exit(); -} - -if (isset($_REQUEST['person_id'])) { - try { - $person = new Person($_REQUEST['person_id']); - } - catch (Exception $e) { - } -} - -if (isset($_POST['user'])) { - - $user = new User(); - foreach ($_POST['user'] as $field=>$value) { - $set = 'set'.ucfirst($field); - $user->$set($value); - } - - if (isset($person)) { - $user->setPerson_id($person->getId()); - } - else { - // Load their information from LDAP - if ($user->getAuthenticationMethod() != 'local') { - try { - $externalIdentity = $user->getAuthenticationMethod(); - $identity = new $externalIdentity($user->getUsername()); - - try { - $person = new Person($identity->getEmail()); - } - catch (Exception $e) { - $person = new Person(); - $person->setFirstname($identity->getFirstname()); - $person->setLastname($identity->getLastname()); - $person->setEmail($identity->getEmail()); - $person->save(); - } - $user->setPerson($person); - } - catch (Exception $e) { - $_SESSION['errorMessages'][] = $e; - } - } - } - - try { - $user->save(); - header('Location: '.BASE_URL.'/users'); - exit(); - } - catch (Exception $e) { - $_SESSION['errorMessages'][] = $e; - } -} - -$template = new Template(); -$template->title = 'Create a user account'; -$template->blocks[] = new Block('users/addUserForm.inc'); -if (isset($person)) { - $template->blocks[] = new Block('people/personInfo.inc',array('person'=>$person)); -} -echo $template->render(); diff --git a/html/users/deleteUser.php b/html/users/deleteUser.php deleted file mode 100644 index 8d12d6b..0000000 --- a/html/users/deleteUser.php +++ /dev/null @@ -1,17 +0,0 @@ - - * @param GET user_id - */ -if (!userIsAllowed('Users')) { - $_SESSION['errorMessages'][] = new Exception('noAccessAllowed'); - header('Location: '.BASE_URL); - exit(); -} - -$user = new User($_GET['user_id']); -$user->delete(); - -header('Location: '.BASE_URL.'/users'); diff --git a/html/users/home.php b/html/users/home.php deleted file mode 100644 index 601752a..0000000 --- a/html/users/home.php +++ /dev/null @@ -1,20 +0,0 @@ - - */ -if (!userIsAllowed('Users')) { - $_SESSION['errorMessages'][] = new Exception('noAccessAllowed'); - header('Location: '.BASE_URL); - exit(); -} - -$template = new Template(); -$template->title = 'User accounts'; - -$userList = new UserList(); -$userList->find(); -$template->blocks[] = new Block('users/userList.inc',array('userList'=>$userList)); - -echo $template->render(); diff --git a/html/users/updateUser.php b/html/users/updateUser.php deleted file mode 100644 index e97aeb9..0000000 --- a/html/users/updateUser.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @param REQUEST user_id - */ -if (!userIsAllowed('Users')) { - $_SESSION['errorMessages'][] = new Exception('noAccessAllowed'); - header('Location: '.BASE_URL); - exit(); -} - -$user = new User($_REQUEST['user_id']); - -if (isset($_POST['user'])) { - foreach ($_POST['user'] as $field=>$value) { - $set = 'set'.ucfirst($field); - $user->$set($value); - } - - try { - $user->save(); - header('Location: '.BASE_URL.'/users'); - exit(); - } - catch (Exception $e) { - $_SESSION['errorMessages'][] = $e; - } -} - -$template = new Template(); -$template->blocks[] = new Block('users/updateUserForm.inc',array('user'=>$user)); -$template->blocks[] = new BlocK('people/personInfo.inc',array('person'=>$user->getPerson())); -echo $template->render(); diff --git a/language/en_US.mo b/language/en_US.mo index dc3ad4ecfcbe327c121699d837edbf8fbeb4fa34..2855536823e9b1bfec3756fb93827616785fe6df 100644 GIT binary patch literal 1856 zcmZvb&2Jk;7{;d%zFa7!rF@hYh67R&8rM!!aGg3LbrTY)rdI4AE?`Y|$Lm46Gt16w zAP278L4r$9oZyc@91)d(3kNv$0OEp#Dg@$y1mbyT*D**P?YzI)*?0E+*nMuDSo(-z zaLh9_k1+NE@h%vQufV&(n_vU{2D}IS0elp^1>Ot(4xR-60*`^maEScRg7o|xNc-o( zC2$RV5bW0+f)C*Sjrw^~GX;-g|80=sy$9Y8eh5+?H$Zy-C*UdYGmzqb0aBcsAo+g_ zJ_LSW@Bdu$7m&{12I<_NAo(A`;UCe928b>8D}qtJzkw9@9~i1<35V(YNf@gCG)VhR zklxn=aj~s>|2jx{y$RC$B9QXVLGpjUe*Qttk3p*c21xaP3R0gw2Puy)L0s%>n1{jd zK=S_yq&T-hs^<@o>i@gmKYCyF{5Xg$b_zTVo&m}KB@pE^e9llm5dIG$4SF}HMLiw? zsgC)e9#DSN6B?8g#d(ZwFrKUsVp3kuU?ODb!Ex|$Od3yNQoUy}slKN%sShVGDNpL* z6PQfKG0jP?3TF+LnT9R>Oc}2u>9sWjHDPEOs)fQ>Mr|Hr0jmMrMl5RGPDy#Y&s0ohPXc63CDscI%a6 zsjSbWHbDunw)8Ah&dEf%rqhX0@kE=6bS%?xoT?BZm|QydjxAzVcOh3cPZcXHjFbB? z|oE|1mz z%X_J{=yu|*X=>9#)qmvNFp(|osNaIrJZPDfZR8OaT+axoY@ymz~nmeSjhNC7a(K|6# zGQ&ab54fH3D~qi8~}?2h1BJr*Nd7Ln>#8FhJ;5?hBxFuCNzN+s(-CF}oF z3F}w-=+E_0FGwHZlPbPm>*FfvgN%a>`lxW|utEADv)Bpx*dWW1N`c=R@7*M!@K;GG zTcngNQc9I0KJnDD?YTY{E63=cs198VQh_C@jDkYAHe5RXoMVF^lFBiJ7|vBvcVSqm aWQSBTB9)9PmFz+#hl&69#xc4Js`(dO-Lp~v literal 1906 zcmZvb&u<(x6vqvuK)3vAftH`D5kjIuUUrfc(n%9Yw+RjE!YaGrM=vYyjCXd*tUVgf zq~wOg9{?Qai7Om9aN)p#6Mq1w9?FFxRpN%=iiCvtzVYl#QfiIo<7YqH?}y*56ANE5 zwCB;ELtnUuu`}QwAhpl$Wvm5$0Uigx0v`gu1D^$d1Rn-(f=`0KSMooVeDprXj$!^Z z_&E3q_zd_4_!xMlTK}lxHSh%HKLsBJuY+{oHz3{fJxF%^1k$-TK+^jSBzyj<=8rA7 z^;012dl7sJ^gz;o8zg(LfVbgm3Sui8-0$vtA3Op%1Rnvfg80~eC4W-MpH=d85J#}D zL9+K-kk0=Br1fLT@^=hUO36pE>uL0PBYkT02FO-wlpESdjm|+j*(nmLMmC(R#uRtT z3B4ckof_qu;zlu{MzJURU`FXL;QXTj+7sxMcb3SpN^Dz(;ep{ORhc!qnVH3nP~=mk z^Ei-sY;;fMQ&VpZqz+Uv-xg#_=4vE^z!W;4&xR^dxjHP}siVTU)~E6R)@L%VuTdn} z`GJ!-v$>YD`i7}W()r@lH1n~Zm^=JT z;c%wPq)BaGW}2~;d-c36#X0ECr z7u%tD54(^tpBFnSHCfKR_PLfDik^+)P+TY?D~87Bq1tyd}{&Cl)*0d(B_Mc)8PoqS#S;F?V~T{hFDw;5O;caaV@7rYzf{TI26fv0b7nyF}&Xj6e=2hEaaq`sK2e@TVH;mBr&0 u%H92Wy;L6bU4`sWX$+_)2Cf)(@z`sd4hoi$RMx?ueEvMvTw4B;W&Z(%JJ*B& diff --git a/language/en_US.po b/language/en_US.po index d0800a8..9709d90 100644 --- a/language/en_US.po +++ b/language/en_US.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: uReport 1.9\n" "Report-Msgid-Bugs-To: dev@bloomington.in.gov\n" "POT-Creation-Date: 2013-09-20 16:33-0400\n" -"PO-Revision-Date: 2014-08-11 13:43-0500\n" +"PO-Revision-Date: 2014-08-18 16:18-0500\n" "Last-Translator: Cliff Ingham \n" "Language-Team: City of Bloomington \n" "MIME-Version: 1.0\n" diff --git a/templates/html/helpers/ButtonLink.php b/templates/html/helpers/ButtonLink.php new file mode 100644 index 0000000..486f96e --- /dev/null +++ b/templates/html/helpers/ButtonLink.php @@ -0,0 +1,27 @@ + + */ +namespace Application\Templates\Helpers; + +use Blossom\Classes\Template; + +class ButtonLink +{ + private $template; + + public function __construct(Template $template) + { + $this->template = $template; + } + + public function buttonLink($url, $label, $type) + { + $a = '%s'; + return sprintf($a, $url, $type, $label); + } +} diff --git a/templates/html/helpers/SaveAndCancelButtons.php b/templates/html/helpers/SaveAndCancelButtons.php new file mode 100644 index 0000000..45ffbac --- /dev/null +++ b/templates/html/helpers/SaveAndCancelButtons.php @@ -0,0 +1,27 @@ + + */ +namespace Application\Templates\Helpers; + +use Blossom\Classes\Template; + +class SaveAndCancelButtons +{ + private $template; + + public function __construct(Template $template) + { + $this->template = $template; + } + + public function saveAndCancelButtons($cancelURL) + { + return " + + {$this->template->_('labels.cancel')} + "; + } +} diff --git a/templates/html/partials/banner.inc b/templates/html/partials/banner.inc index ea568d1..4bf5340 100644 --- a/templates/html/partials/banner.inc +++ b/templates/html/partials/banner.inc @@ -7,14 +7,14 @@ use Blossom\Classes\View; $li = '
  • %s
  • '; if (isset($_SESSION['USER'])) { - echo sprintf($li, BASE_URI.'/login/logout', $this->translate('labels.logout')); + echo sprintf($li, BASE_URI.'/login/logout', $this->translate('logout')); $name = View::escape($_SESSION['USER']->getFullname()); echo sprintf('
  • '.sprintf($this->translate('messages.signed_in_as'), $name).'
  • '); } else { $return_url = View::escape($_SERVER['REQUEST_URI']); - echo sprintf($li, BASE_URI.'/login?return_url='.$return_url, $this->translate('labels.login')); + echo sprintf($li, BASE_URI.'/login?return_url='.$return_url, $this->translate('login')); } ?> diff --git a/templates/html/partials/footer.inc b/templates/html/partials/footer.inc index b61f368..00808e4 100644 --- a/templates/html/partials/footer.inc +++ b/templates/html/partials/footer.inc @@ -1,11 +1,13 @@ diff --git a/templates/html/partials/menubar.inc b/templates/html/partials/menubar.inc index 6d46d8c..4411545 100644 --- a/templates/html/partials/menubar.inc +++ b/templates/html/partials/menubar.inc @@ -14,7 +14,7 @@ use Application\Models\Person; ]; foreach ($routes as $singular=>$plural) { if (Person::isAllowed($plural, 'index')) { - echo sprintf($a, BASE_URI.'/'.$plural, $this->_(["labels.$singular", "labels.$plural", 2])); + echo sprintf($a, BASE_URI.'/'.$plural, $this->_(["$singular", "$plural", 2])); } } ?> diff --git a/templates/html/partials/panel-one.inc b/templates/html/partials/panel-one.inc index b236177..fb0144a 100644 --- a/templates/html/partials/panel-one.inc +++ b/templates/html/partials/panel-one.inc @@ -14,7 +14,7 @@
  • White Oak Cemetery

    Driving Directions, Interment Information, History - +

  • Guidelines for Plot Owners @@ -40,10 +40,10 @@
    -
    Rose Hill Cemetery" />
    -
    White Oak Cemetery" />
    +
    Rose Hill Cemetery" />
    +
    White Oak Cemetery" />
    - \ No newline at end of file +