2018-08-30 18:18:34 +02:00
|
|
|
<?php
|
2020-02-06 03:31:40 +01:00
|
|
|
/*
|
|
|
|
|
FusionPBX
|
|
|
|
|
Version: MPL 1.1
|
|
|
|
|
|
|
|
|
|
The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
|
1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
|
the License. You may obtain a copy of the License at
|
|
|
|
|
http://www.mozilla.org/MPL/
|
|
|
|
|
|
|
|
|
|
Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
|
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
|
for the specific language governing rights and limitations under the
|
|
|
|
|
License.
|
|
|
|
|
|
|
|
|
|
The Original Code is FusionPBX
|
2018-08-30 18:18:34 +02:00
|
|
|
|
2020-02-06 03:31:40 +01:00
|
|
|
The Initial Developer of the Original Code is
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
|
|
|
|
Portions created by the Initial Developer are Copyright (C) 2008-2020
|
|
|
|
|
the Initial Developer. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
Contributor(s):
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
//define the messages class
|
2018-08-30 18:18:34 +02:00
|
|
|
if (!class_exists('messages')) {
|
|
|
|
|
class messages {
|
|
|
|
|
|
|
|
|
|
/**
|
2020-02-06 03:31:40 +01:00
|
|
|
* declare private variables
|
|
|
|
|
*/
|
|
|
|
|
private $app_name;
|
|
|
|
|
private $app_uuid;
|
|
|
|
|
private $permission_prefix;
|
|
|
|
|
private $list_page;
|
|
|
|
|
private $table;
|
|
|
|
|
private $uuid_prefix;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* called when the object is created
|
2018-08-30 18:18:34 +02:00
|
|
|
*/
|
|
|
|
|
public function __construct() {
|
2019-09-04 20:21:57 +02:00
|
|
|
|
2020-02-06 03:31:40 +01:00
|
|
|
//assign private variables
|
|
|
|
|
$this->app_name = 'messages';
|
|
|
|
|
$this->app_uuid = '4a20815d-042c-47c8-85df-085333e79b87';
|
|
|
|
|
$this->permission_prefix = 'message_';
|
|
|
|
|
$this->list_page = 'messages_log.php';
|
|
|
|
|
$this->table = 'messages';
|
|
|
|
|
$this->uuid_prefix = 'message_';
|
|
|
|
|
|
2018-08-30 18:18:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-02-06 03:31:40 +01:00
|
|
|
* called when there are no references to a particular object
|
2018-08-30 18:18:34 +02:00
|
|
|
* unset the variables used in the class
|
|
|
|
|
*/
|
|
|
|
|
public function __destruct() {
|
|
|
|
|
foreach ($this as $key => $value) {
|
|
|
|
|
unset($this->$key);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-02-06 03:31:40 +01:00
|
|
|
* delete records
|
2018-08-30 18:18:34 +02:00
|
|
|
*/
|
2020-02-06 03:31:40 +01:00
|
|
|
public function delete($records) {
|
|
|
|
|
if (permission_exists($this->permission_prefix.'delete')) {
|
|
|
|
|
|
|
|
|
|
//add multi-lingual support
|
|
|
|
|
$language = new text;
|
|
|
|
|
$text = $language->get();
|
|
|
|
|
|
|
|
|
|
//validate the token
|
|
|
|
|
$token = new token;
|
|
|
|
|
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
|
|
|
|
message::add($text['message-invalid_token'],'negative');
|
|
|
|
|
header('Location: '.$this->list_page);
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//delete multiple records
|
|
|
|
|
if (is_array($records) && @sizeof($records) != 0) {
|
|
|
|
|
|
|
|
|
|
//build the delete array
|
|
|
|
|
foreach ($records as $x => $record) {
|
|
|
|
|
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
|
|
|
|
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
|
|
|
|
|
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
|
|
|
|
|
$array['message_media'][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
|
|
|
|
|
$array['message_media'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
|
2018-08-30 18:18:34 +02:00
|
|
|
}
|
|
|
|
|
}
|
2020-02-06 03:31:40 +01:00
|
|
|
|
2018-08-30 18:18:34 +02:00
|
|
|
//delete the checked rows
|
2020-02-06 03:31:40 +01:00
|
|
|
if (is_array($array) && @sizeof($array) != 0) {
|
|
|
|
|
|
|
|
|
|
//grant temporary permissions
|
|
|
|
|
$p = new permissions;
|
|
|
|
|
$p->add('message_media_delete', 'temp');
|
|
|
|
|
|
|
|
|
|
//execute delete
|
|
|
|
|
$database = new database;
|
|
|
|
|
$database->app_name = $this->app_name;
|
|
|
|
|
$database->app_uuid = $this->app_uuid;
|
|
|
|
|
$database->delete($array);
|
|
|
|
|
unset($array);
|
|
|
|
|
|
|
|
|
|
//revoke temporary permissions
|
|
|
|
|
$p->delete('message_media_delete', 'temp');
|
|
|
|
|
|
|
|
|
|
//set message
|
|
|
|
|
message::add($text['message-delete']);
|
2018-08-30 18:18:34 +02:00
|
|
|
}
|
2020-02-06 03:31:40 +01:00
|
|
|
unset($records);
|
2018-08-30 18:18:34 +02:00
|
|
|
}
|
|
|
|
|
}
|
2020-02-06 03:31:40 +01:00
|
|
|
} //method
|
2018-08-31 06:26:06 +02:00
|
|
|
|
2020-02-06 03:31:40 +01:00
|
|
|
} //class
|
2018-08-30 18:18:34 +02:00
|
|
|
}
|
|
|
|
|
|
2019-09-04 20:21:57 +02:00
|
|
|
?>
|