Beispiel #1
0
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();
     }
 }
Beispiel #3
0
// If we found the old one then we must create all the new ones
//
if ($delete_old) {
    $list = daynight_list();
    foreach ($list as $item) {
        $id = $item['ext'];
        $fc_description = $item['dest'];
        $fcc = new featurecode('daynight', 'toggle-mode-' . $id);
        if ($fc_description) {
            $fcc->setDescription("{$id}: {$fc_description}");
        } else {
            $fcc->setDescription("{$id}: Day Night Control");
        }
        $fcc->setDefault('*28' . $id);
        if ($code != '*28' && $code != '') {
            $fcc->setCode($code . $id);
        }
        if (!$enabled) {
            $fcc->setEnabled(false);
        }
        $fcc->update();
        unset($fcc);
    }
}
// Sqlite3 does not like this syntax, but no migration needed since it started in 2.5
//
if ($amp_conf["AMPDBENGINE"] != "sqlite3") {
    outn(_("changing primary keys to all fields.."));
    $sql = 'ALTER TABLE `daynight` DROP PRIMARY KEY , ADD PRIMARY KEY ( `ext` , `dmode` , `dest` )';
    $results = $db->query($sql);
    if (DB::IsError($results)) {
Beispiel #4
0
        $res = $db->query($sql);
        if (!DB::IsError($globals)) {
            out(_("done"));
        } else {
            out(_("could not delete"));
        }
    }
}
// Now setup the new feature code, if blank then disable
//
$fcc = new featurecode('voicemail', 'directdialvoicemail');
$fcc->setDescription('Direct Dial Prefix');
$fcc->setDefault($default_prefix);
if ($current_prefix != $default_prefix) {
    if ($current_prefix != '') {
        $fcc->setCode($current_prefix);
    } else {
        $fcc->setEnabled(false);
    }
}
$fcc->update();
unset($fcc);
//1.6.2
$ver = modules_getversion('voicemail');
if ($ver !== null && version_compare($ver, '1.6.2', 'lt')) {
    //we have to fix existing users with wrong values for vm ticket #1697
    if ($astman) {
        $sql = "select * from users where voicemail='disabled' or voicemail='';";
        $users = sql($sql, "getAll", DB_FETCHMODE_ASSOC);
        foreach ($users as $user) {
            $astman->database_put("AMPUSER", $user['extension'] . "/voicemail", "\"novm\"");
Beispiel #5
0
        if ($code != '*28' && $code != '') {
            $fcc->setCode($code . $id);
        }
        if (!$enabled) {
            $fcc->setEnabled(false);
        }
        $fcc->update();
        unset($fcc);
    }
}
$fcc = new featurecode('daynight', 'toggle-mode-all');
$fcc->setDescription("All: Call Flow Toggle");
$fcc->setDefault('*28');
if ($delete_old) {
    if ($code != '*28' && $code != '') {
        $fcc->setCode($code);
    }
    if (!$enabled) {
        $fcc->setEnabled(false);
    }
}
$fcc->update();
unset($fcc);
// Sqlite3 does not like this syntax, but no migration needed since it started in 2.5
//
if ($amp_conf["AMPDBENGINE"] != "sqlite3") {
    outn(_("changing primary keys to all fields.."));
    $sql = 'ALTER TABLE `daynight` DROP PRIMARY KEY , ADD PRIMARY KEY ( `ext` , `dmode` , `dest` )';
    $results = $db->query($sql);
    if (DB::IsError($results)) {
        out(_("ERROR: failed to alter primary keys ") . $results->getMessage());