Revize 1041
Přidáno uživatelem Michal Kliment před více než 13 roky(ů)
freenetis/branches/testing/application/models/device_admin.php | ||
---|---|---|
ORDER BY id asc
|
||
");
|
||
}
|
||
|
||
public function get_all_devices_in_user_device_admins ($user_id)
|
||
{
|
||
return $this->db->query("
|
||
SELECT * FROM devices d
|
||
WHERE d.id IN
|
||
(
|
||
SELECT da.device_id FROM device_admins da WHERE da.user_id = ? GROUP BY device_id
|
||
)
|
||
ORDER BY d.name
|
||
", array($user_id));
|
||
}
|
||
|
||
public function get_all_devices_not_in_user_device_admins ($user_id)
|
||
{
|
||
return $this->db->query("
|
||
SELECT * FROM devices d
|
||
WHERE d.id NOT IN
|
||
(
|
||
SELECT da.device_id FROM device_admins da WHERE da.user_id = ? GROUP BY device_id
|
||
)
|
||
ORDER BY d.name
|
||
", array($user_id));
|
||
}
|
||
}
|
||
?>
|
freenetis/branches/testing/application/controllers/device_admins.php | ||
---|---|---|
$view->content->remove_button = $remove_button;
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
function edit_user($user_id = NULL)
|
||
{
|
||
// access control
|
||
if (!$this->acl_check_new('Devices_Controller', 'admin'))
|
||
Controller::error(ACCESS);
|
||
|
||
// bad parameter
|
||
if (!isset($user_id) || !is_numeric($user_id))
|
||
Controller::warning(PARAMETER);
|
||
|
||
// user doesn't exist
|
||
$user = new User_Model($user_id);
|
||
if (!$user->id)
|
||
Controller::error(RECORD);
|
||
|
||
$model_aro = new Aro_Model();
|
||
|
||
//po zmacknuti tlacitka X se nastavi filtr na NULL
|
||
if ($this->input->post('search_system_clear'))
|
||
$search_system_input = NULL;
|
||
else
|
||
$search_system_input = $this->input->post('search_system_input');
|
||
|
||
//po zmacknuti tlacitka X se nastavi filtr na NULL
|
||
if ($this->input->post('search_group_clear'))
|
||
$search_group_input = NULL;
|
||
else
|
||
$search_group_input = $this->input->post('search_group_input');
|
||
|
||
//pridani uzivatele do skupiny
|
||
if ($this->input->post('add') != NULL && $this->input->post('system_users') != NULL)
|
||
{
|
||
$aro_id = implode("" ,$this->input->post('system_users'));
|
||
|
||
$device_admin = ORM::factory('device_admin')->where(array('device_id' => $device_id, 'user_id' => $aro_id))->find();
|
||
if ($device_admin->id == 0)
|
||
{
|
||
$device_admin = ORM::factory('device_admin');
|
||
$device_admin->device_id = $device_id;
|
||
$device_admin->user_id = $aro_id;
|
||
$device_admin->save();
|
||
}
|
||
}
|
||
|
||
//odebrani uzivatele ze skupiny
|
||
if ($this->input->post('remove') != NULL && $this->input->post('group_users') != NULL)
|
||
{
|
||
$aro_id = implode("" ,$this->input->post('group_users'));
|
||
|
||
$device_admin = ORM::factory('device_admin')->where(array('device_id' => $device_id, 'user_id' => $aro_id))->find();
|
||
if ($device_admin->id != 0)
|
||
{
|
||
$device_admin->delete();
|
||
}
|
||
}
|
||
|
||
//nacteni dat z databaze a filtrem nebo bez
|
||
if ($search_system_input != NULL)
|
||
$devices1 = ORM::factory('device_admin')->get_all_devices_not_in_user_device_admins ($user->id);
|
||
else
|
||
$devices1 = ORM::factory('device_admin')->get_all_devices_not_in_user_device_admins ($user->id);
|
||
|
||
//nacteni dat z databaze a filtrem nebo bez
|
||
if ($search_group_input != NULL)
|
||
$devices2 = ORM::factory('device_admin')->get_all_devices_in_user_device_admins ($user->id);
|
||
else
|
||
$devices2 = ORM::factory('device_admin')->get_all_devices_in_user_device_admins ($user->id);
|
||
|
||
//osetruje stav kdy v zadne skupine neni zadny uzivatel. Teoreticky nikdy nenastane
|
||
//if (($users1->count() == 0) && ($users2->count() == 0))
|
||
// Controller::error(4);
|
||
|
||
//generovani system dropboxu
|
||
if ($devices1->count() == 0)
|
||
{
|
||
$system_users_select = form::dropdown(array('name' => 'system_devices[]','size' => 20, 'style'=>'width:250px'));
|
||
}
|
||
else
|
||
{
|
||
foreach($devices1 as $device1)
|
||
{
|
||
$system_devices[$device1->id] = $device1->name;
|
||
}
|
||
$system_devices_select = form::dropdown(array('name' => 'system_devices[]','size' => 20, 'style'=>'width:250px'), $system_devices);
|
||
|
||
}
|
||
|
||
//generovani system searchboxu
|
||
$system_devices_search_box = '<table><tr><td>'.form::input('search_system_input', $search_system_input, 'style="width:175px;"').'</td><td>'.form::submit('search_system_submit', url_lang::lang('texts.Search'), 'style="width:50px;"').'</td><td>'.(($search_system_input == NULL )?'':form::submit('search_system_clear', 'X', 'style="width:18px;"')).'</td></tr></table>';
|
||
|
||
//generovani group dropboxu
|
||
if ($devices2->count()==0)
|
||
{
|
||
$group_devices_select = form::dropdown(array('name' => 'group_devices[]','size' => 20, 'style'=>'width:250px'));
|
||
}
|
||
else
|
||
{
|
||
foreach($devices2 as $device2)
|
||
{
|
||
$group_devices[$device2->id] = $device2->name;
|
||
}
|
||
|
||
$group_devices_select = form::dropdown(array('name' => 'group_devices[]','size' => 20, 'style'=>'width:250px'), $group_devices);
|
||
}
|
||
|
||
//generovani group searchboxu
|
||
$group_devices_search_box = '<table><tr><td>'.form::input('search_group_input', $search_group_input, 'style="width:175px;"').'</td><td>'.form::submit('search_group_submit', url_lang::lang('texts.Search'), 'style="width:50px;"').'</td><td>'.(($search_group_input == NULL )?'':form::submit('search_group_clear', 'X', 'style="width:18px;"')).'</td></tr></table>';
|
||
|
||
//tlacitka pro manipulaci
|
||
$add_button = form::submit('add', url_lang::lang('texts.Add').' ►', 'style="width:80px;"');
|
||
|
||
$remove_button = form::submit('remove', '◄ '.url_lang::lang('texts.Remove'), 'style="width:80px;"');
|
||
|
||
$headline = url_lang::lang('texts.Edit device admins').': '.url_lang::lang('texts.'.$user->name);
|
||
$view = new View('main');
|
||
$view->title = $headline;
|
||
$view->content = new View('device_admins/edit_device_admins_user');
|
||
$view->content->headline = $headline;
|
||
$view->content->user_id = $user_id;
|
||
$view->content->system_devices_select = $system_devices_select;
|
||
$view->content->system_devices_search_box = $system_devices_search_box;
|
||
$view->content->group_devices_select = $group_devices_select;
|
||
$view->content->group_devices_search_box = $group_devices_search_box;
|
||
$view->content->add_button = $add_button;
|
||
$view->content->remove_button = $remove_button;
|
||
$view->render(TRUE);
|
||
}
|
||
}
|
||
|
||
?>
|
freenetis/branches/testing/application/views/device_admins/edit_device_admins_user.php | ||
---|---|---|
<h2><?php echo $headline ?></h2>
|
||
<br />
|
||
<?php echo html::anchor(url_lang::base().'users/show/'.$user_id,url_lang::lang('texts.Back to user')) ?>
|
||
<br />
|
||
<br />
|
||
<?php print form::open(NULL, array('id' => 'form')); ?>
|
||
<table style="margin-left:auto;margin-right:auto;">
|
||
<tr>
|
||
<td style="vertical-align:top;"><label><?php echo url_lang::lang('texts.System devices'); ?></label><table><tr><td><?php print $system_devices_select; ?></td></tr></table></td>
|
||
<td><table style="width:100px;text-align:center;"><tr><td><?php print $remove_button; ?></td></tr><tr><td> </td></tr><tr><td> <?php print $add_button; ?> </td></tr></table ></td>
|
||
<td style="vertical-align:top;"><label><?php echo url_lang::lang('texts.devices in group'); ?></label><table><tr><td><?php print $group_devices_select; ?></td></tr></table></td>
|
||
</tr>
|
||
|
||
<tr><td><?php print $system_devices_search_box; ?></td><td></td><td><?php print $group_devices_search_box; ?></td></tr>
|
||
</table>
|
||
|
||
<?php print form::close(); ?>
|
Také k dispozici: Unified diff
Zacaty prace na editace spravce zarizeni z pohledu uzivatele spravce.