From f0f1d71c48be58d3d703d05fc07b37952c66085b Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Wed, 17 Jul 2013 14:04:21 +0300 Subject: [PATCH] Admins can now modify details of other admins --- application/controllers/yllapito.php | 7 +++ application/models/user_model.php | 15 ++++++ application/views/yllapito/users_show.php | 64 +++++++++++++++++++++++ assets/js/scripts.js | 7 ++- 4 files changed, 92 insertions(+), 1 deletion(-) diff --git a/application/controllers/yllapito.php b/application/controllers/yllapito.php index e785d80..d221ef9 100644 --- a/application/controllers/yllapito.php +++ b/application/controllers/yllapito.php @@ -13,6 +13,7 @@ class Yllapito extends CI_Controller $this->load->model('erkanaauth_model', 'erkana'); $this->load->helper('date'); + $this->load->helper('form'); $this->user = $this->erkana->getUser(); @@ -145,6 +146,12 @@ class Yllapito extends CI_Controller $this->user->delete($user_id); redirect('yllapito/users'); break; + case 'save': + $data = $this->input->post(); + $from = $data['from_page']; + $this->users->save($user_id, $data); + redirect($from); + break; case 'show': $data['userid'] = $user_id; $data['userdata'] = $this->users->get($user_id); diff --git a/application/models/user_model.php b/application/models/user_model.php index 2751145..4f33e63 100644 --- a/application/models/user_model.php +++ b/application/models/user_model.php @@ -12,6 +12,21 @@ class User_model extends MY_Model parent::__construct(); } + public function save($uid = null, $data = null) + { + if (empty($uid) || empty($data)) { + return false; + } + + unset( + $data['from_page'], + $data['savedata'], + $data['submit'] + ); + + return $this->update($uid, $data); + } + public function passwordhash($password = null) { return hash( diff --git a/application/views/yllapito/users_show.php b/application/views/yllapito/users_show.php index 82c6a56..91364ec 100644 --- a/application/views/yllapito/users_show.php +++ b/application/views/yllapito/users_show.php @@ -29,9 +29,73 @@ if ($user->can_seeusers == "no") { 'Kyllä voi', 'no' => 'Ei voi'); + $dd = ' class="medium large-6 small-12"'; + + $inputs = array( + 'name' => 'name', + 'id' => 'name', + 'value' => '', + 'required' => null + ); ?>

Käyttäjä #id; ?>

+
+
" method="post" + accept-charset="utf-8" id="user_data" class="custom"> + +
+

Tiedot

+ username; + echo form_input($inputs) . "\n"; + + echo form_label('Etunimi', 'firstname') . "\n"; + $inputs['name'] = 'firstname'; + $inputs['id'] = 'firstname'; + $inputs['value'] = $userdata->firstname; + echo form_input($inputs) . "\n"; + + echo form_label('Sukunimi', 'lastname') . "\n"; + $inputs['name'] = 'lastname'; + $inputs['id'] = 'lastname'; + $inputs['value'] = $userdata->lastname; + echo form_input($inputs) . "\n"; + ?> +
+
+

Oikeudet

+ can_approve, $dd); + + echo form_label('Voi nähdä käyttäjät', 'can_seeusers') . "\n"; + echo form_dropdown('can_seeusers', $options, $userdata->can_seeusers, $dd); + + echo form_label('Voi muokata käyttäjiä', 'can_modusers') . "\n"; + echo form_dropdown('can_modusers', $options, $userdata->can_modusers, $dd); + ?> +
+
+ 'savedata', + 'value' => 'Tallenna tiedot', + 'class' => 'button small large-12 small-12' + ) + ); + + ?> +
+
+