improved the private feature

This commit is contained in:
SJ 2016-02-16 15:37:34 +01:00
parent 2fbb41264c
commit eb3ecfed56
6 changed files with 40 additions and 9 deletions

View File

@ -20,6 +20,7 @@ class ControllerMessagePrivate extends Controller {
$this->document->title = $this->data['text_message'];
$this->data['id'] = $this->request->post['id'];
$this->data['val'] = $this->request->post['val'];
if(!verify_piler_id($this->data['id'])) {
AUDIT(ACTION_UNKNOWN, '', '', $this->data['id'], 'unknown id: ' . $this->data['id']);
@ -36,9 +37,11 @@ class ControllerMessagePrivate extends Controller {
$this->data['username'] = Registry::get('username');
if(Registry::get('auditor_user') == 1) {
syslog(LOG_INFO, "hokamoka:" . $this->data['id']);
$this->model_search_message->mark_as_private($this->data['id']);
if($this->data['val'] == 1) {
$this->model_search_message->mark_as_private($this->data['id']);
} else {
$this->model_search_message->unmark_as_private($this->data['id']);
}
}

View File

@ -80,6 +80,8 @@ class ControllerMessageView extends Controller {
$this->data['message']['tag'] = $this->model_search_message->get_message_tag($this->data['id'], $session->get("uid"));
$this->data['message']['note'] = $this->model_search_message->get_message_note($this->data['id'], $session->get("uid"));
$this->data['message']['private'] = $this->model_search_message->get_message_private($this->data['id']);
$this->data['spam'] = $this->model_search_message->is_message_spam($this->data['id']);
$this->data['images'] = array();

View File

@ -879,6 +879,15 @@ class ModelSearchMessage extends Model {
}
public function unmark_as_private($id = 0) {
if($id > 0) {
$query = $this->db->query("DELETE FROM " . TABLE_PRIVATE . " WHERE id=?", array($id));
}
return 1;
}
public function get_message_tag($id = '', $uid = 0) {
if($id == '' || $uid <= 0) { return ''; }
@ -946,6 +955,15 @@ class ModelSearchMessage extends Model {
}
public function get_message_private($id = 0) {
if($id == 0) { return 0; }
$query = $this->db->query("SELECT `id` FROM " . TABLE_PRIVATE . " WHERE id=?", array($id));
if(isset($query->row['id'])) { return 1; }
return 0;
}
}

View File

@ -742,7 +742,7 @@ class ModelSearchSearch extends Model {
public function check_your_permission_by_id_list($id = array()) {
$q = $q2 = '';
$arr = $a = $result = array();
$arr = $parr = $a = $result = array();
if(count($id) < 1) { return $result; }
@ -801,6 +801,14 @@ class ModelSearchSearch extends Model {
if(Registry::get('auditor_user') == 1 && RESTRICTED_AUDITOR == 1) {
$query = $this->db->query("SELECT id FROM `" . VIEW_MESSAGES . "` WHERE `id` IN ($q2) AND ( `fromdomain` IN ($q) OR `todomain` IN ($q) )", $arr);
} else {
$query = $this->db->query("SELECT id FROM " . TABLE_PRIVATE . " WHERE `id` IN ($q2)", $id);
if($query->num_rows > 0) {
foreach ($query->rows as $r) {
array_push($parr, $r['id']);
}
}
$query = $this->db->query("SELECT id FROM `" . VIEW_MESSAGES . "` WHERE `id` IN ($q2) AND ( `from` IN ($q) OR `to` IN ($q) )", $arr);
}
@ -812,7 +820,7 @@ class ModelSearchSearch extends Model {
if(ENABLE_FOLDER_RESTRICTIONS == 1) {
if(in_array($q['folder'], $session->get("folders"))) { array_push($result, $q['id']); }
}
else if(!in_array($q['id'], $result)) {
else if(!in_array($q['id'], $result) && !in_array($q['id'], $parr)) {
array_push($result, $q['id']);
}
}

View File

@ -328,14 +328,14 @@ var Piler =
},
mark_as_private:function(id)
mark_as_private:function(id, val)
{
Piler.log("[mark_as_private]", id);
Piler.log("[mark_as_private]", id, val);
Piler.poor_mans_keepalive_for_dummy_browsers();
jQuery.ajax('index.php?route=message/private', {
data: { id: id },
data: { id: id, val: val },
type: "POST"
})
.done( function( a ) {})

View File

@ -26,7 +26,7 @@
| <a class="messagelink" href="#" onclick="Piler.view_journal(<?php print $id; ?>);"><i class="icon-envelope-alt"></i>&nbsp;<?php print $text_view_journal_envelope; ?></a>
<?php } ?>
<?php if(Registry::get('auditor_user') == 1) { ?>
| <a class="messagelink" href="#" onclick="Piler.mark_as_private(<?php print $id; ?>);"><i class="icon-bookmark-empty"></i>&nbsp;<?php print $text_private; ?></a>
| <a class="messagelink" href="#" onclick="Piler.mark_as_private(<?php print $id; ?>, <?php $message['private'] == 1 ? print "0" : print "1" ?>);"><i class="icon-bookmark<?php if($message['private'] == 0) { ?>-empty<?php } ?>"></i>&nbsp;<?php print "private"; ?></a>
<?php } ?>
<?php if($spam == 1) { ?>
| <a class="messagelink" href="#" onclick="Piler.not_spam(<?php print $id; ?>);"><i class="icon-exclamation-sign"></i>&nbsp;<?php print $text_not_spam; ?></a>