plugin->getInstitution($institution); } else { $institution = "NULL"; } $q = "UPDATE " . DB_PREFIX . "users SET"; $q .= " first_name = '". $first_name . "',"; $q .= " last_name = '". $last_name . "',"; $q .= " email = '". $email . "',"; $q .= " role = ". $role . ","; $q .= " institution = ". $institution . ""; $q .= " WHERE id=".$id; $update = query_update($q); if ($update) { return $id; } return 0; } function getUsers($order='fullname', $limit=20, $offset=0) { $user_role = get_logged_in_user()->level; $query = "SELECT *, concat(first_name, ' ', last_name) AS fullname FROM " . DB_PREFIX . "users"; $query .= $this->getWhereQuery(); $query .= " ORDER BY {$order} ASC"; $query .= " LIMIT {$limit} OFFSET {$offset}"; $res = query_rows($query); return $res; } function getUser($id) { $query = "SELECT *, concat(first_name, ' ', last_name) AS fullname FROM " . DB_PREFIX . "users"; $query .= " WHERE id = {$id}"; $res = query_row($query); return $res; } function getWhereQuery() { $user_role = get_logged_in_user()->level; $query = " WHERE role <= {$user_role}"; return $query; } function getPageCount($limit=20) { $query = "SELECT * FROM ". DB_PREFIX . $this->table; $query .= $this->getWhereQuery(); $total_count = mysql_num_rows(query($query)); $last_page = ceil($total_count/$limit); return $last_page; } function getProctors($order='fullname') { $query = "SELECT *, concat(first_name, ' ', last_name) AS fullname FROM " . DB_PREFIX . "users"; $query .= " WHERE role = 5"; $query .= " ORDER BY {$order} ASC"; $res = query_rows($query); return $res; } function getInstitutionProctors($institution_id) { $query = "SELECT *, concat(first_name, ' ', last_name) AS fullname FROM " . DB_PREFIX . "users"; $query .= " WHERE institution = {$institution_id} AND role = 5"; $query .= " ORDER BY fullname ASC"; $res = query_rows($query); return $res; } } ?>