Messages: List view and button updates.

This commit is contained in:
Nate
2020-02-05 19:31:40 -07:00
parent b4602d8521
commit 4265a82a78
6 changed files with 940 additions and 952 deletions

View File

@@ -1,22 +1,60 @@
<?php
/*
FusionPBX
Version: MPL 1.1
/**
* call_recordings class
*
* @method null download
*/
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
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
if (!class_exists('messages')) {
class messages {
/**
* Called when the object is created
* 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
*/
public function __construct() {
//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_';
}
/**
* Called when there are no references to a particular object
* called when there are no references to a particular object
* unset the variables used in the class
*/
public function __destruct() {
@@ -26,64 +64,62 @@ if (!class_exists('messages')) {
}
/**
* delete messages
* delete records
*/
public function delete($messages) {
if (permission_exists('message_delete')) {
public function delete($records) {
if (permission_exists($this->permission_prefix.'delete')) {
//delete multiple messages
if (is_array($messages)) {
//get the action
foreach($messages as $row) {
if ($row['action'] == 'delete') {
$action = 'delete';
break;
//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'];
}
}
//delete the checked rows
if ($action == 'delete') {
$x = 0;
foreach($messages as $row) {
if ($row['action'] == 'delete' or $row['checked'] == 'true') {
//build delete array
$array['messages'][$x]['message_uuid'] = $row['message_uuid'];
$x++;
}
}
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p->add('message_delete', 'temp');
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = 'messages';
$database->app_uuid = '4a20815d-042c-47c8-85df-085333e79b87';
$database->delete($array);
unset($array);
//grant temporary permissions
$p = new permissions;
$p->add('message_media_delete', 'temp');
//revoke temporary permissions
$p->delete('message_delete', 'temp');
}
unset($messages);
//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']);
}
unset($records);
}
}
} //end the delete function
} //method
/**
* add messages
*/
public function add() {
} //end the add function
} //end the class
} //class
}
/*
$obj = new messages;
$obj->delete();
*/
?>