Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 134

Přidáno uživatelem Michal Kliment před asi 16 roky(ů)

i18n/cs_CZ/texts.php - pridany nektere preklady
models/device.php - do funkce get_all_members pridan filter
models/user.php - pridana metoda count_all_by_member (viz dalsi bod)
controllers/users.php - pridany funkce show_by_member,
ktera vypisuje uzivatele pro jednotlive cleny
controllers/members.php - opraven odkaz Vypis uzivatele
controllers/devices.php - pridan filter ve funkci show_all
libraries/OrderField.php - pridana podpora query stringu, nyni filter
funguje i po zmene razeni

Zobrazit rozdíly:

freenetis/trunk/kohana/application/i18n/cs_CZ/texts.php
'ip addresses list' => 'Seznam IP adres',
'ip addresses' => 'IP adresy',
'list of all members'=> 'Seznam všech členů',
'list of all users'=> 'Seznam všech uživatelů',
'list of all users'=> 'Seznam všech uživatelů',
'list of users of member'=> 'Seznam uživatelů člena',
'location address' => 'Adresa umístění',
'location details' => 'Detaily umístění',
'logged user' => 'Přihlášený uživatel',
......
'member have to own ONE double entry account.'=> 'Člen musí mít jeden podvojný účet',
'member successfully added.'=> 'Člen úspěšně přidán.',
'member successfully updated.'=> 'Člen úspěšně upraven.',
'members account'=> 'Účet člena',
'members account'=> 'Účet člena',
'members name'=> 'Jméno člena (organizace)',
'members firstname and surname'=> 'Jméno a příjmení člena (jméno organizace)',
'members' => 'Členové',
'middle name' => 'Prostřední jméno',
......
'project account'=> 'Účet projektu',
'qos ceil'=> 'Ceil (max-limit) pro QoS',
'qos rate'=> 'Rate (limit-at) pro QoS',
'really delete this account'=> 'Opravdu smazat tento účet',
'register' => 'Registrovat',
'really delete this account'=> 'Opravdu smazat tento účet',
'reg' => 'Přih.',
'register' => 'Registrovat',
'registration' => 'Přihláška',
'registration form' => 'Registrační formulář',
'save changes'=> 'Uložit změny',
'save' => 'Uložit',
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', $user_id = null, $filters = array())
{
//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->select(array('CONCAT(users.name,\' \',users.surname) as u_name', 'devices.*'))->from('devices')->join('users', 'users.id = devices.user_id')->get();
$arr_sql = array('name' => 'd.name', 'user' => 'concat(users.name,\' \',users.surname)');
$where = '';
if(count($filters)>0) $where .= 'WHERE ';
foreach($filters as $key => $value)
{
if($key!='submit')
{
if($where!='WHERE ') $where .= ' AND ';
$where .= $arr_sql[$key].' LIKE \'%'.$value.'%\'';
}
}
if (isset($user_id))
{
if($where=='') $where .= 'WHERE d.user_id='.$user_id.'';
else $where .= ' AND d.user_id'.$user_id.'';
}
return self::$db->query('SELECT d.id,IFNULL(f.translated_term,e.value) as type,d.name, 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 d
freenetis/trunk/kohana/application/models/user.php
public function count_all_users()
{
return (int) self::$db->count_records('users');
}
public function count_all_users_by_member($member_id = NULL)
{
return (int) self::$db->where('member_id',$member_id)->count_records('users');
}
public function username_exist($username, $user_id = null)
freenetis/trunk/kohana/application/controllers/members.php
$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_members) ? 0 : $sql_offset;
$sql_offset = ($sql_offset>$total_members) ? 0 : $sql_offset;
$filter=new Table_Form("get", array(
"name"=>"Name",
"town"=>"Town",
"tr",
"street"=>"Street",
"td",
"submit"=>"Filter"
)
);
if ($this->input->post()) {
$dotaz = $model_members->like(array(
"name" =>$this->input->post("filter_name"),
"town" =>$this->input->post("filter_town"),
"street" =>$this->input->post("filter_street")
)) -> orderby('id', $order_by_direction)
-> limit($limit_results, $sql_offset)
-> find_all();
} else
$dotaz = $model_members->orderby($order_by, $order_by_direction)->limit($limit_results, $sql_offset)->find_all();
+
$dotaz = $model_members
-> like($filter->values())
-> orderby($order_by, $order_by_direction)
-> limit($limit_results, $sql_offset)
-> find_all();
// $dotaz = $model_members->get_all_members($sql_offset, (int)$limit_results, $order_by, $order_by_direction); // get all members from database
// $dotaz = $model_members->get_all_members();
......
'style' => 'classic',
'order_by' => $order_by,
'order_by_direction' => $order_by_direction,
'limit_results' => $limit_results
'limit_results' => $limit_results,
'query_string' => $this->input->get()
));
if ($this->acl_check_2D('freenetis', 'new_all'))
$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('id')->label('ID');
$grid->order_field('id')->label('ID');
$grid->order_field('registration')->label(url_lang::lang('texts.Reg'))->bool(array(url_lang::lang('texts.No'),url_lang::lang('texts.Yes')))->class('center');
$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->action_field('id') ->label(url_lang::lang('texts.Member')) ->url(url_lang::base().'members/show') ->action(url_lang::lang('texts.Show'));
if ($this->acl_check_2D('freenetis', 'edit_all'))
$grid->action_field('id') ->label(url_lang::lang('texts.Member')) ->url(url_lang::base().'members/edit') ->action(url_lang::lang('texts.Edit'));
$grid->action_field('id') ->label(url_lang::lang('texts.User')) ->url(url_lang::base().'users/show') ->action(url_lang::lang('texts.Show user'));
$grid->action_field('id') ->label(url_lang::lang('texts.User')) ->url(url_lang::base().'users/show_by_member') ->action(url_lang::lang('texts.Show users'));
// if ($this->acl_check_2D('freenetis', 'delete_all'))
// $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 );
......
$view = new View('template');
$view->header = new View('base/header');
// $view->content = new View('content', $data);
$filter = new View('members_filter');
$view->content = $filter . $grid;
$view->content = $filter->view . $grid;
$view->footer = new View('base/footer');
$view->header->menu = Controller::render_menu();
$view->header->title = url_lang::lang('texts.List of all members');
......
{
// IE dont render TD border if content is NULL, so we must put nbsp into empty fields.
if (trim($val)=='') $member_data->$key = ' ';
}
}
$registration_value = array('0'=>url_lang::lang('texts.No'),'1'=>url_lang::lang('texts.Yes'));
$member_data->registration = $registration_value[(bool)$member_data->registration];
$view->content->member_data = $member_data;
$view->content->member_type = $member_type;
$view->content->contact_types = $arr_contact_types;
......
->selected($member_data->typem);
}
if ($this->acl_check_3D('freenetis', 'edit_own', 'edit_membersname'))
$form->input('membername')->label(url_lang::lang('texts.Members name').':')->rules('required|length[3,60]')->value($member_data->namem);
$form->input('membername')->label(url_lang::lang('texts.Members firstname and surname').':')->rules('required|length[3,60]')->value($member_data->namem);
$form->group('')->label(url_lang::lang('texts.Contact informations'));
if ($this->acl_check_3D('freenetis', 'edit_own', 'edit_address'))
freenetis/trunk/kohana/application/controllers/users.php
//$view->content->form = $form->html();
$view->render(TRUE);
// */
} // end of show_all function
} // end of show_all function
function show_by_member($member_id = NULL, $limit_results = 200, $order_by = 'id', $order_by_direction = 'ASC')
{
if (!isset($member_id)) {
Controller::error();
} else {
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');
$member = new Member_Model($member_id);
// 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';
$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_by_member($member_id); // count all members in database
$url_array = explode('/', trim(url::current(), '/'));
$sql_offset = (isset($url_array[8])) ? (int) ($url_array[8] - 1) * $limit_results : 0;
unset($url_array);
$sql_offset = ($sql_offset>$total_users) ? 0 : $sql_offset;
$filter=new Table_Form("get", array(
"name"=>"Name",
"surname"=>"Surname",
"tr",
"email"=>"Email",
"phone"=>"Phone",
"tr",
"login"=>"Login name",
"td",
"submit"=>"Filter"
)
);
$dotaz=$model_users
-> like($filter->values())
-> orderby($order_by,$order_by_direction)
-> where('member_id',$member_id)
-> limit($limit_results,$sql_offset)
-> find_all();
$grid = new Grid(url_lang::base().'users', url_lang::lang('texts.List of users of member').' '.$member->name,array(
'separator' => '',
//'use_paginator' => false,
//'use_selector' => false,
'current' => $limit_results, // current selected 'records_per_page' value
'selector_increace' => 200, // increace
'selector_min' => 200, // minimum where selector start
'selector_max_multiplier' => 10,
'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,
'variables' => $member_id.'/',
'url_array_ofset' => 1,
'query_string' => $this->input->get()
));
//$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 );
$view = new View('template');
$view->header = new View('base/header');
$view->content = $filter->view . $grid;
$view->footer = new View('base/footer');
$view->header->menu = Controller::render_menu();
$view->header->title = url_lang::lang('texts.List of users of member').' '.$member->name;
//$view->content->heading = "Úprava uživatele ".$data['row']['name']." ".$data['row']['surname'];
//$view->content->form = $form->html();
$view->render(TRUE);
}
// */
}
function delete($user_id = NULL)
{
if (isset($user_id))
freenetis/trunk/kohana/application/controllers/devices.php
//$dotaz = $this->model_members->get_all_members($sql_offset, (int)$limit_results, $order_by, $order_by_direction); // get all members from database
//$dotaz = $device_model->find_all();
//$dotaz = $device_model->select(array('CONCAT(users.name,\' \',users.surname) as u_name', 'devices.*'))->join('users', 'devices.user_id = users.id')->orderby($order_by,$order_by_direction)->limit($limit_results,$sql_offset)->find_all();
$query = $device_model->get_all_devices($sql_offset, (int)$limit_results, $order_by, $order_by_direction);
//$dotaz = $device_model->select(array('CONCAT(users.name,\' \',users.surname) as u_name', 'devices.*'))->join('users', 'devices.user_id = users.id')->orderby($order_by,$order_by_direction)->limit($limit_results,$sql_offset)->find_all();
$filter=new Table_Form("get", array(
"name"=>"Name",
"user"=>"User",
"tr",
"td",
"submit"=>"Filter"
)
);
$filters = $filter->values();
$query = $device_model->get_all_devices($sql_offset, (int)$limit_results, $order_by, $order_by_direction, NULL, $filters);
$grid = new Grid(url_lang::base().'devices', null,array(
$grid = new Grid(url_lang::base().'devices', url_lang::lang('texts.Devices list'),array(
//'separator' => '<br />-----------',
//'use_paginator' => false,
//'use_selector' => false,
......
$view->header->title = url_lang::lang('texts.Devices list');
$view->header->menu = Controller::render_menu();
$view->content = new View('show_all');
$view->content->table = $this->template->content;
$view->content->headline = url_lang::lang('texts.Devices list');
$view->content = $filter->view . $grid;
/* $view->content->table = $this->template->content;
$view->content->headline = url_lang::lang('texts.Devices list');*/
$view->footer = new View('base/footer');
......
$query = $device_model->get_all_by_member($sql_offset, (int)$limit_results, $order_by, $order_by_direction, $member_id);
$total_devices=$device_model->count_last_query();
$grid = new Grid(url_lang::base().'devices/show_by_member', null,array(
//'separator' => '<br />-----------',
//'separator' => '&nbsp;&nbsp;-&nbsp;&nbsp;',
//'use_paginator' => false,
//'use_selector' => false,
'current' => $limit_results, // current selected 'records_per_page' value
freenetis/trunk/kohana/application/libraries/Order_field.php
$this->use_selector = $arguments['use_selector'];
$this->use_paginator = $arguments['use_paginator'];
$this->create_order_by_link($new_order,$arguments['order_by'],$arguments['order_by_direction'],$arguments['limit_results'],$arguments['url_array_ofset'],$arguments['variables']);
$this->create_order_by_link($new_order,$arguments['order_by'],$arguments['order_by_direction'],$arguments['limit_results'],$arguments['url_array_ofset'],$arguments['variables'],$arguments['query_string']);
}
public 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, $variables = '')
public 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, $variables = '', $query_string = array())
{
$url_array = explode('/', trim(url::current(), '/'));
if (count($url_array)<7)
......
$order_by_direction = $order_by_direction == 'ASC' ? 'DESC' : 'ASC';
}
$this->return_link = url_lang::base().$pre_url.$new_order_by.'/'.$order_by_direction.'/';
$this->return_link .= ($this->use_paginator) ? $url_array[6+$url_array_ofset].'/'.$url_array[7+$url_array_ofset] : '';
$this->return_link .= ($this->use_paginator) ? $url_array[6+$url_array_ofset].'/'.$url_array[7+$url_array_ofset] : '';
if(count($query_string)>0)
{
$query_link = '';
foreach($query_string as $key => $value) $query_link .= '&'.$key.'='.$value;
$query_link[0] = '?';
$this->return_link .= $query_link;
}
}
}
freenetis/trunk/kohana/application/libraries/Grid.php
protected $order_by_direction;
protected $limit_results;
protected $record_per_page = NULL;
protected $url_array_ofset = 0;
protected $url_array_ofset = 0;
protected $query_string = array();
public function __construct($base_uri, $title, $config = NULL, $template = FALSE)
{
......
}
public function add_new_button($uri, $label, $separator = '')
{
$this->template->add_button .= html::anchor($uri, $label).$separator;
{
$this->template->add_button = substr($this->template->add_button, 0, strlen($this->template->add_button)-2);
$this->template->add_button .= '|&nbsp;'.html::anchor($uri, $label).'&nbsp;|'.$separator;
}
......
'limit_results' => $this->limit_results,
'record_per_page' => $this->record_per_page,
'url_array_ofset' => $this->url_array_ofset,
'variables' => $this->variables,
'variables' => $this->variables,
'query_string' => $this->query_string,
'use_selector' => $this->use_selector,
'use_paginator' => $this->use_paginator
);
freenetis/trunk/kohana/application/libraries/MY_Controller.php
<ul>
<li>'.html::anchor(url_lang::base().$url, url_lang::lang('texts.My profile')).'</li>';
if ($this->acl_check_2D('menu', 'my_users')) $myMenu .= '<li>'.html::anchor(url_lang::base().'members/users/'.$this->session->get('member_id'), url_lang::lang('texts.My users')).'</li>';
if ($this->acl_check_2D('menu', 'my_users')) $myMenu .= '<li>'.html::anchor(url_lang::base().'users/show_by_member/'.$this->session->get('member_id'), url_lang::lang('texts.My users')).'</li>';
if ($this->acl_check_2D('menu', 'my_transfers')) $myMenu .= '<li>'.html::anchor(url_lang::base().'accounts/transfers/'.$this->session->get('member_id'), url_lang::lang('texts.My transfers')).'</li>';
if ($this->acl_check_2D('menu', 'my_devices')) $myMenu .= ' <li>'.html::anchor(url_lang::base().'devices/show_my', url_lang::lang('texts.My devices')).'</li>';
if ($this->acl_check_2D('menu', 'my_devices')) $myMenu .= ' <li>'.html::anchor(url_lang::base().'devices/show_by_member/'.$this->session->get('member_id'), url_lang::lang('texts.My devices')).'</li>';
$myMenu .= ' </ul>
</li>';
$acc_menu = '';
freenetis/trunk/kohana/application/views/members_show.php
<tr>
<th><?php echo url_lang::lang('texts.Type') ?></th>
<td><?php echo $member_type ?></td>
</tr>
<tr>
<th><?php echo url_lang::lang('texts.Registration') ?></th>
<td><?php echo $member_data->registration ?></td>
</tr>
<tr>
<th colspan="2"><?php echo url_lang::lang('texts.Contact informations') ?></th>

Také k dispozici: Unified diff