summaryrefslogtreecommitdiffstats
path: root/application/controllers/user.php
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/controllers/user.php
parent2015e32e3bd6922d0697a875ecdc810243c887f0 (diff)
Add profile page to allow changing the upload id limits
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/controllers/user.php')
-rw-r--r--application/controllers/user.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/application/controllers/user.php b/application/controllers/user.php
index 79e54e84a..abbb846a3 100644
--- a/application/controllers/user.php
+++ b/application/controllers/user.php
@@ -317,6 +317,65 @@ class User extends CI_Controller {
$this->load->view('footer', $this->data);
}
+ function profile()
+ {
+ $this->muser->require_access();
+
+ $this->data["profile_data"] = $this->muser->get_profile_data();
+
+ $this->load->view('header', $this->data);
+ $this->load->view($this->var->view_dir.'profile', $this->data);
+ $this->load->view('footer', $this->data);
+ }
+
+ function save_profile()
+ {
+ $this->muser->require_access();
+
+ /*
+ * Key = name of the form field
+ * Value = function that sanatizes the value and returns it
+ * TODO: some kind of error handling that doesn't loose correctly filled out fields
+ */
+ $value_processor = array();
+
+ $value_processor["upload_id_limits"] = function($value) {
+ $values = explode("-", $value);
+
+ if (!is_array($values) || count($values) != 2) {
+ show_error("Invalid upload id limit value");
+ }
+
+ $lower = intval($values[0]);
+ $upper = intval($values[1]);
+
+ if ($lower > $upper) {
+ show_error("lower limit > upper limit");
+ }
+
+ if ($lower < 3 || $upper > 64) {
+ show_error("upper or lower limit out of bounds (3-64)");
+ }
+
+ return $lower."-".$upper;
+ };
+
+ $data = array();
+ foreach (array_keys($value_processor) as $field) {
+ $value = $this->input->post($field);
+
+ if ($value !== false) {
+ $data[$field] = $value_processor[$field]($value);
+ }
+ }
+
+ if (!empty($data)) {
+ $this->muser->update_profile($data);
+ }
+
+ redirect("user/profile");
+ }
+
function logout()
{
$this->muser->logout();