mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 11:43:50 +00:00
Editor/Clips: Database class integration.
This commit is contained in:
@@ -40,12 +40,12 @@ else {
|
||||
$text = $language->get();
|
||||
|
||||
if (count($_POST)>0) {
|
||||
$clip_name = check_str($_POST["clip_name"]);
|
||||
$clip_folder = check_str($_POST["clip_folder"]);
|
||||
$clip_text_start = check_str($_POST["clip_text_start"]);
|
||||
$clip_text_end = check_str($_POST["clip_text_end"]);
|
||||
$clip_desc = check_str($_POST["clip_desc"]);
|
||||
$clip_order = check_str($_POST["clip_order"]);
|
||||
$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
|
||||
@@ -53,34 +53,30 @@ if (count($_POST)>0) {
|
||||
$clip_name = str_replace('\\', '|', $clip_name);
|
||||
|
||||
//sql insert
|
||||
$sql = "insert into v_clips ";
|
||||
$sql .= "(";
|
||||
$sql .= "clip_uuid, ";
|
||||
$sql .= "clip_name, ";
|
||||
$sql .= "clip_folder, ";
|
||||
$sql .= "clip_text_start, ";
|
||||
$sql .= "clip_text_end, ";
|
||||
$sql .= "clip_desc, ";
|
||||
$sql .= "clip_order ";
|
||||
$sql .= ")";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'".uuid()."', ";
|
||||
$sql .= "'$clip_name', ";
|
||||
$sql .= "'$clip_folder', ";
|
||||
$sql .= "'$clip_text_start', ";
|
||||
$sql .= "'$clip_text_end', ";
|
||||
$sql .= "'$clip_desc', ";
|
||||
$sql .= "'$clip_order' ";
|
||||
$sql .= ")";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql,$db);
|
||||
$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=clipoptions.php\">\n";
|
||||
echo $text['message-add'];
|
||||
require_once "footer.php";
|
||||
return;
|
||||
exit;
|
||||
}
|
||||
|
||||
//show the content
|
||||
@@ -103,19 +99,19 @@ if (count($_POST)>0) {
|
||||
|
||||
echo " <tr>";
|
||||
echo " <td colspan='2'>".$text['label-before-selection']."<br>";
|
||||
echo " <textarea name='clip_text_start' class='txt'></textarea>";
|
||||
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'></textarea>";
|
||||
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'></textarea>";
|
||||
echo " <textarea name='clip_desc' class='txt' style='resize: vertical;'></textarea>";
|
||||
echo " </td>";
|
||||
echo " </tr>";
|
||||
|
||||
|
||||
@@ -40,15 +40,22 @@ else {
|
||||
$text = $language->get();
|
||||
|
||||
//get the uuid from http values
|
||||
$clip_uuid = check_str($_GET["id"]);
|
||||
$clip_uuid = $_GET["id"];
|
||||
|
||||
//delete the clip
|
||||
if (strlen($_GET["id"])>0) {
|
||||
$sql = "delete from v_clips ";
|
||||
$sql .= "where clip_uuid = '".$clip_uuid."' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
unset($sql,$db);
|
||||
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
|
||||
|
||||
@@ -44,7 +44,7 @@ require_once "header.php";
|
||||
|
||||
|
||||
function isfile($filename) {
|
||||
if (@filesize($filename) > 0) { return true; } else { return false; }
|
||||
return @filesize($filename) > 0 ? true : false;
|
||||
}
|
||||
|
||||
function space($count) {
|
||||
@@ -157,12 +157,11 @@ echo "<div style='text-align: left; padding-top: 3px;'>\n";
|
||||
echo "<div style='padding-bottom: 3px;'><a href='javascript:void(0);' onclick=\"window.open('clipoptions.php?id=".$row[id]."','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='".PROJECT_PATH."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";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
$result_count = count($result);
|
||||
$database = new database;
|
||||
$result = $database->select($sql, null, 'all');
|
||||
unset($sql);
|
||||
|
||||
if ($result_count > 0) {
|
||||
if (is_array($result) && @sizeof($result) != 0) {
|
||||
$master_array = array();
|
||||
foreach ($result as $row) {
|
||||
$clip_folder = rtrim($row['clip_folder'], '/');
|
||||
@@ -185,6 +184,7 @@ if ($result_count > 0) {
|
||||
|
||||
$master_array = array_merge_recursive($master_array, $folders);
|
||||
}
|
||||
unset($result, $row);
|
||||
|
||||
function parse_array($arr) {
|
||||
if (is_array($arr)) {
|
||||
@@ -216,7 +216,5 @@ if ($result_count > 0) {
|
||||
|
||||
echo "</div>\n";
|
||||
|
||||
//echo "<pre>".print_r($master_array, true)."</pre>";
|
||||
|
||||
require_once "footer.php";
|
||||
?>
|
||||
@@ -119,12 +119,11 @@ 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";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
$result_count = count($result);
|
||||
$database = new database;
|
||||
$result = $database->select($sql, null, 'all');
|
||||
unset($sql);
|
||||
|
||||
if ($result_count > 0) {
|
||||
if (is_array($result) && @sizeof($result) != 0) {
|
||||
$master_array = array();
|
||||
foreach ($result as $row) {
|
||||
$clip_folder = rtrim($row['clip_folder'], '/');
|
||||
@@ -175,6 +174,7 @@ if ($result_count > 0) {
|
||||
}
|
||||
parse_array($master_array);
|
||||
}
|
||||
unset($result, $row);
|
||||
|
||||
echo "</div>\n";
|
||||
|
||||
|
||||
@@ -39,55 +39,64 @@ else {
|
||||
$text = $language->get();
|
||||
|
||||
if (count($_POST)>0) {
|
||||
$clip_uuid = check_str($_POST["id"]);
|
||||
$clip_name = check_str($_POST["clip_name"]);
|
||||
$clip_folder = check_str($_POST["clip_folder"]);
|
||||
$clip_text_start = check_str($_POST["clip_text_start"], false);
|
||||
$clip_text_end = check_str($_POST["clip_text_end"], false);
|
||||
$clip_desc = check_str($_POST["clip_desc"]);
|
||||
$clip_order = check_str($_POST["clip_order"]);
|
||||
$clip_uuid = $_POST["id"];
|
||||
$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"];
|
||||
|
||||
//no slashes
|
||||
$clip_name = str_replace('/', '|', $clip_name);
|
||||
$clip_name = str_replace('\\', '|', $clip_name);
|
||||
|
||||
//sql update
|
||||
$sql = "update v_clips set ";
|
||||
$sql .= "clip_name = '$clip_name', ";
|
||||
$sql .= "clip_folder = '$clip_folder', ";
|
||||
$sql .= "clip_text_start = '$clip_text_start', ";
|
||||
$sql .= "clip_text_end = '$clip_text_end', ";
|
||||
$sql .= "clip_desc = '$clip_desc', ";
|
||||
$sql .= "clip_order = '$clip_order' ";
|
||||
$sql .= "where clip_uuid = '$clip_uuid' ";
|
||||
$count = $db->exec(check_sql($sql));
|
||||
$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=clipoptions.php\">\n";
|
||||
echo $text['message-update'];
|
||||
require_once "footer.php";
|
||||
return;
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
//get the uuid from http values
|
||||
$clip_uuid = check_str($_GET["id"]);
|
||||
$clip_uuid = $_GET["id"];
|
||||
|
||||
//get the clip
|
||||
$sql = "select * from v_clips ";
|
||||
$sql .= "where clip_uuid = '$clip_uuid' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$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"];
|
||||
break; //limit to 1 row
|
||||
}
|
||||
unset($sql, $parameters, $row);
|
||||
}
|
||||
|
||||
//show the content
|
||||
@@ -110,19 +119,19 @@ else {
|
||||
|
||||
echo " <tr>";
|
||||
echo " <td colspan='2'>Before Selection<br>";
|
||||
echo " <textarea class='txt' name='clip_text_start'>$clip_text_start</textarea>";
|
||||
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' name='clip_text_end'>$clip_text_end</textarea>";
|
||||
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' name='clip_desc'>$clip_desc</textarea>";
|
||||
echo " <textarea class='txt' style='resize: vertical;' name='clip_desc'>$clip_desc</textarea>";
|
||||
echo " </td>";
|
||||
echo " </tr>";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user