diff --git a/webui/controller/folder/edit.php b/webui/controller/folder/edit.php new file mode 100644 index 00000000..b27152a5 --- /dev/null +++ b/webui/controller/folder/edit.php @@ -0,0 +1,68 @@ +id = "content"; + $this->template = "folder/edit.tpl"; + $this->layout = "common/layout"; + + + $request = Registry::get('request'); + $db = Registry::get('db'); + + $this->load->model('folder/folder'); + + $this->document->title = $this->data['text_folders']; + + if(isset($this->request->post['name']) && $this->request->post['name']) { + $this->model_folder_folder->update_folder($this->request->post); + + Header("Location: folders.php"); + return; + } + + if(isset($this->request->get['id']) && $this->request->get['id'] > 0) { + $this->data['folder'] = $this->model_folder_folder->get_folder_by_id($this->request->get['id']); + } + + + $this->data['page_len'] = get_page_length(); + + $this->data['extra_folders'] = $this->model_folder_folder->get_folders_for_user(); + + $this->render(); + } + + + private function validate() { + + if(!isset($this->request->post['password']) || !isset($this->request->post['password2']) ) { + $this->error['password'] = $this->data['text_missing_password']; + } + + if(strlen(@$this->request->post['password']) < MIN_PASSWORD_LENGTH || strlen(@$this->request->post['password2']) < MIN_PASSWORD_LENGTH) { + $this->error['password'] = $this->data['text_invalid_password']; + } + + if($this->request->post['password'] != $this->request->post['password2']) { + $this->error['password'] = $this->data['text_password_mismatch']; + } + + + if (!$this->error) { + return true; + } else { + return false; + } + + } + + + +} + +?> diff --git a/webui/model/folder/folder.php b/webui/model/folder/folder.php index 411ac25f..a64256fa 100644 --- a/webui/model/folder/folder.php +++ b/webui/model/folder/folder.php @@ -187,6 +187,27 @@ class ModelFolderFolder extends Model { } + public function get_folder_by_id($id = 0) { + $query = $this->db->query("SELECT * FROM `" . TABLE_FOLDER . "` WHERE id=?", array($id)); + + if(isset($query->row)) { return $query->row; } + + return array(); + } + + + public function update_folder($data = array()) { + $rc = 0; + + if(isset($data['id']) && isset($data['name'])) { + $query = $this->db->query("UPDATE `" . TABLE_FOLDER . "` SET name=? WHERE id=?", array($data['name'], $data['id'])); + $rc = $this->db->countAffected(); + } + + return $rc; + } + + public function get_folder_id_by_id($id = 0) { $query = $this->db->query("SELECT folder_id FROM `" . TABLE_FOLDER_MESSAGE . "` WHERE id=?", array($id)); diff --git a/webui/view/theme/default/templates/folder/edit.tpl b/webui/view/theme/default/templates/folder/edit.tpl new file mode 100644 index 00000000..69e595e1 --- /dev/null +++ b/webui/view/theme/default/templates/folder/edit.tpl @@ -0,0 +1,47 @@ + + + +
+ + + + + + + + diff --git a/webui/view/theme/default/templates/folder/list.tpl b/webui/view/theme/default/templates/folder/list.tpl index c0e17730..85590f65 100644 --- a/webui/view/theme/default/templates/folder/list.tpl +++ b/webui/view/theme/default/templates/folder/list.tpl @@ -26,13 +26,14 @@+ | ||
---|---|---|
+ |