Example #1
0
function customcontexts_getmodulevalue($id)
{
    static $moduledisplayname = null;
    static $moduleversion = null;
    global $db;
    switch ($id) {
        case 'moduledisplayname':
            if ($moduledisplayname === null) {
                $module_info = module_getinfo('customcontexts');
                $moduledisplayname = $module_info['customcontexts']['name'];
            }
            return $moduledisplayname;
            break;
        case 'moduleversion':
            if ($moduleversion === null) {
                $moduleversion = modules_getversion('customcontexts');
            }
            return $moduleversion;
            break;
        default:
            $sql = "select value from customcontexts_module where id = '{$id}'";
            $results = $db->getAll($sql);
            if (DB::IsError($results)) {
                $results = null;
            }
            return isset($results) ? $results[0][0] : null;
    }
}
Example #2
0
global $amp_conf;
if ($amp_conf["AMPDBENGINE"] == "sqlite3") {
    $sql = "\n\t\tCREATE TABLE IF NOT EXISTS ivr ( \n\t\t\tivr_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, \n\t\t\tdisplayname VARCHAR(50), \n\t\t\tdeptname VARCHAR(50), \n\t\t\tenable_directory VARCHAR(8), \n\t\t\tenable_directdial VARCHAR(8), \n\t\t\ttimeout INT, \n\t\t\tannouncement VARCHAR(255), \n\t\t\tdircontext VARCHAR ( 50 ) DEFAULT 'default', \n\t\t\talt_timeout VARCHAR(8), \n\t\t\talt_invalid VARCHAR(8), \n\t\t\t`loops` TINYINT(1) NOT NULL DEFAULT 2\n\t\t);\n\t";
} else {
    $sql = "\n\t\tCREATE TABLE IF NOT EXISTS ivr ( \n\t\t\tivr_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY\t, \n\t\t\tdisplayname VARCHAR(50), \n\t\t\tdeptname VARCHAR(50), \n\t\t\tenable_directory VARCHAR(8), \n\t\t\tenable_directdial VARCHAR(8), \n\t\t\ttimeout INT, \n\t\t\tannouncement VARCHAR(255), \n\t\t\tdircontext VARCHAR ( 50 ) DEFAULT 'default', \n\t\t\talt_timeout VARCHAR(8), \n\t\t\talt_invalid VARCHAR(8), \n\t\t\t`loops` TINYINT(1) NOT NULL DEFAULT 2\n\t\t);\n\t";
}
sql($sql);
$sql = "\nCREATE TABLE IF NOT EXISTS ivr_dests \n( \n\t`ivr_id` INT NOT NULL, \n\t`selection` VARCHAR(10), \n\t`dest` VARCHAR(50), \n\t`ivr_ret` TINYINT(1) NOT NULL DEFAULT 0\n)\n";
sql($sql);
// Now, we need to check for upgrades.
// V1.0, old IVR. You shouldn't see this, but check for it anyway, and assume that it's 2.0
// V2.0, Original Release
// V2.1, added 'directorycontext' to the schema
// v2.2, announcement changed to support filenames instead of ID's from recordings table
//
$ivr_modcurrentvers = modules_getversion('ivr');
if ($amp_conf["AMPDBENGINE"] != "sqlite3") {
    // As of 2.5 these are all in the sqlite3 schema
    // Add the col
    $sql = "SELECT dircontext FROM ivr";
    $check = $db->getRow($sql, DB_FETCHMODE_ASSOC);
    if (DB::IsError($check)) {
        // add new field
        $sql = 'ALTER TABLE ivr ADD COLUMN dircontext VARCHAR ( 50 ) DEFAULT "default"';
        $result = $db->query($sql);
        if (DB::IsError($result)) {
            die_freepbx($result->getDebugInfo());
        }
    }
    if ($ivr_modcurrentvers !== null && version_compare($ivr_modcurrentvers, "2.2", "<")) {
        // Change existing records
Example #3
0
 function build_manifest()
 {
     $ret = array("manifest_version" => 10, "hostname" => php_uname("n"), "fpbx_db" => "", "mysql" => "", "astdb" => "", "fpbx_cdrdb" => "", "name" => $this->b['name'], "ctime" => $this->b['_ctime'], "pbx_framework_version" => get_framework_version(), "backup_version" => modules_getversion('backup'), "pbx_version" => getversion(), "hooks" => array('pre_backup' => $this->b['prebu_hook'], 'post_backup' => $this->b['postbu_hook'], 'pre_restore' => $this->b['prere_hook'], 'post_restore' => $this->b['postre_hook']));
     // Actually generate the file list
     $ret["file_list"] = $this->getDirContents($this->b['_tmpdir']);
     // Remove the mysql/astdb files, add them seperatly
     foreach ($ret['file_list'] as $key => $file) {
         if (is_array($file)) {
             // It's a subdirectory. Ignore.
             continue;
         }
         // Is it the astdb? We don't report that as part of
         // the file manifest, so people can chose to restore
         // or not restore it individually.
         if ($file == 'astdb') {
             unset($ret['file_list'][$key]);
             $ret['astdb'] = 'astdb';
             continue;
         }
         // Is it a MySQL dump?
         if (strpos($file, 'mysql-') === 0) {
             //get server id
             $s = substr($file, 6);
             $s = substr($s, 0, -4);
             //get exclude
             foreach ($this->b['items'] as $i) {
                 if ($i['type'] == 'mysql' && $i['path'] == 'server-' . $s) {
                     $exclude = $i['exclude'];
                     break;
                 }
             }
             //build array on this server
             $ret['mysql'][$s] = array('file' => $file, 'host' => backup__($this->s[$s]['host']), 'port' => backup__($this->s[$s]['port']), 'name' => backup__($this->s[$s]['name']), 'dbname' => backup__($this->s[$s]['dbname']), 'exclude' => $exclude);
             //if this server is freepbx's primary server datastore, record that
             if ($ret['mysql'][$s]['dbname'] == $this->amp_conf['AMPDBNAME']) {
                 //localhost and 127.0.0.1 are intergangeable, so test both scenarios
                 if (in_array(strtolower($ret['mysql'][$s]['host']), array('localhost', '127.0.0.1')) && in_array(strtolower($this->amp_conf['AMPDBHOST']), array('localhost', '127.0.0.1')) || $ret['mysql'][$s]['host'] == $this->amp_conf['AMPDBHOST']) {
                     $ret['fpbx_db'] = 'mysql-' . $s;
                     unset($ret['file_list'][$key]);
                 }
                 //if this server is freepbx's primary cdr server datastore, record that
             } elseif ($ret['mysql'][$s]['dbname'] == $this->amp_conf['CDRDBNAME']) {
                 //localhost and 127.0.0.1 are intergangeable, so test both scenarios
                 if (in_array(strtolower($ret['mysql'][$s]['host']), array('localhost', '127.0.0.1')) && in_array(strtolower($this->amp_conf['CDRDBHOST']), array('localhost', '127.0.0.1')) || $ret['mysql'][$s]['host'] == $this->amp_conf['CDRDBHOST']) {
                     $ret['fpbx_cdrdb'] = 'mysql-' . $s;
                     unset($ret['file_list'][$key]);
                 }
             }
             continue;
         }
         // Also exclude random .lock files left around.
         if ($file == '.lock') {
             unset($ret['file_list'][$key]);
             // Yes, I know, I'm the last thing in the loop. Consistancy!
             continue;
         }
     }
     $ret['file_count'] = count($ret['file_list'], COUNT_RECURSIVE);
     $ret['mysql_count'] = $ret['mysql'] ? count($ret['mysql']) : 0;
     $ret['astdb_count'] = $ret['astdb'] ? count($ret['astdb']) : 0;
     $ret['ftime'] = time();
     //finish time
     $this->b['manifest'] = $ret;
 }
Example #4
0
}
global $astman;
global $amp_conf;
// Register FeatureCode - Activate
$fcc = new featurecode('voicemail', 'myvoicemail');
$fcc->setDescription('My Voicemail');
$fcc->setDefault('*97');
$fcc->update();
unset($fcc);
// Register FeatureCode - Deactivate
$fcc = new featurecode('voicemail', 'dialvoicemail');
$fcc->setDescription('Dial Voicemail');
$fcc->setDefault('*98');
$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\"");
        }
    } else {
        echo _("Cannot connect to Asterisk Manager with ") . $amp_conf["AMPMGRUSER"] . "/" . $amp_conf["AMPMGRPASS"];
        return false;
    }
    sql("update users set voicemail='novm' where voicemail='disabled' or voicemail='';");
}
Example #5
0
function timeconditions_updatedb()
{
    $ver = modules_getversion('timeconditions');
    if ($ver !== null && version_compare_freepbx($ver, '2.5', 'lt')) {
        outn(_("Checking for old timeconditions to upgrade.."));
        $upgradelist = timeconditions_list_forupgrade();
        if (isset($upgradelist)) {
            // we have old conditions to upgrade
            //
            out(_("starting migration"));
            foreach ($upgradelist as $upgrade) {
                $times[] = $upgrade['time'];
                $newid = _timeconditions_timegroups_add_group_timestrings('migrated-' . $upgrade['displayname'], $times);
                timeconditions_set_timegroupid($upgrade['timeconditions_id'], $newid);
                $newtimes = _timeconditions_timegroups_get_times($newid);
                out(sprintf(_("Upgraded %s and created group %s"), $upgrade['displayname'], 'migrated-' . $upgrade['displayname']));
                if (!is_array($newtimes)) {
                    out(sprintf(_("%sWARNING:%s No time defined for this condition, please review"), "<font color='red'>", "</font>"));
                }
                unset($times);
            }
        } else {
            out(_("no upgrade needed"));
        }
    }
}