Conference Centers - Sessions: Add delete functionality.

This commit is contained in:
Nate
2020-04-10 17:45:56 -06:00
parent 7a12565084
commit aeee14226a
2 changed files with 123 additions and 3 deletions

View File

@@ -17,7 +17,8 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Copyright (C) 2008-2019 All Rights Reserved.
Portions created by the Initial Developer are Copyright (C) 2008 - 2019
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
@@ -42,6 +43,29 @@
$language = new text;
$text = $language->get();
//get the http post data
if (is_array($_POST['conference_sessions'])) {
$action = $_POST['action'];
$meeting_uuid = $_POST['meeting_uuid'];
$conference_sessions = $_POST['conference_sessions'];
}
//process the http post data by action
if ($action != '' && is_array($conference_sessions) && @sizeof($conference_sessions) != 0) {
switch ($action) {
case 'delete':
if (permission_exists('conference_session_delete')) {
$obj = new conference_centers;
$obj->meeting_uuid = $meeting_uuid;
$obj->delete_conference_sessions($conference_sessions);
}
break;
}
header('Location: conference_sessions.php?id='.urlencode($meeting_uuid));
exit;
}
//set variables from the http values
$meeting_uuid = $_GET["id"];
$order_by = $_GET["order_by"] != '' ? $_GET["order_by"] : 'start_epoch';
@@ -84,7 +108,12 @@
$conference_sessions = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//includes the header
$document['title'] = $text['title-conference_sessions'];
require_once "resources/header.php";
//styles
@@ -107,6 +136,9 @@
echo " <div class='heading'><b>".$text['title-conference_sessions']." (".$num_rows.")</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','link'=>'conference_rooms.php']);
if (permission_exists('conference_session_delete') && $conference_sessions) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'name'=>'btn_delete','style'=>'margin-left: 15px;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
}
if ($paging_controls_mini != '') {
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
}
@@ -114,11 +146,24 @@
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if (permission_exists('conference_session_delete') && $conference_sessions) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]);
}
echo $text['description-conference_sessions']."\n";
echo "<br /><br />\n";
echo "<form id='form_list' method='post'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<input type='hidden' name='meeting_uuid' value=\"".escape($meeting_uuid)."\">\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
if (permission_exists('conference_session_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".($conference_sessions ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
echo th_order_by('start_epoch', $text['label-start'], $order_by, $order);
echo th_order_by('end_epoch', $text['label-end'], $order_by, $order);
echo "<th>".$text['label-time']."</th>\n";
@@ -131,6 +176,7 @@
echo "</tr>\n";
if (is_array($conference_sessions) && sizeof($conference_sessions) != 0) {
$x = 0;
foreach($conference_sessions as $row) {
$tmp_year = date("Y", $row['start_epoch']);
$tmp_month = date("M", $row['start_epoch']);
@@ -149,9 +195,15 @@
$time_difference = gmdate("G:i:s", $time_difference);
}
if (strlen( $row['start_epoch']) > 0) {
if (strlen($row['start_epoch']) > 0) {
$list_row_url = "conference_session_details.php?uuid=".urlencode($row['conference_session_uuid']);
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('conference_session_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='conference_sessions[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='conference_sessions[$x][uuid]' value='".escape($row['conference_session_uuid'])."' />\n";
echo " </td>\n";
}
echo " <td><a href='".$list_row_url."'>".$start_date."</a>&nbsp;</td>\n";
echo " <td>".$end_date."&nbsp;</td>\n";
echo " <td>".$time_difference."&nbsp;</td>\n";
@@ -191,7 +243,7 @@
echo " </td>\n";
}
echo "</tr>\n";
$x++;
}
}
unset($result);
@@ -200,6 +252,8 @@
echo "</table>\n";
echo "<br />\n";
echo "<div align='center'>".$paging_controls."</div>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
//include the footer
require_once "resources/footer.php";

View File

@@ -457,6 +457,72 @@ if (!class_exists('conference_centers')) {
}
}
public function delete_conference_sessions($records) {
//assign private variables
$this->permission_prefix = 'conference_session_';
$this->list_page = 'conference_sessions.php?id='.$this->meeting_uuid;
$this->table = 'conference_sessions';
$this->uuid_prefix = 'conference_session_';
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'])) {
//create array
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
$array['conference_session_details'][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
$array['conference_session_details'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
}
}
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p->add('conference_session_detail_delete', 'temp');
$p->add('meeting_user_delete', 'temp');
$p->add('meeting_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('conference_session_detail_delete', 'temp');
$p->delete('meeting_user_delete', 'temp');
$p->delete('meeting_delete', 'temp');
//set message
message::add($text['message-delete']);
}
unset($records);
}
}
}
/**
* toggle records
*/