summaryrefslogtreecommitdiffstats
path: root/application/models
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2013-07-13 22:30:54 +0200
committerFlorian Pritz <bluewind@xinu.at>2013-07-13 22:58:07 +0200
commitcabec2e1c8e468279f17bee9fb87f1676e8cec9a (patch)
tree9caf931dbf8edd67470a778493ac2740049c3c90 /application/models
parent2015e32e3bd6922d0697a875ecdc810243c887f0 (diff)
Add profile page to allow changing the upload id limits
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/models')
-rw-r--r--application/models/muser.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/application/models/muser.php b/application/models/muser.php
index 947b87d97..f7da8c1fd 100644
--- a/application/models/muser.php
+++ b/application/models/muser.php
@@ -8,6 +8,9 @@
*/
class Muser extends CI_Model {
+
+ private $default_upload_id_limits = "3-6";
+
function __construct()
{
parent::__construct();
@@ -157,6 +160,62 @@ class Muser extends CI_Model {
return $query;
}
+ public function get_profile_data()
+ {
+ $userid = $this->get_userid();
+
+ $fields = array(
+ "user" => $userid,
+ "upload_id_limits" => $this->default_upload_id_limits,
+ );
+
+ $query = $this->db->query("
+ SELECT ".implode(", ", array_keys($fields))."
+ FROM `profiles`
+ WHERE user = ?
+ ", array($userid))->row_array();
+
+ $extra_fields = array(
+ "username" => $this->get_username(),
+ "email" => $this->get_email($userid),
+ );
+
+ return array_merge($fields, $query, $extra_fields);
+ }
+
+ public function update_profile($data)
+ {
+ assert(is_array($data));
+
+ $data["user"] = $this->get_userid();
+
+ $exists_in_db = $this->db->get_where("profiles", array("user" => $data["user"]))->num_rows() > 0;
+
+ if ($exists_in_db) {
+ $this->db->where("user", $data["user"]);
+ $this->db->update("profiles", $data);
+ } else {
+ $this->db->insert("profiles", $data);
+ }
+ }
+
+ public function get_upload_id_limits()
+ {
+ $userid = $this->get_userid();
+
+ $query = $this->db->query("
+ SELECT upload_id_limits
+ FROM `profiles`
+ WHERE user = ?
+ ", array($userid))->row_array();
+
+ if (empty($query)) {
+ return $this->default_upload_id_limits;
+ }
+
+ return explode("-", $query["upload_id_limits"]);
+ }
+
function hash_password($password)
{