mirror of
https://github.com/Ekokumppanit/ystavakylaecard.git
synced 2026-01-26 03:04:00 +00:00
Admins can now modify details of other admins
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -29,9 +29,73 @@ if ($user->can_seeusers == "no") {
|
||||
<?php echo lnk("yllapito/users", "Takaisin"); ?>
|
||||
<?php
|
||||
} else {
|
||||
|
||||
$post_url = site_url("yllapito/users/");
|
||||
$options = array('yes' => 'Kyllä voi', 'no' => 'Ei voi');
|
||||
$dd = ' class="medium large-6 small-12"';
|
||||
|
||||
$inputs = array(
|
||||
'name' => 'name',
|
||||
'id' => 'name',
|
||||
'value' => '',
|
||||
'required' => null
|
||||
);
|
||||
?>
|
||||
<h2>Käyttäjä #<?php echo $userdata->id; ?></h2>
|
||||
|
||||
<div class="row">
|
||||
<form action="<?php echo $post_url."/save/".$userid; ?>" method="post"
|
||||
accept-charset="utf-8" id="user_data" class="custom">
|
||||
<input type="hidden" name="from_page" value="<?php echo current_url(); ?>">
|
||||
<div class="large-6 small-12 columns">
|
||||
<h3>Tiedot</h3>
|
||||
<?php
|
||||
echo form_label('Käyttäjätunnus', 'username') . "\n";
|
||||
$inputs['name'] = 'username';
|
||||
$inputs['id'] = 'username';
|
||||
$inputs['value'] = $userdata->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";
|
||||
?>
|
||||
</div>
|
||||
<div class="large-6 small-12 columns">
|
||||
<h3>Oikeudet</h3>
|
||||
<?php
|
||||
echo form_label('Voi hallita kortteja', 'can_approve') . "\n";
|
||||
echo form_dropdown('can_approve', $options, $userdata->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);
|
||||
?>
|
||||
</div>
|
||||
<div class="large-12 small-12 columns">
|
||||
<?php
|
||||
echo form_submit(
|
||||
array(
|
||||
'name' => 'savedata',
|
||||
'value' => 'Tallenna tiedot',
|
||||
'class' => 'button small large-12 small-12'
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user