Revize 1076
Přidáno uživatelem Ondřej Fibich před asi 13 roky(ů)
freenetis/branches/testing/application/models/device.php | ||
---|---|---|
public $arr_sql = array
|
||
(
|
||
'id' => 'd.id',
|
||
'devicename' => 'd.name',
|
||
'login' => 'u.login',
|
||
'device_name' => 'd.name',
|
||
'username' => 'concat(u.name,\' \',u.surname)',
|
||
'device_type' => 'd.type',
|
||
'member_id' => 'users.member_id'
|
||
... | ... | |
{
|
||
$where = '';
|
||
// filter
|
||
if (is_array($filter_values) && count($filter_values) > 1)
|
||
{
|
||
$where .= 'WHERE ';
|
||
|
||
if (is_array($filter_values))
|
||
{
|
||
foreach($filter_values as $key => $value)
|
||
{
|
||
if($key != 'submit')
|
||
{
|
||
if($where != 'WHERE ')
|
||
$where .= ' AND ';
|
||
$where .= empty($where) ? 'WHERE ' : ' AND ';
|
||
|
||
if (array_key_exists($key, $this->arr_sql))
|
||
{
|
||
if ($key != 'device_type' AND $key != 'member_id')
|
||
if ($key != 'device_type' && $key != 'member_id')
|
||
{
|
||
$where .= $this->arr_sql[$key].' LIKE ' . $this->db->escape("%$value%")
|
||
. ' COLLATE utf8_general_ci';
|
||
... | ... | |
$where .= $this->arr_sql[$key].' = '.$this->db->escape($value);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
$where .= $this->db->escape_column($key).' = '.$this->db->escape($value);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
... | ... | |
*/
|
||
public function get_all_devices($limit_from = 0, $limit_results = 50,
|
||
$order_by = 'device_id', $order_by_direction = 'ASC',
|
||
$user_id = null, $filters = array())
|
||
$user_id = null, $filter_values = array())
|
||
{
|
||
// order by check
|
||
if (in_array($order_by, $this->arr_sql))
|
||
{
|
||
$order_by = $this->arr_sql[$order_by];
|
||
}
|
||
else if (!$this->has_column($order_by))
|
||
else
|
||
{
|
||
$order_by = 'device_id';
|
||
$order_by = $this->db->escape_column($order_by);
|
||
}
|
||
// order by direction check
|
||
$order_by_direction = strtolower($order_by_direction);
|
||
if ($order_by_direction != 'desc')
|
||
if (strtolower($order_by_direction) != 'desc')
|
||
{
|
||
$order_by_direction = 'asc';
|
||
}
|
||
$where = '';
|
||
// filter
|
||
if (is_array($filter_values) && count($filter_values) > 1)
|
||
{
|
||
$where .= 'WHERE ';
|
||
|
||
if (is_array($filter_values))
|
||
{
|
||
foreach($filter_values as $key => $value)
|
||
{
|
||
if($key!='submit')
|
||
if($key != 'submit')
|
||
{
|
||
if($where!='WHERE ')
|
||
$where .= ' AND ';
|
||
$where .= empty($where) ? 'WHERE ' : ' AND ';
|
||
|
||
if (array_key_exists($key, $this->arr_sql))
|
||
{
|
||
if ($key != 'device_type' AND $key != 'member_id')
|
||
if ($key != 'device_type' && $key != 'member_id')
|
||
{
|
||
$where .= $this->arr_sql[$key].' LIKE ' . $this->db->escape("%$value%")
|
||
. ' COLLATE utf8_general_ci';
|
||
... | ... | |
$where .= $this->arr_sql[$key].' = '.$this->db->escape($value);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
$where .= $this->db->escape_column($key).' = '.$this->db->escape($value);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
... | ... | |
ORDER BY $order_by $order_by_direction
|
||
LIMIT " . intval($limit_from) . ", " . intval($limit_results) . "
|
||
", Config::get('lang'));
|
||
|
||
die($this->db->last_query());
|
||
} // end of get_all_devices
|
||
|
||
|
freenetis/branches/testing/application/models/login_log.php | ||
---|---|---|
*/
|
||
public function count_all_login_logs()
|
||
{
|
||
return $this->db->query('
|
||
SELECT COUNT(*) AS count
|
||
FROM (
|
||
SELECT *
|
||
FROM (
|
||
SELECT u.id, CONCAT(u.name,\' \',u.surname) AS name,
|
||
l.time AS last_time
|
||
FROM users u
|
||
LEFT JOIN login_logs l ON u.id = l.user_id
|
||
ORDER BY time DESC
|
||
) AS q1
|
||
GROUP BY q1.id
|
||
) AS q3
|
||
ORDER BY q3.last_time DESC
|
||
')->current()->count;
|
||
$user = new User_Model();
|
||
return $user->count_all();
|
||
}
|
||
|
||
/**
|
freenetis/branches/testing/application/controllers/devices.php | ||
---|---|---|
$arr_types[0] = '----- '.url_lang::lang('texts.select type').' -----';
|
||
asort($arr_types);
|
||
$filter = new Table_Form(url_lang::base()."devices/show_all", "get", array(
|
||
new Table_Form_Item('text','devicename','Name'),
|
||
new Table_Form_Item('text','username','User', array('username'=>'Unart')),
|
||
new Table_Form_Item('text','device_name','Name'),
|
||
new Table_Form_Item('text','login','User', array('username'=>'Unart')),
|
||
"tr",
|
||
new Table_Form_Item('select','device_type','Type', $arr_types),
|
||
"td",
|
freenetis/branches/testing/application/upgrade_sql/upgrade_sql.php | ||
---|---|---|
// array of sql queries that upgrade database
|
||
$upgrade_sql[get_SVN_rev()] = array(
|
||
|
||
"ALTER TABLE `phone_invoice_users` ADD `locked` TINYINT( 1 ) UNSIGNED NOT NULL COMMENT 'User locked his invoice as filled in.'"
|
||
// optimalization of login logs
|
||
"ALTER TABLE `login_logs` ADD INDEX ( `time` )",
|
||
// optimalization of contacts
|
||
"ALTER TABLE `contacts` ADD INDEX ( `type` )",
|
||
// optimalization of contacts
|
||
"ALTER TABLE `contacts` ADD INDEX ( `value` )"
|
||
|
||
);
|
freenetis/branches/testing/application/upgrade_sql/upgrade_sql_1064.php | ||
---|---|---|
<?php
|
||
function get_SVN_rev() {
|
||
$svnid = '$Rev$';
|
||
$svnid = substr($svnid , 6);
|
||
$svnid = substr($svnid , 0, -2);
|
||
return $svnid;
|
||
}
|
||
|
||
// array of sql queries that upgrade database
|
||
$upgrade_sql[1064] = array(
|
||
|
||
"ALTER TABLE `phone_invoice_users` ADD `locked` TINYINT( 1 ) UNSIGNED NOT NULL COMMENT 'User locked his invoice as filled in.'"
|
||
|
||
);
|
||
Také k dispozici: Unified diff
Opravy razeni zařízení.
Oprimalizace přihlašovacích logů a kontaktů.