summaryrefslogtreecommitdiff
path: root/manager
diff options
context:
space:
mode:
authorMichael Tänzer <neo@nhng.de>2010-07-06 18:16:10 +0200
committerMichael Tänzer <neo@nhng.de>2010-07-06 18:16:10 +0200
commit46d228ccc3d7e0ceb701802790de6de9717feef0 (patch)
tree6bac39f2dedd256f3da7dfa09ed6bbb928295ca4 /manager
parentcb4755dd3b55118d2299122e110bf254f6acc372 (diff)
downloadcacert-mgr-46d228ccc3d7e0ceb701802790de6de9717feef0.tar.gz
cacert-mgr-46d228ccc3d7e0ceb701802790de6de9717feef0.tar.xz
cacert-mgr-46d228ccc3d7e0ceb701802790de6de9717feef0.zip
Add the Set Flags feature
Signed-off-by: Michael Tänzer <neo@nhng.de>
Diffstat (limited to 'manager')
-rw-r--r--manager/application/controllers/ManageAccountController.php70
-rw-r--r--manager/application/views/scripts/manage-account/flags.phtml8
2 files changed, 78 insertions, 0 deletions
diff --git a/manager/application/controllers/ManageAccountController.php b/manager/application/controllers/ManageAccountController.php
index 9378419..33eed81 100644
--- a/manager/application/controllers/ManageAccountController.php
+++ b/manager/application/controllers/ManageAccountController.php
@@ -28,6 +28,7 @@ class ManageAccountController extends Zend_Controller_Action
$actions['assurance'] = I18n::_('Automated Assurance');
$actions['admin-increase'] = I18n::_('Administrative Increase');
$actions['assurer-challenge'] = I18n::_('Assurer Challenge');
+ $actions['flags'] = I18n::_('Set Flags');
$url = array('controller' => 'manage-account');
foreach ($actions as $action => $label) {
$url['action'] = $action;
@@ -196,6 +197,33 @@ class ManageAccountController extends Zend_Controller_Action
return;
}
+ public function flagsAction()
+ {
+ // Get user data
+ $user['id'] = $this->getUserId();
+
+ // Validate form
+ $form = $this->getFlagsForm($user['id']);
+ $this->view->flags_form = $form;
+ if (!$this->getRequest()->isPost() || !$form->isValid($_POST)) {
+ return;
+ }
+
+ $flags = array('admin', 'codesign', 'orgadmin', 'ttpadmin', 'board',
+ 'locadmin', 'locked', 'assurer_blocked');
+ $update = array(); // Make sure array is empty
+ foreach ($flags as $flag) {
+ if ($form->getElement($flag)->isChecked()) {
+ $update[$flag] = 1;
+ } else {
+ $update[$flag] = 0;
+ }
+ }
+ $this->db->update('users', $update, '`id` = '.$user['id']);
+
+ return;
+ }
+
/**
* Get and check the user ID of the current user
*
@@ -378,4 +406,46 @@ class ManageAccountController extends Zend_Controller_Action
return $form;
}
+
+ protected function getFlagsForm($user_id)
+ {
+ $form = new Zend_Form();
+ $form->setAction('/manage-account/flags')
+ ->setMethod('post');
+
+ // Get the current setting of the flags
+ $query = 'select `admin`, `codesign`, `orgadmin`, `ttpadmin`, `board`,
+ `tverify`, `locadmin`, `locked`, `assurer_blocked` from `users`
+ where `id` = :user';
+ $query_params['user'] = $user_id;
+ $result = $this->db->query($query, $query_params);
+ if ($result->rowCount() !== 1) {
+ throw new Exception(__METHOD__ . ': user ID not found in the data base');
+ }
+ $row = $result->fetch();
+
+ // Add a checkbox for each flag
+ $labels = array();
+ $labels['admin'] = I18n::_('Support Engineer');
+ $labels['codesign'] = I18n::_('Code Signing');
+ $labels['orgadmin'] = I18n::_('Organisation Admin');
+ $labels['ttpadmin'] = I18n::_('TTP Admin');
+ $labels['board'] = I18n::_('Board Member');
+ $labels['locadmin'] = I18n::_('Location Admin');
+ $labels['locked'] = I18n::_('Lock Account');
+ $labels['assurer_blocked'] = I18n::_('Block Assurer');
+
+ foreach ($labels as $flag => $label) {
+ $checkbox = new Zend_Form_Element_Checkbox($flag);
+ $checkbox->setLabel($label)
+ ->setChecked($row[$flag] === 1);
+ $form->addElement($checkbox);
+ }
+
+ $submit = new Zend_Form_Element_Submit('submit');
+ $submit->setLabel(I18n::_('Save Flags'));
+ $form->addElement($submit);
+
+ return $form;
+ }
}
diff --git a/manager/application/views/scripts/manage-account/flags.phtml b/manager/application/views/scripts/manage-account/flags.phtml
new file mode 100644
index 0000000..40298a1
--- /dev/null
+++ b/manager/application/views/scripts/manage-account/flags.phtml
@@ -0,0 +1,8 @@
+<?php
+/**
+ * @author Michael Tänzer
+ * @todo Text
+ */
+?>
+
+<?php print $this->flags_form ?> \ No newline at end of file