<?php if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } //for translation only if (false) { _("Phonebook dial-by-name directory"); } // Enable phonebook directory as a feature code $fcc = new featurecode('pbdirectory', 'app-pbdirectory'); $fcc->setDescription('Phonebook dial-by-name directory'); $fcc->setDefault('411'); $fcc->setProvideDest(); $fcc->update(); unset($fcc);
/** * Update Recording by ID * @param integer $id The recording ID * @param string $name The recording short name * @param string $description The recording long name * @param string $files & separated list of files to playback * @param integer $fcode Feature Code number_format * @param string $fcode_pass Feature code password */ public function updateRecording($id, $name, $description, $files, $fcode = 0, $fcode_pass = '') { $sql = "UPDATE recordings SET displayname = ?, description = ?, filename = ?, fcode = ?, fcode_pass = ? WHERE id = ?"; $sth = $this->db->prepare($sql); $sth->execute(array($name, $description, $files, $fcode, $fcode_pass, $id)); if ($fcode != 1) { // delete the feature code if it existed // $fcc = new \featurecode('recordings', 'edit-recording-' . $id); $fcc->delete(); unset($fcc); } else { // Add the feature code if it is needed // $fcc = new \featurecode('recordings', 'edit-recording-' . $id); $fcc->setDescription("Edit Recording: {$name}"); $fcc->setDefault('*29' . $id); $fcc->setProvideDest(); $fcc->update(); unset($fcc); } needreload(); }
public function createFeatureCode($id, $displayname = '') { $fcc = new \featurecode('timeconditions', 'toggle-mode-' . $id); if ($displayname) { $fcc->setDescription("{$id}: {$displayname}"); } else { $fcc->setDescription($id . _(": Time Condition Override")); } $fcc->setDefault('*27' . $id); $fcc->setProvideDest(); $fcc->update(); unset($fcc); $this->setState($id, ''); }
function daynight_edit($post, $id = 0) { global $db; // TODO: Probably have separate add and edit (and change in page.daynight.php also) // Need to set the day/night mode in the system if new // Delete all the old dests if ($post['action'] != "add") { sql("DELETE FROM daynight WHERE dmode IN ('day', 'night', 'password', 'fc_description','day_recording_id','night_recording_id') AND ext = {$id}"); } $day = isset($post[$post['goto0'] . '0']) ? $post[$post['goto0'] . '0'] : ''; $night = isset($post[$post['goto1'] . '1']) ? $post[$post['goto1'] . '1'] : ''; sql("INSERT INTO daynight (ext, dmode, dest) VALUES ({$id}, 'day', '{$day}')"); sql("INSERT INTO daynight (ext, dmode, dest) VALUES ({$id}, 'night', '{$night}')"); if (isset($post['password']) && trim($post['password'] != "")) { $password = trim($post['password']); sql("INSERT INTO daynight (ext, dmode, dest) VALUES ({$id}, 'password', '{$password}')"); } $fc_description = isset($post['fc_description']) ? trim($post['fc_description']) : ""; sql("INSERT INTO daynight (ext, dmode, dest) VALUES ({$id}, 'fc_description', '" . $db->escapeSimple($fc_description) . "')"); $day_recording_id = isset($post['day_recording_id']) ? trim($post['day_recording_id']) : ""; sql("INSERT INTO daynight (ext, dmode, dest) VALUES ({$id}, 'day_recording_id', '{$day_recording_id}')"); $night_recording_id = isset($post['night_recording_id']) ? trim($post['night_recording_id']) : ""; sql("INSERT INTO daynight (ext, dmode, dest) VALUES ({$id}, 'night_recording_id', '{$night_recording_id}')"); $dn = new dayNightObject($id); $dn->del(); $dn->create($post['state']); $fcc = new featurecode('daynight', 'toggle-mode-' . $id); if ($fc_description) { $fcc->setDescription("{$id}: {$fc_description}"); } else { $fcc->setDescription("{$id}: Call Flow Toggle Control"); } $fcc->setDefault('*28' . $id); $fcc->setProvideDest(); $fcc->update(); unset($fcc); needreload(); }
function recordings_update($id, $rname, $descr, $request, $fcode = 0, $fcode_pass = '') { global $db; // Update the descriptive fields $fcode_pass = preg_replace("/[^0-9*]/", "", trim($fcode_pass)); $results = sql("UPDATE recordings SET displayname = '" . $db->escapeSimple($rname) . "', description = '" . $db->escapeSimple($descr) . "', fcode='{$fcode}', fcode_pass='******' WHERE id = '{$id}'"); // Build the file list from request $astsnd = isset($asterisk_conf['astvarlibdir']) ? $asterisk_conf['astvarlibdir'] : '/var/lib/asterisk'; $astsnd .= "/sounds/"; $recordings = array(); // Set the file names from the submitted page, sysrec[N] // We don't set if feature code was selected, we use what was already there // because the fields will have been disabled and won't be accessible in the // $request array anyhow // if ($fcode != 1) { // delete the feature code if it existed // $fcc = new featurecode('recordings', 'edit-recording-' . $id); $fcc->delete(); unset($fcc); foreach ($request as $key => $val) { $res = strpos($key, 'sysrec'); if ($res !== false) { // strip out any relative paths, since this is coming from a URL str_replace('..', '', $val); $recordings[substr($key, 6)] = $val; } } // Stick the filename in the database recordings_set_file($id, implode('&', $recordings)); } else { // Add the feature code if it is needed // $fcc = new featurecode('recordings', 'edit-recording-' . $id); $fcc->setDescription("Edit Recording: {$rname}"); $fcc->setDefault('*29' . $id); $fcc->setProvideDest(); $fcc->update(); unset($fcc); } // In request there are also various actions (possibly) // up[N] - Move file id N up one place // down[N] - Move fid N down one place // del[N] - Delete fid N foreach ($request as $key => $val) { if (strpos($key, "_") == 0) { $up = strpos($key, "up"); $down = strpos($key, "down"); $del = strpos($key, "del"); } if ($up !== false) { $up = substr($key, 2); recordings_move_file_up($id, $up); } if ($del !== false) { $del = substr($key, 3); recordings_delete_file($id, $del); } if ($down !== false) { $down = substr($key, 4); recordings_move_file_down($id, $down); } } }
public function install() { $fcc = new \featurecode('blacklist', 'blacklist_add'); $fcc->setDescription('Blacklist a number'); $fcc->setHelpText('Adds a number to the Blacklist Module. All calls from that number to the system will receive a disconnect recording. Manage these in the Blacklist module.'); $fcc->setDefault('*30'); $fcc->setProvideDest(); $fcc->update(); unset($fcc); $fcc = new \featurecode('blacklist', 'blacklist_remove'); $fcc->setDescription('Remove a number from the blacklist'); $fcc->setHelpText('Removes a number from the Blacklist Module'); $fcc->setDefault('*31'); $fcc->setProvideDest(); $fcc->update(); unset($fcc); $fcc = new featurecode('blacklist', 'blacklist_last'); $fcc->setDescription('Blacklist the last caller'); $fcc->setHelpText('Adds the last caller to the Blacklist Module. All calls from that number to the system will receive a disconnect recording.'); $fcc->setDefault('*32'); $fcc->update(); unset($fcc); }