Beispiel #1
0
 function handleJSON_getContent($smarty, $module_name, $appletlist)
 {
     $respuesta = array('status' => 'success', 'message' => '(no message)');
     // Leer credenciales a partir del usuario y el perfil asociado
     global $arrConf;
     $dbAcl = new paloDB($arrConf["elastix_dsn"]["acl"]);
     $pACL = new paloACL($dbAcl);
     $userId = $pACL->getIdUser($_SESSION['elastix_user']);
     $mailCred = $this->leerPropiedadesWebmail($dbAcl, $userId);
     if (count($mailCred) <= 0) {
         $respuesta['status'] = 'error';
         $respuesta['message'] = _tr("You don't have a webmail account");
     } elseif (!$this->_checkEmailPassword("{$mailCred['login']}@{$mailCred['domain']}", isset($mailCred['password']) ? $mailCred['password'] : '')) {
         $respuesta['status'] = 'error';
         $respuesta['message'] = "{$mailCred['login']}@{$mailCred['domain']} " . _tr("does not exist locally or password is incorrect");
     } else {
         $imap = @imap_open("{localhost:143/notls}", "{$mailCred['login']}@{$mailCred['domain']}", isset($mailCred['password']) ? $mailCred['password'] : '');
         if (!$imap) {
             $respuesta['status'] = 'error';
             $respuesta['message'] = _tr('Imap: Connection error');
         } else {
             $this->leerInformacionImap($smarty, $module_name, $imap, $respuesta);
             imap_close($imap);
         }
     }
     $json = new Services_JSON();
     Header('Content-Type: application/json');
     return $json->encode($respuesta);
 }
Beispiel #2
0
function _moduleContent(&$smarty, $module_name)
{
    //global variables
    global $arrConf;
    global $arrConfModule;
    $arrConf = array_merge($arrConf, $arrConfModule);
    //folder path for custom templates
    $local_templates_dir = getWebDirModule($module_name);
    // se conecta a la base
    $pDB = new paloDB($arrConf['elastix_dsn']['elastix']);
    $pACL = new paloACL($pDB);
    $user = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : "";
    $uid = $pACL->getIdUser($user);
    //actions
    $accion = getAction();
    $content = "";
    switch ($accion) {
        case "save":
            $content = saveThemes($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $uid);
            break;
        default:
            $content = formThemes($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $uid);
            break;
    }
    return $content;
}
Beispiel #3
0
 function handleJSON_getContent($smarty, $module_name, $appletlist)
 {
     $respuesta = array('status' => 'success', 'message' => '(no message)');
     // Leer credenciales a partir del usuario y el perfil asociado
     global $arrConf;
     $dbAcl = new paloDB($arrConf["elastix_dsn"]["acl"]);
     $pACL = new paloACL($dbAcl);
     $userId = $pACL->getIdUser($_SESSION['elastix_user']);
     $listaEventos = $this->_leerRegistrosEventos($userId);
     $listaEventosDias = $this->_expandirRegistrosEventos($listaEventos);
     $smarty->assign(array('NO_EVENTOS' => _tr("You don't have events"), 'EVENTOS_DIAS' => $listaEventosDias, 'tag_date' => _tr("Date"), 'tag_call' => _tr("Call")));
     $local_templates_dir = dirname($_SERVER['SCRIPT_FILENAME']) . "/modules/{$module_name}/applets/Calendar/tpl";
     $respuesta['html'] = $smarty->fetch("{$local_templates_dir}/calendar_events.tpl");
     $json = new Services_JSON();
     Header('Content-Type: application/json');
     return $json->encode($respuesta);
 }
Beispiel #4
0
function CashCollection(&$pDB, $pDB_2)
{
    // collect parameters
    $sTicketId = trim(getParameter('ticket_id'));
    $pACL = new paloACL($pDB_2);
    $id_user = $pACL->getIdUser($_SESSION["elastix_user"]);
    $sNote = trim(getParameter('note'));
    $pCashCollection = new Ticket_Delivery($pDB);
    if (is_null(getParameter('unpaid'))) {
        $response = array('action' => 'collect', 'message' => 'Đã nhận tiền từ mã giao vé số ' . $sTicketId);
        $result = $pCashCollection->Cash_Collection($sTicketId, $id_user, false, $sNote);
    } else {
        $response = array('action' => 'uncollect', 'message' => 'Đã hủy nhận tiền từ mã giao vé số ' . $sTicketId);
        $result = $pCashCollection->Cash_Collection($sTicketId, $id_user, true, $sNote);
    }
    // return json
    if (!$result) {
        $response['action'] = 'error';
        $response['message'] = 'Lỗi: ' . $pCashCollection->errMsg;
    }
    $json = new Services_JSON();
    Header('Content-Type: application/json');
    return $json->encode($response);
}
Beispiel #5
0
function transferCALL($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);
    $id_user = $pACL->getIdUser($_SESSION["elastix_user"]);
    if ($id_user != FALSE) {
        $user = $pACL->getUsers($id_user);
        if ($user != FALSE) {
            $extension = $user[0][3];
            if ($extension != "") {
                $id = isset($_GET['id']) ? $_GET['id'] : (isset($_POST['id']) ? $_POST['id'] : "");
                $phone2tranfer = '';
                if (isset($_GET['type']) && $_GET['type'] == 'external') {
                    $contactData = $padress_book->contactData($id, $id_user, "external", false, null);
                    $phone2tranfer = $contactData['telefono'];
                } else {
                    $phone2tranfer = $id;
                }
                $result = $padress_book->Obtain_Protocol_from_Ext($dsnAsterisk, $extension);
                if ($result != FALSE) {
                    $result = $padress_book->TranferCall($dsn_agi_manager, $extension, $phone2tranfer, $result['dial'], $result['description']);
                    if (!$result) {
                        $smarty->assign("mb_title", $arrLang['ERROR'] . ":");
                        $smarty->assign("mb_message", $arrLang["The transfer couldn't be realized, maybe you don't have any conversation now."]);
                    }
                } else {
                    $smarty->assign("mb_title", $arrLang["Validation Error"]);
                    $smarty->assign("mb_message", $padress_book->errMsg);
                }
            }
        } else {
            $smarty->assign("mb_title", $arrLang["Validation Error"]);
            $smarty->assign("mb_message", $padress_book->errMsg);
        }
    } else {
        $smarty->assign("mb_title", $arrLang["Validation Error"]);
        $smarty->assign("mb_message", $padress_book->errMsg);
    }
    $content = report_adress_book($smarty, $module_name, $local_templates_dir, $pDB, $pDB_2, $arrLang, $arrConf, $dsn_agi_manager, $dsnAsterisk);
    return $content;
}
Beispiel #6
0
function disactivateEmailVacations($smarty, $module_name, $local_templates_dir, &$pDB, &$pDBACL, $arrConf, $arrLang)
{
    $pVacations = new paloSantoVacations($pDB);
    $pACL = new paloACL($pDBACL);
    $objAntispam = new paloSantoAntispam($arrConf['path_postfix'], $arrConf['path_spamassassin'], $arrConf['file_master_cf'], $arrConf['file_local_cf']);
    $arrFormVacations = createFieldForm($arrLang);
    $oForm = new paloForm($smarty, $arrFormVacations);
    $id = getParameter("id");
    $email = getParameter("email");
    $subject = getParameter("subject");
    $body = getParameter("body");
    $ini_date = getParameter("ini_date");
    $end_date = getParameter("end_date");
    $result = "";
    $userAccount = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : "";
    $idUserInt = $pACL->getIdUser($userAccount);
    $emails = $pVacations->getAccountByIdUser($idUserInt, $pDBACL);
    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 viewFormVacations($smarty, $module_name, $local_templates_dir, $pDB, $pDBACL, $arrConf, $arrLang);
    }
    if (!preg_match("/^[a-z0-9]+([\\._\\-]?[a-z0-9]+[_\\-]?)*@[a-z0-9]+([\\._\\-]?[a-z0-9]+)*(\\.[a-z0-9]{2,6})+\$/", $email)) {
        $smarty->assign("mb_title", _tr("Error"));
        $smarty->assign("mb_message", _tr('Email is empty or is not correct. Please write the email account.'));
        return viewFormVacations($smarty, $module_name, $local_templates_dir, $pDB, $pDBACL, $arrConf, $arrLang);
    }
    if ($email != $emails) {
        if (!$pACL->isUserAdministratorGroup($userAccount)) {
            $smarty->assign("mb_title", _tr("Error"));
            $smarty->assign("mb_message", _tr('Email is not correct. Please write the email assigned to your elastix account.'));
            return viewFormVacations($smarty, $module_name, $local_templates_dir, $pDB, $pDBACL, $arrConf, $arrLang);
        }
    }
    $timestamp0 = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
    $timestamp1 = mktime(0, 0, 0, date("m", strtotime($ini_date)), date("d", strtotime($ini_date)), date("Y", strtotime($ini_date)));
    $timestamp2 = mktime(0, 0, 0, date("m", strtotime($end_date)), date("d", strtotime($end_date)), date("Y", strtotime($end_date)));
    $timeSince = $timestamp0 - $timestamp1;
    //resto a una fecha la otra
    $seconds = $timestamp2 - $timestamp1;
    $dias = $seconds / (60 * 60 * 24);
    $dias = floor($dias);
    $smarty->assign("num_days", $dias);
    if ($seconds < 0) {
        $smarty->assign("mb_title", _tr("Alert"));
        $smarty->assign("mb_message", _tr("End date should be greater than the initial date"));
        return viewFormVacations($smarty, $module_name, $local_templates_dir, $pDB, $pDBACL, $arrConf, $arrLang);
    }
    $statusSieve = $pVacations->verifySieveStatus($arrLang);
    if (!$statusSieve['response']) {
        $smarty->assign("mb_title", _tr("Alert"));
        $smarty->assign("mb_message", $statusSieve['message']);
        return viewFormVacations($smarty, $module_name, $local_templates_dir, $pDB, $pDBACL, $arrConf, $arrLang);
    }
    $pDB->beginTransaction();
    $scripts = $objAntispam->existScriptSieve($email, "scriptTest.sieve");
    $spamCapture = false;
    // si CapturaSpam=OFF y Vacations=OFF
    if ($scripts['actived'] != "") {
        // hay un script activo
        if (preg_match("/vacations.sieve/", $scripts['actived']) && $scripts['status']) {
            // si CapturaSpam=? y Vacations=ON
            $spamCapture = true;
        }
        // si CapturaSpam=ON y Vacations=OFF
        $band = $pVacations->existMessage($email);
        $res = "";
        if ($band) {
            //actualizacion
            $arr_Vaca = $pVacations->getMessageVacationByUser($email);
            if (count($arr_Vaca) > 1) {
                $pVacations->deleteMessagesByUser($email, $subject, $body, $ini_date, $end_date);
                $res = $pVacations->insertMessageByUser($email, $subject, $body, $ini_date, $end_date, "no");
            } else {
                $res = $pVacations->updateMessageByUser($email, $subject, $body, $ini_date, $end_date, "no");
            }
        } else {
            // insersion
            $res = $pVacations->insertMessageByUser($email, $subject, $body, $ini_date, $end_date, "no");
        }
        if ($res) {
            if ($timeSince >= 0) {
                $result = $pVacations->deleteVacationScript($email, $objAntispam, $spamCapture, $arrLang);
            } else {
                $result = true;
            }
        } else {
            $result = false;
        }
    }
    if ($result) {
        $pDB->commit();
        $smarty->assign("mb_message", _tr("Email's Vacations have been disabled"));
    } else {
        $msgError = $pVacations->errMsg;
        $pDB->rollBack();
        $smarty->assign("mb_message", $msgError);
    }
    return viewFormVacations($smarty, $module_name, $local_templates_dir, $pDB, $pDBACL, $arrConf, $arrLang);
}
 /**
  * Procedimiento que actualiza los passwords de un usuario dentro de elastix
  * La calve ingresada sera configurada para la cuenta de interfaz web, para su cuenta
  * de email, su secret en el caso de las extensiones sip e iax
  */
 function changeUserPassword($username, $password)
 {
     $pEmail = new paloEmail($this->_DB);
     $pFax = new paloFax($this->_DB);
     $pACL = new paloACL($this->_DB);
     //comprobamos que la calve este seteada y sea una clave fuerte
     //verificamos que la nueva contraseña sea fuerte
     if (!isStrongPassword($password)) {
         $this->errMsg = _tr("The new password can not be empty. It must have at least 10 characters and contain digits, uppers and little case letters");
         return false;
     }
     //obtenemos la conversion md5 de la clave
     $md5_password = md5($password);
     //verficamos que el usuario exista
     $idUser = $pACL->getIdUser($username);
     if ($idUser == false) {
         $this->errMsg = $pACL->errMsg == '' ? _tr("User does not exist") : _tr("DATABASE ERROR");
         return false;
     }
     //obtenemos los datos del usuario
     //extension de fax y de telefonia
     $arrUser = $pACL->getUsers($idUser);
     if ($arrUser == false) {
         $this->errMsg = $arrUser === false ? _tr("DATABASE ERROR") : _tr("User dosen't exist");
         return false;
     }
     $this->_DB->beginTransaction();
     if ($pACL->isUserSuperAdmin($username)) {
         //si es superadmin solo se cambia la clave de interfaz administrativa
         //cambiamos la clave en la insterfax administrativa
         if (!$pACL->changePassword($idUser, $md5_password)) {
             $this->_DB->rollBack();
             $this->errMsg = $pACL->errMsg;
             return false;
         } else {
             $this->_DB->commit();
             return true;
         }
     } else {
         //obtenemos el dominio al cual pertenece el usuario
         $arrOrgz = $this->getOrganizationById($arrUser[0][4]);
         if ($arrOrgz == false) {
             $this->errMsg = _tr("An error has ocurred to retrieve organization data");
             return false;
         }
         $domain = $arrOrgz['domain'];
         $extension = $arrUser[0][5];
         $fax_extension = $arrUser[0][6];
         $pDevice = new paloDevice($domain, "sip", $this->_DB);
         $arrExtUser = $pDevice->getExtension($extension);
         $listFaxs = $pFax->getFaxList(array("exten" => $fax_extension, "organization_domain" => $domain));
         $faxUser = $listFaxs[0];
         //cambiamos la clave en la insterfax administrativa
         if (!$pACL->changePassword($idUser, $md5_password)) {
             $this->_DB->rollBack();
             $this->errMsg = $pACL->errMsg;
             return false;
         }
         //cambiamos la clave en la extension telefonica
         if (!$pDevice->changePasswordExtension($password, $extension)) {
             $this->_DB->rollBack();
             $this->errMsg = _tr("Extension password couldn't be updated") . $pDevice->errMsg;
             return false;
         }
         //cambiamos la clave para el fax (peer, archivos de configuracion)
         if (!$pFax->editFaxToUser(array("idUser" => $idUser, "country_code" => $faxUser['country_code'], "area_code" => $faxUser['area_code'], "clid_name" => $faxUser['clid_name'], "clid_number" => $faxUser['clid_number']))) {
             $this->_DB->rollBack();
             $this->errMsg = _tr("Fax Extension password couldn't be updated") . $pFax->errMsg;
             return false;
         }
         //cambiamos la clave en el correo
         if (!$pEmail->setAccountPassword($username, $password)) {
             $this->_DB->rollBack();
             $this->errMsg = _tr("Error to update email account password");
             //reestauramos la configuracion anterior en los archivos de fax
             $pFax->editFaxFileConfig($faxUser['dev_id'], $faxUser['country_code'], $faxUser['area_code'], $faxUser['clid_name'], $faxUser['clid_number'], $arrUser[0][3], 0, $arrOrgz['domain']);
             return false;
         } else {
             $this->_DB->commit();
             //recargamos la configuracion en realtime de los dispositivos para que tomen efectos los cambios
             $pDevice->tecnologia->prunePeer($arrExtUser["device"], $arrExtUser["tech"]);
             $pDevice->tecnologia->loadPeer($arrExtUser["device"], $arrExtUser["tech"]);
             if (!empty($arrExtUser["elxweb_device"])) {
                 $pDevice->tecnologia->prunePeer($arrExtUser["elxweb_device"], $arrExtUser["tech"]);
                 $pDevice->tecnologia->loadPeer($arrExtUser["elxweb_device"], $arrExtUser["tech"]);
             }
             //se recarga la faxextension del usuario por los cambios que pudo haber
             $pDevice->tecnologia->prunePeer($faxUser["device"], $faxUser["tech"]);
             $pDevice->tecnologia->loadPeer($faxUser["device"], $faxUser["tech"]);
             $pFax->restartService();
             return true;
         }
     }
 }
Beispiel #8
0
function backup_contacts($pDB, $pDB_2, $arrLang)
{
    $Messages = "";
    $csv = "";
    $pAdressBook = new paloAdressBook($pDB);
    $fields = "name, last_name, telefono, email";
    $pACL = new paloACL($pDB_2);
    $id_user = $pACL->getIdUser($_SESSION["elastix_user"]);
    $arrResult = $pAdressBook->getAddressBookByCsv(null, null, $fields, null, null, $id_user);
    if (!$arrResult) {
        $Messages .= $arrLang["There aren't contacts"] . ". " . $pAdressBook->errMsg;
        echo $Messages;
    } else {
        //cabecera
        $csv .= "\"Name\",\"Last Name\",\"Phone Number\",\"Email\",\"Address\",\"Company\"\n";
        foreach ($arrResult as $key => $contact) {
            $csv .= "\"{$contact['name']}\",\"{$contact['last_name']}\"," . "\"{$contact['telefono']}\",\"{$contact['email']}\"," . "\"{$contact['address']}\",\"{$contact['company']}\"" . "\n";
        }
    }
    return $csv;
}
function getContactEmails2($arrConf)
{
    $pDBACL = new paloDB($arrConf['dsn_conn_database1']);
    $pACL = new paloACL($pDBACL);
    $id_user = $pACL->getIdUser($_SESSION["elastix_user"]);
    $tag = getParameter('name_startsWith');
    $salida = array();
    if (isset($id_user) && $id_user != "") {
        $pDB = new paloDB($arrConf['dsn_conn_database']);
        $pDBAddress = new paloDB($arrConf['dsn_conn_database3']);
        $pCalendar = new paloSantoCalendar($pDB);
        $salida = $pCalendar->getContactByTag($pDBAddress, $tag, $id_user);
        if (!$salida) {
            $salida = array();
        }
    }
    header('Content-Type: application/json');
    // se instancia a JSON
    $json = new Services_JSON();
    return $json->encode($salida);
}
Beispiel #10
0
function report_TicketDelivery($smarty, $module_name, $local_templates_dir, &$pDB, $pDB_2)
{
    $pTicket_Delivery = new Ticket_Delivery($pDB);
    $pACL = new paloACL($pDB_2);
    $id_user = $pACL->getIdUser($_SESSION["elastix_user"]);
    $img_dir = "modules/{$module_name}/images/";
    // get filter parameters
    $filter = array('date_start' => trim($_POST['date_start']) == '' ? '' : date("Y-m-d", strtotime($_POST['date_start'])), 'date_end' => trim($_POST['date_end']) == '' ? '' : date("Y-m-d", strtotime($_POST['date_end'])), 'customer_name' => trim($_POST['customer_name']), 'customer_phone' => trim($_POST['customer_number']), 'ticket_code' => trim($_POST['ticket_code']), 'status' => trim($_POST['status']));
    //begin grid parameters
    $oGrid = new paloSantoGrid($smarty);
    $oGrid->setTitle("Yêu cầu giao vé");
    $oGrid->setTableName("delivery_grid");
    $oGrid->pagingShow(true);
    // show paging section.
    $oGrid->enableExport();
    // enable export.
    $oGrid->setNameFile_Export("ticket_delivery");
    $url = array("menu" => $module_name);
    $oGrid->setURL($url);
    $arrColumns = array("ID", "Tên Khách Hàng", "Số điện thoại", "Booker", "Địa chỉ", "Tiền trả", "Mã số vé", "Tình trạng", "Nhân viên giao", "Ngày phân công", "Vé đính kèm", "Ngày nhận tiền", "Xử lý", "Chi tiết", " ");
    $oGrid->setColumns($arrColumns);
    $total = $pTicket_Delivery->getNumTicket_Delivery($filter);
    $arrData = null;
    if ($oGrid->isExportAction()) {
        $limit = $total;
        // max number of rows.
        $offset = 0;
        // since the start.
    } else {
        $limit = 20;
        $oGrid->setLimit($limit);
        $oGrid->setTotal($total);
        $offset = $oGrid->calculateOffset();
    }
    $arrResult = $pTicket_Delivery->getTicket_Delivery($limit, $offset, $filter, $id_user);
    if (is_array($arrResult) && $total > 0) {
        foreach ($arrResult as $key => $value) {
            $ticket = '';
            $name = $pACL->getUsers($value['accounting_id']);
            $elastix_user = is_null($value['accounting_id']) ? '(Chưa nhận)' : $name[0][1];
            // show files
            $download = '';
            foreach ($value['ticket_attachment'] as $row) {
                $url = "/modules/agent_console/ajax-attachments-handler.php?download=" . $row['filepath'] . "&name=" . $row['filename'];
                $filename = $row['filename'];
                $download .= "*<a href='{$url}' target='_blank' title='{$filename}'>" . shorten($filename) . "</a><br/>";
            }
            $print = '<a href="javascript:void(0)" onclick="print(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'print.png" title="In phiếu"></a>';
            $enable = $value['isActive'] == '1' ? '<a href="javascript:void(0)" onclick="disable(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'disable.png" title="Hủy yêu cầu giao vé"></a>&nbsp;' : '
            <a href="javascript:void(0)" onclick="enable(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'enable.png" title="Tạo lại yêu cầu giao vé"></a>';
            $print .= '&nbsp;&nbsp;' . $enable;
            // function show base on status
            if ($value['isActive'] == '0') {
                $value['status'] = 'Đã hủy';
            }
            switch ($value['status']) {
                case 'Mới':
                    $function = '<a href="javascript:void(1)" onclick="assign_form(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'assign.png" title="Phân công"></a>';
                    break;
                case 'Đang giao':
                    $function = '<a href="javascript:void(1)" onclick="assign_form(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'assign.png" title="Đổi phân công"></a>&nbsp;
                        <a href="javascript:void(1)" onclick="collect_form(\'' . $value['id'] . '\',\'' . $elastix_user . '\')"><img src="' . $img_dir . 'result.png" title="Kết quả"></a>';
                    break;
                case 'Đã nhận tiền':
                    $function = '<a href="javascript:void(1)" onclick="uncollect_form(\'' . $value['id'] . '\',\'' . $elastix_user . '\')"><img src="' . $img_dir . 'unpaid.png" title="Hủy nhận tiền"></a>';
                    break;
                case 'Chờ xử lý':
                    $function = '<a href="javascript:void(1)" onclick="assign_form(\'' . $value['id'] . '\')"><img src="' . $img_dir . 'assign.png" title="Phân công"></a>';
                    break;
                default:
                    $function = '';
            }
            // show ticket code
            foreach ($value['ticket_code'] as $row) {
                $ticket .= $row . '<br>';
            }
            $arrTmp[0] = $value['id'];
            $arrTmp[1] = $value['customer_name'];
            $arrTmp[2] = $value['customer_phone'];
            $arrTmp[3] = '<span title="Chi nhánh: ' . $value['office'] . '">' . $value['agent_name'] . '</span>';
            $arrTmp[4] = '<a href="javascript:void(1)" title="' . $value['deliver_address'] . '"
			                onclick="view_address(\'' . $value['deliver_address'] . '\')">' . shorten($value['deliver_address']) . '
			              </a>';
            $arrTmp[5] = $value['pay_amount'];
            $arrTmp[6] = $ticket;
            $arrTmp[7] = showStatus($value['status']);
            $arrTmp[8] = $value['delivery_name'];
            $arrTmp[9] = is_null($value['delivery_date']) ? '' : date("d-m-Y H:m:s", strtotime($value['delivery_date']));
            $arrTmp[10] = $download;
            $arrTmp[11] = is_null($value['collection_date']) ? '' : date("d-m-Y H:m:s", strtotime($value['collection_date']));
            $arrTmp[12] = $function;
            $arrTmp[13] = '<a href="javascript:void(1)" onclick="view_log(\'' . $value['id'] . '\')">
			            <img src="' . $img_dir . 'extra.png" title="Xem chi tiết"></a>';
            $arrTmp[14] = $print;
            $arrData[] = $arrTmp;
        }
    }
    $oGrid->setData($arrData);
    //begin section filter
    $oFilterForm = new paloForm($smarty, createFieldFilter());
    // get delivery man list
    $delivery_man_list = $pTicket_Delivery->getDeliveryMan();
    $smarty->assign("DELIVERY_MAN_LIST", $delivery_man_list);
    $htmlFilter = $oFilterForm->fetchForm("{$local_templates_dir}/filter.tpl", "", $_POST);
    //end section filter
    $oGrid->showFilter(trim($htmlFilter));
    $content = $oGrid->fetchGrid();
    //end grid parameters
    return $content;
}
Beispiel #11
0
if (isset($_POST['submit_login']) and !empty($_POST['input_user'])) {
    $pass_md5 = md5(trim($_POST['input_pass']));
    if ($pACL->authenticateUser($_POST['input_user'], $pass_md5)) {
        session_regenerate_id(TRUE);
        $_SESSION['elastix_user'] = trim($_POST['input_user']);
        $_SESSION['elastix_pass'] = $pass_md5;
        //fue necesario incluir esto aqui porque cuando te logueas en la interfaz
        //de usario final haces uso de esta variable
        $_SESSION['elastix_pass2'] = $_POST['input_pass'];
        header("Location: index.php");
        writeLOG("audit.log", "LOGIN {$_POST['input_user']}: Web Interface login successful. Accepted password for {$_POST['input_user']} from {$_SERVER['REMOTE_ADDR']}.");
        update_theme();
        exit;
    } else {
        $user = urlencode(substr($_POST['input_user'], 0, 20));
        if (!$pACL->getIdUser($_POST['input_user'])) {
            // not exists user?
            writeLOG("audit.log", "LOGIN {$user}: Authentication Failure to Web Interface login. Invalid user {$user} from {$_SERVER['REMOTE_ADDR']}.");
        } else {
            writeLOG("audit.log", "LOGIN {$user}: Authentication Failure to Web Interface login. Failed password for {$user} from {$_SERVER['REMOTE_ADDR']}.");
        }
        // Debo hacer algo aquí?
    }
}
// 2) Autentico usuario
if (isset($_SESSION['elastix_user']) && isset($_SESSION['elastix_pass']) && $pACL->authenticateUser($_SESSION['elastix_user'], $_SESSION['elastix_pass'])) {
    $idUser = $pACL->getIdUser($_SESSION['elastix_user']);
    $pMenu = new paloMenu($arrConf['elastix_dsn']['elastix']);
    //obtenemos los menu a los que el usuario tiene acceso
    $arrMenuFiltered = $pMenu->filterAuthorizedMenus($idUser, 'yes');
    $id_organization = $pACL->getIdOrganizationUser($idUser);
Beispiel #12
0
function manejarLogin_HTML($module_name, &$smarty, $sDirLocalPlantillas)
{
    global $arrConf;
    // Acciones para mostrar el formulario, fuera de cualquier acción AJAX
    $smarty->assign(array('FRAMEWORK_TIENE_TITULO_MODULO' => existeSoporteTituloFramework(), 'icon' => 'modules/' . $module_name . '/images/call_center.png', 'title' => "Màn hình chính dành cho tổng đài viên", 'WELCOME_AGENT' => _tr('Welcome to Agent Console'), 'ENTER_USER_PASSWORD' => _tr('Please select your agent number and your extension'), 'USERNAME' => _tr('Agent Number'), 'EXTENSION' => _tr('Extension'), 'CALLBACK_LOGIN' => _tr('Callback Login'), 'PASSWORD' => _tr('Password'), 'CALLBACK_EXTENSION' => _tr('Callback Extension'), 'LABEL_SUBMIT' => _tr('Enter'), 'LABEL_NOEXTENSIONS' => _tr('There are no extensions available. At least one extension is required for agent login.'), 'LABEL_NOAGENTS' => _tr('There are no agents available. At least one agent is required for agent login.'), 'ESTILO_FILA_ESTADO_LOGIN' => 'style="visibility: hidden; position: absolute;"', 'REANUDAR_VERIFICACION' => 0));
    $oPaloConsola = new PaloSantoConsola();
    $listaExtensiones = $oPaloConsola->listarExtensiones();
    $listaAgentes = $oPaloConsola->listarAgentes('static');
    $listaExtensionesCallback = $oPaloConsola->listarAgentes('dynamic');
    $oPaloConsola->desconectarTodo();
    $oPaloConsola = NULL;
    $bNoHayAgentes = count($listaAgentes) == 0 && count($listaExtensionesCallback) == 0;
    if (count($listaAgentes) == 0) {
        $listaAgentes[] = _tr('(no agents)');
    }
    if (count($listaExtensionesCallback) == 0) {
        $listaExtensionesCallback[] = _tr('(no agents)');
    }
    $smarty->assign(array('LISTA_EXTENSIONES' => $listaExtensiones, 'LISTA_AGENTES' => $listaAgentes, 'LISTA_EXTENSIONES_CALLBACK' => $listaExtensionesCallback, 'NO_EXTENSIONS' => count($listaExtensiones) == 0, 'NO_AGENTS' => $bNoHayAgentes));
    // Restaurar el estado de espera en caso de que se refresque la página
    if (!is_null($_SESSION['callcenter']['agente']) && !is_null($_SESSION['callcenter']['extension'])) {
        $smarty->assign(array('ID_AGENT' => $_SESSION['callcenter']['agente'], 'ID_EXTENSION' => $_SESSION['callcenter']['extension'], 'ID_EXTENSION_CALLBACK' => $_SESSION['callcenter']['agente'], 'ESTILO_FILA_ESTADO_LOGIN' => 'style="visibility: visible; position: none;"', 'MSG_ESPERA' => _tr('Logging agent in. Please wait...'), 'REANUDAR_VERIFICACION' => 1));
    } else {
        /* Si el usuario Elastix logoneado coincide con el número de agente de
         * la lista, se coloca este agente como opción por omisión para login.
         */
        if (isset($listaAgentes['Agent/' . $_SESSION['elastix_user']])) {
            $smarty->assign('ID_AGENT', 'Agent/' . $_SESSION['elastix_user']);
        }
        /* Si el usuario Elastix logoneado tiene una extensión y aparece en la
         * lista, se sugiere esta extension como la extensión a usar para 
         * marcar. */
        $pACL = new paloACL($arrConf['elastix_dsn']['acl']);
        $idUser = $pACL->getIdUser($_SESSION['elastix_user']);
        if ($idUser !== FALSE) {
            $tupla = $pACL->getUsers($idUser);
            if (is_array($tupla) && count($tupla) > 0) {
                $sExtension = $tupla[0][3];
                if (isset($listaExtensiones[$sExtension])) {
                    $smarty->assign('ID_EXTENSION', $sExtension);
                }
                foreach (array_keys($listaExtensionesCallback) as $k) {
                    $regs = NULL;
                    if (preg_match('|^(\\w+)/(\\d+)$|', $k, $regs) && $regs[2] == $sExtension) {
                        $smarty->assign('ID_EXTENSION_CALLBACK', $k);
                    }
                }
            }
        }
    }
    $sContenido = $smarty->fetch("{$sDirLocalPlantillas}/hnh_login_agent.tpl");
    return $sContenido;
}
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 handleJSON_get_sticky_note($smarty, $module_name)
{
    $jsonObject = new PaloSantoJSON();
    $id_menu = getParameter("id_menu");
    if (empty($id_menu)) {
        $jsonObject->set_status('ERROR');
        $jsonObject->set_error(_tr('Module not specified'));
    } else {
        global $arrConf;
        $pdbACL = new paloDB($arrConf['elastix_dsn']['acl']);
        $pACL = new paloACL($pdbACL);
        $idUser = $pACL->getIdUser($_SESSION['elastix_user']);
        $output = getStickyNote($pdbACL, $idUser, $id_menu);
        $jsonObject->set_status($output['status'] === TRUE ? 'OK' : 'ERROR');
        $jsonObject->set_error($output['msg']);
        $jsonObject->set_message($output['data']);
    }
    return $jsonObject->createJSON();
}
Beispiel #15
0
function saveNeoToggleTabByUser($menu, $action_status)
{
    include_once "libs/paloSantoACL.class.php";
    $arrResult['status'] = FALSE;
    $arrResult['msg'] = _tr("Please your session id does not exist. Refresh the browser and try again.");
    if ($menu != "") {
        $user = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : "";
        global $arrConf;
        $pdbACL = new paloDB("sqlite3:///{$arrConf['elastix_dbdir']}/acl.db");
        $pACL = new paloACL($pdbACL);
        $uid = $pACL->getIdUser($user);
        if ($uid !== FALSE) {
            $exist = false;
            $togglesTabs = "SELECT * FROM acl_user_shortcut WHERE id_user = ? AND type = 'NeoToggleTab'";
            $arr_result1 = $pdbACL->getFirstRowQuery($togglesTabs, TRUE, array($uid));
            if ($arr_result1 !== FALSE && count($arr_result1) > 0) {
                $exist = true;
            }
            if ($exist) {
                $pdbACL->beginTransaction();
                $query = "UPDATE acl_user_shortcut SET description = ? WHERE id_user = ? AND type = ?";
                $r = $pdbACL->genQuery($query, array($action_status, $uid, "NeoToggleTab"));
                if (!$r) {
                    $pdbACL->rollBack();
                    $arrResult['status'] = FALSE;
                    $arrResult['msg'] = _tr("Request cannot be completed. Please try again or contact with your elastix administrator and notify the next error: ") . $pdbACL->errMsg;
                    return $arrResult;
                } else {
                    $pdbACL->commit();
                    $arrResult['status'] = TRUE;
                    $arrResult['msg'] = _tr("Request has been sent.");
                    return $arrResult;
                }
            } else {
                $pdbACL->beginTransaction();
                $query = "INSERT INTO acl_user_shortcut(id_user, id_resource, type, description) VALUES(?, ?, ?, ?)";
                $r = $pdbACL->genQuery($query, array($uid, $uid, "NeoToggleTab", $action_status));
                if (!$r) {
                    $pdbACL->rollBack();
                    $arrResult['status'] = FALSE;
                    $arrResult['msg'] = _tr("Request cannot be completed. Please try again or contact with your elastix administrator and notify the next error: ") . $pdbACL->errMsg;
                    return $arrResult;
                } else {
                    $pdbACL->commit();
                    $arrResult['status'] = TRUE;
                    $arrResult['msg'] = _tr("Request has been sent.");
                    return $arrResult;
                }
            }
        }
    }
    return $arrResult;
}
 function getDataUserLogon($nameUser)
 {
     global $arrConf;
     //consulto datos del usuario logoneado
     $dbAcl = new paloDB($arrConf["elastix_dsn"]["acl"]);
     $pACL = new paloACL($dbAcl);
     $arrData = null;
     //paso 1: consulta de los datos de webmail si existen
     $userId = $pACL->getIdUser($nameUser);
     $arrData = $this->leerPropiedadesWebmail($dbAcl, $userId);
     if (!$arrData) {
         $arrData['login'] = '';
         $arrData['domain'] = '';
         $arrData['password'] = '';
     }
     //paso 2: consulta de la extension si tiene asignada
     $extension = $pACL->getUserExtension($nameUser);
     if ($extension) {
         $arrData['extension'] = $extension;
     }
     $arrData['id'] = $userId;
     return $arrData;
 }
Beispiel #17
0
 $webmail_login = NULL;
 $webmail_domain = NULL;
 $webmail_password = NULL;
 $webmail_imapsvr = 'localhost';
 $path_root = $_SERVER["DOCUMENT_ROOT"];
 include_once "{$path_root}/libs/misc.lib.php";
 include_once "{$path_root}/configs/default.conf.php";
 include_once "{$path_root}/libs/paloSantoDB.class.php";
 include_once "{$path_root}/libs/paloSantoACL.class.php";
 global $arrConf;
 $pDB = new paloDB($arrConf["elastix_dsn"]["acl"]);
 if (!empty($pDB->errMsg)) {
     echo "ERROR DE DB: {$pDB->errMsg} <br/>";
 } else {
     $pACL = new paloACL($pDB);
     $idUser = $pACL->getIdUser($_SESSION['elastix_user']);
     $sPeticionPropiedades = 'SELECT pp.property, pp.value ' . 'FROM acl_profile_properties pp, acl_user_profile up, acl_resource r ' . 'WHERE up.id_user = ? ' . 'AND up.profile = "default" ' . 'AND up.id_profile = pp.id_profile ' . 'AND up.id_resource = r.id ' . 'AND r.name = "webmail"';
     $tabla = $pDB->fetchTable($sPeticionPropiedades, FALSE, array($idUser));
     if ($tabla === FALSE) {
         print "ERROR DE DB: " . $pDB->errMsg;
     } else {
         foreach ($tabla as $tupla) {
             switch ($tupla[0]) {
                 case 'login':
                     $webmail_login = $tupla[1];
                     break;
                 case 'domain':
                     $webmail_domain = $tupla[1];
                     break;
                 case 'password':
                     $webmail_password = $tupla[1];
Beispiel #18
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 #19
0
function assign_CashCollection(&$pDB, $pDB_2)
{
    // collect parameters
    $sTicketId = trim(getParameter('ticket_id'));
    $pACL = new paloACL($pDB_2);
    $id_user = $pACL->getIdUser($_SESSION["elastix_user"]);
    $response = array('action' => 'collect', 'message' => 'Đã nhận tiền từ mã giao vé số ' . $sTicketId);
    $pCashCollection = new Cash_Collection($pDB);
    $result = $pCashCollection->assign_CashCollection($sTicketId, $id_user);
    // return json
    if (!$result) {
        $response['action'] = 'error';
        $response['message'] = 'Lỗi: ' . $pCashCollection->errMsg;
    }
    $json = new Services_JSON();
    Header('Content-Type: application/json');
    return $json->encode($response);
}