瀏覽代碼

Add the clip library

FusionPBX 2 年之前
父節點
當前提交
039e24acb3
共有 6 個文件被更改,包括 854 次插入0 次删除
  1. 137 0
      clip_add.php
  2. 67 0
      clip_delete.php
  3. 230 0
      clip_list.php
  4. 75 0
      clip_options.php
  5. 186 0
      clip_options_list.php
  6. 159 0
      clip_update.php

+ 137 - 0
clip_add.php

@@ -0,0 +1,137 @@
+<?php
+/*
+	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
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2023
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+	James Rose <[email protected]>
+*/
+
+//includes files
+	require_once dirname(__DIR__, 2) . "/resources/require.php";
+	require_once "resources/check_auth.php";
+
+//check permissions
+	if (permission_exists('edit_save')) {
+		//access granted
+	}
+	else {
+		echo "access denied";
+		exit;
+	}
+
+//add multi-lingual support
+	$language = new text;
+	$text = $language->get();
+
+if (count($_POST)>0) {
+	$clip_name = $_POST["clip_name"];
+	$clip_folder = $_POST["clip_folder"];
+	$clip_text_start = $_POST["clip_text_start"];
+	$clip_text_end = $_POST["clip_text_end"];
+	$clip_desc = $_POST["clip_desc"];
+	$clip_order = $_POST["clip_order"];
+	if (strlen($clip_order) == 0) { $clip_order = 0; }
+
+	//no slashes
+	$clip_name = str_replace('/', '|', $clip_name);
+	$clip_name = str_replace('\\', '|', $clip_name);
+
+	//sql insert
+	$array['clips'][0]['clip_uuid'] = uuid();
+	$array['clips'][0]['clip_name'] = $clip_name;
+	$array['clips'][0]['clip_folder'] = $clip_folder;
+	$array['clips'][0]['clip_text_start'] = $clip_text_start;
+	$array['clips'][0]['clip_text_end'] = $clip_text_end;
+	$array['clips'][0]['clip_desc'] = $clip_desc;
+	$array['clips'][0]['clip_order'] = $clip_order;
+
+	$p = new permissions;
+	$p->add('clip_add', 'temp');
+
+	$database = new database;
+	$database->app_name = 'edit';
+	$database->app_uuid = '17e628ee-ccfa-49c0-29ca-9894a0384b9b';
+	$database->save($array);
+	unset($array);
+
+	$p->add('clip_add', 'temp');
+
+	require_once "header.php";
+	echo "<meta http-equiv=\"refresh\" content=\"1;url=clip_options.php\">\n";
+	echo $text['message-add'];
+	require_once "footer.php";
+	exit;
+}
+
+//show the content
+	require_once "header.php";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
+	echo "<tr>\n";
+	echo "	<td align=\"left\">\n";
+
+	echo "<form method='post' action=''>";
+	echo "<table width='100%' border='0'>";
+	echo "	<tr>";
+	echo "		<td>Name</td>";
+	echo "		<td><input type='text' class='txt' name='clip_name' id='clip_name'></td>";
+	echo "	</tr>";
+
+	echo "	<tr>";
+	echo "		<td>".$text['label-folder']."</td>";
+	echo "		<td><input type='text' class='txt' name='clip_folder'></td>";
+	echo "	</tr>";
+
+	echo "	<tr>";
+	echo "		<td colspan='2'>".$text['label-before-selection']."<br>";
+	echo "		  <textarea name='clip_text_start' class='txt' style='resize: vertical;'></textarea>";
+	echo "		</td>";
+	echo "	</tr>";
+
+	echo "	<tr>";
+	echo "		<td colspan='2'>".$text['label-after-selection']."<br>";
+	echo "		  <textarea name='clip_text_end' class='txt' style='resize: vertical;'></textarea>";
+	echo "		</td>";
+	echo "	</tr>";
+
+	echo "	<tr>";
+	echo "		<td colspan='2'>".$text['label-notes']."<br>";
+	echo "		  <textarea name='clip_desc' class='txt' style='resize: vertical;'></textarea>";
+	echo "		</td>";
+	echo "	</tr>";
+
+	echo "	<tr>";
+	echo "		<td align='left'><input type='button' value='".$text['button-back']."' onclick='history.back()'></td>";
+	echo "		<td align='right'><input type='submit' name='submit' value='".$text['button-add']."'></td>";
+	echo "	</tr>";
+	echo "</table>";
+	echo "</form>";
+
+	echo "	</td>";
+	echo "	</tr>";
+	echo "</table>";
+
+	echo "<script>document.getElementById('clip_name').focus();</script>";
+
+//include the footer
+	require_once "footer.php";
+
+?>

+ 67 - 0
clip_delete.php

@@ -0,0 +1,67 @@
+<?php
+/*
+	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
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2023
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+	James Rose <[email protected]>
+*/
+
+//includes files
+	require_once dirname(__DIR__, 2) . "/resources/require.php";
+	require_once "resources/check_auth.php";
+
+//check permissions
+	if (permission_exists('clip_delete')) {
+		//access granted
+	}
+	else {
+		echo "access denied";
+		exit;
+	}
+
+//add multi-lingual support
+	$language = new text;
+	$text = $language->get();
+
+//get the uuid from http values
+	$clip_uuid = $_GET["id"];
+
+//delete the clip
+	if (is_uuid($clip_uuid)) {
+		$array['clips'][0]['clip_uuid'] = $clip_uuid;
+
+		$p = new permissions;
+		$p->add('clip_delete', 'temp');
+
+		$database = new database;
+		$database->app_name = 'edit';
+		$database->app_uuid = '17e628ee-ccfa-49c0-29ca-9894a0384b9b';
+		$database->delete($array);
+		unset($array);
+
+		$p->delete('clip_delete', 'temp');
+	}
+
+//redirect the browser
+	header("Location: clip_options.php");
+
+?>

+ 230 - 0
clip_list.php

@@ -0,0 +1,230 @@
+<?php
+/*
+	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
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2023
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+	James Rose <[email protected]>
+*/
+
+//includes files
+	require_once dirname(__DIR__, 2) . "/resources/require.php";
+	require_once "resources/check_auth.php";
+
+//check permissions
+	if (permission_exists('clip_view')) {
+		//access granted
+	}
+	else {
+		echo "access denied";
+		exit;
+	}
+
+//include the header
+	require_once "header.php";
+
+//add multi-lingual support
+	$language = new text;
+	$text = $language->get();
+
+//check if this is a file
+	function isfile($filename) {
+		return @filesize($filename) > 0 ? true : false;
+	}
+
+//count the spaces
+	function space($count) {
+		$r=''; $i=0;
+		while($i < $count) {
+			$r .= '     ';
+			$i++;
+		}
+		return $r;
+	}
+
+//setup ajax
+	echo "<script type=\"text/javascript\" language=\"javascript\">\n";
+	echo "    function makeRequest(url, strpost) {\n";
+	echo "        var http_request = false;\n";
+	echo "\n";
+	echo "        if (window.XMLHttpRequest) { // Mozilla, Safari, ...\n";
+	echo "            http_request = new XMLHttpRequest();\n";
+	echo "            if (http_request.overrideMimeType) {\n";
+	echo "                http_request.overrideMimeType('text/xml');\n";
+	echo "                // See note below about this line\n";
+	echo "            }\n";
+	echo "        } else if (window.ActiveXObject) { // IE\n";
+	echo "            try {\n";
+	echo "                http_request = new ActiveXObject(\"Msxml2.XMLHTTP\");\n";
+	echo "            } catch (e) {\n";
+	echo "                try {\n";
+	echo "                    http_request = new ActiveXObject(\"Microsoft.XMLHTTP\");\n";
+	echo "                } catch (e) {}\n";
+	echo "            }\n";
+	echo "        }\n";
+	echo "\n";
+	echo "        if (!http_request) {\n";
+	echo "            alert('".$text['message-give-up']."');\n";
+	echo "            return false;\n";
+	echo "        }\n";
+	echo "        http_request.onreadystatechange = function() { returnContent(http_request); };\n";
+	echo "        if (http_request.overrideMimeType) {\n";
+	echo "            http_request.overrideMimeType('text/html');\n";
+	echo "        }\n";
+	echo "        http_request.open('POST', url, true);\n";
+	echo "\n";
+	echo "\n";
+	echo "        if (strpost.length == 0) {\n";
+	echo "            //http_request.send(null);\n";
+	echo "            http_request.send('name=value&foo=bar');\n";
+	echo "        }\n";
+	echo "        else {\n";
+	echo "            http_request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');\n";
+	echo "            http_request.send(strpost);\n";
+	echo "        }\n";
+	echo "\n";
+	echo "    }\n";
+	echo "\n";
+	echo "    function returnContent(http_request) {\n";
+	echo "\n";
+	echo "        if (http_request.readyState == 4) {\n";
+	echo "            if (http_request.status == 200) {\n";
+
+	echo "                  parent.editAreaLoader.setValue('edit1', http_request.responseText); \n";
+	echo "\n";
+
+	echo "            }\n";
+	echo "            else {\n";
+	echo "                alert('".$text['message-problem']."');\n";
+	echo "            }\n";
+	echo "        }\n";
+	echo "\n";
+	echo "    }\n";
+	echo "</script>";
+
+//setup the tree view
+	//echo "// ---------------------------------------------\n";
+	//echo "// --- http://www.codeproject.com/jscript/dhtml_treeview.asp\n";
+	//echo "// --- Name:    Easy DHTML Treeview           --\n";
+	//echo "// --- Author:  D.D. de Kerf                  --\n";
+	//echo "// --- Version: 0.2          Date: 13-6-2001  --\n";
+	//echo "// ---------------------------------------------\n";
+	echo "<script language='JavaScript'>\n";
+	echo "function Toggle(node) {\n";
+	echo "	// Unfold the branch if it isn't visible\n";
+	echo "	if (node.nextSibling.style.display == 'none')	{\n";
+	echo "  		node.nextSibling.style.display = 'block';\n";
+	echo "	}\n";
+	echo "	// Collapse the branch if it IS visible\n";
+	echo "	else	{\n";
+	echo "  		node.nextSibling.style.display = 'none';\n";
+	echo "	}\n";
+	echo "\n";
+	echo "}\n";
+	echo "</script>";
+
+// keyboard shortcut bindings
+	echo "<script language='JavaScript' type='text/javascript' src='".PROJECT_PATH."/resources/jquery/jquery-3.6.1.min.js'></script>\n";
+	echo "<script src='https://code.jquery.com/jquery-migrate-3.1.0.js'></script>\n";
+
+//save file
+	key_press('ctrl+s', 'down', 'window', null, null, "if (parent.document.getElementById('frm_edit')) { parent.$('form#frm_edit').submit(); return false; }", true);
+
+//open file manager/clip library pane
+	key_press('ctrl+q', 'down', 'window', null, null, "if (parent.document.getElementById('sidebar')) { parent.toggle_sidebar(); parent.focus_editor(); return false; }", true);
+
+//prevent backspace (browser history back)
+	key_press('backspace', 'down', 'window', null, null, 'return false;', true);
+
+//keyboard shortcut to execute command (when included on command page)
+	key_press('ctrl+enter', 'down', 'window', null, null, "if (!parent.document.getElementById('sidebar')) { parent.$('form#frm').submit(); return false; }", true);
+
+//show the content
+	echo "</head>\n";
+	echo "<body style='margin: 0; padding: 5px;' onfocus='blur();'>\n";
+
+	echo "<div style='text-align: left; padding-top: 3px;'>\n";
+	echo "<div style='padding-bottom: 3px;'><a href='javascript:void(0);' onclick=\"window.open('clip_options.php','clipwin','left=20,top=20,width=310,height=350,toolbar=0,resizable=0');\" style='text-decoration:none; cursor: pointer;' title=\"".$text['label-clip-library']."\"><img src='resources/images/icon_gear.png' border='0' align='absmiddle' style='margin: 0px 2px 4px -1px;'>".$text['label-clip-library']."</a></div>\n";
+
+	$sql = "select * from v_clips order by clip_folder asc, clip_name asc";
+	$database = new database;
+	$result = $database->select($sql, null, 'all');
+	unset($sql);
+
+	if (!empty($result) && is_array($result) && @sizeof($result) != 0) {
+		$master_array = array();
+		foreach ($result as $row) {
+			if (!empty($row['clip_folder'])) {
+				$clip_folder = rtrim($row['clip_folder'], '/');
+			}
+			$clip_folder .= '/'.$row['clip_name'];
+
+			$parts = explode('/', $clip_folder);
+			$folders = array();
+			while ($bottom = array_pop($parts)) {
+				if (sizeof($folders) > 0) {
+					$folders = array($bottom => $folders);
+				}
+				else {
+					$clip['uuid'] = $row['clip_uuid'];
+					$clip['name'] = $row['clip_name'];
+					$clip['before'] = $row['clip_text_start'];
+					$clip['after'] = $row['clip_text_end'];
+					$folders = array($bottom => $clip);
+				}
+			}
+
+			$master_array = array_merge_recursive($master_array, $folders);
+		}
+		unset($result, $row);
+
+		function parse_array($array) {
+			if (!empty(is_array($array)) && is_array($array)) {
+				foreach ($array as $folder_name => $clips) {
+					//folder
+					echo "<a onclick='Toggle(this);' style='display: block; cursor: pointer; text-decoration: none;'><img src='resources/images/icon_folder.png' border='none' align='absmiddle' style='margin: 1px 2px 3px 0px;'>".$folder_name."</a>";
+					echo "<div style='display: none; padding-left: 16px;'>\n";
+
+					//clips
+					foreach($clips as $row) {
+						//clip
+						echo "<div style='white-space: nowrap;'>\n";
+						echo "<a href='javascript:void(0);' onclick=\"parent.insert_clip(document.getElementById('before_".$row['uuid']."').value, document.getElementById('after_".$row['uuid']."').value);\">";
+						echo "<img src='resources/images/icon_file.png' border='0' align='absmiddle' style='margin: 1px 2px 3px -1px;'>";
+						echo escape($row['name']);
+						echo "</a>\n";
+						echo "<textarea style='display: none' id='before_".$row['uuid']."'>".$row['before']."</textarea>\n";
+						echo "<textarea style='display: none' id='after_".$row['uuid']."'>".$row['after']."</textarea>\n";
+						echo "</div>\n";
+					}
+					
+					echo "</div>\n";
+				}
+			}
+		}
+		parse_array($master_array);
+	}
+	echo "</div>\n";
+
+//inclue the footer
+require_once "footer.php";
+
+?>

+ 75 - 0
clip_options.php

@@ -0,0 +1,75 @@
+<?php
+/*
+	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
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2023
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+	James Rose <[email protected]>
+*/
+
+//includes files
+	require_once dirname(__DIR__, 2) . "/resources/require.php";
+	require_once "resources/check_auth.php";
+
+//check permissions
+	if (permission_exists('clip_edit')) {
+		//access granted
+	}
+	else {
+		echo "access denied";
+		exit;
+	}
+
+//add multi-lingual support
+	$language = new text;
+	$text = $language->get();
+
+//prepare the header
+	$title = $text['title-manage-clips'];
+	require_once "header.php";
+
+//show the content
+	echo "<table cellpadding='0' cellspacing='0' border='0' style='height: 100%; width: 100%;'>\n";
+	echo "<form method='post' name='frm' action=''>";
+	echo "<tr><td colspan='2' style='padding-bottom: 3px;'><div id='selectedclip'>".$text['label-selected-clip']." <input type='text' name='clip_name' id='clip_name' value=''><input type='hidden' name='clip_uuid' id='clip_uuid' value=''></div></td></tr>\n";
+	echo "</form>";
+	echo "<tr>\n";
+	echo "<td valign='top' width='200' nowrap>";
+	echo "  <iframe src='clip_options_list.php' style='border: solid 1px #ccc; height: calc(100% - 3px); width: calc(100% - 4px);'></iframe>";
+	echo "</td>\n";
+	echo "<td valign='top' style='height: 100%; padding: 0;'>";
+
+	echo "<table cellpadding='0' cellspacing='0' border='0' width='100%' height='100%'>";
+	echo "  <tr><td><input type='button' class='btn' onclick=\"window.location='clip_add.php'\" value='".$text['button-add-clip']."'></td></tr>\n";
+	echo "  <tr><td><input type='button' class='btn' onclick=\"window.location='clip_update.php?id='+document.getElementById('clip_uuid').value;\" value='".$text['button-edit-clip']."'></td></tr>\n";
+	echo "  <tr><td><input type='button' class='btn' onclick=\"if (confirm('".$text['message-delete-clip']."')){ window.location='clip_delete.php?id='+document.getElementById('clip_uuid').value; }\" value='".$text['button-delete']."'></td></tr>\n";
+	echo "  <tr><td height='100%'>&nbsp;</td></tr>\n";
+	echo "  <tr><td><input type='button' class='btn' onclick='opener.location.reload(); self.close();' value='".$text['button-close']."'></td></tr>\n";
+	echo "</table>";
+
+	echo "</td>\n";
+	echo "</tr>\n";
+	echo "</table>";
+
+//include footer
+	require_once "footer.php";
+
+?>

+ 186 - 0
clip_options_list.php

@@ -0,0 +1,186 @@
+<?php
+/*
+	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
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2023
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+	James Rose <[email protected]>
+*/
+
+//includes files
+	require_once dirname(__DIR__, 2) . "/resources/require.php";
+	require_once "resources/check_auth.php";
+
+//check permissions
+	if (permission_exists('clip_edit')) {
+		//access granted
+	}
+	else {
+		echo "access denied";
+		exit;
+	}
+
+//add multi-lingual support
+	$language = new text;
+	$text = $language->get();
+
+//include
+	require_once "header.php";
+
+//show the content
+	echo "<script type=\"text/javascript\" language=\"javascript\">\n";
+	echo "    function makeRequest(url, strpost) {\n";
+	echo "        var http_request = false;\n";
+	echo "\n";
+	echo "        if (window.XMLHttpRequest) { // Mozilla, Safari, ...\n";
+	echo "            http_request = new XMLHttpRequest();\n";
+	echo "            if (http_request.overrideMimeType) {\n";
+	echo "                http_request.overrideMimeType('text/xml');\n";
+	echo "                // See note below about this line\n";
+	echo "            }\n";
+	echo "        } else if (window.ActiveXObject) { // IE\n";
+	echo "            try {\n";
+	echo "                http_request = new ActiveXObject(\"Msxml2.XMLHTTP\");\n";
+	echo "            } catch (e) {\n";
+	echo "                try {\n";
+	echo "                    http_request = new ActiveXObject(\"Microsoft.XMLHTTP\");\n";
+	echo "                } catch (e) {}\n";
+	echo "            }\n";
+	echo "        }\n";
+	echo "\n";
+	echo "        if (!http_request) {\n";
+	echo "            alert('".$text['message-give-up']."');\n";
+	echo "            return false;\n";
+	echo "        }\n";
+	echo "        http_request.onreadystatechange = function() { returnContent(http_request); };\n";
+	echo "        http_request.overrideMimeType('text/html');\n";
+	echo "        http_request.open('POST', url, true);\n";
+	echo "\n";
+	echo "        if (strpost.length == 0) {\n";
+	echo "            //http_request.send(null);\n";
+	echo "            http_request.send('name=value&foo=bar');\n";
+	echo "        }\n";
+	echo "        else {\n";
+	echo "            http_request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');\n";
+	echo "            http_request.send(strpost);\n";
+	echo "        }\n";
+	echo "    }\n";
+	echo "\n";
+	echo "    function returnContent(http_request) {\n";
+	echo "\n";
+	echo "        if (http_request.readyState == 4) {\n";
+	echo "            if (http_request.status == 200) {\n";
+	echo "                  parent.editAreaLoader.setValue('edit1', http_request.responseText); \n";
+	echo "            }\n";
+	echo "            else {\n";
+	echo "                alert('".$text['message-problem']."');\n";
+	echo "            }\n";
+	echo "        }\n";
+	echo "    }\n";
+	echo "</script>";
+
+	echo "<SCRIPT LANGUAGE=\"JavaScript\">\n";
+	//echo "// ---------------------------------------------\n";
+	//echo "// --- http://www.codeproject.com/jscript/dhtml_treeview.asp\n";
+	//echo "// --- Name:    Easy DHTML Treeview           --\n";
+	//echo "// --- Author:  D.D. de Kerf                  --\n";
+	//echo "// --- Version: 0.2          Date: 13-6-2001  --\n";
+	//echo "// ---------------------------------------------\n";
+	echo "function Toggle(node) {\n";
+	echo "	// Unfold the branch if it isn't visible\n";
+	echo "	if (node.nextSibling.style.display == 'none') {\n";
+	echo "  	node.nextSibling.style.display = 'block';\n";
+	echo "	}\n";
+	echo "	// Collapse the branch if it IS visible\n";
+	echo "	else {\n";
+	echo "  	node.nextSibling.style.display = 'none';\n";
+	echo "	}\n";
+	echo "\n";
+	echo "}\n";
+	echo "</SCRIPT>";
+
+	echo "</head>\n";
+	echo "<body style='margin: 0; padding: 5px;' onfocus='blur();'>\n";
+
+	echo "<div style='text-align: left;'>\n";
+
+	$sql = "select * from v_clips order by clip_folder asc, clip_name asc";
+	$database = new database;
+	$result = $database->select($sql, null, 'all');
+	unset($sql);
+
+	if (is_array($result) && @sizeof($result) != 0) {
+		$master_array = array();
+		foreach ($result as $row) {
+			$clip_folder = rtrim($row['clip_folder'], '/');
+			$clip_folder .= '/'.$row['clip_name'];
+
+			$parts = explode('/', $clip_folder);
+			$folders = array();
+			while ($bottom = array_pop($parts)) {
+				if (sizeof($folders) > 0) {
+					$folders = array($bottom => $folders);
+				}
+				else {
+					$clip['uuid'] = $row['clip_uuid'];
+					$clip['name'] = $row['clip_name'];
+					$clip['before'] = $row['clip_text_start'];
+					$clip['after'] = $row['clip_text_end'];
+					$folders = array($bottom => $clip);
+				}
+			}
+
+			$master_array = array_merge_recursive($master_array, $folders);
+		}
+
+		function parse_array($array) {
+			if (is_array($array)) {
+				foreach ($array as $folder_name => $clips) {
+					//folder
+					echo "<a onclick='Toggle(this);' style='display: block; cursor: pointer; text-decoration: none;'><img src='resources/images/icon_folder.png' border='none' align='absmiddle' style='margin: 1px 2px 3px 0px;'>".$folder_name."</a>";
+					echo "<div style='display: none; padding-left: 16px;'>\n";
+
+					//clips
+					foreach($clips as $row) {
+						//clip
+						echo "<div style='white-space: nowrap;'>\n";
+						echo "<a href='javascript:void(0);' onclick=\"parent.document.getElementById('clip_uuid').value='".$row['uuid']."'; parent.document.getElementById('clip_name').value='".$row['name']."';\">";
+						echo "<img src='resources/images/icon_file.png' border='0' align='absmiddle' style='margin: 1px 2px 3px -1px;'>";
+						echo escape($row['name']);
+						echo "</a>\n";
+						echo "<textarea style='display: none' id='before_".$row['uuid']."'>".$row['before']."</textarea>\n";
+						echo "<textarea style='display: none' id='after_".$row['uuid']."'>".$row['after']."</textarea>\n";
+						echo "</div>\n";
+					}
+					
+					echo "</div>\n";
+				}
+			}
+		}
+		parse_array($master_array);
+	}
+	unset($result, $row);
+	echo "</div>\n";
+
+//include the footer
+	require_once "footer.php";
+
+?>

+ 159 - 0
clip_update.php

@@ -0,0 +1,159 @@
+<?php
+/*
+	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
+
+	The Initial Developer of the Original Code is
+	Mark J Crane <[email protected]>
+	Portions created by the Initial Developer are Copyright (C) 2008-2023
+	the Initial Developer. All Rights Reserved.
+
+	Contributor(s):
+	Mark J Crane <[email protected]>
+*/
+
+//includes files
+	require_once dirname(__DIR__, 2) . "/resources/require.php";
+	require_once "resources/check_auth.php";
+
+//check permissions
+	if (permission_exists('clip_edit')) {
+		//access granted
+	}
+	else {
+		echo "access denied";
+		exit;
+	}
+
+//add multi-lingual support
+	$language = new text;
+	$text = $language->get();
+
+//process the HTTP POST
+	if (count($_POST) > 0) {
+		$clip_uuid = $_POST["id"];
+		$clip_name = $_POST["clip_name"];
+		$clip_folder = $_POST["clip_folder"];
+		$clip_text_start = empty($_POST["clip_text_start"]) ? '' : $_POST["clip_text_start"];
+		$clip_text_end = empty($_POST["clip_text_end"]) ? '' : $_POST["clip_text_end"];
+		$clip_desc = empty($_POST["clip_desc"]) ? '' : $_POST["clip_desc"];
+		$clip_order = empty($_POST["clip_order"]) ? '0' : $_POST["clip_order"];
+
+		//no slashes
+		$clip_name = str_replace('/', '|', $clip_name);
+		$clip_name = str_replace('\\', '|', $clip_name);
+
+		//sql update
+		$array['clips'][0]['clip_uuid'] = $clip_uuid;
+		$array['clips'][0]['clip_name'] = $clip_name;
+		$array['clips'][0]['clip_folder'] = $clip_folder;
+		$array['clips'][0]['clip_text_start'] = $clip_text_start;
+		$array['clips'][0]['clip_text_end'] = $clip_text_end;
+		$array['clips'][0]['clip_desc'] = $clip_desc;
+		$array['clips'][0]['clip_order'] = $clip_order;
+
+		$p = new permissions;
+		$p->add('clip_edit', 'temp');
+
+		$database = new database;
+		$database->app_name = 'edit';
+		$database->app_uuid = '17e628ee-ccfa-49c0-29ca-9894a0384b9b';
+		$database->save($array);
+		unset($array);
+
+		$p->add('clip_edit', 'temp');
+
+		//redirect the browser
+		require_once "header.php";
+		echo "<meta http-equiv=\"refresh\" content=\"1;url=clip_options.php\">\n";
+		echo $text['message-update'];
+		require_once "footer.php";
+		exit;
+	}
+	else {
+		//get the uuid from http values
+			$clip_uuid = $_GET["id"];
+
+		//get the clip
+			$sql = "select * from v_clips ";
+			$sql .= "where clip_uuid = :clip_uuid ";
+			$parameters['clip_uuid'] = $clip_uuid;
+			$database = new database;
+			$row = $database->select($sql, $parameters, 'row');
+			if (is_array($row) && @sizeof($row) != 0) {
+				$clip_name = $row["clip_name"];
+				$clip_folder = $row["clip_folder"];
+				$clip_text_start = $row["clip_text_start"];
+				$clip_text_end = $row["clip_text_end"];
+				$clip_desc = $row["clip_desc"];
+				$clip_order = $row["clip_order"];
+			}
+			unset($sql, $parameters, $row);
+	}
+
+//show the content
+	require_once "header.php";
+	echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
+	echo "<tr>\n";
+	echo "	<td align=\"left\">\n";
+
+	echo "<form method='post' action=''>";
+	echo "<table border='0' width='100%'>";
+	echo "	<tr>";
+	echo "		<td>Name</td>";
+	echo "		<td><input type='text' class='txt' name='clip_name' value='$clip_name'></td>";
+	echo "	</tr>";
+
+	echo "	<tr>";
+	echo "		<td>Folder</td>";
+	echo "		<td><input type='text' class='txt'  name='clip_folder' value='$clip_folder'></td>";
+	echo "	</tr>";
+
+	echo "	<tr>";
+	echo "		<td colspan='2'>Before Selection<br>";
+	echo "		  <textarea class='txt' style='resize: vertical;' name='clip_text_start'>$clip_text_start</textarea>";
+	echo "		</td>";
+	echo "	</tr>";
+
+	echo "	<tr>";
+	echo "		<td colspan='2'>After Selection<br>";
+	echo "		  <textarea class='txt' style='resize: vertical;' name='clip_text_end'>$clip_text_end</textarea>";
+	echo "		</td>";
+	echo "	</tr>";
+
+	echo "	<tr>";
+	echo "		<td colspan='2'>Notes<br>";
+	echo "		  <textarea class='txt' style='resize: vertical;' name='clip_desc'>$clip_desc</textarea>";
+	echo "		</td>";
+	echo "	</tr>";
+
+	echo "	<tr>";
+	echo "		<td align='left'><input type='button' value='".$text['button-back']."' onclick='history.back()'></td>";
+	echo "		<td align='right'>";
+	echo "			<input type='hidden' name='id' value='$clip_uuid'>";
+	echo "			<input type='submit' name='submit' value='Update'>";
+	echo "		</td>";
+	echo "	</tr>";
+	echo "</table>";
+	echo "</form>";
+
+	echo "	</td>";
+	echo "	</tr>";
+	echo "</table>";
+
+//include the footer
+	require_once "footer.php";
+
+?>