function featurecodeadmin_update($req) { foreach ($req as $key => $item) { // Split up... // 0 - action // 1 - modulename // 2 - featurename $arr = explode("#", $key); if (count($arr) == 3) { $action = $arr[0]; $modulename = $arr[1]; $featurename = $arr[2]; $fieldvalue = $item; // Is there a more efficient way of doing this? switch ($action) { case "ena": $fcc = new featurecode($modulename, $featurename); if ($fieldvalue == 1) { $fcc->setEnabled(true); } else { $fcc->setEnabled(false); } $fcc->update(); break; case "custom": $fcc = new featurecode($modulename, $featurename); if ($fieldvalue == $fcc->getDefault()) { $fcc->setCode(''); // using default } else { $fcc->setCode($fieldvalue); } $fcc->update(); break; } } } needreload(); }
public function update($codes = array()) { if (!empty($codes)) { foreach ($codes as $module => $features) { foreach ($features as $name => $data) { $fcc = new \featurecode($module, $name); if (!empty($data['enable'])) { $fcc->setEnabled(true); } else { $fcc->setEnabled(false); } if (empty($data['customize']) || $data['code'] == $fcc->getDefault()) { $fcc->setCode(''); } else { $fcc->setCode($data['code']); } $fcc->update(); } } needreload(); } }
// the Free Software Foundation, either version 2 of the License, or // (at your option) any later version. // // FreePBX is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with FreePBX. If not, see <http://www.gnu.org/licenses/>. // // Copyright (C) 2005 mheydon1973 // //for translation only if (false) { _("Call Waiting"); _("Call Waiting - Activate"); _("Call Waiting - Deactivate"); } // Register FeatureCode - Activate $fcc = new featurecode('callwaiting', 'cwon'); $fcc->setDescription('Call Waiting - Activate'); $fcc->setDefault('*70'); $fcc->update(); unset($fcc); // Register FeatureCode - Deactivate $fcc = new featurecode('callwaiting', 'cwoff'); $fcc->setDescription('Call Waiting - Deactivate'); $fcc->setDefault('*71'); $fcc->update(); unset($fcc);
function miscapps_edit($miscapps_id, $description, $ext, $dest, $enabled = true) { global $db; $sql = "UPDATE miscapps SET " . "description = '" . $db->escapeSimple($description) . "', " . "ext = '" . $db->escapeSimple($ext) . "', " . "dest = '" . $db->escapeSimple($dest) . "' " . "WHERE miscapps_id = " . $db->escapeSimple($miscapps_id); $result = $db->query($sql); if (DB::IsError($result)) { die_freepbx($result->getMessage() . $sql); } $fc = new featurecode('miscapps', 'miscapp_' . $miscapps_id); $fc->setDescription($description); $fc->setDefault($ext, true); $fc->setEnabled($enabled); $fc->update(); }
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->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); } } }
/** * 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 edit($miscapps_id, $description, $ext, $dest, $enabled = true) { $db = $this->db; $sql = 'UPDATE miscapps SET description = ?, ext = ?, dest = ? WHERE miscapps_id = ?'; $q = $db->prepare($sql); $q->execute(array($description, $ext, $dest, $miscapps_id)); if ($q) { $fc = new \featurecode('miscapps', 'miscapp_' . $miscapps_id); $fc->setDescription($description); $fc->setDefault($ext, true); $fc->setEnabled($enabled); $fc->update(); } }
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(); }
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); }