Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 768

Přidáno uživatelem Michal Kliment před více než 13 roky(ů)

Opravena drobna logicka chyba u validacni funkce telefonu uzivatele, ktera zabranovala editaci uzivatele. Dale u vypisu zarizeni uzivatele opraveno razeni podle IP adresy a spatny pocet vsech zarizeni uzivatele.

Zobrazit rozdíly:

freenetis/trunk/kohana/application/models/device.php
* @param $user_id
* @return unknown_type
*/
public function get_devices_of_user($limit_from = 0, $limit_results = 50, $order_by = 'inet_aton(ip.ip_address)', $order_by_direction = 'ASC', $user_id = null)
public function get_devices_of_user($limit_from = 0, $limit_results = 50, $order_by = 'id', $order_by_direction = 'ASC', $user_id = null)
{
if ($order_by == 'id')
$order_by = 'device_id';
else if ($order_by == 'ip_address')
$order_by = 'inet_aton(ip_address)';
return $this->db->query("SELECT
d.id AS device_id,
IFNULL(f.translated_term,e.value) as type,
......
*/
public function count_devices_of_user($user_id = null)
{
return $this->db->query("SELECT
COUNT(*) AS total
FROM devices d
return $this->db->query("SELECT * FROM devices d
JOIN users u ON d.user_id = u.id
LEFT JOIN ifaces i ON d.id = i.device_id
LEFT JOIN segments s ON s.id = i.segment_id
LEFT JOIN ip_addresses ip ON i.id = ip.iface_id
WHERE u.id = $user_id
")->current()->total;
GROUP BY d.id
")->count();
}
public function get_device_names($device_name)
freenetis/trunk/kohana/application/models/user.php
protected $has_and_belongs_to_many = array('users_contacts' => 'contacts');
public $arr_sql = array('id' => 'u.id', 'name' => 'u.name', 'surname' => 'u.surname', 'email' => 'u.email', 'phone' => 'u.phone', 'login' => 'u.login', 'member_name' => 'm.name');
/**
* Model constructor
*
* @param numeric $id
*/
public function __construct($id = false)
{
parent::__construct($id);
}
/**
* Returns all users
*
* @param numeric $limit_from
* @param numeric $limit_results
* @param string $order_by
* @param string $order_by_direction
* @param array $filter_values
* @param numeric $member_id
* @return Mysql_Result object
*/
public function get_all_users($limit_from = 0, $limit_results = 50, $order_by = 'id', $order_by_direction = 'ASC', $filter_values = array(), $member_id=NULL)
{
$where = '';
......
);
}
/**
* Login test function
*
* @param string $username
* @param string $password
* @return boolean
*/
public function login_request($username = '', $password = '')
{
$query = $this->db->from('users')->select('id')->where(array('login' => $username, 'password' => sha1($password)))->get();
return ($query->count()) ? $query->current()->id : 0;
// return (bool) $this->db->where('login', $username)->where('password', sha1($password))->count_records('user');
}
/**
* Counts all users
*
* @param array $filter_values
* @param numeric $member_id
* @return numeric
*/
public function count_all_users($filter_values = array(), $member_id=NULL)
{
$where = '';
......
return count($users);
}
/**
* Counts all users belong to member
*
* @param numeric $member_id
* @return numeric
*/
public function count_all_users_by_member($member_id = NULL)
{
return (int) $this->db->where('member_id',$member_id)->count_records('users');
}
/**
* Tests if username exist
*
* @param string $username
* @param numeric $user_id
* @return boolean
*/
public function username_exist($username, $user_id = null)
{
if (isset($user_id)) {
// tests if user_id is id of user with this username (for validation in user edit function)
if (isset($user_id))
{
$count=$this->db->where(array('login' => $username, 'id!=' => $user_id))->count_records('users');
//print_r("userid=$user_id, count=$count");
return (bool)$count;
}
else return (bool) $this->db->where('login', $username)->count_records('users');
}
/**
* Tests if phone exist
*
* @param string $phone
* @param numeric $user_id
* @return boolean
*/
public function phone_exist($phone, $user_id = null)
{
if (empty ($user_id) || !is_numeric($user_id))
......
return $this->db->query("
SELECT COUNT(*) AS count FROM users_contacts u
LEFT JOIN contacts c ON u.contact_id = c.id
WHERE u.user_id = ? AND c.type = ? AND c.value = ?
WHERE u.user_id <> ? AND c.type = ? AND c.value = ?
", array($user_id, Contact_Model::TYPE_PHONE, $phone))->current()->count > 0;
}
}
/**
* Tests if email exist
*
* @param string $email
* @param numeric $user_id
* @return boolean
*/
public function email_exist($email, $user_id = null)
{
if (empty ($user_id) || !is_numeric($user_id))
freenetis/trunk/kohana/application/controllers/devices.php
* Function shows all devices of user.
* @return unknown_type
*/
function show_by_user($user_id = null, $limit_results = 500, $order_by = 'id', $order_by_direction = 'asc', $page_word = null, $page = 1)
function show_by_user($user_id = null, $limit_results = 500, $order_by = 'ip_address', $order_by_direction = 'asc', $page_word = null, $page = 1)
{
if (!isset($user_id))
Controller::warning(PARAMETER);

Také k dispozici: Unified diff