mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-24 18:40:13 +01:00
improved folder handling
This commit is contained in:
parent
a145554ea3
commit
3ea8ed50a5
68
webui/controller/folder/edit.php
Normal file
68
webui/controller/folder/edit.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
|
||||
class ControllerFolderEdit extends Controller {
|
||||
private $error = array();
|
||||
|
||||
public function index(){
|
||||
|
||||
$this->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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -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));
|
||||
|
||||
|
47
webui/view/theme/default/templates/folder/edit.tpl
Normal file
47
webui/view/theme/default/templates/folder/edit.tpl
Normal file
@ -0,0 +1,47 @@
|
||||
|
||||
<?php if(ENABLE_FOLDER_RESTRICTIONS == 1) { ?>
|
||||
|
||||
<form action="index.php?route=folder/edit" method="post" name="extra_folders" class="form-horizontal">
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="domain"><?php print $text_folder; ?>:</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="name" name="name" value="<?php print $folder['name']; ?>" />
|
||||
<input type="hidden" id="id" name="id" value="<?php print $folder['id']; ?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<input type="submit" value="<?php print $text_modify; ?>" class="btn btn-primary" />
|
||||
<input type="reset" value="<?php print $text_clear; ?>" class="btn" />
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
<div id="search">
|
||||
|
||||
<h4><?php print $text_existing_folders; ?></h4>
|
||||
|
||||
<table id="search1" class="table table-striped table-condensed">
|
||||
<thead>
|
||||
<th><?php print $text_folder; ?></th>
|
||||
<th> </th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($extra_folders as $folder) { ?>
|
||||
<tr>
|
||||
<td><?php print $folder['name']; ?></td>
|
||||
<td><a href="index.php?route=folder/edit&id=<?php print $folder['id']; ?>"><?php print $text_edit; ?></a></td>
|
||||
<td><a href="/folders.php?id=<?php print $folder['id']; ?>&remove=1"><?php print $text_remove; ?></a></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
|
||||
|
@ -26,13 +26,14 @@
|
||||
|
||||
<table id="search1" class="table table-striped table-condensed">
|
||||
<thead>
|
||||
<th><?php print $_['text_folder']; ?> <?php print $_['text_name']; ?></th>
|
||||
<th><?php print $text_folder; ?></th>
|
||||
<th> </th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($extra_folders as $folder) { ?>
|
||||
<tr>
|
||||
<td><?php print $folder['name']; ?></td>
|
||||
<td><a href="index.php?route=folder/edit&id=<?php print $folder['id']; ?>"><?php print $text_edit; ?></a></td>
|
||||
<td><a href="/folders.php?id=<?php print $folder['id']; ?>&remove=1"><?php print $text_remove; ?></a></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
Loading…
Reference in New Issue
Block a user