Skip to content

Commit

Permalink
Forbid contact with myself
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzegit committed Aug 11, 2023
1 parent 7a7e57e commit bc22d89
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
5 changes: 5 additions & 0 deletions system/controllers/messages/actions/write.php
Expand Up @@ -12,6 +12,11 @@ public function run($contact_id) {
return cmsCore::error404();
}

// Самому себе нельзя
if ($this->cms_user->id == $contact_id) {
return cmsCore::error404();
}

$contact_exists_id = $this->model->isContactExists($this->cms_user->id, $contact_id);

if (!$contact_exists_id) {
Expand Down
11 changes: 10 additions & 1 deletion system/controllers/messages/frontend.php
Expand Up @@ -99,7 +99,16 @@ public function clearRecipients() {
public function sendMessage($content) {

// Создаем контакты получателям
foreach ($this->recipients as $contact_id) {
foreach ($this->recipients as $key => $contact_id) {

// Контакт сам с собой невозможен
if ($contact_id == $this->sender_id) {

unset($this->recipients[$key]);

continue;
}

if (!$this->model->isContactExists($contact_id, $this->sender_id)) {
$this->model->addContact($contact_id, $this->sender_id);
}
Expand Down
13 changes: 8 additions & 5 deletions wysiwyg/redactor/files/redactor.js
Expand Up @@ -765,6 +765,8 @@
setEditor: function(html, strip)
{

html = this.sanitizeHTML(html);

if (strip !== false)
{
html = this.cleanSavePreCode(html);
Expand All @@ -778,9 +780,7 @@
}

html = html.replace(/$/g, '$');

html = this.cleanEmpty(html);
html = this.sanitizeHTML(html);
html = this.cleanEmpty(html);

this.$editor.html(html);

Expand All @@ -791,6 +791,9 @@
},
sanitizeHTML: function(htmlStr)
{
if(htmlStr.length === 0){
return htmlStr;
}
function stringToHTML () {
let parser = new DOMParser();
let doc = parser.parseFromString(htmlStr, 'text/html');
Expand Down Expand Up @@ -849,6 +852,7 @@
},
setFullpageOnInit: function(html)
{
html = this.sanitizeHTML(html);
this.fullpageDoctype = html.match(/^<\!doctype[^>]*>/i);
if (this.fullpageDoctype && this.fullpageDoctype.length == 1)
{
Expand All @@ -858,7 +862,6 @@
html = this.cleanSavePreCode(html, true);
html = this.cleanConverters(html);
html = this.cleanEmpty(html);
html = this.sanitizeHTML(html);

this.$editor.html(html);

Expand Down Expand Up @@ -7835,4 +7838,4 @@
}
};

})(jQuery);
})(jQuery);
2 changes: 1 addition & 1 deletion wysiwyg/redactor/files/redactor.min.js

Large diffs are not rendered by default.

0 comments on commit bc22d89

Please sign in to comment.