Revize 57
Přidáno uživatelem kenod před více než 16 roky(ů)
freenetis/trunk/kohana/media/css/style.css | ||
---|---|---|
/* --------- MENU --------- */
|
||
/* ------------------------ */
|
||
#menu ul {
|
||
|
||
|
||
margin:0 0 10px 30px;
|
||
}
|
||
#menu ul ul {
|
||
margin:0 0 10px 10px;
|
||
list-style-type:none;
|
||
#meu li {
|
||
}
|
||
#menu ul ul li {
|
||
background:url(../images/bull.gif) 0px 6px no-repeat;
|
||
padding-left:15px;
|
||
}
|
||
#menu li h2 {
|
||
color:#544A5C;
|
||
font-size:140%;
|
||
font-weight:normal;
|
||
padding-bottom:5px;
|
||
}
|
||
#menu li.account, #menu li.transfer, #menu li.users, #menu li.networks {
|
||
padding-left:45px;
|
||
padding-top:10px;
|
||
list-style-type:none;
|
||
background: #FFFFFF url(../images/bg-gray2.gif) repeat-x;
|
||
border:1px #ebebeb solid;
|
||
margin-bottom:20px;
|
||
}
|
||
|
||
#menu li.account {
|
||
background: #FFFFFF url(../images/menu/account.jpg) 5px 5px no-repeat;
|
||
}
|
||
#menu li.transfer {
|
||
background: #FFFFFF url(../images/menu/transfer.jpg) 5px 5px no-repeat;
|
||
}
|
||
#menu li.users {
|
||
background: #FFFFFF url(../images/menu/user.jpg) 5px 5px no-repeat;
|
||
}
|
||
#menu li.networks {
|
||
background: #FFFFFF url(../images/menu/network.jpg) 5px 5px no-repeat;
|
||
}
|
||
|
||
#menu a:hover {
|
||
color: #EC7A04;
|
||
}
|
||
/*#menu ul ul {
|
||
margin:0 0 10px 55px;
|
||
}
|
||
#menu ul ul li {
|
||
}
|
||
#menu li h2 {
|
||
font-size:140%;
|
||
font-weight:normal;
|
||
padding:5px 0 5px 45px;
|
||
background:url(../images/bg-gray.gif) repeat-x;
|
||
|
||
}
|
||
#menu .account, #menu li.transfer, #menu li.users, #menu li.networks {
|
||
padding-left:0px;
|
||
padding-top:5px;
|
||
list-style-type:none;
|
||
|
||
}
|
||
#menu li.account h2 {
|
||
background: #FFFFFF url(../images/menu/account.jpg) 0px top no-repeat;
|
||
}
|
||
#menu li.transfer h2 {
|
||
background: #FFFFFF url(../images/menu/transfer.jpg) 0px top no-repeat;
|
||
}
|
||
#menu li.users h2 {
|
||
background: #FFFFFF url(../images/menu/user.jpg) 0px top no-repeat;
|
||
}
|
||
#menu li.networks h2 {
|
||
background: #FFFFFF url(../images/menu/network.jpg) 0px top no-repeat;
|
||
}*/
|
||
|
||
/* -------#end MENU-------- */
|
||
/* ------------------------ */
|
freenetis/trunk/kohana/media/js/js.js | ||
---|---|---|
document.getElementById('subnet_name').readOnly = false;
|
||
document.getElementById('subnet_network_address').readOnly = false;
|
||
document.getElementById('subnet_netmask').readOnly = false;
|
||
document.getElementById('subnet_ospf_area_id').readOnly = false;
|
||
|
||
document.getElementById('subnet_name').value = '';
|
||
document.getElementById('subnet_network_address').value = '';
|
||
document.getElementById('subnet_netmask').value = '';
|
||
document.getElementById('subnet_ospf_area_id').value = '';
|
||
}
|
||
|
||
else{
|
||
... | ... | |
var value = xmlhttp.responseXML.getElementsByTagName ('netmask');
|
||
document.getElementById('subnet_netmask').value = value[0].firstChild.nodeValue;
|
||
document.getElementById('subnet_netmask').readOnly = true;
|
||
|
||
var value = xmlhttp.responseXML.getElementsByTagName ('OSPF_area_id');
|
||
document.getElementById('subnet_ospf_area_id').value = value[0].firstChild.nodeValue;
|
||
document.getElementById('subnet_ospf_area_id').readOnly = true;
|
||
}
|
||
|
||
document.getElementById('ajax_subnet_id').style.display = 'none';
|
freenetis/trunk/kohana/application/helpers/special.php | ||
---|---|---|
$form_array = $form->as_array();
|
||
foreach($form_array as $key => $value)
|
||
{
|
||
if (in_array('required',$form->$key->rules()))
|
||
if (is_object ($form->$key))
|
||
{
|
||
if ($class != '')
|
||
{
|
||
if ($form->$key->class != '') $old_class = $form->$key->class.' ';
|
||
else $old_class = '';
|
||
|
||
$form->$key->class($old_class.$class);
|
||
}
|
||
if ($post_label != '')
|
||
if (in_array('required',$form->$key->rules()))
|
||
{
|
||
$old_label = $form->$key->label;
|
||
unset($form->$key->label);
|
||
$form->$key->label($old_label.$post_label);
|
||
unset($old_label);
|
||
if ($class != '') $form->$key->class($class);
|
||
if ($post_label != '')
|
||
{
|
||
$old_label = $form->$key->label;
|
||
unset($form->$key->label);
|
||
$form->$key->label($old_label.$post_label);
|
||
unset($old_label);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
... | ... | |
}
|
||
else return false;
|
||
}
|
||
|
||
/*
|
||
* Method: create_order_by_link
|
||
* Created language flags for multilaguage versions.
|
||
*
|
||
* Parameters:
|
||
* flags_array - array of flags
|
||
* extension - images format
|
||
*
|
||
* Returns:
|
||
* flag / false
|
||
*/
|
||
public static function create_order_by_link($new_order_by = 'users.id', $order_by = 'users.id', $order_by_direction = 'ASC', $record_per_page = NULL, $url_array_ofset = 0)
|
||
{
|
||
$url_array = explode('/', trim(url::current(), '/'));
|
||
if (count($url_array)<7)
|
||
{
|
||
$url_array[3] = 50;
|
||
$url_array[6] = 'page';
|
||
$url_array[7] = 1;
|
||
$url_array_ofset = 0;
|
||
|
||
}
|
||
if (isset($record_per_page)) $url_array[3] = (int) $record_per_page;
|
||
|
||
$pre_url = $url_array[1+$url_array_ofset].'/'.$url_array[2+$url_array_ofset].'/'.$url_array[3+$url_array_ofset].'/';
|
||
if ($new_order_by == $order_by)
|
||
{
|
||
$order_by_direction = $order_by_direction == 'ASC' ? 'DESC' : 'ASC';
|
||
}
|
||
return url_lang::base().$pre_url.$new_order_by.'/'.$order_by_direction.'/'.$url_array[6+$url_array_ofset].'/'.$url_array[7+$url_array_ofset];
|
||
}
|
||
}
|
freenetis/trunk/kohana/application/models/group_aro_map.php | ||
---|---|---|
{
|
||
if ($where)
|
||
{
|
||
$this->db->update('groups_aro_map', $data, array('aro_id' => $where, 'group_id!=' => 21));
|
||
$query=$this->db->select('group_id')->where('aro_id', $where)->from('groups_aro_map')->get()->current();
|
||
if ($query->group_id == 23) $this->db->update('groups_aro_map', $data, array('aro_id' => $where));
|
||
}
|
||
else
|
||
{
|
freenetis/trunk/kohana/application/models/device.php | ||
---|---|---|
return self::$db->count_records('devices');
|
||
}
|
||
|
||
public function get_all_devices($limit_from = 0, $limit_results = 50, $order_by = 'devices.id', $order_by_direction = 'ASC', $user_id = null)
|
||
public function get_all_devices($limit_from = 0, $limit_results = 50, $order_by = 'devices.id', $order_by_direction = 'ASC')
|
||
{
|
||
//return self::$db->select(array('CONCAT(users.name,\' \',users.surname) as u_name', 'devices.*'))->from('devices')->join('users', 'users.id = devices.user_id')->get();
|
||
if (isset($user_id)) $where = 'WHERE d.user_id='.$user_id.'';
|
||
else $where = '';
|
||
return self::$db->query('SELECT d.id,d.type,d.name, CONCAT(users.name, \' \', users.surname) AS u_name,CONCAT(u2.name, \' \', u2.surname) AS engineer_name,
|
||
IFNULL(ifaces.iface_count,0) AS iface_count,
|
||
IFNULL(ports.port_count,0) AS port_count FROM devices d
|
||
LEFT JOIN users ON d.user_id = users.id
|
||
LEFT JOIN users u2 ON d.engineer_id = u2.id
|
||
LEFT JOIN (SELECT COUNT(*) as iface_count,device_id FROM ifaces GROUP BY ifaces.device_id) ifaces ON d.id=ifaces.device_id
|
||
LEFT JOIN (SELECT COUNT(*) as port_count,device_id FROM ports GROUP BY ports.device_id) ports ON d.id=ports.device_id
|
||
'.$where.'
|
||
ORDER BY '.$order_by.' '.$order_by_direction.' LIMIT '.$limit_from.','.$limit_results);
|
||
LEFT JOIN (SELECT COUNT(*) as port_count,device_id FROM ports GROUP BY ports.device_id) ports ON d.id=ports.device_id ORDER BY '.$order_by.' '.$order_by_direction.' LIMIT '.$limit_from.','.$limit_results);
|
||
}
|
||
}
|
||
|
freenetis/trunk/kohana/application/models/subnet.php | ||
---|---|---|
|
||
protected $has_many = array('ip_addresses');
|
||
|
||
public function count_all_subnets()
|
||
{
|
||
return self::$db->count_records('subnets');
|
||
}
|
||
|
||
}
|
||
|
||
?>
|
freenetis/trunk/kohana/application/models/vlan.php | ||
---|---|---|
class Vlan_Model extends ORM {
|
||
|
||
protected $has_many = array('vlan_ifaces','ports');
|
||
|
||
public function count_all_vlans()
|
||
{
|
||
return self::$db->count_records('vlans');
|
||
}
|
||
|
||
}
|
||
|
freenetis/trunk/kohana/application/models/money_transfer_bank_info.php | ||
---|---|---|
|
||
public function get_unidentified_transfers($account_id = null, $limit_from = 0, $limit_results = 50, $order_by = 'mt.id', $order_by_direction = 'DESC')
|
||
{
|
||
|
||
/*
|
||
return self::$db->query('SELECT mt. * , mt.id AS mtid, bi. *
|
||
FROM money_transfers mt
|
||
LEFT JOIN money_transfer_bank_infos bi ON bi.id = mt.bank_info_id
|
||
WHERE mt.destination_id = '.$account_id.'
|
||
AND bi.identified = 0
|
||
ORDER BY '.$order_by.' '.$order_by_direction.'
|
||
LIMIT '.$limit_from.' , '.$limit_results.'' */
|
||
|
||
if ($order_by=='amount') $order_by = 'IF( mt.destination_id = '.$account_id.', amount, amount*-1 )';
|
||
return self::$db->query('SELECT mt. * , mt.id AS mtid, bi. * , IF( mt.destination_id = '.$account_id.', FALSE, TRUE ) AS trans_type
|
||
FROM money_transfers mt
|
freenetis/trunk/kohana/application/models/segment.php | ||
---|---|---|
{
|
||
return self::$db->count_records('segments');
|
||
}
|
||
|
||
|
||
public function get_all_devices($limit_from = 0, $limit_results = 50, $order_by = 'devices.id', $order_by_direction = 'ASC')
|
||
{
|
||
//return self::$db->select(array('CONCAT(users.name,\' \',users.surname) as u_name', 'devices.*'))->from('devices')->join('users', 'users.id = devices.user_id')->get();
|
||
return self::$db->query('SELECT devices.*, CONCAT(users.name, \' \', users.surname) AS u_name, IFNULL(ifaces.iface_count,0) AS iface_count, IFNULL(ports.port_count,0) AS port_count FROM devices JOIN users ON devices.user_id = users.id LEFT JOIN (SELECT COUNT(*) as iface_count,device_id FROM ifaces GROUP BY ifaces.device_id) ifaces ON devices.id=ifaces.device_id LEFT JOIN (SELECT COUNT(*) as port_count,device_id FROM ports GROUP BY ports.device_id) ports ON devices.id=ports.device_id ORDER BY '.$order_by.' '.$order_by_direction.' LIMIT '.$limit_from.','.$limit_results);
|
||
}
|
||
}
|
||
|
||
?>
|
freenetis/trunk/kohana/application/models/member.php | ||
---|---|---|
<?
|
||
class Member_Model extends ORM {
|
||
//protected $table = 'member';
|
||
/*
|
||
public function login_request($username = '', $password = '')
|
||
|
||
protected $has_many = array('users');
|
||
|
||
public function __construct($id = false)
|
||
{
|
||
$query = self::$db->from('user')->select('ID')->where(array('login' => $username, 'password' => sha1($password)))->get();
|
||
return ($query->count()) ? $query->current()->ID : 0;
|
||
// return (bool) self::$db->where('login', $username)->where('password', sha1($password))->count_records('user');
|
||
parent::__construct($id);
|
||
}
|
||
|
||
public function username_exist($username)
|
||
public function get_all_members($limit_from = 0, $limit_results = 50, $order_by = 'users.id', $order_by_direction = 'ASC')
|
||
{
|
||
return (bool) self::$db->where('login', $username)->count_records('user');
|
||
return self::$db->select(array('members.name as namem', 'members.street', 'members.street_number', 'members.town', 'members.ZIP_code', 'members.type as typem', 'members.qos_ceil', 'members.qos_rate', 'members.entrance_fee', 'members.debt_payment_rate', 'members.entrance_fee_left', 'members.must_pay_regular_fee', 'members.current_credit', 'members.entrance_date', 'members.comment', 'users.*'))->from('members')->join('users', 'users.member_id = members.id')->where('users.type', 'member')->orderby($order_by, $order_by_direction)->limit($limit_results,$limit_from)->get();
|
||
}
|
||
|
||
public function new_member_id()
|
||
public function count_all_members()
|
||
{
|
||
// $query = self::$db->query("INSERT");
|
||
return (int) self::$db->insert_id();
|
||
return (int) self::$db->from('members')->count_records();
|
||
}
|
||
*/
|
||
|
||
public function get_member($id)
|
||
{
|
||
return self::$db->select(array('members.name as namem', 'members.street', 'members.street_number', 'members.town', 'members.ZIP_code', 'members.type as typem', 'members.qos_ceil', 'members.qos_rate', 'members.entrance_fee', 'members.debt_payment_rate', 'members.entrance_fee_left', 'members.must_pay_regular_fee', 'members.current_credit', 'members.entrance_date', 'users.*'))->from('members')->join('users', 'users.member_id = members.id')->where(array('members.id' => (int)$id, 'users.type!=' => 'user'))->limit(1)->get();
|
||
}
|
||
/* array('id' => 5, 'title' => 'Demo')
|
||
public function get_one_user($)
|
||
{
|
||
return self::$db->from('members')->join('users', 'users.member_id = members.id')->where('login', 'kenod')->get();
|
||
}
|
||
//*/
|
||
}
|
||
|
||
?>
|
freenetis/trunk/kohana/application/models/ip_address.php | ||
---|---|---|
|
||
public function get_all_ip_addresses($limit_from = 0, $limit_results = 50, $order_by = 'ip_addresses.id', $order_by_direction = 'ASC')
|
||
{
|
||
return self::$db->query(' SELECT ifaces.name AS iface_name, vlan_ifaces.name AS vlan_iface_name,subnets.name as subnet_name, ip_addresses.* FROM ip_addresses
|
||
LEFT JOIN ifaces ON ifaces.id = ip_addresses.iface_id
|
||
LEFT JOIN vlan_ifaces ON vlan_ifaces.id = ip_addresses.VLAN_iface_id
|
||
LEFT JOIN subnets ON subnets.id=ip_addresses.subnet_id
|
||
ORDER BY '.$order_by.' '.$order_by_direction.' LIMIT '.$limit_from.','.$limit_results);
|
||
return self::$db->query('SELECT ifaces.name AS iface_name, vlan_ifaces.name AS vlan_iface_name, ip_addresses.* FROM ip_addresses LEFT JOIN ifaces ON ifaces.id = ip_addresses.iface_id LEFT JOIN vlan_ifaces ON vlan_ifaces.id = ip_addresses.VLAN_iface_id ORDER BY '.$order_by.' '.$order_by_direction.' LIMIT '.$limit_from.','.$limit_results);
|
||
}
|
||
|
||
}
|
freenetis/trunk/kohana/application/models/user.php | ||
---|---|---|
<?
|
||
class User_Model extends ORM {
|
||
protected $has_many = array('devices');
|
||
|
||
protected $belongs_to = array('member');
|
||
protected $has_many = array('jobs');
|
||
|
||
public function __construct($id = false)
|
||
{
|
||
parent::__construct($id);
|
||
}
|
||
|
||
public function login_request($username = '', $password = '')
|
||
{
|
||
$query = self::$db->from('users')->select('id')->where(array('login' => $username, 'password' => sha1($password)))->get();
|
||
return ($query->count()) ? $query->current()->id : 0;
|
||
// return (bool) self::$db->where('login', $username)->where('password', sha1($password))->count_records('user');
|
||
}
|
||
|
||
public function count_all_users()
|
||
{
|
||
return (int) self::$db->count_records('users');
|
||
}
|
||
|
||
public function username_exist($username)
|
||
public function username_exist($username, $user_id = null)
|
||
{
|
||
return (bool) self::$db->where('login', $username)->count_records('users');
|
||
if (isset($user_id)) return (bool) self::$db->where(array('login' => $username, 'id!=' => $user_id))->count_records('users');
|
||
else return (bool) self::$db->where('login', $username)->count_records('users');
|
||
}
|
||
|
||
public function phone_exist($phone)
|
||
public function phone_exist($phone, $user_id = null)
|
||
{
|
||
return (bool) self::$db->where('phone', $phone)->count_records('users');
|
||
if (isset($user_id)) return (bool) self::$db->where(array('phone' => $phone, 'id!=' => $user_id))->count_records('users');
|
||
else return (bool) self::$db->where('phone', $phone)->count_records('users');
|
||
}
|
||
|
||
public function email_exist($email)
|
||
public function email_exist($email, $user_id = null)
|
||
{
|
||
return (bool) self::$db->where('email', $email)->count_records('users');
|
||
if (isset($user_id)) return (bool) self::$db->where(array('email' => $email, 'id!=' => $user_id))->count_records('users');
|
||
else return (bool) self::$db->where('email', $email)->count_records('users');
|
||
}
|
||
}
|
||
|
freenetis/trunk/kohana/application/models/vlan_iface.php | ||
---|---|---|
protected $belongs_to = array('iface','vlan');
|
||
protected $has_many = array('ip_addresses');
|
||
|
||
public function count_all_vlan_ifaces()
|
||
{
|
||
return self::$db->count_records('vlan_ifaces');
|
||
}
|
||
}
|
||
|
||
?>
|
freenetis/trunk/kohana/application/controllers/members.php | ||
---|---|---|
<?php
|
||
class Members_Controller extends Controller {
|
||
|
||
protected $member_id = false;
|
||
protected $user_id = false;
|
||
|
||
function index()
|
||
{
|
||
url::redirect('members/show_all');
|
||
... | ... | |
|
||
function show_all($limit_results = 50, $order_by = 'member_id', $order_by_direction = 'ASC')
|
||
{
|
||
if (!$this->gacl_class->acl_check('freenetis', 'view_all', 'all', $_SESSION['username'])) Controller::error(1);
|
||
// get new selector
|
||
if (is_numeric($this->input->get('record_per_page'))) $limit_results = (int) $this->input->get('record_per_page');
|
||
|
||
|
||
// parameters control
|
||
$allowed_order_type = array('members.name', 'street', 'street_number', 'town', 'ZIP_code', 'members.type', 'qos_ceil', 'qos_rate', 'entrance_fee', 'debt_payment_rate', 'entrance_fee_left', 'must_pay_regular_fee', 'current_credit', 'entrance_date', 'members.comment', 'users.name', 'surname','login','birthday','users.comment','phone','email');
|
||
$allowed_order_type = array('members.name', 'street', 'street_number', 'town', 'ZIP_code', 'users.type', 'qos_ceil', 'qos_rate', 'entrance_fee', 'debt_payment_rate', 'entrance_fee_left', 'must_pay_regular_fee', 'current_credit', 'entrance_date', 'members.comment', 'users.name', 'surname','login','birthday','users.comment','phone','email');
|
||
if (!in_array(strtolower($order_by),$allowed_order_type)) $order_by = 'member_id';
|
||
if (strtolower($order_by_direction) != 'asc' && strtolower($order_by_direction) != 'desc') $order_by_direction = 'asc';
|
||
|
||
... | ... | |
'limit_results' => $limit_results
|
||
));
|
||
|
||
$grid->add_new_button('/add', url_lang::lang('texts.Add new member'));
|
||
if ($this->gacl_class->acl_check('freenetis', 'new_all', 'all', $_SESSION['username'])) $grid->add_new_button(url_lang::base().'members/add', url_lang::lang('texts.Add new member'));
|
||
$grid->order_field('member_id')->label('ID');
|
||
$grid->order_field('name','members.name')->label('Name');
|
||
$grid->order_field('surname')->label('Surname');
|
||
$grid->order_field('login')->label('Login');
|
||
$grid->order_field('email')->label('Email');
|
||
$grid->order_field('street')->label('Street');
|
||
$grid->order_field('phone')->label('Phone');
|
||
$grid->order_field('name','members.name')->label(url_lang::lang('texts.Name'));
|
||
$grid->order_field('surname')->label(url_lang::lang('texts.Surname'));
|
||
$grid->order_field('login')->label(url_lang::lang('texts.Username'));
|
||
$grid->order_field('email')->label('E-mail');
|
||
$grid->order_field('street')->label(url_lang::lang('texts.Street'));
|
||
$grid->order_field('phone')->label(url_lang::lang('texts.Phone'));
|
||
$grid->action_field('member_id') ->label(url_lang::lang('texts.Show')) ->url(url_lang::base().'members/show') ->action(url_lang::lang('texts.Show'));
|
||
$grid->action_field('member_id') ->label(url_lang::lang('texts.Edit')) ->url('http://edit') ->action(url_lang::lang('texts.Edit'));
|
||
$grid->action_field('member_id') ->label(url_lang::lang('texts.Delete')) ->url('delete') ->action(url_lang::lang('texts.Delete'));
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_all', 'all', $_SESSION['username'])) $grid->action_field('member_id') ->label(url_lang::lang('texts.Edit')) ->url(url_lang::base().'members/edit') ->action(url_lang::lang('texts.Edit'));
|
||
if ($this->gacl_class->acl_check('freenetis', 'delete_all', 'all', $_SESSION['username'])) $grid->action_field('member_id') ->label(url_lang::lang('texts.Delete')) ->url(url_lang::base().'members/delete') ->action(url_lang::lang('texts.Delete'))->script('onclick="return potvrd(\''.url_lang::lang('texts.delete_member').'\');"');
|
||
$grid->datasource( $dotaz );
|
||
$this->template->content = $grid;
|
||
// echo
|
||
... | ... | |
// $view->content = new View('content', $data);
|
||
$view->content = $this->template->content;
|
||
$view->footer = new View('base/footer');
|
||
|
||
$view->header->menu = Controller::render_menu();
|
||
$view->header->title = "Úprava uživatele";
|
||
//$view->content->heading = "Úprava uživatele ".$data['row']['name']." ".$data['row']['surname'];
|
||
//$view->content->form = $form->html();
|
||
... | ... | |
|
||
function show($member_id = NULL, $order_by = 'member_id', $order_by_direction = 'ASC')
|
||
{
|
||
//if (!$this->gacl_class->acl_check('freenetis', 'view_own', 'all', $_SESSION['username'],get_class($this),'function_'.__FUNCTION__)) Controller::error(1);
|
||
if (isset($member_id))
|
||
{
|
||
$data['title'] = url_lang::lang('texts.Association members');
|
||
$data['heading'] = url_lang::lang('texts.Association members');
|
||
$model_members = new Member_Model();
|
||
$member_data = $model_members->get_member($member_id)->current();
|
||
|
||
print_r($member_data->id);
|
||
//print_r($member_data->id);
|
||
|
||
if ($member_id == $_SESSION['member_id'])
|
||
{
|
||
if (!$this->gacl_class->acl_check('freenetis', 'view_own', 'all', $_SESSION['username'])) Controller::error(1);
|
||
}
|
||
else
|
||
{
|
||
if (!$this->gacl_class->acl_check('freenetis', 'view_all', 'all', $_SESSION['username'])) Controller::error(1);
|
||
}
|
||
$model_contacts = new Contact_Model();
|
||
$contacts = $model_contacts->find_all_by_user_id($member_data->id);
|
||
|
||
foreach ($contacts as $row)
|
||
{
|
||
echo "<br /><b>".$row->type."</b> : ".$row->value;
|
||
}
|
||
|
||
|
||
$model_users = new User_Model();
|
||
$users = $model_users->orderby($order_by,$order_by_direction)->find_all_by_member_id($member_id);
|
||
|
||
$grid = new Grid(url_lang::base().'members', null,array(
|
||
'separator' => '',
|
||
'separator' => '<br /><br />',
|
||
'use_paginator' => false,
|
||
'use_selector' => false,
|
||
|
||
... | ... | |
|
||
));
|
||
|
||
$grid->add_new_button('/add', url_lang::lang('texts.Add new member'));
|
||
if ($this->gacl_class->acl_check('freenetis', 'new_own', 'all', $_SESSION['username'])) $grid->add_new_button(url_lang::base().'users/add/'.$member_id, url_lang::lang('texts.Add new user'));
|
||
$grid->add_back_button(url_lang::lang('texts.Back'));
|
||
$grid->order_field('id','id')->label('ID');
|
||
$grid->order_field('name','name')->label('Name');
|
||
$grid->order_field('surname','surname')->label('Surname');
|
||
$grid->order_field('login','login')->label('Login');
|
||
$grid->order_field('email','email')->label('Email');
|
||
$grid->action_field('id') ->label(url_lang::lang('texts.Show')) ->url(url_lang::base().'members/show') ->action(url_lang::lang('texts.Show'));
|
||
$grid->action_field('id') ->label(url_lang::lang('texts.Edit')) ->url('http://edit') ->action(url_lang::lang('texts.Edit'));
|
||
$grid->action_field('id') ->label(url_lang::lang('texts.Delete')) ->url('delete') ->action(url_lang::lang('texts.Delete'));
|
||
$grid->order_field('name','name')->label(url_lang::lang('texts.Name'));
|
||
$grid->order_field('surname','surname')->label(url_lang::lang('texts.Surname'));
|
||
$grid->order_field('login','login')->label(url_lang::lang('texts.Username'));
|
||
$grid->order_field('email','email')->label('E-mail');
|
||
$grid->action_field('id') ->label(url_lang::lang('texts.Show'))->url(url_lang::base().'users/show')->action(url_lang::lang('texts.Show'));
|
||
$grid->action_field('id') ->label(url_lang::lang('texts.Edit'))->url(url_lang::base().'users/edit')->action(url_lang::lang('texts.Edit'));
|
||
$grid->action_field('id') ->label(url_lang::lang('texts.Delete'))->url(url_lang::base().'users/delete')->action(url_lang::lang('texts.Delete'))->script('onclick="return potvrd(\''.url_lang::lang('texts.delete_user').'\');"');;
|
||
$grid->datasource( $users );
|
||
$this->template->content = $grid;
|
||
echo $this->template->content;
|
||
$view = new View('template');
|
||
$view->header = new View('base/header');
|
||
$view->content = new View('members_show');
|
||
// $view->content = $this->template->content;
|
||
$view->footer = new View('base/footer');
|
||
|
||
$view->header->title = url_lang::lang('texts.Display member');
|
||
$view->header->menu = Controller::render_menu();
|
||
//$view->content->heading = "Úprava uživatele ".$data['row']['name']." ".$data['row']['surname'];
|
||
$view->content->users = $this->template->content;
|
||
$view->content->member_data = $member_data;
|
||
$view->content->contacts = $contacts;
|
||
$view->content->message = $this->session->get_once('message');
|
||
$view->render(TRUE);
|
||
|
||
}
|
||
else
|
||
{
|
||
echo url_lang::lang('texts.Error: parameter ID is required!');
|
||
Controller::error();
|
||
}
|
||
|
||
} // end of show function
|
||
|
||
|
||
function add()
|
||
{
|
||
$form = new Forge(url_lang::base()."registration", '', 'POST', array('id' => 'article_form'));
|
||
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
|
||
if (!$this->gacl_class->acl_check('freenetis', 'new_all', 'all', $_SESSION['username'])) Controller::error(1);
|
||
|
||
$form = new Forge(url_lang::base().'members/add', '', 'POST', array('id' => 'article_form'));
|
||
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
|
||
|
||
$form->group('')->label(url_lang::lang('texts.Basic informations'));
|
||
// KONTROLA PRAV PHPGACL if ($this->gacl_class->acl_check('freenetis', 'edit', 'all', 'mara', get_class($this), 'surname'))
|
||
$form->input('username')->label(url_lang::lang('texts.username').':')->rules('required|length[3,50]')->callback(array($this, 'valid_username'));
|
||
|
||
$form->input('pre_title')->label(url_lang::lang('texts.pre title').':')->rules('length[3,40]');
|
||
$form->input('name')->label(url_lang::lang('texts.name').':')->rules('required|length[3,30]');
|
||
$form->input('middle_name')->label(url_lang::lang('texts.middle name').':')->rules('length[3,30]');
|
||
$form->input('surname')->label(url_lang::lang('texts.surname').':')->rules('required|length[3,60]');
|
||
$form->input('post_title')->label(url_lang::lang('texts.post title').':')->rules('length[3,30]');
|
||
$form->dropdown('type')->label(url_lang::lang('texts.Type').':')->options(array('member'=>url_lang::lang('texts.Honest member'),'wannabe'=>url_lang::lang('texts.Wanna be a member')));
|
||
$form->input('membername')->label(url_lang::lang('texts.Members name').':')->rules('required|length[3,60]');
|
||
$form->group('')->label(url_lang::lang('texts.Password'));
|
||
$form->password('password')->label(url_lang::lang('texts.password').':')->rules('required|length[3,50]')->class('required');
|
||
$form->password('confirm_password')->label(url_lang::lang('texts.confirm password').':')->rules('required|length[3,50]')->matches($form->password);
|
||
$form->group('')->label(url_lang::lang('texts.Contact informations'));
|
||
$form->input('street')->label(url_lang::lang('texts.street').':')->rules('required|length[1,200]');
|
||
$form->input('street_number')->label(url_lang::lang('texts.street number').':')->rules('required|length[1,50]');
|
||
$form->input('town')->label(url_lang::lang('texts.town').':')->rules('required|length[3,200]');
|
||
$form->input('zip_code')->label(url_lang::lang('texts.zip code').':')->rules('required|length[5,10]');
|
||
$form->input('phone')->label(url_lang::lang('texts.phone').':')->rules('required|length[9,40]')->callback(array($this, 'valid_phone'));
|
||
$form->input('email')->label(url_lang::lang('texts.email').':')->rules('required|length[3,50]|valid_email')->callback(array($this, 'valid_email'));
|
||
$form->group('')->label(url_lang::lang('texts.Account informations'));
|
||
//$form->dropdown('acctype')->label(url_lang::lang('texts.Account type').':')->options(array('analytic'=>url_lang::lang('texts.Double entry account'),'bank'=>url_lang::lang('texts.Bank account')));
|
||
if ($this->gacl_class->acl_check('freenetis', 'new_all', 'all', $_SESSION['username'],get_class($this),'add_current_credit')) $form->input('current_credit')->label(url_lang::lang('texts.Current credit').':')->rules('valid_numeric');
|
||
$form->input('entrance_fee')->label(url_lang::lang('texts.Entrance fee').':')->rules('valid_numeric');
|
||
$form->input('entrance_fee_left')->label(url_lang::lang('texts.Entrance fee left').':')->rules('valid_numeric');
|
||
$form->input('debt_payment_rate')->label(url_lang::lang('texts.Debit payment rate').':')->rules('valid_numeric');
|
||
$form->group('')->label(url_lang::lang('texts.Completive informations'));
|
||
$form->input('qos_ceil')->label(url_lang::lang('texts.qos ceil').':')->rules('valid_numeric');
|
||
$form->input('qos_rate')->label(url_lang::lang('texts.qos rate').':')->rules('valid_numeric');
|
||
$form->date('birthday')->label(url_lang::lang('texts.birthday').':')->years(date('Y')-100, date('Y'))->rules('required');
|
||
$form->date('entrance_date')->label(url_lang::lang('texts.Entrance date').':')->years(date('Y')-100, date('Y'))->rules('required');
|
||
$form->textarea('comment')->label(url_lang::lang('texts.Comment').':')->rules('length[0,250]');
|
||
if ($this->gacl_class->acl_check('freenetis', 'new_all', 'all', $_SESSION['username'],get_class($this),'add_must_pay')) $form->radio('must_pay_regular_fee')->label(url_lang::lang('texts.Must pay regular fee').':')->options(array('1'=>url_lang::lang('texts.Yes'),'0'=>url_lang::lang('texts.No')))->default(1);
|
||
|
||
$form->submit('submit')->value(url_lang::lang('texts.Add'));
|
||
special::required_forge_style($form, ' *', 'required');
|
||
|
||
if($form->validate())
|
||
{
|
||
$form_data = $form->as_array();
|
||
foreach($form_data as $key => $value)
|
||
{
|
||
$form_data[$key] = htmlspecialchars($value);
|
||
}
|
||
$user_data = new User_Model();
|
||
$member_data = new Member_Model();
|
||
$account_data = new Account_Model();
|
||
|
||
$account_data->type = 'analytic';
|
||
$account_data->name = $form_data['membername'];
|
||
if ($this->gacl_class->acl_check('freenetis', 'new_all', 'all', $_SESSION['username'],get_class($this),'add_current_credit')) $account_data->start_amount = $form_data['current_credit'];
|
||
|
||
//print_r($member_data);die();
|
||
$user_data->name = $form_data['name'];
|
||
$user_data->middle_name = $form_data['middle_name'];
|
||
$user_data->login = $form_data['username'];
|
||
$user_data->surname = $form_data['surname'];
|
||
$user_data->pre_title = $form_data['pre_title'];
|
||
$user_data->post_title = $form_data['post_title'];
|
||
$user_data->birthday = date("Y-m-d",$form_data['birthday']);
|
||
$user_data->phone = $form_data['phone'];
|
||
$user_data->email = $form_data['email'];
|
||
$user_data->type = $form_data['type'];
|
||
$user_data->comment = $form_data['comment'];
|
||
$user_data->password = sha1($form_data['password']);
|
||
|
||
$member_data->entrance_date = date("Y-m-d",$form_data['entrance_date']);
|
||
$member_data->name = $form_data['membername'];;
|
||
$member_data->street = $form_data['street'];
|
||
$member_data->street_number = $form_data['street_number'];
|
||
$member_data->town = $form_data['town'];
|
||
$member_data->ZIP_code = $form_data['zip_code'];
|
||
$member_data->qos_ceil = $form_data['qos_ceil'];
|
||
$member_data->qos_rate = $form_data['qos_rate'];
|
||
$member_data->entrance_fee = $form_data['entrance_fee'];
|
||
$member_data->entrance_fee_left = $form_data['entrance_fee_left'];
|
||
$member_data->debt_payment_rate = $form_data['debt_payment_rate'];
|
||
if ($this->gacl_class->acl_check('freenetis', 'new_all', 'all', $_SESSION['username'],get_class($this),'add_current_credit')) $member_data->current_credit = $form_data['current_credit'];
|
||
if ($this->gacl_class->acl_check('freenetis', 'new_all', 'all', $_SESSION['username'],get_class($this),'add_must_pay')) $member_data->must_pay_regular_fee = $form_data['must_pay_regular_fee'];
|
||
|
||
|
||
$member_saved = $member_data->save();
|
||
|
||
$user_data->member_id = $member_data->id;
|
||
$account_data->owner_id = $member_data->id;
|
||
|
||
$user_saved = $user_data->save();
|
||
|
||
Controller::insert_phpgacl($user_data->id,$user_data->surname.' '.$user_data->name,$user_data->login,$form_data['type']);
|
||
|
||
unset($form_data);
|
||
|
||
if ($member_saved && $user_saved && $account_data->save())
|
||
{
|
||
$this->session->set_flash('message', url_lang::lang('texts.Member successfully added.'));
|
||
}
|
||
else
|
||
{
|
||
$this->session->set_flash('message', url_lang::lang('texts.Error - cant add new member.'));
|
||
}
|
||
url::redirect(url_lang::base().'members/show/'.(int)$member_data->id, 'redirect');
|
||
}
|
||
else
|
||
{
|
||
$view->form = new View('registration');
|
||
|
||
$view = new View('template');
|
||
|
||
$view->header = new View('base/header');
|
||
$view->content = new View('members_add');
|
||
$view->footer = new View('base/footer');
|
||
$view->header->menu = Controller::render_menu();
|
||
$view->header->title = url_lang::lang('texts.Add new member');
|
||
$view->header->other_styles = html::stylesheet('media/css/forms.css');
|
||
$view->content->form = $form->html();
|
||
|
||
$form->group('')->label(url_lang::lang('texts.login data'));
|
||
// KONTROLA PRAV PHPGACL if ($this->gacl_class->acl_check('freenetis', 'edit', 'all', 'mara', get_class($this), 'surname'))
|
||
$form->input('username')->label(url_lang::lang('texts.username').':')->rules('required|length[3,50]')->callback(array($this, 'valid_username'));
|
||
$form->password('password')->label(url_lang::lang('texts.password').':')->rules('required|length[3,50]')->class('required');
|
||
$form->password('confirm_password')->label(url_lang::lang('texts.confirm password').':')->rules('required|length[3,50]')->matches($form->password);
|
||
|
||
$form->group('')->label(url_lang::lang('texts.contact data'));
|
||
$form->input('pre_title')->label(url_lang::lang('texts.pre title').':')->rules('length[3,40]');
|
||
$form->input('name')->label(url_lang::lang('texts.name').':')->rules('required|length[3,30]');
|
||
$form->input('middle_name')->label(url_lang::lang('texts.middle name').':')->rules('length[3,30]');
|
||
$form->input('surname')->label(url_lang::lang('texts.surname').':')->rules('required|length[3,60]');
|
||
$form->input('post_title')->label(url_lang::lang('texts.post title').':')->rules('length[3,30]');
|
||
$form->date('birthday')->label(url_lang::lang('texts.birthday').':')->years(date('Y')-100, date('Y'))->rules('required');
|
||
$form->input('street')->label(url_lang::lang('texts.street').':')->rules('required|length[1,200]');
|
||
$form->input('street_number')->label(url_lang::lang('texts.street number').':')->rules('required|length[1,50]');
|
||
$form->input('town')->label(url_lang::lang('texts.town').':')->rules('required|length[3,200]');
|
||
$form->input('zip_code')->label(url_lang::lang('texts.zip code').':')->rules('required|length[5,10]');
|
||
$form->input('phone')->label(url_lang::lang('texts.phone').':')->rules('required|length[3,40]')->callback(array($this, 'valid_phone'));
|
||
$form->input('email')->label(url_lang::lang('texts.email').':')->rules('required|length[3,50]|valid_email')->callback(array($this, 'valid_email'));
|
||
|
||
$form->submit('submit')->value(url_lang::lang('texts.register'));
|
||
special::required_forge_style($form, ' *', 'required');
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
$view = new View('registration');
|
||
$view->title = url_lang::lang('texts.registration form');
|
||
$view->form = $form->html();
|
||
$view->render(TRUE);
|
||
} // end of add function
|
||
|
||
function edit($member_id = NULL)
|
||
{
|
||
if (isset($member_id))
|
||
{
|
||
|
||
$user_model=new User_Model();
|
||
$user_model->select('id, login');
|
||
$user_model->where('type!=','user');
|
||
$user_model->find_by_member_id($member_id);
|
||
if ($member_id == $_SESSION['member_id'])
|
||
{
|
||
if (!$this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'])) Controller::error(1);
|
||
}
|
||
else
|
||
{
|
||
if (!$this->gacl_class->acl_check('freenetis', 'edit_all', 'all', $_SESSION['username'])) Controller::error(1);
|
||
}
|
||
$this->user_id = $user_model->id;
|
||
unset($user_model);
|
||
|
||
$model_members = new Member_Model();
|
||
$member_data = $model_members->get_member($member_id)->current();
|
||
|
||
$form = new Forge(url_lang::base().'members/edit/'.$member_id, '', 'POST', array('id' => 'article_form'));
|
||
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
|
||
|
||
$form->group('')->label(url_lang::lang('texts.Basic informations'));
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_username')) $form->input('username')->label(url_lang::lang('texts.username').':')->rules('required|length[3,50]')->callback(array($this, 'valid_username'))->value($member_data->login);
|
||
|
||
$form->input('pre_title')->label(url_lang::lang('texts.pre title').':')->rules('length[3,40]')->value($member_data->pre_title);
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_name')) $form->input('name')->label(url_lang::lang('texts.name').':')->rules('required|length[3,30]')->value($member_data->name);
|
||
$form->input('middle_name')->label(url_lang::lang('texts.middle name').':')->rules('length[3,30]')->value($member_data->middle_name);
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_surname'))$form->input('surname')->label(url_lang::lang('texts.surname').':')->rules('required|length[3,60]')->value($member_data->surname);
|
||
$form->input('post_title')->label(url_lang::lang('texts.post title').':')->rules('length[3,30]')->value($member_data->post_title);
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_type'))$form->dropdown('type')->label(url_lang::lang('texts.Type').':')->options(array('member'=>url_lang::lang('texts.Honest member'),'wannabe'=>url_lang::lang('texts.Wanna be a member')))->selected($member_data->type);
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_membersname'))$form->input('membername')->label(url_lang::lang('texts.Members name').':')->rules('required|length[3,60]')->value($member_data->namem);
|
||
|
||
$form->group('')->label(url_lang::lang('texts.Contact informations'));
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_address'))
|
||
{
|
||
$form->input('street')->label(url_lang::lang('texts.street').':')->rules('required|length[1,200]')->value($member_data->street);
|
||
$form->input('street_number')->label(url_lang::lang('texts.street number').':')->rules('required|length[1,50]')->value($member_data->street_number);
|
||
$form->input('town')->label(url_lang::lang('texts.town').':')->rules('required|length[3,200]')->value($member_data->town);
|
||
$form->input('zip_code')->label(url_lang::lang('texts.zip code').':')->rules('required|length[5,10]')->value($member_data->ZIP_code);
|
||
}
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_phone')) $form->input('phone')->label(url_lang::lang('texts.phone').':')->rules('required|length[3,40]')->callback(array($this, 'valid_phone'))->value($member_data->phone);
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_email')) $form->input('email')->label(url_lang::lang('texts.email').':')->rules('required|length[3,50]|valid_email')->callback(array($this, 'valid_email'))->value($member_data->email);
|
||
|
||
$form->group('')->label(url_lang::lang('texts.Account informations'));
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_currentcredit')) $form->input('current_credit')->label(url_lang::lang('texts.Current credit').':')->rules('valid_numeric')->value($member_data->current_credit);
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_en_fee')) $form->input('entrance_fee')->label(url_lang::lang('texts.Entrance fee').':')->rules('valid_numeric')->value($member_data->entrance_fee);
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_en_fee_left')) $form->input('entrance_fee_left')->label(url_lang::lang('texts.Entrance fee left').':')->rules('valid_numeric')->value($member_data->entrance_fee_left);
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_debit')) $form->input('debt_payment_rate')->label(url_lang::lang('texts.Debit payment rate').':')->rules('valid_numeric')->value($member_data->debt_payment_rate);
|
||
|
||
$form->group('')->label(url_lang::lang('texts.Completive informations'));
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_qos_ceil')) $form->input('qos_ceil')->label(url_lang::lang('texts.qos ceil').':')->rules('valid_numeric')->value($member_data->qos_ceil);
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_qos_rate')) $form->input('qos_rate')->label(url_lang::lang('texts.qos rate').':')->rules('valid_numeric')->value($member_data->qos_rate);
|
||
$form->date('birthday')->label(url_lang::lang('texts.birthday').':')->years(date('Y')-100, date('Y'))->rules('required')->value(strtotime($member_data->birthday));
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_entrance_date')) $form->date('entrance_date')->label(url_lang::lang('texts.Entrance date').':')->years(date('Y')-100, date('Y'))->rules('required')->value(strtotime($member_data->entrance_date));
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_comment')) $form->textarea('comment')->label(url_lang::lang('texts.Comment').':')->rules('length[0,250]')->value($member_data->comment);
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_must_pay')) $form->radio('must_pay_regular_fee')->label(url_lang::lang('texts.Must pay regular fee').':')->options(array('1'=>url_lang::lang('texts.Yes'),'0'=>url_lang::lang('texts.No')))->default((int)$member_data->must_pay_regular_fee);
|
||
|
||
$form->submit('submit')->value(url_lang::lang('texts.Edit'));
|
||
special::required_forge_style($form, ' *', 'required');
|
||
|
||
if($form->validate())
|
||
{
|
||
$form_data = $form->as_array();
|
||
foreach($form_data as $key => $value)
|
||
{
|
||
$form_data[$key] = htmlspecialchars($value);
|
||
}
|
||
$user_data = new User_Model;
|
||
$member_data = new Member_Model;
|
||
|
||
$member_data->find_by_id($member_id);
|
||
$user_data->where('type!=','user');
|
||
$user_data->find_by_member_id($member_id);
|
||
|
||
//print_r($member_data);die();
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_name')) $user_data->name = $form_data['name'];
|
||
$user_data->middle_name = $form_data['middle_name'];
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_username')) $user_data->login = $form_data['username'];
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_surname')) $user_data->surname = $form_data['surname'];
|
||
$user_data->pre_title = $form_data['pre_title'];
|
||
$user_data->post_title = $form_data['post_title'];
|
||
$user_data->birthday = date("Y-m-d",$form_data['birthday']);
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_phone')) $user_data->phone = $form_data['phone'];
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_email')) $user_data->email = $form_data['email'];
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_type')) $user_data->type = $form_data['type'];
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_comment')) $user_data->comment = $form_data['comment'];
|
||
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_entrance_date')) $member_data->entrance_date = date("Y-m-d",$form_data['entrance_date']);
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_membersname')) $member_data->name = $form_data['membername'];;
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_address'))
|
||
{ $member_data->street = $form_data['street'];
|
||
$member_data->street_number = $form_data['street_number'];
|
||
$member_data->town = $form_data['town'];
|
||
$member_data->ZIP_code = $form_data['zip_code'];
|
||
}
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_qos_ceil')) $member_data->qos_ceil = $form_data['qos_ceil'];
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_qos_rate')) $member_data->qos_rate = $form_data['qos_rate'];
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_en_fee')) $member_data->entrance_fee = $form_data['entrance_fee'];
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_en_fee_left')) $member_data->entrance_fee_left = $form_data['entrance_fee_left'];
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_debit')) $member_data->debt_payment_rate = $form_data['debt_payment_rate'];
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_currentcredit')) $member_data->current_credit = $form_data['current_credit'];
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_must_pay')) $member_data->must_pay_regular_fee = $form_data['must_pay_regular_fee'];
|
||
|
||
|
||
$member_saved = $member_data->save();
|
||
$user_data->member_id = $member_data->id;
|
||
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_type')) Controller::insert_phpgacl($user_data->id,$user_data->surname.' '.$user_data->name,$user_data->login,$form_data['type'], true);
|
||
unset($form_data);
|
||
if ($member_saved && $user_data->save())
|
||
{
|
||
$this->session->set_flash('message', url_lang::lang('texts.Member successfully updated.'));
|
||
}
|
||
else
|
||
{
|
||
$this->session->set_flash('message', url_lang::lang('texts.Error - cant update member.'));
|
||
}
|
||
url::redirect(url_lang::base().'members/show/'.(int)$member_id, 'redirect');
|
||
}
|
||
else
|
||
{
|
||
$view->form = new View('registration');
|
||
|
||
$view = new View('template');
|
||
|
||
$view->header = new View('base/header');
|
||
$view->content = new View('members_edit');
|
||
$view->footer = new View('base/footer');
|
||
$view->header->menu = Controller::render_menu();
|
||
$view->header->title = url_lang::lang('texts.Display member');
|
||
$view->header->other_styles = html::stylesheet('media/css/forms.css');
|
||
$view->content->form = $form->html();
|
||
$view->content->member_data = $member_data;
|
||
$view->render(TRUE);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Controller::error();
|
||
}
|
||
} // end of edit function
|
||
|
||
function valid_username($input)
|
||
{
|
||
$user_model=new User_Model();
|
||
if ($user_model->username_exist($input->value,$this->user_id) || trim($input->value)=='')
|
||
{
|
||
$input->add_error('required', url_lang::lang('texts.Username already exists in database.'));
|
||
}
|
||
}
|
||
|
||
function valid_phone($input)
|
||
{
|
||
$user_model=new User_Model();
|
||
if ($user_model->phone_exist($input->value,$this->user_id) || trim($input->value)=='')
|
||
{
|
||
$input->add_error('required', url_lang::lang('texts.Phone already exists in database.'));
|
||
}
|
||
}
|
||
|
||
function valid_email($input)
|
||
{
|
||
$user_model=new User_Model();
|
||
if ($user_model->email_exist($input->value,$this->user_id) || trim($input->value)=='')
|
||
{
|
||
$input->add_error('required', url_lang::lang('texts.Email already exists in database.'));
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
?>
|
freenetis/trunk/kohana/application/controllers/ifaces.php | ||
---|---|---|
|
||
function index()
|
||
{
|
||
|
||
/*$segment_model = new Segment_Model();
|
||
$segment = $segment_model->find_by_id(2);
|
||
print_r($segment);
|
||
$test=$segment->iface; //$student->car,
|
||
//car is an object of type Car_Model
|
||
//echo 'Car:'. $test->name; //Retrieve name from the Car_Model
|
||
echo '<br>';*/
|
||
|
||
/*$segment_model=new Segment_Model(2);
|
||
$segments=$segment_model->find_related_ifaces();
|
||
print_r($segments);
|
||
foreach ($segments as $segment) {
|
||
echo $segment->name;
|
||
|
||
}
|
||
if ($segment_model->has_ifaces(2)) echo 'ahoj<br>';
|
||
else echo 'nema';*/
|
||
|
||
|
||
|
||
|
||
/*$iface_model=new Iface_Model();
|
||
$iface = $iface_model->find_by_id(1);
|
||
echo 'Segment:'.$iface->segment->name; //$car->student,
|
||
//student is an object of type Student_Model
|
||
echo '<br>';*/
|
||
|
||
//var_dump($iface);
|
||
|
||
url::redirect('ifaces/show_all');
|
||
}
|
||
|
||
... | ... | |
{
|
||
//---- delete session device ----
|
||
$this->session->del('ssDevice_id');
|
||
$this->session->del('ssIface_id');
|
||
|
||
$iface_model = new Iface_Model();
|
||
|
||
... | ... | |
'selector_increace' => 10, // increace
|
||
'selector_min' => 10, // minimum where selector start
|
||
'selector_max_multiplier' => 5,
|
||
'base_url' => Config::item('locale.lang').'/ifaces/show_all/'.$limit_results.'/'.$order_by.'/'.$order_by_direction ,
|
||
'base_url' => Config::item('locale.lang').'/devices/show_all/'.$limit_results.'/'.$order_by.'/'.$order_by_direction ,
|
||
'uri_segment' => 'page', // pass a string as uri_segment to trigger former 'label' functionality
|
||
'total_items' => $total_ifaces, // use db count query here of course
|
||
'items_per_page' => $limit_results, // it may be handy to set defaults for stuff like this in config/pagination.php
|
||
... | ... | |
$grid->action_field('id')->label(url_lang::lang('texts.Delete')) ->url('delete') ->action(url_lang::lang('texts.Delete'))->class('center');
|
||
$grid->datasource( $query );
|
||
$this->template->content = $grid;
|
||
|
||
// echo
|
||
|
||
$view = new View('template');
|
||
|
||
... | ... | |
//=============================================================================
|
||
function show($iface_id = null)
|
||
{
|
||
$ssDevice_id = $this->session->get('ssDevice_id');
|
||
|
||
$iface = new Iface_Model($iface_id);
|
||
|
||
... | ... | |
|
||
$this->session->set('ssIface_id',$iface->id);
|
||
|
||
$this->session->del('ssVlan_iface_id');
|
||
|
||
//----------- list of IP ADDRESSES ---------------
|
||
$ip_model = new Ip_address_Model();
|
||
|
||
... | ... | |
));
|
||
|
||
$grid_ip_addresses->add_new_button('ip_addresses/add', url_lang::lang('texts.Add new IP address'));
|
||
$grid_ip_addresses->field('id')->label('ID')->class('center');
|
||
$grid_ip_addresses->field('IP_address')->label(url_lang::lang('texts.IP address'));
|
||
$grid_ip_addresses->field('id')->label('ID');
|
||
$grid_ip_addresses->field('IP_address')->label(url_lang::lang('texts.ip addresses'));
|
||
$grid_ip_addresses->field('subnet_name')->label(url_lang::lang('texts.Subnet name'));
|
||
$grid_ip_addresses->action_field('id')->label(url_lang::lang('texts.Show')) ->url(url_lang::base().'ip_addresses/show') ->action(url_lang::lang('texts.Show'))->class('center');
|
||
$grid_ip_addresses->action_field('id')->label(url_lang::lang('texts.Edit')) ->url(url_lang::base().'ip_addresses/edit') ->action(url_lang::lang('texts.Edit'))->class('center');
|
||
$grid_ip_addresses->action_field('id')->label(url_lang::lang('texts.Delete')) ->url('delete') ->action(url_lang::lang('texts.Delete'))->class('center');
|
||
$grid_ip_addresses->action_field('id')->label(url_lang::lang('texts.Show')) ->url(url_lang::base().'ip_addresses/show') ->action(url_lang::lang('texts.Show'));
|
||
$grid_ip_addresses->action_field('id')->label(url_lang::lang('texts.Edit')) ->url(url_lang::base().'ip_addresses/edit') ->action(url_lang::lang('texts.Edit'));
|
||
$grid_ip_addresses->action_field('id')->label(url_lang::lang('texts.Delete')) ->url('delete') ->action(url_lang::lang('texts.Delete'));
|
||
$grid_ip_addresses->datasource( $query );
|
||
|
||
|
||
//----------- list of VLAN INTERFACES ---------------
|
||
$VLAN_iface_model = new Vlan_iface_Model();
|
||
|
||
$query = $VLAN_iface_model->select(array('id','name'))->orderby('id','ASC')->find_all_by_iface_id($iface_id);
|
||
|
||
$grid_VLAN_ifaces = new Grid(url_lang::base().'ifaces', null,array(
|
||
'use_paginator' => false,
|
||
'use_selector' => false
|
||
));
|
||
|
||
$grid_VLAN_ifaces->add_new_button('vlan_ifaces/add', url_lang::lang('texts.Add new VLAN interface'));
|
||
$grid_VLAN_ifaces->field('id')->label('ID')->class('center');
|
||
$grid_VLAN_ifaces->field('name')->label(url_lang::lang('texts.Name'));
|
||
$grid_VLAN_ifaces->action_field('id')->label(url_lang::lang('texts.Show')) ->url(url_lang::base().'vlan_ifaces/show') ->action(url_lang::lang('texts.Show'))->class('center');
|
||
$grid_VLAN_ifaces->action_field('id')->label(url_lang::lang('texts.Edit')) ->url(url_lang::base().'vlan_ifaces/edit') ->action(url_lang::lang('texts.Edit'))->class('center');
|
||
$grid_VLAN_ifaces->action_field('id')->label(url_lang::lang('texts.Delete')) ->url('delete') ->action(url_lang::lang('texts.Delete'))->class('center');
|
||
$grid_VLAN_ifaces->datasource( $query );
|
||
|
||
if ($ssDevice_id) $link_back = html::anchor(url_lang::base().'devices/show/'.$ssDevice_id, url_lang::lang('texts.Back to device parameters'));
|
||
else $link_back = html::anchor(url_lang::base().'ifaces/show_all', url_lang::lang('texts.Back to interfaces list'));
|
||
|
||
|
||
|
||
$view = new View('template');
|
||
$view->header = new View('base/header');
|
||
... | ... | |
$view->content->iface = $iface;
|
||
$view->content->headline = url_lang::lang('texts.Interface detail').' - '.$iface->name;
|
||
$view->content->table_ip_addresses = $grid_ip_addresses;
|
||
$view->content->table_VLAN_ifaces = $grid_VLAN_ifaces;
|
||
$view->content->link_back = $link_back;
|
||
|
||
|
||
$view->footer = new View('base/footer');
|
||
|
||
$view->render(TRUE);
|
||
... | ... | |
//=============================================================================
|
||
function add()
|
||
{
|
||
$ssDevice_id = $this->session->get('ssDevice_id');
|
||
|
||
$ssDevice_id = $this->session->get('ssDevice_id');
|
||
|
||
$form = new Forge(url_lang::base()."ifaces/add/", '', 'POST', array('id' => 'article_form'));
|
||
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
|
||
... | ... | |
{
|
||
|
||
$device_model = new Device_Model();
|
||
$devices = $device_model->select(array('id','name'))->orderby('name')->find_all();
|
||
$devices = $device_model->select(array('id','name'))->orderby('id')->find_all();
|
||
$arr_devices[0] = '----- '.url_lang::lang('texts.select device').' -----';
|
||
foreach ($devices as $device) {
|
||
$arr_devices[$device->id] = $device->name;
|
||
... | ... | |
}
|
||
|
||
$segment_model = new Segment_Model();
|
||
$segments = $segment_model->select(array('id','name'))->orderby('name')->find_all();
|
||
$segments = $segment_model->select(array('id','name'))->orderby('id')->find_all();
|
||
$arr_segments[0] = '----- '.url_lang::lang('texts.select segment').' -----';
|
||
foreach ($segments as $segment) {
|
||
$arr_segments[$segment->id] = $segment->name;
|
||
... | ... | |
|
||
if ($iface->save()) {
|
||
$this->session->set_flash('message', url_lang::lang('texts.Interface is successfully saved.'));
|
||
url::redirect(url_lang::base().'ifaces/show/'.$iface->id, 'redirect');
|
||
url::redirect(url_lang::base().'devices/show/'.$ssDevice_id, 'redirect');
|
||
exit;
|
||
}
|
||
|
||
... | ... | |
else $link_back = html::anchor(url_lang::base().'ifaces/show_all/', url_lang::lang('texts.Back to interfaces list'));
|
||
|
||
$view = new View('template');
|
||
$view->header = new View('base/header');
|
||
// $view->content = new View('content', $data);
|
||
|
||
$view->header = new View('base/header');
|
||
$view->header->title = url_lang::lang('texts.Create new interface');
|
||
$view->header->menu = Controller::render_menu();
|
||
$view->content = new View('form');
|
||
$view->content->form = $form->html();
|
||
$view->content->link_back = $link_back;
|
||
$view->content->headline = url_lang::lang('texts.Create new interface');
|
||
|
||
$view->content = new View('form');
|
||
$view->content->form = $form->html();
|
||
$view->content->link_back = $link_back;
|
||
$view->content->headline = url_lang::lang('texts.Create new interface');
|
||
|
||
|
||
$view->footer = new View('base/footer');
|
||
|
||
$view->header->title = url_lang::lang('texts.Add new device');
|
||
$view->header->menu = Controller::render_menu();
|
||
$view->render(TRUE);
|
||
}
|
||
//----- end ADD ---------------------------------------------------------------
|
||
... | ... | |
|
||
//=============================================================================
|
||
//----- EDIT ------------------------------------------------------------------
|
||
//=============================================================================
|
||
//=============================================================================
|
||
function icontrol ()
|
||
{
|
||
|
||
}
|
||
function edit($iface_id = null)
|
||
{
|
||
$ssDevice_id = $this->session->get('ssDevice_id');
|
||
$ssIface_id = $this->session->get('ssIface_id');
|
||
|
||
$iface = new Iface_Model($iface_id);
|
||
|
||
... | ... | |
{
|
||
|
||
$device_model = new Device_Model();
|
||
$devices = $device_model->select(array('id','name'))->orderby('name')->find_all();
|
||
$devices = $device_model->select(array('id','name'))->orderby('id')->find_all();
|
||
$arr_devices[0] = '----- '.url_lang::lang('texts.select device').' -----';
|
||
foreach ($devices as $device) {
|
||
$arr_devices[$device->id] = $device->name;
|
||
... | ... | |
}
|
||
|
||
$segment_model = new Segment_Model();
|
||
$segments = $segment_model->select(array('id','name'))->orderby('name')->find_all();
|
||
$segments = $segment_model->select(array('id','name'))->orderby('id')->find_all();
|
||
$arr_segments[0] = '----- '.url_lang::lang('texts.select segment').' -----';
|
||
foreach ($segments as $segment) {
|
||
$arr_segments[$segment->id] = $segment->name;
|
||
... | ... | |
|
||
if ($iface->save()) {
|
||
$this->session->set_flash('message', url_lang::lang('texts.Interface is successfully updated.'));
|
||
url::redirect(url_lang::base().'ifaces/show/'.$iface->id, 'redirect');
|
||
url::redirect(url_lang::base().'devices/show/'.$ssDevice_id, 'redirect');
|
||
exit;
|
||
}
|
||
|
||
}
|
||
//----- end validate --------------------------------------------------
|
||
|
||
if ($ssIface_id) $link_back = html::anchor(url_lang::base().'ifaces/show/'.$ssIface_id, url_lang::lang('texts.Back to interface parameters'));
|
||
else $link_back = html::anchor(url_lang::base().'ifaces/show_all/', url_lang::lang('texts.Back to interfaces list'));
|
||
|
||
$view = new View('template');
|
||
$view->header = new View('base/header');
|
||
// $view->content = new View('content', $data);
|
||
|
||
$view = new View('template');
|
||
$view->header = new View('base/header');
|
||
$view->header->title = url_lang::lang('texts.Edit interface').' - '.$iface->name;
|
||
$view->header->menu = Controller::render_menu();
|
||
$view->content = new View('form');
|
||
$view->content->form = $form->html();
|
||
$view->content->link_back = html::anchor(url_lang::base().'ifaces/show/'.$iface_id, url_lang::lang('texts.Back to detail'));
|
||
$view->content->headline = url_lang::lang('texts.Edit interface').' - '.$iface->name;
|
||
|
||
$view->content = new View('form');
|
||
$view->content->form = $form->html();
|
||
$view->content->link_back = $link_back;
|
||
$view->content->headline = url_lang::lang('texts.Edit interface').' - '.$iface->name;
|
||
|
||
|
||
$view->footer = new View('base/footer');
|
||
|
||
$view->header->title = url_lang::lang('texts.Add new device');
|
||
$view->header->menu = Controller::render_menu();
|
||
$view->render(TRUE);
|
||
}
|
||
//----- end EDIT --------------------------------------------------------------
|
freenetis/trunk/kohana/application/controllers/users.php | ||
---|---|---|
<?php
|
||
class Users_Controller extends Controller {
|
||
|
||
function index($id_clena)
|
||
{
|
||
$this->load->model('Members', 'model_members');
|
||
protected $user_id = false;
|
||
|
||
print_r(get_class($this));
|
||
print_r(get_class_methods(get_class($this)));
|
||
$data['title'] = "Uživatelé";
|
||
$data['heading'] = "Uživatelé člena ".$this->model_members->get_name($id_clena);
|
||
function index()
|
||
{
|
||
url::redirect('users/show_all');
|
||
}
|
||
|
||
function show_all($limit_results = 50, $order_by = 'id', $order_by_direction = 'ASC')
|
||
{
|
||
if (!$this->gacl_class->acl_check('freenetis', 'view_all', 'all', $_SESSION['username'])) Controller::error(1);
|
||
// get new selector
|
||
if (is_numeric($this->input->get('record_per_page'))) $limit_results = (int) $this->input->get('record_per_page');
|
||
|
||
$this->model_users = new Users_Model;
|
||
$data['q_uzivatele'] = $this->model_users->get_where($id_clena);
|
||
// parameters control
|
||
$allowed_order_type = array('street', 'street_number', 'town', 'ZIP_code', 'type', 'name', 'surname','login','birthday','comment','phone','email', 'id', 'members_id');
|
||
if (!in_array(strtolower($order_by),$allowed_order_type)) $order_by = 'id';
|
||
if (strtolower($order_by_direction) != 'asc' && strtolower($order_by_direction) != 'desc') $order_by_direction = 'asc';
|
||
|
||
$this->load->library('session');
|
||
//if ($this->session->get('vypis')!='') $data['vypis'] = '<b>'.$this->session->get('vypis').'</b><br /><br />';
|
||
//else $data['vypis'] = '';
|
||
$data['vypis'] = ($this->session->get('vypis')!='') ? '<b>'.$this->session->get('vypis').'</b><br /><br />' : '';
|
||
$data['title'] = url_lang::lang('texts.Association members');
|
||
$data['heading'] = url_lang::lang('texts.Association members');
|
||
$model_users = new User_Model();
|
||
|
||
$total_users = $model_users->count_all_users(); // count all members in database
|
||
|
||
$url_array = explode('/', trim(url::current(), '/'));
|
||
$sql_offset = (isset($url_array[7])) ? (int) ($url_array[7] - 1) * $limit_results : 0;
|
||
unset($url_array);
|
||
$sql_offset = ($sql_offset>$total_users) ? 0 : $sql_offset;
|
||
$dotaz = $model_users->orderby($order_by,$order_by_direction)->limit($limit_results,$sql_offset)->find_all(); // get all members from database
|
||
|
||
$view = $this->load->view('users_index', $data);
|
||
$view->render(TRUE);
|
||
|
||
}
|
||
$grid = new Grid(url_lang::base().'users', null,array(
|
||
'separator' => '',
|
||
//'use_paginator' => false,
|
||
//'use_selector' => false,
|
||
'current' => $limit_results, // current selected 'records_per_page' value
|
||
'selector_increace' => 10, // increace
|
||
'selector_min' => 10, // minimum where selector start
|
||
'selector_max_multiplier' => 5,
|
||
'base_url' => Config::item('locale.lang').'/users/show_all/'.$limit_results.'/'.$order_by.'/'.$order_by_direction ,
|
||
'uri_segment' => 'page', // pass a string as uri_segment to trigger former 'label' functionality
|
||
'total_items' => $total_users, // use db count query here of course
|
||
'items_per_page' => $limit_results, // it may be handy to set defaults for stuff like this in config/pagination.php
|
||
'style' => 'classic',
|
||
'order_by' => $order_by,
|
||
'order_by_direction' => $order_by_direction,
|
||
'limit_results' => $limit_results
|
||
));
|
||
|
||
//$grid->add_new_button(url_lang::base().'users/add', url_lang::lang('texts.Add new user'));
|
||
$grid->order_field('id')->label('ID');
|
||
$grid->order_field('name')->label(url_lang::lang('texts.Name'));
|
||
$grid->order_field('surname')->label(url_lang::lang('texts.Surname'));
|
||
$grid->order_field('login')->label(url_lang::lang('texts.Username'));
|
||
$grid->order_field('email')->label('E-mail');
|
||
$grid->action_field('id') ->label(url_lang::lang('texts.Show')) ->url(url_lang::base().'users/show') ->action(url_lang::lang('texts.Show'));
|
||
$grid->action_field('id') ->label(url_lang::lang('texts.Edit')) ->url(url_lang::base().'users/edit') ->action(url_lang::lang('texts.Edit'));
|
||
$grid->action_field('id')->label(url_lang::lang('texts.Delete'))->url(url_lang::base().'users/delete')->action(url_lang::lang('texts.Delete'))->script('onclick="return potvrd(\''.url_lang::lang('texts.delete_user').'\');"');
|
||
$grid->datasource( $dotaz );
|
||
$this->template->content = $grid;
|
||
// echo
|
||
|
||
$view = new View('template');
|
||
$view->header = new View('base/header');
|
||
// $view->content = new View('content', $data);
|
||
$view->content = $this->template->content;
|
||
$view->footer = new View('base/footer');
|
||
$view->header->menu = Controller::render_menu();
|
||
$view->header->title = "Úprava uživatele";
|
||
//$view->content->heading = "Úprava uživatele ".$data['row']['name']." ".$data['row']['surname'];
|
||
//$view->content->form = $form->html();
|
||
$view->render(TRUE);
|
||
// */
|
||
} // end of show_all function
|
||
|
||
function icontrol($input)
|
||
function delete($user_id = NULL)
|
||
{
|
||
if (isset($user_id))
|
||
{
|
||
$user_model=new User_Model($user_id);
|
||
$member_id = $user_model->member_id;
|
||
|
||
if ($member_id == $_SESSION['member_id'])
|
||
{
|
||
if (!$this->gacl_class->acl_check('freenetis', 'delete_own', 'all', $_SESSION['username'])) Controller::error(1);
|
||
}
|
||
else
|
||
{
|
||
if (!$this->gacl_class->acl_check('freenetis', 'delete_all', 'all', $_SESSION['username'])) Controller::error(1);
|
||
}
|
||
|
||
if ($user_model->delete())
|
||
{
|
||
$this->session->set_flash('message', url_lang::lang('texts.User successfully deleted.'));
|
||
}
|
||
else
|
||
{
|
||
$this->session->set_flash('message', url_lang::lang('texts.Error - cant delete user.'));
|
||
}
|
||
url::redirect(url_lang::base().'members/show/'.$member_id, 'redirect');
|
||
}
|
||
else
|
||
{
|
||
Controller::error();
|
||
}
|
||
} // end of delete function
|
||
|
||
function edit($user_id = NULL)
|
||
{
|
||
if (!valid::alpha($input->value, true)) $input->add_error('required', "Hodnota ".$input->label." může obsahovat pouze alfabetické znaky.");
|
||
return true;
|
||
}
|
||
if (isset($user_id))
|
||
{
|
||
|
||
$user_model=new User_Model();
|
||
$user_model->find($user_id);
|
||
$this->user_id = $user_id;
|
||
if ($user_model->login == $_SESSION['username'] || $user_model->member_id == $_SESSION['member_id'])
|
||
{
|
||
if (!$this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'])) Controller::error(1);
|
||
}
|
||
else
|
||
{
|
||
if (!$this->gacl_class->acl_check('freenetis', 'edit_all', 'all', $_SESSION['username'])) Controller::error(1);
|
||
}
|
||
$form = new Forge(url_lang::base().'users/edit/'.$user_id, '', 'POST', array('id' => 'article_form'));
|
||
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
|
||
|
||
function edit($id, $m_id = 0)
|
||
{
|
||
$this->model_users = new Users_Model;
|
||
$data['row'] = $this->model_users->get_user($id);
|
||
$this->model_members = new Members_Model;
|
||
$data['jmeno_clena'] = $this->model_members->get_name($data['row']['id_member']);
|
||
$form->group('')->label(url_lang::lang('texts.Basic informations'));
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_username')) $form->input('username')->label(url_lang::lang('texts.username').':')->rules('required|length[3,50]')->callback(array($this, 'valid_username'))->value($user_model->login);
|
||
|
||
$form->input('pre_title')->label(url_lang::lang('texts.pre title').':')->rules('length[3,40]')->value($user_model->pre_title);
|
||
$form->input('name')->label(url_lang::lang('texts.name').':')->rules('required|length[3,30]')->value($user_model->name);
|
||
$form->input('middle_name')->label(url_lang::lang('texts.middle name').':')->rules('length[3,30]')->value($user_model->middle_name);
|
||
$form->input('surname')->label(url_lang::lang('texts.surname').':')->rules('required|length[3,60]')->value($user_model->surname);
|
||
$form->input('post_title')->label(url_lang::lang('texts.post title').':')->rules('length[3,30]')->value($user_model->post_title);
|
||
$form->group('')->label(url_lang::lang('texts.Contact informations'));
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_phone')) $form->input('phone')->label(url_lang::lang('texts.phone').':')->rules('required|length[3,40]')->callback(array($this, 'valid_phone'))->value($user_model->phone);
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_email')) $form->input('email')->label(url_lang::lang('texts.email').':')->rules('required|length[3,50]|valid_email')->callback(array($this, 'valid_email'))->value($user_model->email);
|
||
|
||
$form->group('')->label(url_lang::lang('texts.Completive informations'));
|
||
$form->date('birthday')->label(url_lang::lang('texts.birthday').':')->years(date('Y')-100, date('Y'))->rules('required')->value(strtotime($user_model->birthday));
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_own', 'all', $_SESSION['username'],get_class($this),'edit_comment')) $form->textarea('comment')->label(url_lang::lang('texts.Comment').':')->rules('length[0,250]')->value($user_model->comment);
|
||
$form->submit('submit')->value(url_lang::lang('texts.Edit'));
|
||
special::required_forge_style($form, ' *', 'required');
|
||
|
||
if($form->validate())
|
||
{
|
||
$form_data = $form->as_array();
|
||
foreach($form_data as $key => $value)
|
||
{
|
||
$form_data[$key] = htmlspecialchars($value);
|
||
}
|
||
$user_data = new User_Model;
|
||
$user_data->find($user_id);
|
||
$form_data['birthday'] = date("Y-m-d",$form_data['birthday']);
|
||
if ($this->gacl_class->acl_check('freenetis', 'edit_username', 'all', $_SESSION['username'],get_class($this),'edit_username')) $form_data['login'] = $form_data['username'];
|
||
foreach($form_data as $key => $value)
|
||
{
|
||
$user_data->$key = $value;
|
||
}
|
||
|
||
if ($user_data->save())
|
||
{
|
||
$this->session->set_flash('message', url_lang::lang('texts.User successfully updated.'));
|
||
}
|
||
else
|
||
{
|
||
$this->session->set_flash('message', url_lang::lang('texts.Error - cant update user.'));
|
||
}
|
||
url::redirect(url_lang::base().'users/show/'.(int)$user_id, 'redirect');
|
||
}
|
||
else
|
||
{
|
||
$view->form = new View('registration');
|
||
|
||
$view = new View('template');
|
||
$view->header = new View('base/header');
|
||
$view->content = new View('users_edit');
|
||
$view->footer = new View('base/footer');
|
||
$view->header->menu = Controller::render_menu();
|
||
$view->header->title = url_lang::lang('texts.Display member');
|
||
// $view->header->other_styles = html::stylesheet('media/css/forms.css');
|
||
$view->content->form = $form->html();
|
||
$view->content->user_data = $user_model;
|
||
$view->render(TRUE);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Controller::error();
|
||
}
|
||
} // end of edit function
|
||
|
||
function show($user_id = NULL)
|
||
{
|
||
if (isset($user_id))
|
||
{
|
||
$model_users = new User_Model($user_id);
|
||
if ($model_users->login == $_SESSION['username'] || $model_users->member_id == $_SESSION['member_id'])
|
||
{
|
||
if (!$this->gacl_class->acl_check('freenetis', 'view_own', 'all', $_SESSION['username'])) Controller::error(1);
|
||
}
|
||
else
|
||
{
|
||
if (!$this->gacl_class->acl_check('freenetis', 'view_all', 'all', $_SESSION['username'])) Controller::error(1);
|
||
}
|
||
$model_contacts = new Contact_Model();
|
||
$contacts = $model_contacts->find_all_by_user_id($user_id);
|
||
$model_works = new Job_Model();
|
||
//echo "jmeno je ". $model_users->member->name;
|
||
// ********** VIEW WORKS **********
|
||
|
||
$form = new Forge(url_lang::base()."users/edit/".$id."/".$data['row']['id_member']."", '', 'POST', array('id' => 'article_form'));
|
||
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
|
||
$form->input('name')->label('Jméno')->rules('required|length[3,40]')->value($data['row']['name'])->callback(array($this, 'icontrol'));
|
||
$form->input('surname')->label('Příjmení')->rules('required|length[3,40]')->value($data['row']['surname']);
|
||
$form->input('phone')->label('Telefon')->rules('required|length[3,40]|valid_numeric')->value($data['row']['phone']);
|
||
$form->input('email')->label('Email')->rules('required|valid_email')->value($data['row']['email']);
|
||
$form->submit('submit')->value('Upravit');
|
||
$grid = new Grid(url_lang::base().'members', null,array(
|
||
'separator' => '<br /><br />',
|
||
'use_paginator' => false,
|
||
'use_selector' => false
|
||
),'work_grid_template');
|
||
|
||
if($form->validate())
|
||
|
||
if ($this->gacl_class->acl_check('freenetis', 'view_own', 'all', $_SESSION['username'],get_class($this),'add_work')) $grid->add_new_button(url_lang::base().'users/add_work/'.$user_id, url_lang::lang('texts.Add new work'));
|
||
|
||
$grid->field('id')->label('ID');
|
||
$grid->field('description')->label(url_lang::lang('texts.Description'));
|
||
$grid->field('hours')->label(url_lang::lang('texts.Hours'));
|
||
$grid->action_field('u_name')->label(url_lang::lang('texts.Confirmed by'))->url(url_lang::base().'users/edit')->action(url_lang::lang('texts.Show transfer'));
|
||
$grid->action_field('transfer_id')->label(url_lang::lang('texts.Money transfer'))->url(url_lang::base().'accounts/trans_detail')->action(url_lang::lang('texts.Edit'))->nextval($model_users->member_id);
|
||
$grid->action_field('id') ->label(url_lang::lang('texts.Edit'))->url(url_lang::base().'users/edit_work')->action(url_lang::lang('texts.Edit'));
|
||
$grid->action_field('id') ->label(url_lang::lang('texts.Delete'))->url(url_lang::base().'users/delete_work')->action(url_lang::lang('texts.Delete'))->script('onclick="return potvrd(\''.url_lang::lang('texts.delete_work').'\');"');;
|
||
//print_r($model_works->get_wokrs($user_id)->current());die();
|
||
$grid->datasource( $model_works->get_jobs($user_id) );
|
||
|
||
$view = new View('template');
|
||
$view->header = new View('base/header');
|
||
$view->content = new View('users_show');
|
||
$view->footer = new View('base/footer');
|
||
$view->header->menu = Controller::render_menu();
|
||
$view->header->title = url_lang::lang('texts.Display user');
|
||
//$view->content->heading = "Úprava uživatele ".$data['row']['name']." ".$data['row']['surname'];
|
||
// $view->content->user_data = $model_users->get_user($user_id)->current();
|
||
$view->content->user_data = $model_users;
|
||
$view->content->contacts = $contacts;
|
||
$view->content->works = $grid ;
|
||
$view->content->message = $this->session->get_once('message');
|
||
$view->render(TRUE);
|
||
|
||
}
|
||
else
|
Také k dispozici: Unified diff