Exemplo n.º 1
0
function new_recording($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $dsn_agi_manager, $credentials)
{
    $domain = null;
    if ($credentials['userlevel'] != 'superadmin') {
        $domain = $credentials["domain"];
    } else {
        //el superadmin no tiene una extesion asociada por lo que no puede realizar esta accion
        $result["msg"] = _tr("Invalid Action");
        $result["status"] = "error";
        return $result;
    }
    $recording_name = getParameter("recording_name");
    if (basename($recording_name) != $recording_name) {
        $recording_name = '';
    }
    if (strpbrk($recording_name, "\r\n") !== FALSE) {
        $recording_name = '';
    }
    if ($recording_name != '') {
        $pRecording = new paloSantoRecordings($pDB);
        $filename = "/var/lib/asterisk/sounds/" . $domain . "/system/" . $recording_name . ".wav";
        //verifcamos que no haya otra grbacion con el mismo nombre
        //para no crear un nuevo registro en caso de qu eexista
        $checkRecordingName = $pRecording->checkFileName($filename);
        //obtenemos la extension del usuario que esta haciendo la grabacion
        $extension = $pRecording->Obtain_Extension_Current_User();
        if (!$extension) {
            $result["msg"] = _tr("An error has ocurred to obtain user extension");
            $result["status"] = "error";
            return $result;
        }
        $result = $pRecording->Obtain_Protocol_Current_User($domain, $extension);
        if ($result != FALSE) {
            $result = $pRecording->Call2Phone($dsn_agi_manager, $result['exten'], $result['dial'], $result['clid_name'], $recording_name, $domain);
            if ($result) {
                $result["filename"] = $recording_name;
                $result["msg"] = _tr("Recording...");
                $result["status"] = "ok";
                if ($checkRecordingName == TRUE) {
                    $pDB->beginTransaction();
                    $name = $recording_name . ".wav";
                    $success = $pRecording->createNewRecording($name, $filename, "system", $domain);
                    if ($success) {
                        $pDB->commit();
                        $name = $recording_name . ".wav";
                        $recId = $pRecording->getId($name, "system", $domain);
                        $id = $recId["uniqueid"];
                        $result["id"] = $id;
                    } else {
                        $pDB->rollBack();
                        $error = $pRecording->errMsg;
                        $result["msg"] = _tr("The record couldn't be saved ");
                        $result["status"] = "error";
                    }
                }
            } else {
                $result["msg"] = _tr("The record couldn't be realized.") . " " . _tr($pRecording->errMsg);
                $result["status"] = "error";
            }
        } else {
            $result["msg"] = _tr("An error has ocurred to obtain user extension");
            $result["status"] = "error";
        }
    } else {
        $result["msg"] = _tr("Insert the Recording Name.");
        $result["status"] = "error";
    }
    return $result;
}
Exemplo n.º 2
0
function new_recording($smarty, $module_name, $local_templates_dir, $arrLang, $dsn_agi_manager, $arrConf, $pDBACL)
{
    $recording_name = isset($_POST['recording_name']) ? $_POST['recording_name'] : '';
    if ($recording_name != '') {
        $pRecording = new paloSantoRecordings();
        $result = $pRecording->Obtain_Protocol_Current_User($arrConf);
        $number2call = '*77';
        if ($result != FALSE) {
            $result = $pRecording->Call2Phone($dsn_agi_manager, $result['id'], $number2call, $result['dial'], $result['description']);
            if ($result) {
                $smarty->assign("filename", $recording_name);
                $smarty->assign("mb_message", $arrLang["To continue: record a message then click on save"]);
            } else {
                $smarty->assign("mb_title", $arrLang['ERROR'] . ":");
                $smarty->assign("mb_message", $arrLang["The call couldn't be realized"]);
            }
        }
    } else {
        $smarty->assign("mb_title", $arrLang["Validation Error"]);
        $smarty->assign("mb_message", $arrLang['Insert the Recording Name']);
    }
    return form_Recordings($smarty, $module_name, $local_templates_dir, $arrLang, $pDBACL);
}