Beispiel #1
0
function _moduleContent(&$smarty, $module_name)
{
    //include module files
    include_once "modules/{$module_name}/configs/default.conf.php";
    include_once "modules/{$module_name}/libs/paloSantoMyExtension.class.php";
    //include file language agree to elastix configuration
    //if file language not exists, then include language by default (en)
    $lang = get_language();
    $base_dir = dirname($_SERVER['SCRIPT_FILENAME']);
    $lang_file = "modules/{$module_name}/lang/{$lang}.lang";
    if (file_exists("{$base_dir}/{$lang_file}")) {
        include_once "{$lang_file}";
    } else {
        include_once "modules/{$module_name}/lang/en.lang";
    }
    //global variables
    global $arrConf;
    global $arrConfModule;
    global $arrLang;
    global $arrLangModule;
    $arrConf = array_merge($arrConf, $arrConfModule);
    $arrLang = array_merge($arrLang, $arrLangModule);
    //folder path for custom templates
    $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes';
    $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme'];
    //conexion resource
    $arrConf['dsn_conn_database'] = generarDSNSistema('asteriskuser', 'asterisk');
    $pDB = new paloDB($arrConf['dsn_conn_database']);
    $pDBACL = new paloDB($arrConf['elastix_dsn']['acl']);
    $pACL = new paloACL($pDBACL);
    $user = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : "";
    $extension = $pACL->getUserExtension($user);
    $isAdministrator = $pACL->isUserAdministratorGroup($user);
    if ($extension == "" || is_null($extension)) {
        if ($isAdministrator) {
            $smarty->assign("mb_message", "<b>" . $arrLang["no_extension"] . "</b>");
        } else {
            $smarty->assign("mb_message", "<b>" . $arrLang["contact_admin"] . "</b>");
        }
        return "";
    }
    //actions
    $action = getAction();
    $content = "";
    switch ($action) {
        case "save_new":
            $content = saveNewMyExtension($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrLang, $extension, $isAdministrator);
            break;
        default:
            // view_form
            $content = viewFormMyExtension($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrLang, $extension);
            break;
    }
    return $content;
}
 function setApplets_User($arrIDs_DAU, $user)
 {
     global $arrConf;
     $dsn = "sqlite3:///{$arrConf['elastix_dbdir']}/dashboard.db";
     $pDB = new paloDB($dsn);
     if (is_array($arrIDs_DAU) & count($arrIDs_DAU) > 0) {
         $pDB2 = new paloDB($arrConf['elastix_dsn']['acl']);
         $pACL = new paloACL($pDB2);
         if ($pACL->isUserAdministratorGroup($user)) {
             $typeUser = "******";
         } else {
             $typeUser = "******";
         }
         $pDB->beginTransaction();
         // Parte 1: Elimino todas las actuales
         $query1 = " delete from activated_applet_by_user \n                        where username=? and id_dabu in (select id from default_applet_by_user where username=?)";
         $result1 = $pDB->genQuery($query1, array($user, $typeUser));
         if ($result1 == FALSE) {
             $this->errMsg = $pDB->errMsg;
             $pDB->rollBack();
             return false;
         }
         // Parte 2: Inserto todas las checked
         foreach ($arrIDs_DAU as $key => $value) {
             $query2 = "insert into activated_applet_by_user (id_dabu, order_no, username) values (?,?,?)";
             $result2 = $pDB->genQuery($query2, array($value, $key + 1, $user));
             if ($result2 == FALSE) {
                 $this->errMsg = $pDB->errMsg;
                 $pDB->rollBack();
                 return false;
             }
         }
         $pDB->commit();
     }
     return true;
 }
Beispiel #3
0
function _moduleContent(&$smarty, $module_name)
{
    include_once "libs/paloSantoGrid.class.php";
    include_once "libs/paloSantoConfig.class.php";
    include_once "libs/paloSantoACL.class.php";
    include_once "libs/paloSantoForm.class.php";
    require_once "libs/misc.lib.php";
    include_once "lib/paloSantoVoiceMail.class.php";
    //include module files
    include_once "modules/{$module_name}/configs/default.conf.php";
    $lang = get_language();
    $base_dir = dirname($_SERVER['SCRIPT_FILENAME']);
    $lang_file = "modules/{$module_name}/lang/{$lang}.lang";
    if (file_exists("{$base_dir}/{$lang_file}")) {
        include_once "{$lang_file}";
    } else {
        include_once "modules/{$module_name}/lang/en.lang";
    }
    //global variables
    global $arrConf;
    global $arrConfModule;
    global $arrLang;
    global $arrLangModule;
    $arrConf = array_merge($arrConf, $arrConfModule);
    $arrLang = array_merge($arrLang, $arrLangModule);
    //folder path for custom templates
    $base_dir = dirname($_SERVER['SCRIPT_FILENAME']);
    $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes';
    $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme'];
    //segun el usuario que esta logoneado consulto si tiene asignada extension para buscar los voicemails
    $pDB = new paloDB($arrConf['elastix_dsn']['acl']);
    $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*");
    $arrAMP = $pConfig->leer_configuracion(false);
    $dsnAsterisk = $arrAMP['AMPDBENGINE']['valor'] . "://" . $arrAMP['AMPDBUSER']['valor'] . ":" . $arrAMP['AMPDBPASS']['valor'] . "@" . $arrAMP['AMPDBHOST']['valor'] . "/asterisk";
    $pDB_ast = new paloDB($dsnAsterisk);
    if (!empty($pDB->errMsg)) {
        echo "ERROR DE DB: {$pDB->errMsg} <br>";
    }
    $arrData = array();
    $pACL = new paloACL($pDB);
    if (!empty($pACL->errMsg)) {
        echo "ERROR DE ACL: {$pACL->errMsg} <br>";
    }
    $arrVoiceData = array();
    $inicio = $fin = $total = 0;
    $extension = $pACL->getUserExtension($_SESSION['elastix_user']);
    $ext = $extension;
    $esAdministrador = $pACL->isUserAdministratorGroup($_SESSION['elastix_user']);
    $bandCustom = true;
    if (is_null($ext) || $ext == "") {
        $bandCustom = false;
        if (!$esAdministrador) {
            $smarty->assign("mb_message", "<b>" . $arrLang["contact_admin"] . "</b>");
            return "";
        }
    }
    if ($esAdministrador) {
        $extension = "[[:digit:]]+";
    }
    $smarty->assign("menu", "voicemail");
    $smarty->assign("Filter", $arrLang['Show']);
    //formulario para el filtro
    $arrFormElements = createFieldFormVoiceList($arrLang);
    $oFilterForm = new paloForm($smarty, $arrFormElements);
    // Por omision las fechas toman el sgte. valor (la fecha de hoy)
    $date_start = date("Y-m-d") . " 00:00:00";
    $date_end = date("Y-m-d") . " 23:59:59";
    $dateStartFilter = getParameter('date_start');
    $dateEndFilter = getParameter('date_end');
    $report = false;
    if (getParameter('filter')) {
        if ($oFilterForm->validateForm($_POST)) {
            // Exito, puedo procesar los datos ahora.
            $date_start = translateDate($dateStartFilter) . " 00:00:00";
            $date_end = translateDate($dateEndFilter) . " 23:59:59";
            $arrFilterExtraVars = array("date_start" => $dateStartFilter, "date_end" => $dateEndFilter);
        } else {
            // Error
            $smarty->assign("mb_title", $arrLang["Validation Error"]);
            $arrErrores = $oFilterForm->arrErroresValidacion;
            $strErrorMsg = "<b>{$arrLang['The following fields contain errors']}:</b><br>";
            foreach ($arrErrores as $k => $v) {
                $strErrorMsg .= "{$k}, ";
            }
            $strErrorMsg .= "";
            $smarty->assign("mb_message", $strErrorMsg);
        }
        if ($dateStartFilter == "") {
            $dateStartFilter = " ";
        }
        if ($dateEndFilter == "") {
            $dateEndFilter = " ";
        }
        //se añade control a los filtros
        $report = true;
        $arrDate = array('date_start' => $dateStartFilter, 'date_end' => $dateEndFilter);
        $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    } else {
        if (isset($dateStartFilter) and isset($dateEndFilter)) {
            $report = true;
            $date_start = translateDate($dateStartFilter) . " 00:00:00";
            $date_end = translateDate($dateEndFilter) . " 23:59:59";
            $arrDate = array('date_start' => $dateStartFilter, 'date_end' => $dateEndFilter);
            $arrFilterExtraVars = array("date_start" => $dateStartFilter, "date_end" => $dateEndFilter);
            $htmlFilter = $contenidoModulo = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_GET);
        } else {
            $report = true;
            //se añade control a los filtros
            $arrDate = array('date_start' => date("d M Y"), 'date_end' => date("d M Y"));
            $htmlFilter = $contenidoModulo = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", array('date_start' => date("d M Y"), 'date_end' => date("d M Y")));
        }
    }
    $oGrid = new paloSantoGrid($smarty);
    if ($report) {
        $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Start Date") . " = " . $arrDate['date_start'] . ", " . _tr("End Date") . " = " . $arrDate['date_end'], $arrDate, array('date_start' => date("d M Y"), 'date_end' => date("d M Y")), true);
    }
    if (getParameter('submit_eliminar')) {
        borrarVoicemails();
        if ($oFilterForm->validateForm($_POST)) {
            // Exito, puedo procesar los datos ahora.
            $date_start = translateDate($_POST['date_start']) . " 00:00:00";
            $date_end = translateDate($_POST['date_end']) . " 23:59:59";
            $arrFilterExtraVars = array("date_start" => $_POST['date_start'], "date_end" => $_POST['date_end']);
        }
        $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    }
    if (getParameter('config')) {
        if (!(is_null($ext) || $ext == "")) {
            return form_config($smarty, $module_name, $local_templates_dir, $arrLang, $ext, $pDB_ast);
        }
    }
    if (getParameter('save')) {
        if (!save_config($smarty, $module_name, $local_templates_dir, $arrLang, $ext, $pDB_ast)) {
            return form_config($smarty, $module_name, $local_templates_dir, $arrLang, $ext, $pDB_ast);
        }
    }
    if (getParameter('action') == "display_record") {
        $file = getParameter("name");
        $ext = getParameter("ext");
        $user = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : "";
        $extension = $pACL->getUserExtension($user);
        $esAdministrador = $pACL->isUserAdministratorGroup($user);
        $path = "/var/spool/asterisk/voicemail/default";
        $voicemailPath = "{$path}/{$ext}/INBOX/" . base64_decode($file);
        $tmpfile = basename($voicemailPath);
        $filetmp = "{$path}/{$ext}/INBOX/{$tmpfile}";
        if (!is_file($filetmp)) {
            die("<b>404 " . $arrLang["no_file"] . "</b>");
        }
        if (!$esAdministrador) {
            if ($extension != $ext) {
                die("<b>404 " . $arrLang["no_file"] . "</b>");
            }
            $voicemailPath = "{$path}/{$extension}/INBOX/" . base64_decode($file);
        }
        if (isset($file) && preg_match("/^[[:alpha:]]+[[:digit:]]+\\.(wav|WAV|Wav|mp3|gsm)\$/", base64_decode($file))) {
            if (!is_file($voicemailPath)) {
                die("<b>404 " . $arrLang["no_file"] . "</b>");
            }
            $sContenido = "";
            $name = basename($voicemailPath);
            $format = substr(strtolower($name), -3);
            // This will set the Content-Type to the appropriate setting for the file
            $ctype = '';
            switch ($format) {
                case "mp3":
                    $ctype = "audio/mpeg";
                    break;
                case "wav":
                    $ctype = "audio/x-wav";
                    break;
                case "Wav":
                    $ctype = "audio/x-wav";
                    break;
                case "WAV":
                    $ctype = "audio/x-wav";
                    break;
                case "gsm":
                    $ctype = "audio/x-gsm";
                    break;
                    // not downloadable
                // not downloadable
                default:
                    die("<b>404 " . $arrLang["no_file"] . "</b>");
                    break;
            }
            if ($sContenido == "") {
                $session_id = session_id();
            }
            $sContenido = <<<contenido
                    <embed src='index.php?menu={$module_name}&action=download&ext={$ext}&name={$file}&rawmode=yes&elastixSession={$session_id}' width=300, height=20 autoplay=true loop=false type="{$ctype}"></embed><br>
contenido;
            $smarty->assign("CONTENT", $sContenido);
            $smarty->display("_common/popup.tpl");
        } else {
            die("<b>404 " . $arrLang["no_file"] . "</b>");
        }
        return;
    }
    if (getParameter('action') == "download") {
        $user = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : "";
        $extension = $pACL->getUserExtension($user);
        $esAdministrador = $pACL->isUserAdministratorGroup($user);
        $record = getParameter("name");
        $ext = getParameter("ext");
        if (!preg_match("/^[[:digit:]]+\$/", $ext)) {
            Header("HTTP/1.1 404 Not Found");
            die("<b>404 " . $arrLang["no_file"] . "</b>");
        }
        $record = base64_decode($record);
        $path = "/var/spool/asterisk/voicemail/default";
        $voicemailPath = "{$path}/{$ext}/INBOX/" . $record;
        //"$path/$record";
        $tmpfile = basename($voicemailPath);
        $filetmp = "{$path}/{$ext}/INBOX/{$tmpfile}";
        if (!is_file($filetmp)) {
            die("<b>404 " . $arrLang["no_file"] . "</b>");
        }
        if (!$esAdministrador) {
            if ($extension != $ext) {
                Header("HTTP/1.1 404 Not Found");
                die("<b>404 " . $arrLang["no_extension"] . "</b>");
            }
            $voicemailPath = "{$path}/{$extension}/INBOX/" . $record;
        }
        if (isset($record) && preg_match("/^[[:alpha:]]+[[:digit:]]+\\.(wav|WAV|Wav|mp3|gsm)\$/", $record)) {
            // See if the file exists
            if (!is_file($voicemailPath)) {
                Header("HTTP/1.1 404 Not Found");
                die("<b>404 " . $arrLang["no_file"] . "</b>");
            }
            // Gather relevent info about file
            $size = filesize($voicemailPath);
            $name = basename($voicemailPath);
            //$extension = strtolower(substr(strrchr($name,"."),1));
            $extension = substr(strtolower($name), -3);
            // This will set the Content-Type to the appropriate setting for the file
            $ctype = '';
            switch ($extension) {
                case "mp3":
                    $ctype = "audio/mpeg";
                    break;
                case "wav":
                    $ctype = "audio/x-wav";
                    break;
                case "Wav":
                    $ctype = "audio/x-wav";
                    break;
                case "WAV":
                    $ctype = "audio/x-wav";
                    break;
                case "gsm":
                    $ctype = "audio/x-gsm";
                    break;
                    // not downloadable
                // not downloadable
                default:
                    die("<b>404 " . $arrLang["no_file"] . "</b>");
                    break;
            }
            // need to check if file is mislabeled or a liar.
            $fp = fopen($voicemailPath, "rb");
            if ($size && $ctype && $fp) {
                header("Pragma: public");
                header("Expires: 0");
                header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                header("Cache-Control: public");
                header("Content-Description: wav file");
                header("Content-Type: " . $ctype);
                header("Content-Disposition: attachment; filename=" . $name);
                header("Content-Transfer-Encoding: binary");
                header("Content-length: " . $size);
                fpassthru($fp);
            }
        } else {
            Header("HTTP/1.1 404 Not Found");
            die("<b>404 " . $arrLang["no_file"] . "</b>");
        }
        return;
    }
    $end = 0;
    $url = array('menu' => $module_name);
    //si tiene extension consulto sino, muestro un mensaje de que no tiene asociada extension
    $archivos = array();
    if (!(is_null($ext) || $ext == "") || $esAdministrador) {
        if (is_null($ext) || $ext == "") {
            $smarty->assign("mb_message", "<b>" . $arrLang["no_extension_assigned"] . "</b>");
        }
        $path = "/var/spool/asterisk/voicemail/default";
        $folder = "INBOX";
        if ($esAdministrador) {
            if ($handle = opendir($path)) {
                while (false !== ($dir = readdir($handle))) {
                    if ($dir != "." && $dir != ".." && ereg($extension, $dir, $regs) && is_dir($path . "/" . $dir)) {
                        $directorios[] = $dir;
                    }
                }
            }
        } else {
            $directorios[] = $extension;
        }
        //if($esAdministrador)
        $arrData = array();
        foreach ($directorios as $directorio) {
            $voicemailPath = "{$path}/{$directorio}/{$folder}";
            if (file_exists($voicemailPath)) {
                if ($handle = opendir($voicemailPath)) {
                    $bExito = true;
                    while (false !== ($file = readdir($handle))) {
                        //no tomar en cuenta . y ..
                        //buscar los archivos de texto (txt) que son los que contienen los datos de las llamadas
                        if ($file != "." && $file != ".." && ereg("(.+)\\.[txt|TXT]", $file, $regs)) {
                            //leer la info del archivo
                            $pConfig = new paloConfig($voicemailPath, $file, "=", "[[:space:]]*=[[:space:]]*");
                            $arrVoiceMailDes = array();
                            $arrVoiceMailDes = $pConfig->leer_configuracion(false);
                            //verifico que tenga datos
                            if (is_array($arrVoiceMailDes) && count($arrVoiceMailDes) > 0 && isset($arrVoiceMailDes['origtime']['valor'])) {
                                //uso las fechas del filtro
                                //si la fecha de llamada esta dentro del rango, la muestro
                                $fecha = date("Y-m-d", $arrVoiceMailDes['origtime']['valor']);
                                $hora = date("H:i:s", $arrVoiceMailDes['origtime']['valor']);
                                if (strtotime("{$fecha} {$hora}") <= strtotime($date_end) && strtotime("{$fecha} {$hora}") >= strtotime($date_start)) {
                                    $arrTmp[0] = "<input type='checkbox' name='" . utf8_encode("voc-" . $file) . ",{$directorio}' />";
                                    $arrTmp[1] = $fecha;
                                    $arrTmp[2] = $hora;
                                    $arrTmp[3] = $arrVoiceMailDes['callerid']['valor'];
                                    $arrTmp[4] = $arrVoiceMailDes['origmailbox']['valor'];
                                    $arrTmp[5] = $arrVoiceMailDes['duration']['valor'] . ' sec.';
                                    $pathRecordFile = base64_encode($regs[1] . '.wav');
                                    $recordingLink = "<a href='#' onClick=\"javascript:popUp('index.php?menu={$module_name}&action=display_record&ext={$directorio}&name={$pathRecordFile}&rawmode=yes',350,100); return false;\">{$arrLang['Listen']}</a>&nbsp;";
                                    $recordingLink .= "<a href='?menu={$module_name}&action=download&ext={$directorio}&name={$pathRecordFile}&rawmode=yes'>{$arrLang['Download']}</a>";
                                    $arrTmp[6] = $recordingLink;
                                    $arrData[] = $arrTmp;
                                }
                            }
                        }
                    }
                    closedir($handle);
                }
            } else {
                // No vale la ruta
            }
        }
        /*
        function sort_voicemails_hora_desc($a, $b) { return ($a[2] == $b[2]) ? 0 : (($a[2] < $b[2]) ? 1 : -1); }
        function sort_voicemails_fecha_desc($a, $b) { return ($a[1] == $b[1]) ? 0 : (($a[1] < $b[1]) ? 1 : -1); }
        usort($arrData, 'sort_voicemails_hora_desc');
        usort($arrData, 'sort_voicemails_fecha_desc');
        */
        $fechas = array();
        $horas = array();
        foreach ($arrData as $llave => $fila) {
            $fechas[$llave] = $fila[1];
            $horas[$llave] = $fila[2];
        }
        array_multisort($fechas, SORT_DESC, $horas, SORT_DESC, $arrData);
        //Paginacion
        $limit = 15;
        $total = count($arrData);
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
        $end = $offset + $limit <= $total ? $offset + $limit : $total;
        // Construyo el URL base
        if (isset($arrFilterExtraVars) && is_array($arrFilterExtraVars) and count($arrFilterExtraVars) > 0) {
            $url = array_merge($url, $arrFilterExtraVars);
        }
        //Fin Paginacion
        $arrVoiceData = array_slice($arrData, $offset, $limit);
    } else {
        $smarty->assign("mb_message", "<b>" . $arrLang["contact_admin"] . "</b>");
    }
    $arrGrid = array("title" => $arrLang["Voicemail List"], "url" => $url, "icon" => "/modules/{$module_name}/images/pbx_voicemail.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total, "columns" => array(0 => array("name" => "", "property1" => ""), 1 => array("name" => $arrLang["Date"], "property1" => ""), 2 => array("name" => $arrLang["Time"], "property1" => ""), 3 => array("name" => $arrLang["CallerID"], "property1" => ""), 4 => array("name" => $arrLang["Extension"], "property1" => ""), 5 => array("name" => $arrLang["Duration"], "property1" => ""), 6 => array("name" => $arrLang["Message"], "property1" => "")));
    if ($bandCustom == true) {
        $oGrid->customAction("config", _tr("Configuration"));
    }
    $oGrid->deleteList(_tr("Are you sure you wish to delete voicemails?"), "submit_eliminar", _tr("Delete"));
    $oGrid->showFilter($htmlFilter);
    $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrVoiceData, $arrLang);
    if (strpos($contenidoModulo, '<form') === FALSE) {
        $contenidoModulo = "<form style='margin-bottom:0;' method='POST' action='?menu={$module_name}'>{$contenidoModulo}</form>";
    }
    return $contenidoModulo;
}
Beispiel #4
0
function report_conference($smarty, $module_name, $local_templates_dir, $pDB, $arrLang2, $arrConfig, $dsn_agi_manager, $dsnAsterisk)
{
    global $arrLang;
    global $arrConf;
    $bSoporteWebConf = file_exists('modules/conferenceroom_list/libs/conferenceActions.lib.php');
    $arrConference = array("Past_Conferences" => $arrLang["Past Conferences"], "Current_Conferences" => $arrLang["Current Conferences"], "Future_Conferences" => $arrLang["Future Conferences"]);
    $arrFormElements = array("conference" => array("LABEL" => $arrLang["State"], "REQUIRED" => "yes", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrConference, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "", "EDITABLE" => "no", "SIZE" => "1"), "filter" => array("LABEL" => $arrLang["Filter"], "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => array("id" => "filter_value"), "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""));
    $oFilterForm = new paloForm($smarty, $arrFormElements);
    $smarty->assign("SHOW", $arrLang["Show"]);
    // $smarty->assign("NEW_CONFERENCE", $arrLang["New Conference"]);
    $startDate = $endDate = date("Y-m-d H:i:s");
    $conference = getParameter("conference");
    $field_pattern = getParameter("filter");
    if ($conference) {
        $_POST['conference'] = $conference;
    } else {
        $_POST['conference'] = "Current_Conferences";
    }
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("State") . " = " . $arrConference[$_POST['conference']], $_POST, array("conference" => "Current_Conferences"), true);
    $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Conference Name") . " = {$field_pattern}", $_POST, array("filter" => ""));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/conference.tpl", "", $_POST);
    $pConference = new paloSantoConference($pDB);
    $total_datos = $pConference->ObtainNumConferences($startDate, $endDate, "confDesc", $field_pattern, $conference);
    //Paginacion
    $limit = 8;
    $total = $total_datos[0];
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $end = $offset + $limit <= $total ? $offset + $limit : $total;
    $url = array('menu' => $module_name, 'conference' => $conference, 'filter' => $field_pattern);
    //Fin Paginacion
    $arrResult = $pConference->ObtainConferences($limit, $offset, $startDate, $endDate, "confDesc", $field_pattern, $conference);
    $pConfWeb = NULL;
    if ($bSoporteWebConf) {
        $pConfWeb = embedded_prepareWebConfLister();
    }
    $arrData = null;
    if (is_array($arrResult) && $total > 0) {
        // En caso de haber soporte de conferencias web, se recoge el ID de
        // conferencia telefónica asociada a la conferencia web, y se construye
        // la lista de datos para las columnas adicionales
        $listaWebConf = array();
        if (!is_null($pConfWeb)) {
            $pACL = new paloACL($arrConf['elastix_dsn']['acl']);
            $listaWC = $pConfWeb->listarConferencias($pACL->isUserAdministratorGroup($_SESSION['elastix_user']));
            foreach ($listaWC as $tuplaConf) {
                if (!is_null($tuplaConf['id_cbmysql_conference'])) {
                    $listaWebConf[$tuplaConf['id_cbmysql_conference']] = $tuplaConf;
                }
            }
        }
        foreach ($arrResult as $key => $conference) {
            $arrTmp[0] = "<input type='checkbox' name='conference_{$conference['bookId']}'  />";
            $arrTmp[1] = "<a href='?menu={$module_name}&accion=view_conference&conferenceId=" . $conference['bookId'] . "'>" . htmlentities($conference['confDesc'], ENT_COMPAT, "UTF-8") . "</a>";
            $arrTmp[2] = $conference['roomNo'];
            $arrTmp[3] = $conference['startTime'] . ' - ' . $conference['endTime'];
            if ($_POST['conference'] == "Current_Conferences") {
                $arrCallers = $pConference->ObtainCallers($dsn_agi_manager, $conference['roomNo']);
                $numCallers = count($arrCallers);
                $arrTmp[4] = "<a href='?menu={$module_name}&accion=show_callers&roomNo=" . $conference['roomNo'] . "'>{$numCallers} / {$conference['maxUser']}</a>";
            } else {
                $arrTmp[4] = $conference['maxUser'];
            }
            if ($bSoporteWebConf) {
                $arrTmp[5] = '';
                $arrTmp[6] = '';
                $arrTmp[7] = '';
                $arrTmp[8] = '';
                if (isset($listaWebConf[$conference['bookId']])) {
                    $tuplaConf = $listaWebConf[$conference['bookId']];
                    $arrTmp[5] = htmlentities($tuplaConf['tema'], ENT_COMPAT, "UTF-8");
                    $arrTmp[6] = $tuplaConf['num_invitados'];
                    $arrTmp[7] = $tuplaConf['num_documentos'];
                    $arrTmp[8] = "<a href=\"?menu={$module_name}&amp;action=list_guests&amp;id_conference={$tuplaConf['id_conferencia']}\">[{$arrLang['List guests']}]</a>&nbsp;" . "<a href=\"?menu={$module_name}&amp;action=list_chatlog&amp;id_conference={$tuplaConf['id_conferencia']}\">[{$arrLang['Chatlog']}]</a>";
                }
            }
            $arrData[] = $arrTmp;
        }
    }
    $arrGrid = array("title" => $arrLang["Conference"], "url" => $url, "icon" => "/modules/{$module_name}/images/pbx_conference.png", "width" => "99%", "start" => $total == 0 ? 0 : $offset + 1, "end" => $end, "total" => $total, 'columns' => array(array('name' => ""), array("name" => $arrLang["Conference Name"]), array("name" => $arrLang["Conference #"]), array('name' => 'Period'), array('name' => $arrLang["Participants"])));
    if ($bSoporteWebConf) {
        $arrGrid['columns'][] = array('name' => $arrLang['Topic']);
        $arrGrid['columns'][] = array('name' => $arrLang['# Guests']);
        $arrGrid['columns'][] = array('name' => $arrLang['# Docs']);
        $arrGrid['columns'][] = array('name' => $arrLang['Options']);
    }
    $oGrid->addNew("new_conference", _tr('New Conference'));
    $oGrid->deleteList(_tr("Are you sure you wish to delete conference (es)?"), "delete_conference", _tr("Delete"));
    $oGrid->showFilter(trim($htmlFilter));
    $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang);
    return $contenidoModulo;
}
Beispiel #5
0
 private function _controlServicio($sAccion)
 {
     global $arrConf;
     $respuesta = array('status' => 'success', 'message' => '(no message)');
     $acciones = array('start', 'restart', 'stop', 'on', 'off');
     $servicios = array('Asterisk' => 'asterisk', 'OpenFire' => 'openfire', 'Hylafax' => 'hylafax', 'Postfix' => 'postfix', 'MySQL' => 'mysqld', 'Apache' => 'httpd', 'Dialer' => 'elastixdialer');
     if (!isset($_REQUEST['process'])) {
         $respuesta['status'] = 'error';
         $respuesta['message'] = _tr('Invalid request');
     } elseif (!in_array($_REQUEST['process'], array_keys($servicios))) {
         $respuesta['status'] = 'error';
         $respuesta['message'] = _tr('Invalid service');
     } elseif (!in_array($sAccion, $acciones)) {
         $respuesta['status'] = 'error';
         $respuesta['message'] = _tr('Invalid process action');
     } else {
         $pDBACL = new paloDB($arrConf['elastix_dsn']['acl']);
         if (!empty($pDBACL->errMsg)) {
             $respuesta['status'] = 'error';
             $respuesta['message'] = "ERROR DE DB: {$pDBACL->errMsg}";
         } else {
             $pACL = new paloACL($pDBACL);
             if (!empty($pACL->errMsg)) {
                 $respuesta['status'] = 'error';
                 $respuesta['message'] = "ERROR DE ACL: {$pACL->errMsg}";
             } elseif (!$pACL->isUserAdministratorGroup($_SESSION['elastix_user'])) {
                 $respuesta['status'] = 'error';
                 $respuesta['message'] = _tr('Process control restricted to administrators');
             } else {
                 $flag = 0;
                 $sServicio = $_REQUEST['process'];
                 $output = $retval = NULL;
                 if ($sAccion == 'off' || $sAccion == 'on') {
                     exec('/usr/bin/elastix-helper rchkconfig --level 3 ' . escapeshellarg($servicios[$sServicio]) . ' ' . escapeshellarg($sAccion), $output, $retval);
                     $arrServices = $this->getStatusServices();
                     if ($arrServices[$sServicio]["status_service"] == "Shutdown" && $sAccion == 'on' || $arrServices[$sServicio]["status_service"] == "OK" && $sAccion == 'off') {
                         $sAccion = $sAccion == 'off' ? 'stop' : 'start';
                     } else {
                         $flag = 1;
                     }
                 }
                 if ($flag != 1) {
                     exec('sudo -u root service generic-cloexec ' . $servicios[$sServicio] . ' ' . $sAccion . ' 1>/dev/null 2>/dev/null');
                 }
             }
         }
     }
     $json = new Services_JSON();
     Header('Content-Type: application/json');
     return $json->encode($respuesta);
 }
Beispiel #6
0
 function setDefaultActivatedAppletsByUser($user)
 {
     global $arrConf;
     $dsn = "sqlite3:///{$arrConf['elastix_dbdir']}/dashboard.db";
     $pDB = new paloDB($dsn);
     $pDB2 = new paloDB($arrConf['elastix_dsn']['acl']);
     $pACL = new paloACL($pDB2);
     if ($pACL->isUserAdministratorGroup($user)) {
         $id_dabu = 1;
     } else {
         $id_dabu = 13;
     }
     for ($i = 1; $i <= 5; $i++) {
         $query = "insert into activated_applet_by_user (id_dabu,order_no,username) values (?,?,?)";
         $result = $pDB->genQuery($query, array($id_dabu, $i, $user));
         if ($result == FALSE) {
             $this->errMsg = $pDB->errMsg;
             return false;
         }
         $id_dabu++;
     }
     return true;
 }
Beispiel #7
0
function isAdministrator()
{
    include_once "libs/paloSantoACL.class.php";
    require_once "modules/agent_console/libs/JSON.php";
    global $arrConf;
    $pDBACL = new paloDB($arrConf['elastix_dsn']['acl']);
    $pACL = new paloACL($pDBACL);
    $user = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : "";
    $esAdministrador = $pACL->isUserAdministratorGroup($user);
    $json = new Services_JSON();
    Header('Content-Type: application/json');
    return $json->encode($esAdministrador);
}
Beispiel #8
0
    /**
     * Procedimiento para leer la lista de los applets activados para el usuario.
     * Para compatibilidad con la implementación anterior, y como efecto 
     * secundario, si el usuario indicado no tiene applets activados, se crea una
     * nueva lista de activaciones por omisión y se guarda esta lista durante la
     * consulta.
     * 
     * @param   string  $user   Usuario de sistema para el cual se consulta
     * 
     * @return  mixed   NULL en caso de error, o lista de applets activados.
     */
    function leerAppletsActivados($user)
    {
        global $arrConf;
        // Leer rol del usuario: admin o no_admin
        $pDB2 = new paloDB($arrConf['elastix_dsn']['acl']);
        $pACL = new paloACL($pDB2);
        $rol = $pACL->isUserAdministratorGroup($user) ? 'admin' : 'no_admin';
        // Verificar si hay applets activados para este usuario
        $tupla = $this->_db->getFirstRowQuery('SELECT COUNT(*) AS n FROM activated_applet_by_user WHERE username = ?', TRUE, array($user));
        if (!is_array($tupla)) {
            $this->errMsg = $this->_db->errMsg;
            return NULL;
        }
        if ($tupla['n'] <= 0) {
            /* No hay applets activados. Se consulta el mapeo de applets por 
             * omisión.
             * FIXME: esto es esencialmente un grupo de applets disponibles por
             * rol, el cual debería estar representado en una tabla separada. No
             * hay manera de cambiar desde la interfaz web si es que se requiere
             * un número distinto de applets por omisión, o un orden distinto.
             * La implementación actual requiere que hayan al menos 5 applets
             * en el mapeo de la base de datos, empezando desde el mínimo ID 
             * con el rol requerido. Por lo menos ya no está quemado el ID 
             * inicial como en la implementación anterior.
             */
            $num_applets_omision = 5;
            $recordset = $this->_db->fetchTable('SELECT id FROM default_applet_by_user WHERE username = ? ORDER BY id LIMIT ?', TRUE, array($rol, $num_applets_omision));
            if (!is_array($recordset)) {
                $this->errMsg = $this->_db->errMsg;
                return NULL;
            }
            for ($i = 0; $i < count($recordset); $i++) {
                $r = $this->_db->genQuery('INSERT INTO activated_applet_by_user (id_dabu, order_no, username) VALUES (?, ?, ?)', array($recordset[$i]['id'], $i + 1, $user));
                if (!$r) {
                    $this->errMsg = $this->_db->errMsg;
                    return NULL;
                }
            }
        }
        // Consultar el mapeo de applets para el usuario actual
        $sql = <<<SQL_APPLETS_BY_USER
SELECT a.code, a.name, aau.id AS aau_id, a.icon
FROM activated_applet_by_user aau, default_applet_by_user dau, applet a
WHERE aau.id_dabu = dau.id AND dau.id_applet = a.id AND dau.username = ?
    AND aau.username = ?
ORDER BY aau.order_no
SQL_APPLETS_BY_USER;
        $recordset = $this->_db->fetchTable($sql, TRUE, array($rol, $user));
        if (!is_array($recordset)) {
            $this->errMsg = $this->_db->errMsg;
            return NULL;
        }
        $listaApplets = array();
        foreach ($recordset as $tupla) {
            $code = $tupla['code'];
            if (substr($code, 0, 7) == 'Applet_') {
                $code = substr($code, 7);
            }
            $tupla['applet'] = $code;
            $listaApplets[] = $tupla;
        }
        return $listaApplets;
    }
Beispiel #9
0
function saveNewKey($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrAST, $arrAMP)
{
    $arrFormNew = createFieldForm($pDB);
    $arrValues['id'] = getParameter("Extension");
    $arrValues['key'] = getParameter("Current_Secret");
    $arrValues['new_key'] = getParameter("New_Secret");
    $confirmation = getParameter("Confirm_New_Secret");
    $pDB2 = new paloDB($arrConf['elastix_dsn']['acl']);
    $pACL = new paloACL($pDB2);
    $oForm = new paloForm($smarty, $arrFormNew);
    if (!$oForm->validateForm($_POST)) {
        // Falla la validación básica del formulario
        $strErrorMsg = "<b>" . _tr('The following fields contain errors') . ":</b><br/>";
        $arrErrores = $oForm->arrErroresValidacion;
        if (is_array($arrErrores) && count($arrErrores) > 0) {
            foreach ($arrErrores as $k => $v) {
                $strErrorMsg .= "{$k}: [{$v['mensaje']}] <br /> ";
            }
        }
        $smarty->assign("mb_title", _tr("Validation Error"));
        $smarty->assign("mb_message", $strErrorMsg);
        return editWeakKeys($smarty, $module_name, $local_templates_dir, $arrConf, $pDB, $arrValues['id']);
    }
    $pWeakKeys = new paloSantoWeakKeys($pDB);
    $device = $pWeakKeys->getWeakKeyById($arrValues['id']);
    if (!$pACL->isUserAdministratorGroup($_SESSION['elastix_user'])) {
        if ($arrValues['key'] != $device['data']) {
            $smarty->assign("mb_title", _tr("Error"));
            $smarty->assign("mb_message", _tr("The Current Secret is invalid"));
            return editWeakKeys($smarty, $module_name, $local_templates_dir, $arrConf, $pDB, $arrValues['id']);
        }
    }
    if ($arrValues['new_key'] != $confirmation) {
        $smarty->assign("mb_title", _tr("Error"));
        $smarty->assign("mb_message", _tr("The New Secret does not match with the Confirmation Secret"));
        return editWeakKeys($smarty, $module_name, $local_templates_dir, $arrConf, $pDB, $arrValues['id']);
    }
    $mensaje = getMensaje($arrValues['id'], $arrValues['new_key']);
    if ($mensaje != "OK") {
        $smarty->assign("mb_title", _tr("Error"));
        $smarty->assign("mb_message", $mensaje);
        return editWeakKeys($smarty, $module_name, $local_templates_dir, $arrConf, $pDB, $arrValues['id']);
    }
    if (!$pWeakKeys->saveNewKey($arrValues, $device['tech'])) {
        $smarty->assign("mb_title", _tr("Error"));
        $smarty->assign("mb_message", $pWeakKeys->errMsg);
        return editWeakKeys($smarty, $module_name, $local_templates_dir, $arrConf, $pDB, $arrValues['id']);
    }
    $data_connection = array('host' => $arrConf['AMI_HOST'], 'user' => $arrConf['AMI_USER'], 'password' => $arrConf['AMI_PASS']);
    $pLoadExtension = new paloSantoLoadExtension($pDB);
    if (!$pLoadExtension->do_reloadAll($data_connection, $arrAST, $arrAMP)) {
        $smarty->assign("mb_title", _tr("Error"));
        $smarty->assign("mb_message", $pLoadExtension->errMsg);
        return editWeakKeys($smarty, $module_name, $local_templates_dir, $arrConf, $pDB, $arrValues['id']);
    }
    $smarty->assign("mb_title", _tr("Message"));
    $smarty->assign("mb_message", _tr("Successful Secret Update"));
    return reportWeakKeys($smarty, $module_name, $local_templates_dir, $pDB, $arrConf);
}
Beispiel #10
0
function _moduleContent(&$smarty, $module_name)
{
    //include module files
    include_once "modules/{$module_name}/configs/default.conf.php";
    include_once "modules/{$module_name}/libs/paloSantoMonitoring.class.php";
    include_once "libs/paloSantoACL.class.php";
    //include file language agree to elastix configuration
    //if file language not exists, then include language by default (en)
    $lang = get_language();
    $base_dir = dirname($_SERVER['SCRIPT_FILENAME']);
    // Include language file for EN, then for local, and merge the two.
    include_once "modules/{$module_name}/lang/en.lang";
    $lang_file = "modules/{$module_name}/lang/{$lang}.lang";
    if (file_exists("{$base_dir}/{$lang_file}")) {
        $arrLanEN = $arrLangModule;
        include_once $lang_file;
        $arrLangModule = array_merge($arrLanEN, $arrLangModule);
    }
    //global variables
    global $arrConf;
    global $arrConfModule;
    global $arrLang;
    global $arrLangModule;
    $arrConf = array_merge($arrConf, $arrConfModule);
    $arrLang = array_merge($arrLang, $arrLangModule);
    //folder path for custom templates
    $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes';
    $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme'];
    //conexion resource
    $arrConf['dsn_conn_database'] = generarDSNSistema('asteriskuser', 'asteriskcdrdb');
    $pDB = new paloDB($arrConf['dsn_conn_database']);
    $pDBACL = new paloDB($arrConf['elastix_dsn']['acl']);
    $pACL = new paloACL($pDBACL);
    $user = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : "";
    $extension = $pACL->getUserExtension($user);
    $esAdministrador = $pACL->isUserAdministratorGroup($user);
    if ($extension == "" || is_null($extension)) {
        if ($esAdministrador) {
            $smarty->assign("mb_message", "<b>" . _tr("no_extension") . "</b>");
        } else {
            $smarty->assign("mb_message", "<b>" . _tr("contact_admin") . "</b>");
            return "";
        }
    }
    //actions
    $action = getAction();
    $content = "";
    switch ($action) {
        case 'delete':
            $content = deleteRecord($smarty, $module_name, $local_templates_dir, $pDB, $pACL, $arrConf, $user, $extension, $esAdministrador);
            break;
        case 'download':
            $content = downloadFile($smarty, $module_name, $local_templates_dir, $pDB, $pACL, $arrConf, $user, $extension, $esAdministrador);
            break;
        case "display_record":
            $content = display_record($smarty, $module_name, $local_templates_dir, $pDB, $pACL, $arrConf, $user, $extension, $esAdministrador);
            break;
        default:
            $content = reportMonitoring($smarty, $module_name, $local_templates_dir, $pDB, $pACL, $arrConf, $user, $extension, $esAdministrador);
            break;
    }
    return $content;
}
Beispiel #11
0
function reconstruir_mailBox($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $arrLang)
{
    $pACL = new paloACL(new paloDB($arrConf['elastix_dsn']['acl']));
    $pEmail = new paloEmail($pDB);
    $userAccount = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : "";
    $isAdmisnistrator = $pACL->isUserAdministratorGroup($userAccount);
    if ($isAdmisnistrator) {
        if ($pEmail->resconstruirMailBox(getParameter("username"))) {
            $smarty->assign("mb_title", _tr('MESSAGE') . ":");
            $smarty->assign("mb_message", _tr("The MailBox was reconstructed succefully"));
        } else {
            $smarty->assign("mb_title", _tr('ERROR') . ":");
            $smarty->assign("mb_message", _tr("The MailBox couldn't be reconstructed.\n" . $pEmail->errMsg));
        }
    }
    unset($_GET['action']);
    return viewFormAccount($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrLang);
}
Beispiel #12
0
/**
    funcion que sirve para obtener las credenciales de un usuario
    @return
    Array => ( idUser => (idUser or ""),
               id_organization => (ID_ORG or false),
               userlevel => (superadmin,organization),
               domain => (dominio de la ORG or false)
             )
*/
function getUserCredentials($username)
{
    global $arrConf, $elxPath;
    require_once "{$elxPath}/libs/paloSantoACL.class.php";
    $pdbACL = new paloDB($arrConf['elastix_dsn']['elastix']);
    $pACL = new paloACL($pdbACL);
    $userLevel1 = "other";
    $idOrganization = $domain = false;
    $idUser = $pACL->getIdUser($username);
    if ($idUser != false) {
        $idOrganization = $pACL->getIdOrganizationUser($idUser);
        if ($idOrganization != false) {
            if ($pACL->isUserSuperAdmin($username)) {
                $userLevel1 = "superadmin";
            } elseif ($pACL->isUserAdministratorGroup($username)) {
                $userLevel1 = "admin";
            }
        }
    }
    if ($idOrganization != false) {
        //obtenemos el dominio de las organizacion
        $query = "SELECT domain from organization where id=?";
        $result = $pdbACL->getFirstRowQuery($query, false, array($idOrganization));
        if ($result == false) {
            $domain = false;
        } else {
            if (!preg_match("/^(([[:alnum:]-]+)\\.)+([[:alnum:]])+\$/", $result[0])) {
                $domain = false;
            } else {
                $domain = $result[0];
            }
        }
    }
    return array("idUser" => $idUser, "id_organization" => $idOrganization, "userlevel" => $userLevel1, "domain" => $domain);
}
Beispiel #13
0
function _moduleContent(&$smarty, $module_name)
{
    include_once "libs/paloSantoDB.class.php";
    include_once "libs/paloSantoConfig.class.php";
    include_once "libs/paloSantoGrid.class.php";
    include_once "libs/paloSantoACL.class.php";
    include_once "modules/{$module_name}/configs/default.conf.php";
    //include file language agree to elastix configuration
    //if file language not exists, then include language by default (en)
    $lang = get_language();
    $base_dir = dirname($_SERVER['SCRIPT_FILENAME']);
    $lang_file = "modules/{$module_name}/lang/{$lang}.lang";
    if (file_exists("{$base_dir}/{$lang_file}")) {
        include_once "{$lang_file}";
    } else {
        include_once "modules/{$module_name}/lang/en.lang";
    }
    //global variables
    global $arrConf;
    global $arrConfModule;
    global $arrLang;
    global $arrLangModule;
    $arrConf = array_merge($arrConf, $arrConfModule);
    $arrLang = array_merge($arrLang, $arrLangModule);
    //conexion acl.db
    $pDB = new paloDB($arrConf['elastix_dsn']['acl']);
    //folder path for custom templates
    $base_dir = dirname($_SERVER['SCRIPT_FILENAME']);
    $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes';
    $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme'];
    $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*");
    $arrConfig = $pConfig->leer_configuracion(false);
    $dsn = $arrConfig['AMPDBENGINE']['valor'] . "://" . $arrConfig['AMPDBUSER']['valor'] . ":" . $arrConfig['AMPDBPASS']['valor'] . "@" . $arrConfig['AMPDBHOST']['valor'] . "/asterisk";
    $pDBa = new paloDB($dsn);
    ////////////////////
    if (!empty($pDB->errMsg)) {
        echo "ERROR DE DB: {$pDB->errMsg} <br>";
    }
    $arrData = array();
    $arrData[""] = $arrLang["no extension"];
    $pACL = new paloACL($pDB);
    if (!empty($pACL->errMsg)) {
        echo "ERROR DE ACL: {$pACL->errMsg} <br>";
    }
    /*******/
    $typeUser = "";
    $userLevel1 = "";
    $extOther = "";
    $userAccount = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : "";
    $idUserAccount = $pACL->isUserAdministratorGroup($userAccount);
    $idUserInt = $pACL->getIdUser($userAccount);
    if ($idUserAccount) {
        $userLevel1 = "admin";
    } else {
        $userLevel1 = "other";
    }
    $smarty->assign("userLevel1", $userLevel1);
    /*******/
    $sQuery = "select extension from users order by extension;";
    $arrayResult = $pDBa->fetchTable($sQuery, true);
    if (!$arrayResult) {
        $error = $pDBa->errMsg;
    } else {
        if (is_array($arrayResult) && count($arrayResult) > 0) {
            //$arrData[$item["null"]] = "No extension";
            if ($idUserAccount) {
                foreach ($arrayResult as $item) {
                    $arrData[$item["extension"]] = $item["extension"];
                }
            } else {
                $idOther = $pACL->getIdUser($userAccount);
                $arrUserOther = $pACL->getUsers($idOther);
                $extOther = $arrUserOther[0][3];
                $arrData[$extOther] = $extOther;
            }
        }
    }
    $arrGruposACL = $pACL->getGroups();
    for ($i = 0; $i < count($arrGruposACL); $i++) {
        if ($arrGruposACL[$i][1] == 'administrator') {
            $arrGruposACL[$i][1] = $arrLang['administrator'];
        } else {
            if ($arrGruposACL[$i][1] == 'operator') {
                $arrGruposACL[$i][1] = $arrLang['operator'];
            } else {
                if ($arrGruposACL[$i][1] == 'extension') {
                    $arrGruposACL[$i][1] = $arrLang['extension'];
                }
            }
        }
        if ($idUserAccount) {
            $arrGrupos[$arrGruposACL[$i][0]] = $arrGruposACL[$i][1];
        } else {
            $arrUserPer = $pACL->getMembership($idUserInt);
            foreach ($arrUserPer as $key => $value) {
                if ($arrGruposACL[$i][1] == $key) {
                    $arrGrupos[$arrGruposACL[$i][0]] = $arrGruposACL[$i][1];
                }
            }
        }
    }
    $arrFormElements = array("description" => array("LABEL" => "{$arrLang['Name']} {$arrLang['(Ex. John Doe)']}", "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "name" => array("LABEL" => $arrLang["Login"], "REQUIRED" => "yes", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "", "EDITABLE" => "no"), "password1" => array("LABEL" => $arrLang["Password"], "REQUIRED" => "yes", "INPUT_TYPE" => "PASSWORD", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "password2" => array("LABEL" => $arrLang["Retype password"], "REQUIRED" => "yes", "INPUT_TYPE" => "PASSWORD", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "group" => array("LABEL" => $arrLang["Group"], "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrGrupos, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "extension" => array("LABEL" => $arrLang["Extension"], "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrData, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "webmailpassword1" => array("LABEL" => $arrLang["Webmail Password"], "REQUIRED" => "no", "INPUT_TYPE" => "PASSWORD", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "webmailuser" => array("LABEL" => $arrLang["Webmail User"], "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "webmaildomain" => array("LABEL" => $arrLang["Webmail Domain"], "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""));
    $contenidoModulo = "";
    $smarty->assign("REQUIRED_FIELD", $arrLang["Required field"]);
    $smarty->assign("CANCEL", $arrLang["Cancel"]);
    $smarty->assign("APPLY_CHANGES", $arrLang["Apply changes"]);
    $smarty->assign("SAVE", $arrLang["Save"]);
    $smarty->assign("EDIT", $arrLang["Edit"]);
    $smarty->assign("DELETE", $arrLang["Delete"]);
    $smarty->assign("CONFIRM_CONTINUE", $arrLang["Are you sure you wish to continue?"]);
    $smarty->assign("icon", "images/user.png");
    $smarty->assign("title_webmail", $arrLang["Mail Profile"]);
    if (isset($_POST['submit_create_user'])) {
        // Implementar
        include_once "libs/paloSantoForm.class.php";
        $arrFillUser['description'] = '';
        $arrFillUser['name'] = '';
        $arrFillUser['group'] = '';
        $arrFillUser['extension'] = '';
        $arrFillUser['password1'] = '';
        $arrFillUser['password2'] = '';
        $oForm = new paloForm($smarty, $arrFormElements);
        $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/new.tpl", $arrLang["New User"], $arrFillUser);
    } else {
        if (!is_null(getParameter("edit"))) {
            $contenidoModulo = editUser($userAccount, $pACL, $pDB, $arrFormElements, $smarty, $local_templates_dir, $arrLang, $idUserAccount, $userLevel1);
        } else {
            if (isset($_POST['submit_save_user'])) {
                include_once "libs/paloSantoForm.class.php";
                $oForm = new paloForm($smarty, $arrFormElements);
                if ($oForm->validateForm($_POST)) {
                    // Exito, puedo procesar los datos ahora.
                    $pACL = new paloACL($pDB);
                    if (empty($_POST['password1']) or $_POST['password1'] != $_POST['password2']) {
                        // Error claves
                        $smarty->assign("mb_message", $arrLang["The passwords are empty or don't match"]);
                        $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/new.tpl", $arrLang["New User"], $_POST);
                    } else {
                        if ($userLevel1 == "admin") {
                            // Creo al usuario
                            $md5_password = md5($_POST['password1']);
                            $pACL->createUser($_POST['name'], $_POST['description'], $md5_password, $_POST['extension']);
                            $idUser = $pACL->getIdUser($_POST['name']);
                            // Versiones viejas del archivo acl.db tienen una fila con una
                            // tupla que asocia al usuario inexistente con ID 2, con el
                            // grupo 2 (Operadores). Se limpia cualquier membresía extraña.
                            $listaMembresia = $pACL->getMembership($idUser);
                            if (is_array($listaMembresia) && count($listaMembresia) > 0) {
                                foreach ($listaMembresia as $idGrupo) {
                                    $pACL->delFromGroup($idUser, $idGrupo);
                                }
                            }
                            // Creo la membresia
                            $pACL->addToGroup($idUser, $_POST['group']);
                            $bExito = TRUE;
                            if (empty($pACL->errMsg)) {
                                $nuevasPropiedades = array();
                                if (!empty($_POST['webmailuser'])) {
                                    $nuevasPropiedades['login'] = $_POST['webmailuser'];
                                }
                                if (!empty($_POST['webmailpassword1'])) {
                                    $nuevasPropiedades['password'] = $_POST['webmailpassword1'];
                                }
                                if (!empty($_POST['webmaildomain'])) {
                                    $nuevasPropiedades['domain'] = $_POST['webmaildomain'];
                                }
                                $bExito = actualizarPropiedades($pDB, $smarty, $idUser, 'webmail', 'default', $nuevasPropiedades);
                            }
                            if (!empty($pACL->errMsg)) {
                                // Ocurrio algun error aqui
                                $smarty->assign("mb_message", "ERROR: {$pACL->errMsg}");
                                $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/new.tpl", $arrLang["New User"], $_POST);
                            } else {
                                if ($bExito) {
                                    header("Location: ?menu=userlist");
                                }
                            }
                        } else {
                            $smarty->assign("mb_message", $arrLang["userNoAllowed"]);
                        }
                    }
                } else {
                    // Error
                    $smarty->assign("mb_title", $arrLang["Validation Error"]);
                    $arrErrores = $oForm->arrErroresValidacion;
                    $strErrorMsg = "<b>{$arrLang['The following fields contain errors']}:</b><br>";
                    foreach ($arrErrores as $k => $v) {
                        $strErrorMsg .= "{$k}, ";
                    }
                    $strErrorMsg .= "";
                    $smarty->assign("mb_message", $strErrorMsg);
                    $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/new.tpl", $arrLang["New User"], $_POST);
                }
            } else {
                if (isset($_POST['submit_apply_changes'])) {
                    $arrayContent = applyChanges($userAccount, $pACL, $smarty, $arrLang, $idUserAccount, $userLevel1, $arrFormElements, $pDB, $local_templates_dir, $idUserInt, $extOther);
                    if (isset($arrayContent["mb_title"]) && isset($arrayContent["mb_message"])) {
                        $smarty->assign("mb_title", $arrayContent["mb_title"]);
                        $smarty->assign("mb_message", $arrayContent["mb_message"]);
                    }
                    if ($arrayContent["success"]) {
                        header("Location: ?menu=userlist");
                    } else {
                        if (isset($arrayContent["id_user"])) {
                            $smarty->assign("id_user", $_POST['id_user']);
                        }
                        if (isset($arrayContent["fill_user"])) {
                            $contenidoModulo = $arrayContent["form"]->fetchForm("{$local_templates_dir}/new.tpl", $arrLang["Edit User"], $arrayContent["fill_user"]);
                        } else {
                            $contenidoModulo = $arrayContent["content"];
                        }
                    }
                } else {
                    if (isset($_GET['action']) && $_GET['action'] == "view") {
                        if (!$pACL->isUserAdministratorGroup($userAccount)) {
                            if ($pACL->getIdUser($userAccount) != $_GET['id']) {
                                $smarty->assign("mb_title", $arrLang["ERROR"]);
                                $smarty->assign("mb_message", $arrLang["You are not authorized to access to information of that user"]);
                                return reportUserList($arrLang, $pACL, $idUserAccount, $smarty, $userLevel1, $userAccount);
                            }
                        }
                        include_once "libs/paloSantoForm.class.php";
                        $oForm = new paloForm($smarty, $arrFormElements);
                        //- TODO: Tengo que validar que el id sea valido, si no es valido muestro un mensaje de error
                        $oForm->setViewMode();
                        // Esto es para activar el modo "preview"
                        $arrUser = $pACL->getUsers($_GET['id']);
                        // Conversion de formato
                        $arrTmp['name'] = $arrUser[0][1];
                        $arrTmp['description'] = $arrUser[0][2];
                        $arrTmp['password1'] = "****";
                        $arrTmp['password2'] = "****";
                        $arrTmp['extension'] = $arrUser[0][3];
                        //- TODO: Falta llenar el grupo
                        $arrMembership = $pACL->getMembership($_GET['id']);
                        $id_group = "";
                        if (is_array($arrMembership)) {
                            foreach ($arrMembership as $groupName => $groupId) {
                                $id_group = $groupId;
                                // Asumo que cada usuario solo puede pertenecer a un grupo
                                break;
                            }
                        }
                        $arrTmp['group'] = $id_group;
                        $listaPropiedades = leerPropiedadesWebmail($pDB, $smarty, $_GET['id']);
                        if (isset($listaPropiedades['login'])) {
                            $arrTmp['webmailuser'] = $listaPropiedades['login'];
                        }
                        if (isset($listaPropiedades['domain'])) {
                            $arrTmp['webmaildomain'] = $listaPropiedades['domain'];
                        }
                        if (isset($listaPropiedades['password'])) {
                            $arrTmp['webmailpassword1'] = '****';
                        }
                        //if (isset($listaPropiedades['imapsvr'])) $arrTmp['webmailimapsvr'] = $listaPropiedades['imapsvr'];
                        $smarty->assign("id_user", $_GET['id']);
                        $contenidoModulo = $oForm->fetchForm("{$local_templates_dir}/new.tpl", $arrLang["View User"], $arrTmp);
                        // hay que pasar el arreglo
                    } else {
                        if (getParameter('action') == "edit_userExtension") {
                            $smarty->assign("editUserExtension", "yes");
                            $html = editUser($userAccount, $pACL, $pDB, $arrFormElements, $smarty, $local_templates_dir, $arrLang, $idUserAccount, $userLevel1);
                            $smarty->assign("CONTENT", $html);
                            $smarty->assign("THEMENAME", $arrConf['mainTheme']);
                            $smarty->assign("MODULE_NAME", $module_name);
                            $smarty->assign("path", "");
                            $contenidoModulo = $smarty->display("{$local_templates_dir}/edit_userExtension.tpl");
                        } else {
                            if (getParameter('action') == "apply_changes_UserExtension") {
                                include_once "libs/paloSantoJSON.class.php";
                                $jsonObject = new PaloSantoJSON();
                                $result = applyChanges($userAccount, $pACL, $smarty, $arrLang, $idUserAccount, $userLevel1, $arrFormElements, $pDB, $local_templates_dir, $idUserInt, $extOther);
                                $arrMessage["mb_title"] = isset($result["mb_title"]) ? $result["mb_title"] : null;
                                $arrMessage["mb_message"] = isset($result["mb_message"]) ? $result["mb_message"] : null;
                                $arrMessage["success"] = $result["success"];
                                $jsonObject->set_message($arrMessage);
                                $contenidoModulo = $jsonObject->createJSON();
                            } else {
                                $contenidoModulo = reportUserList($arrLang, $pACL, $idUserAccount, $smarty, $userLevel1, $userAccount);
                            }
                        }
                    }
                }
            }
        }
    }
    return $contenidoModulo;
}
Beispiel #14
0
function form_Recordings($smarty, $module_name, $local_templates_dir, $arrLang, $pDBACL)
{
    $pACL = new paloACL($pDBACL);
    $user = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : "";
    $extension = $pACL->getUserExtension($user);
    if (is_null($extension) || $extension == "") {
        $smarty->assign("DISABLED", "DISABLED");
        if ($pACL->isUserAdministratorGroup($user)) {
            $smarty->assign("mb_message", "<b>" . $arrLang["You don't have extension number associated with user"] . "</b>");
        } else {
            $smarty->assign("mb_message", "<b>" . $arrLang["contact_admin"] . "</b>");
        }
    }
    if (isset($_POST['option_record']) && $_POST['option_record'] == 'by_file') {
        $smarty->assign("check_file", "checked");
    } else {
        $smarty->assign("check_record", "checked");
    }
    $oForm = new paloForm($smarty, array());
    $smarty->assign("recording_name_Label", $arrLang["Record Name"]);
    $smarty->assign("record_Label", $arrLang["File Upload"]);
    $smarty->assign("Record", $arrLang["Record"]);
    $smarty->assign("SAVE", $arrLang["Save"]);
    $smarty->assign("INFO", $arrLang["You can start your recording after you hear a beep in your phone. Once you have finished recording you must press the # key and then hangup"] . ".");
    $smarty->assign("NAME", $arrLang["You do not need to add an extension to the record name"] . ".");
    $smarty->assign("icon", "/modules/{$module_name}/images/recording.png");
    $smarty->assign("module_name", $module_name);
    $smarty->assign("file_upload", $arrLang["File Upload"]);
    $smarty->assign("record", $arrLang["Record"]);
    $htmlForm = $oForm->fetchForm("{$local_templates_dir}/form.tpl", $arrLang["Recordings"], $_POST);
    $contenidoModulo = "<form enctype='multipart/form-data' method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>";
    return $contenidoModulo;
}
Beispiel #15
0
function _moduleContent(&$smarty, $module_name)
{
    require_once "modules/{$module_name}/libs/ringgroup.php";
    //include module files
    include_once "modules/{$module_name}/configs/default.conf.php";
    load_language_module($module_name);
    global $arrConf;
    global $arrConfModule;
    $arrConf = array_merge($arrConf, $arrConfModule);
    //folder path for custom templates
    $base_dir = dirname($_SERVER['SCRIPT_FILENAME']);
    $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes';
    $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme'];
    // DSN para consulta de cdrs
    $dsn = generarDSNSistema('asteriskuser', 'asteriskcdrdb');
    $pDB = new paloDB($dsn);
    $oCDR = new paloSantoCDR($pDB);
    $pDBACL = new paloDB($arrConf['elastix_dsn']['acl']);
    if (!empty($pDBACL->errMsg)) {
        return "ERROR DE DB: {$pDBACL->errMsg}";
    }
    $pACL = new paloACL($pDBACL);
    if (!empty($pACL->errMsg)) {
        return "ERROR DE ACL: {$pACL->errMsg}";
    }
    $exten = $pACL->getUserExtension($_SESSION['elastix_user']);
    $isAdministrator = $pACL->isUserAdministratorGroup($_SESSION['elastix_user']);
    if (is_null($exten) || $exten == "") {
        if (!$isAdministrator) {
            $smarty->assign('mb_message', "<b>" . _tr("contact_admin") . "</b>");
            return "";
        } else {
            $smarty->assign('mb_message', "<b>" . _tr("no_extension") . "</b>");
        }
    }
    // Para usuarios que no son administradores, se restringe a los CDR de la
    // propia extensión
    $sExtension = $isAdministrator ? '' : $pACL->getUserExtension($_SESSION['elastix_user']);
    // DSN para consulta de ringgroups
    $dsn_asterisk = generarDSNSistema('asteriskuser', 'asterisk');
    $pDB_asterisk = new paloDB($dsn_asterisk);
    $oRG = new RingGroup($pDB_asterisk);
    $dataRG = $oRG->getRingGroup();
    $dataRG[''] = _tr('(Any ringgroup)');
    // Cadenas estáticas en la plantilla
    $smarty->assign(array("Filter" => _tr("Filter")));
    $arrFormElements = array("date_start" => array("LABEL" => _tr("Start Date"), "REQUIRED" => "yes", "INPUT_TYPE" => "DATE", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "ereg", "VALIDATION_EXTRA_PARAM" => "^[[:digit:]]{1,2}[[:space:]]+[[:alnum:]]{3}[[:space:]]+[[:digit:]]{4}\$"), "date_end" => array("LABEL" => _tr("End Date"), "REQUIRED" => "yes", "INPUT_TYPE" => "DATE", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "ereg", "VALIDATION_EXTRA_PARAM" => "^[[:digit:]]{1,2}[[:space:]]+[[:alnum:]]{3}[[:space:]]+[[:digit:]]{4}\$"), "field_name" => array("LABEL" => _tr("Field Name"), "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => array("dst" => _tr("Destination"), "src" => _tr("Source"), "channel" => _tr("Src. Channel"), "accountcode" => _tr("Account Code"), "dstchannel" => _tr("Dst. Channel")), "VALIDATION_TYPE" => "ereg", "VALIDATION_EXTRA_PARAM" => "^(dst|src|channel|dstchannel|accountcode)\$"), "field_pattern" => array("LABEL" => _tr("Field"), "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "ereg", "VALIDATION_EXTRA_PARAM" => "^[\\*|[:alnum:]@_\\.,/\\-]+\$"), "status" => array("LABEL" => _tr("Status"), "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => array("ALL" => _tr("ALL"), "ANSWERED" => _tr("ANSWERED"), "BUSY" => _tr("BUSY"), "FAILED" => _tr("FAILED"), "NO ANSWER " => _tr("NO ANSWER")), "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "ringgroup" => array("LABEL" => _tr("Ring Group"), "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $dataRG, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""));
    $oFilterForm = new paloForm($smarty, $arrFormElements);
    // Parámetros base y validación de parámetros
    $url = array('menu' => $module_name);
    $paramFiltroBase = $paramFiltro = array('date_start' => date("d M Y"), 'date_end' => date("d M Y"), 'field_name' => 'dst', 'field_pattern' => '', 'status' => 'ALL', 'ringgroup' => '');
    foreach (array_keys($paramFiltro) as $k) {
        if (!is_null(getParameter($k))) {
            $paramFiltro[$k] = getParameter($k);
        }
    }
    $oGrid = new paloSantoGrid($smarty);
    if ($paramFiltro['date_start'] === "") {
        $paramFiltro['date_start'] = " ";
    }
    if ($paramFiltro['date_end'] === "") {
        $paramFiltro['date_end'] = " ";
    }
    $valueFieldName = $arrFormElements['field_name']["INPUT_EXTRA_PARAM"][$paramFiltro['field_name']];
    $valueStatus = $arrFormElements['status']["INPUT_EXTRA_PARAM"][$paramFiltro['status']];
    $valueRingGRoup = $arrFormElements['ringgroup']["INPUT_EXTRA_PARAM"][$paramFiltro['ringgroup']];
    $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Start Date") . " = " . $paramFiltro['date_start'] . ", " . _tr("End Date") . " = " . $paramFiltro['date_end'], $paramFiltro, array('date_start' => date("d M Y"), 'date_end' => date("d M Y")), true);
    $oGrid->addFilterControl(_tr("Filter applied: ") . $valueFieldName . " = " . $paramFiltro['field_pattern'], $paramFiltro, array('field_name' => "dst", 'field_pattern' => ""));
    $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Status") . " = " . $valueStatus, $paramFiltro, array('status' => 'ALL'), true);
    $oGrid->addFilterControl(_tr("Filter applied: ") . _tr("Ring Group") . " = " . $valueRingGRoup, $paramFiltro, array('ringgroup' => ''));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $paramFiltro);
    if (!$oFilterForm->validateForm($paramFiltro)) {
        $smarty->assign(array('mb_title' => _tr('Validation Error'), 'mb_message' => '<b>' . _tr('The following fields contain errors') . ':</b><br/>' . implode(', ', array_keys($oFilterForm->arrErroresValidacion))));
        $paramFiltro = $paramFiltroBase;
        unset($_POST['delete']);
        // Se aborta el intento de borrar CDRs, si había uno.
    }
    // Tradudir fechas a formato ISO para comparación y para API de CDRs.
    $url = array_merge($url, $paramFiltro);
    $paramFiltro['date_start'] = translateDate($paramFiltro['date_start']) . ' 00:00:00';
    $paramFiltro['date_end'] = translateDate($paramFiltro['date_end']) . ' 23:59:59';
    // Valores de filtrado que no se seleccionan mediante filtro
    if ($sExtension != '') {
        $paramFiltro['extension'] = $sExtension;
    }
    // Ejecutar el borrado, si se ha validado.
    if (isset($_POST['delete'])) {
        if ($isAdministrator) {
            if ($paramFiltro['date_start'] <= $paramFiltro['date_end']) {
                $r = $oCDR->borrarCDRs($paramFiltro);
                if (!$r) {
                    $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oCDR->errMsg));
                }
            } else {
                $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => _tr("Please End Date must be greater than Start Date")));
            }
        } else {
            $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => _tr("Only administrators can delete CDRs")));
        }
    }
    $oGrid->setTitle(_tr("CDR Report"));
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export(_tr("CDRReport"));
    $oGrid->setURL($url);
    if ($isAdministrator) {
        $oGrid->deleteList("Are you sure you wish to delete CDR(s) Report(s)?", "delete", _tr("Delete"));
    }
    $arrData = null;
    if (!isset($sExtension) || $sExtension == "" && !$isAdministrator) {
        $total = 0;
    } else {
        $total = $oCDR->contarCDRs($paramFiltro);
    }
    if ($oGrid->isExportAction()) {
        $limit = $total;
        $offset = 0;
        $arrColumns = array(_tr("Date"), _tr("Source"), _tr("Ring Group"), _tr("Destination"), _tr("Src. Channel"), _tr("Account Code"), _tr("Dst. Channel"), _tr("Status"), _tr("Duration"));
        $oGrid->setColumns($arrColumns);
        $arrResult = $oCDR->listarCDRs($paramFiltro, $limit, $offset);
        if (is_array($arrResult['cdrs']) && $total > 0) {
            foreach ($arrResult['cdrs'] as $key => $value) {
                $arrTmp[0] = $value[0];
                $arrTmp[1] = $value[1];
                $arrTmp[2] = $value[11];
                $arrTmp[3] = $value[2];
                $arrTmp[4] = $value[3];
                $arrTmp[5] = $value[9];
                $arrTmp[6] = $value[4];
                $arrTmp[7] = $value[5];
                $iDuracion = $value[8];
                $iSec = $iDuracion % 60;
                $iDuracion = (int) (($iDuracion - $iSec) / 60);
                $iMin = $iDuracion % 60;
                $iDuracion = (int) (($iDuracion - $iMin) / 60);
                $sTiempo = "{$value[8]}s";
                if ($value[8] >= 60) {
                    if ($iDuracion > 0) {
                        $sTiempo .= " ({$iDuracion}h {$iMin}m {$iSec}s)";
                    } elseif ($iMin > 0) {
                        $sTiempo .= " ({$iMin}m {$iSec}s)";
                    }
                }
                $arrTmp[8] = $sTiempo;
                $arrData[] = $arrTmp;
            }
        }
        if (!is_array($arrResult)) {
            $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oCDR->errMsg));
        }
    } else {
        $limit = 20;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
        $arrResult = $oCDR->listarCDRs($paramFiltro, $limit, $offset);
        $arrColumns = array(_tr("Date"), _tr("Source"), _tr("Ring Group"), _tr("Destination"), _tr("Src. Channel"), _tr("Account Code"), _tr("Dst. Channel"), _tr("Status"), _tr("Duration"));
        $oGrid->setColumns($arrColumns);
        if (is_array($arrResult['cdrs']) && $total > 0) {
            foreach ($arrResult['cdrs'] as $key => $value) {
                $arrTmp[0] = $value[0];
                $arrTmp[1] = $value[1];
                $arrTmp[2] = $value[11];
                $arrTmp[3] = $value[2];
                $arrTmp[4] = $value[3];
                $arrTmp[5] = $value[9];
                $arrTmp[6] = $value[4];
                $arrTmp[7] = $value[5];
                $iDuracion = $value[8];
                $iSec = $iDuracion % 60;
                $iDuracion = (int) (($iDuracion - $iSec) / 60);
                $iMin = $iDuracion % 60;
                $iDuracion = (int) (($iDuracion - $iMin) / 60);
                $sTiempo = "{$value[8]}s";
                if ($value[8] >= 60) {
                    if ($iDuracion > 0) {
                        $sTiempo .= " ({$iDuracion}h {$iMin}m {$iSec}s)";
                    } elseif ($iMin > 0) {
                        $sTiempo .= " ({$iMin}m {$iSec}s)";
                    }
                }
                $arrTmp[8] = $sTiempo;
                $arrData[] = $arrTmp;
            }
        }
        if (!is_array($arrResult)) {
            $smarty->assign(array('mb_title' => _tr('ERROR'), 'mb_message' => $oCDR->errMsg));
        }
    }
    $oGrid->setData($arrData);
    $smarty->assign("SHOW", _tr("Show"));
    $oGrid->showFilter($htmlFilter);
    $content = $oGrid->fetchGrid();
    return $content;
}
Beispiel #16
0
function viewFormRegister($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, &$pDBACL)
{
    $pRegister = new paloSantoRegistration($pDB);
    $pACL = new paloACL($pDBACL);
    $arrFormRegister = createFieldForm();
    $oForm = new paloForm($smarty, $arrFormRegister);
    //begin, Form data persistence to errors and other events.
    $_DATA = $_POST;
    $action = getParameter("action");
    $id = getParameter("id");
    $registered = "";
    $smarty->assign("ID", $id);
    //persistence id with input hidden in tpl
    $smarty->assign("identitykeylbl", _tr("Your Server ID"));
    $smarty->assign("registration", _tr("registration"));
    $smarty->assign("alert_message", _tr("alert_message"));
    $smarty->assign("Cancel", _tr("Cancel"));
    $smarty->assign("module_name", $module_name);
    $smarty->assign("sending", _tr("Save information and sending data"));
    $smarty->assign("errorMsg", _tr("Impossible connect to Elastix Web services. Please check your internet connection."));
    $smarty->assign("getinfo", _tr("Getting infomation from Elastix Web Services."));
    $user = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : "";
    if (!is_file("/etc/elastix.key")) {
        $smarty->assign("Activate_registration", _tr("Activate registration"));
    } else {
        $registered = "registered";
        $smarty->assign("Activate_registration", _tr("Update Information"));
    }
    $smarty->assign("registered", $registered);
    $smarty->assign("displayError", "display: none;");
    if ($pACL->isUserAdministratorGroup($user)) {
        $htmlForm = $oForm->fetchForm("{$local_templates_dir}/_registration.tpl", "", "");
    } else {
        $htmlForm = "<div align='center' style='font-weight: bolder;'>" . _tr("Not user allowed to access this content") . "</div>";
    }
    return $htmlForm;
}
Beispiel #17
0
include_once "libs/misc.lib.php";
include_once "configs/default.conf.php";
include_once "libs/paloSantoACL.class.php";
include_once "libs/paloSantoDB.class.php";
load_language();
session_name("elastixSession");
session_start();
$pDB = new paloDB($arrConf["elastix_dsn"]["acl"]);
$pACL = new paloACL($pDB);
if (isset($_SESSION["elastix_user"])) {
    $elastix_user = $_SESSION["elastix_user"];
} else {
    $elastix_user = "";
}
session_commit();
if (!$pACL->isUserAdministratorGroup($elastix_user)) {
    $advice = _tr("Unauthorized");
    $msg1 = _tr("You are not authorized to access to this page");
    $msg2 = _tr("You need administrator privileges");
    $template['content']['theme'] = $arrConf['mainTheme'];
    $template['content']['title'] = _tr("Elastix Authentication");
    $template['content']['msg'] = "<br /><b style='font-size:1.5em;'>{$advice}</b> <p>{$msg1}<br/>{$msg2}</p>";
    extract($template);
    if (file_exists("elastix_warning_authentication.php")) {
        include "elastix_warning_authentication.php";
    }
    exit;
}
$style = "<style type='text/css'>\n                .moduleTitle {\n                    padding: 4px 4px 4px 4px;\n                    color: #444;\n                    background-color: #ffffff;\n                      background-image: url(/images/bggrisForm.gif); \n                    color: #990033;\n                    FONT-FAMILY: verdana, arial, helvetica, sans-serif;\n                    FONT-SIZE: 16px;\n                    FONT-WEIGHT: bold;\n                }\n              </style>";
$tabla_ini = $style . "\n              <table class='table_data' border='0' cellspacing='6' cellpading='6' align='center'  width='100%'>\n                    <tr class='moduleTitle'>\n                        <td class='moduleTitle' align='center'>";
$tabla_fin = "          </td>\n                    </tr>\n              </table>";
Beispiel #18
0
function viewFormDatosbasicos($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{
    $pDatosbasicos = new paloSantoDatosbasicos($pDB);
    $arrFormDatosbasicos = createFieldForm();
    $oForm = new paloForm($smarty, $arrFormDatosbasicos);
    $pDBSqlite = new paloDB("sqlite3:////var/www/db/acl.db");
    $pACL = new paloACL($pDBSqlite);
    if ($pACL->isUserAdministratorGroup($_SESSION['elastix_user'])) {
        $smarty->assign("esAdmin", true);
    } else {
        $smarty->assign("esAdmin", false);
    }
    //begin, Form data persistence to errors and other events.
    $_DATA = $_POST;
    $action = getParameter("action");
    if (isset($_SESSION['ci'])) {
        // si esta seteado la cedula en la session, procedo a editar
        $action = "view_edit";
    }
    $id = getParameter("id");
    $smarty->assign("ID", $id);
    //persistence id with input hidden in tpl
    if ($_GET["ci"]) {
        $smarty->assign("CI", getParameter("ci"));
        //persistence ci with input hidden in tpl
        $smarty->assign("action_edit", "yes");
        //persistence ci with input hidden in tpl
        $_SESSION["ci"] = getParameter("ci");
    } else {
        $smarty->assign("CI", $_SESSION['ci']);
        //persistence ci with input hidden in tpl
    }
    //Clientes Recargables
    if ($_GET["id_cliente"]) {
        $dataDatosbasicos = $pDatosbasicos->getDatosbasicosByIdCliente(getParameter("id_cliente"));
        $smarty->assign("CI", $dataDatosbasicos["ci"]);
        //persistence ci with input hidden in tpl
        $smarty->assign("action_edit", "yes");
        //persistence ci with input hidden in tpl
        $_SESSION["id_cliente"] = getParameter("id_cliente");
        $_SESSION["ci"] = $dataDatosbasicos["ci"];
    }
    if ($action == "view") {
        $oForm->setViewMode();
    } else {
        if ($action == "view_edit" || getParameter("save_edit")) {
            $oForm->setEditMode();
        }
    }
    //end, Form data persistence to errors and other events.
    if ($action == "view" || $action == "view_edit") {
        // the action is to view or view_edit.
        // $dataDatosbasicos = $pDatosbasicos->getDatosbasicosById($id); // Cambiado para editar al cliente de la Sesión
        //if(!empty($_SESSION["id_campania_cliente_recargable"])){
        //    $dataDatosbasicos = $pDatosbasicos->getDatosbasicosByIdCampaniaRecargable($_SESSION['id_campania_cliente_recargable']);
        //}else{
        $dataDatosbasicos = $pDatosbasicos->getDatosbasicosByCI($_SESSION['ci']);
        //}
        if ($_GET["id_cliente"]) {
            $dataDatosbasicos = $pDatosbasicos->getDatosbasicosByIdCliente($_SESSION['id_cliente']);
            $dataDatosbasicos["cedula"] = $dataDatosbasicos["ci"];
        }
        if (is_array($dataDatosbasicos) & count($dataDatosbasicos) > 0) {
            $_DATA = $dataDatosbasicos;
        } else {
            $smarty->assign("mb_title", _tr("Error get Data"));
            $smarty->assign("mb_message", $pDatosbasicos->errMsg);
        }
    }
    if (empty($_DATA["cedula"])) {
        $_DATA["cedula"] = getParameter("ci");
    }
    $smarty->assign("SAVE", _tr("Save"));
    $smarty->assign("EDIT", _tr("Edit"));
    $smarty->assign("CANCEL", _tr("Cancel"));
    $smarty->assign("REQUIRED_FIELD", _tr("Required field"));
    $smarty->assign("IMG", "images/list.png");
    $smarty->assign("IMG", "images/list.png");
    $htmlForm = $oForm->fetchForm("{$local_templates_dir}/form.tpl", _tr("Datos básicos"), $_DATA);
    $content = "<form  method='POST' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>";
    return $content;
}
Beispiel #19
0
function report_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk)
{
    $padress_book = new paloAdressBook($pDB);
    $pACL = new paloACL($pDB_2);
    $user = $_SESSION["elastix_user"];
    $id_user = $pACL->getIdUser($user);
    $extension = $pACL->getUserExtension($user);
    if (is_null($extension) || $extension == "") {
        if ($pACL->isUserAdministratorGroup($user)) {
            $smarty->assign("mb_title", _tr("MESSAGE"));
            $smarty->assign("mb_message", "<b>" . $arrLang["You don't have extension number associated with user"] . "</b>");
        } else {
            $smarty->assign("mb_message", "<b>" . $arrLang["contact_admin"] . "</b>");
        }
    }
    if (getParameter('select_directory_type') != null && getParameter('select_directory_type') == 'external') {
        $smarty->assign("external_sel", 'selected=selected');
        $directory_type = 'external';
    } else {
        $smarty->assign("internal_sel", 'selected=selected');
        $directory_type = 'internal';
    }
    $_POST['select_directory_type'] = $directory_type;
    $arrComboElements = array("name" => $arrLang["Name"], "telefono" => $arrLang["Phone Number"]);
    if ($directory_type == 'external') {
        $arrComboElements["last_name"] = $arrLang["Last Name"];
    }
    $arrFormElements = array("field" => array("LABEL" => $arrLang["Filter"], "REQUIRED" => "no", "INPUT_TYPE" => "SELECT", "INPUT_EXTRA_PARAM" => $arrComboElements, "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => ""), "pattern" => array("LABEL" => "", "REQUIRED" => "no", "INPUT_TYPE" => "TEXT", "INPUT_EXTRA_PARAM" => "", "VALIDATION_TYPE" => "text", "VALIDATION_EXTRA_PARAM" => "", "INPUT_EXTRA_PARAM" => array('id' => 'filter_value')));
    $oFilterForm = new paloForm($smarty, $arrFormElements);
    $smarty->assign("SHOW", $arrLang["Show"]);
    $smarty->assign("NEW_adress_book", $arrLang["New Contact"]);
    $smarty->assign("CSV", $arrLang["CSV"]);
    $smarty->assign("module_name", $module_name);
    $smarty->assign("Phone_Directory", $arrLang["Phone Directory"]);
    $smarty->assign("Internal", $arrLang["Internal"]);
    $smarty->assign("External", $arrLang["External"]);
    $field = NULL;
    $pattern = NULL;
    $namePattern = NULL;
    $allowSelection = array("name", "telefono", "last_name");
    if (isset($_POST['field']) and isset($_POST['pattern']) and $_POST['pattern'] != "") {
        $field = $_POST['field'];
        if (!in_array($field, $allowSelection)) {
            $field = "name";
        }
        $pattern = "%{$_POST['pattern']}%";
        $namePattern = $_POST['pattern'];
        $nameField = $arrComboElements[$field];
    }
    $arrFilter = array("select_directory_type" => $directory_type, "field" => $field, "pattern" => $namePattern);
    $startDate = $endDate = date("Y-m-d H:i:s");
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->addFilterControl(_tr("Filter applied ") . _tr("Phone Directory") . " =  {$directory_type} ", $arrFilter, array("select_directory_type" => "internal"), true);
    $oGrid->addFilterControl(_tr("Filter applied ") . $field . " = {$namePattern}", $arrFilter, array("field" => "name", "pattern" => ""));
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter_adress_book.tpl", "", $arrFilter);
    if ($directory_type == 'external') {
        $total = $padress_book->getAddressBook(NULL, NULL, $field, $pattern, TRUE, $id_user);
    } else {
        $total = $padress_book->getDeviceFreePBX($dsnAsterisk, NULL, NULL, $field, $pattern, TRUE);
    }
    $total_datos = $total[0]["total"];
    //Paginacion
    $limit = 20;
    $total = $total_datos;
    $oGrid->setLimit($limit);
    $oGrid->setTotal($total);
    $offset = $oGrid->calculateOffset();
    $inicio = $total == 0 ? 0 : $offset + 1;
    $end = $offset + $limit <= $total ? $offset + $limit : $total;
    //Fin Paginacion
    if ($directory_type == 'external') {
        $arrResult = $padress_book->getAddressBook($limit, $offset, $field, $pattern, FALSE, $id_user);
    } else {
        $arrResult = $padress_book->getDeviceFreePBX($dsnAsterisk, $limit, $offset, $field, $pattern);
    }
    $arrData = null;
    //echo print_r($arrResult,true);
    if (is_array($arrResult) && $total > 0) {
        $arrMails = array();
        $typeContact = "";
        if ($directory_type == 'internal') {
            $arrMails = $padress_book->getMailsFromVoicemail();
        }
        foreach ($arrResult as $key => $adress_book) {
            if ($directory_type == 'external') {
                $exten = explode(".", $adress_book["picture"]);
                if (isset($exten[count($exten) - 1])) {
                    $exten = $exten[count($exten) - 1];
                }
                $picture = "/var/www/address_book_images/{$adress_book['id']}_Thumbnail.{$exten}";
                if (file_exists($picture)) {
                    $arrTmp[1] = "<a href='?menu={$module_name}&action=show&id=" . $adress_book['id'] . "'><img alt='image' border='0' src='index.php?menu={$module_name}&action=getImage&idPhoto={$adress_book['id']}&thumbnail=yes&rawmode=yes'/></a>";
                } else {
                    $defaultPicture = "modules/{$module_name}/images/Icon-user_Thumbnail.png";
                    $arrTmp[1] = "<a href='?menu={$module_name}&action=show&id=" . $adress_book['id'] . "'><img border='0' alt='image' src='{$defaultPicture}'/></a>";
                }
            }
            $arrTmp[0] = $directory_type == 'external' ? "<input type='checkbox' name='contact_{$adress_book['id']}'  />" : '';
            if ($directory_type == 'external') {
                $email = $adress_book['email'];
                if ($adress_book['status'] == 'isPublic') {
                    if ($id_user == $adress_book['iduser']) {
                        $typeContact = "<div><div style='float: left;'><a href='?menu={$module_name}&action=show&id=" . $adress_book['id'] . "'><img alt='public' style='padding: 5px;' title='" . $arrLang['Public Contact'] . "' border='0' src='modules/{$module_name}/images/public_edit.png' /></a></div><div style='padding: 16px 0px 0px 5px; text-align:center;'><span style='visibility: hidden;'>" . $arrLang['Public editable'] . "</span></div></div>";
                        $arrTmp[0] = "<input type='checkbox' name='contact_{$adress_book['id']}'  />";
                    } else {
                        $typeContact = "<div><div style='float: left;'><a href='?menu={$module_name}&action=show&id=" . $adress_book['id'] . "'><img alt='public' style='padding: 5px;' title='" . $arrLang['Public Contact'] . "' border='0' src='modules/{$module_name}/images/public.png' /></a></div><div style='padding: 16px 0px 0px 5px; text-align:center;'><span style='visibility: hidden;'>" . $arrLang['Public not editable'] . "</span></div></div>";
                        $arrTmp[0] = "";
                    }
                } else {
                    $typeContact = "<div><div style='float: left;'><a href='?menu={$module_name}&action=show&id=" . $adress_book['id'] . "'><img alt='private' style='padding: 5px;' title='" . $arrLang['Private Contact'] . "' border='0' src='modules/{$module_name}/images/contact.png' /></a></div><div style='padding: 16px 0px 0px 5px; text-align:center;'><span style='visibility: hidden;'>" . $arrLang['Private'] . "</span></div></div>";
                }
            } else {
                if (isset($arrMails[$adress_book['id']])) {
                    $email = $arrMails[$adress_book['id']];
                    $typeContact = "<div><div style='float: left;'><img alt='public' title='" . $arrLang['Public Contact'] . "' src='modules/{$module_name}/images/public.png' /></div><div style='padding: 16px 0px 0px 5px; text-align:center;'><span style='visibility: hidden;'>" . $arrLang['Public not editable'] . "</span></div></div>";
                } else {
                    $email = '';
                    $typeContact = "<div><div style='float: left;'><img alt='public' title='" . $arrLang['Public Contact'] . "' src='modules/{$module_name}/images/public.png' /></div><div style='padding: 16px 0px 0px 5px; text-align:center;'><span style='visibility: hidden;'>" . $arrLang['Public not editable'] . "</span></div></div>";
                }
            }
            $arrTmp[2] = $directory_type == 'external' ? "<a href='?menu={$module_name}&action=show&id=" . $adress_book['id'] . "'>" . htmlspecialchars($adress_book['last_name'], ENT_QUOTES, "UTF-8") . " " . htmlspecialchars($adress_book['name'], ENT_QUOTES, "UTF-8") . "</a>" : $adress_book['description'];
            $arrTmp[3] = $directory_type == 'external' ? $adress_book['telefono'] : $adress_book['id'];
            $arrTmp[4] = $email;
            $arrTmp[5] = "<a href='?menu={$module_name}&action=call2phone&id=" . $adress_book['id'] . "&type=" . $directory_type . "'><img border=0 src='/modules/{$module_name}/images/call.png' /></a>";
            $arrTmp[6] = "<a href='?menu={$module_name}&action=transfer_call&id=" . $adress_book['id'] . "&type=" . $directory_type . "'>{$arrLang["Transfer"]}</a>";
            $arrTmp[7] = $typeContact;
            $arrData[] = $arrTmp;
        }
    }
    if ($directory_type == 'external') {
        $name = "";
        $picture = $arrLang["picture"];
        $oGrid->deleteList(_tr("Are you sure you wish to delete the contact."), "delete", _tr("Delete"));
    } else {
        $name = "";
        $picture = "";
    }
    $arrGrid = array("title" => $arrLang["Address Book"], "url" => array('menu' => $module_name, 'filter' => $pattern, 'select_directory_type' => $directory_type), "icon" => "modules/{$module_name}/images/address_book.png", "width" => "99%", "start" => $inicio, "end" => $end, "total" => $total, "columns" => array(0 => array("name" => $name, "property1" => ""), 1 => array("name" => $picture, "property1" => ""), 2 => array("name" => $arrLang["Name"], "property1" => ""), 3 => array("name" => $arrLang["Phone Number"], "property1" => ""), 4 => array("name" => $arrLang["Email"], "property1" => ""), 5 => array("name" => $arrLang["Call"], "property1" => ""), 6 => array("name" => $arrLang["Transfer"], "property1" => ""), 7 => array("name" => $arrLang["Type Contact"], "property1" => "")));
    $oGrid->addNew("new", _tr("New Contact"));
    $oGrid->showFilter(trim($htmlFilter));
    $contenidoModulo = $oGrid->fetchGrid($arrGrid, $arrData, $arrLang);
    return $contenidoModulo;
}
Beispiel #20
0
function showAllEmails($smarty, $module_name, $local_templates_dir, &$pDB, &$pDBACL, $arrConf, $arrLang)
{
    $pVacations = new paloSantoVacations($pDB);
    $oGrid = new paloSantoGrid($smarty);
    $pACL = new paloACL($pDBACL);
    $id = getParameter("id");
    $filter_field = getParameter("filter_field");
    $filter_value = getParameter("filter_value");
    $userAccount = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : "";
    $url = array("menu" => $module_name, "filter_field" => $filter_field, "filter_value" => $filter_value);
    if (!$pACL->isUserAdministratorGroup($userAccount)) {
        return _tr("User isn't allowed to view this content.");
    } else {
        $totalEmail = $pVacations->getNumVacations($filter_field, $filter_value, $arrLang);
        $url = array_merge($url, array('rawmode' => 'yes'));
        $oGrid->setURL($url);
        $oGrid->setTitle(_tr("Emails Account"));
        $limit = 10;
        $total = $totalEmail;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        //$oGrid->enableExport(false);   // enable csv export.
        $oGrid->pagingShow(true);
        // show paging section.
        $offset = $oGrid->calculateOffset();
        $arrData = null;
        $arrResult = $pVacations->getVacations($limit, $offset, $filter_field, $filter_value, $arrLang);
        $tmpIDs = 1;
        $infoHtml = "<div id='infoDataAccount'>";
        if (is_array($arrResult) && $total > 0) {
            foreach ($arrResult as $key => $value) {
                $tmpAccountId = $tmpIDs . "Id";
                $arrTmp[0] = "<a href='javascript:getAccount(\"" . $value['username'] . "\",\"{$tmpAccountId}\");' class='getAccount' id='{$tmpAccountId}' >" . $value['username'] . "</a>";
                $timestamp0 = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
                $timestamp1 = mktime(0, 0, 0, date("m", strtotime($value['ini_date'])), date("d", strtotime($value['ini_date'])), date("Y", strtotime($value['ini_date'])));
                $timestamp2 = mktime(0, 0, 0, date("m", strtotime($value['end_date'])), date("d", strtotime($value['end_date'])), date("Y", strtotime($value['end_date'])));
                if ($timestamp0 >= $timestamp1 && $timestamp0 <= $timestamp2) {
                    if ($value['vacation'] == "yes") {
                        $arrTmp[1] = _tr("yes");
                    } else {
                        $arrTmp[1] = _tr("no");
                    }
                } else {
                    $arrTmp[1] = _tr("no");
                }
                if ($value['vacation'] == "yes") {
                    $arrTmp[2] = _tr("yes");
                } else {
                    $arrTmp[2] = _tr("no");
                }
                if (!isset($value['subject']) || $value['subject'] == "") {
                    $value['subject'] = _tr("Auto-Reply: Out of the office");
                }
                if (!isset($value['body']) || $value['body'] == "") {
                    $value['body'] = _tr("I will be out of the office until {END_DATE}.\n\n----\nBest Regards.");
                }
                $value['ini_date'] = isset($value['ini_date']) ? $value['ini_date'] : date("d M Y");
                $value['end_date'] = isset($value['end_date']) ? $value['end_date'] : date("d M Y");
                $infoHtml .= "<div id='" . $tmpIDs . "Idinfo'>";
                $infoHtml .= "<div style='display: none;'>" . $value['subject'] . "</div>";
                $infoHtml .= "<div style='display: none;'>" . $value['body'] . "</div>";
                $infoHtml .= "<div style='display: none;'>" . $value['vacation'] . "</div>";
                $infoHtml .= "<div style='display: none;'>" . $value['ini_date'] . "</div>";
                $infoHtml .= "<div style='display: none;'>" . $value['end_date'] . "</div>";
                $infoHtml .= "</div>";
                $arrData[] = $arrTmp;
                $tmpIDs++;
            }
        }
        $infoHtml .= "</div>";
        $arrColumns = array(_tr("Account"), _tr("Vacations in progress"), _tr("Vacations Activated"));
        $oGrid->setColumns($arrColumns);
        $oGrid->setData($arrData);
        $size = count($arrData);
        //begin section filter
        $arrFormFilter = createFieldFilter($arrLang);
        $oFilterForm = new paloForm($smarty, $arrFormFilter);
        $smarty->assign("SHOW", $arrLang["Show"]);
        $arrFilter = array("username" => $arrLang["Account"], "vacation" => $arrLang["Vacations Activated"]);
        if (!is_null($filter_field)) {
            $nameField = $arrFilter[$filter_field];
        } else {
            $nameField = "";
        }
        $oGrid->addFilterControl(_tr("Filter applied: ") . $nameField . " = " . $filter_value, $_POST, array("filter_field" => "username", "filter_value" => ""));
        $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filterEmailGrid.tpl", "", $_POST);
        //end section filter
        $oGrid->showFilter(trim($htmlFilter));
        $content = $oGrid->fetchGrid() . $infoHtml;
        //end grid parameters
    }
    return $content;
}