Esempio n. 1
0
 /**
  * Toma el valor para el idioma.
  * @param optional string $lang     The language abbriviation.
  *
  * @access public
  *
  */
 function setLang($lang = null)
 {
     include_once Util::base_Path('include/classes/nls.inc.php');
     //Debug::oneVar($lang, __FILE__, __LINE__);
     if (empty($lang) || !NLS::isValid($lang)) {
         if (Session::getValue('lang') != null) {
             $lang = Session::getValue('lang');
         } else {
             if (Session::getContextValue('gettext_lang') != null) {
                 $lang = Session::getContextValue('gettext_lang');
             } else {
                 $lang = 'es_ES';
             }
         }
     }
     Session::setValue('language', $lang);
     //Debug::oneVar($lang, __FILE__, __LINE__);
     /* First try language with the current charset. */
     $lang_charset = $lang . '.' . NLS::getCharset();
     if ($lang_charset != setlocale(LC_ALL, $lang_charset)) {
         /* Next try language with its default charset. */
         global $nls;
         $charset = !empty($nls['charsets'][$lang]) ? $nls['charsets'][$lang] : $nls['defaults']['charset'];
         $lang_charset = $lang . '.' . $charset;
         NLS::_cachedCharset(0, $charset);
         if ($lang_charset != setlocale(LC_ALL, $lang_charset)) {
             /* At last try language solely. */
             $lang_charset = $lang;
             setlocale(LC_ALL, $lang_charset);
         }
     }
     @putenv('LANG=' . $lang_charset);
     @putenv('LANGUAGE=' . $lang_charset);
 }
Esempio n. 2
0
 function createSession($username, $name, $id, $accessM, $accessSM)
 {
     Session::init();
     Session::setValue('U_NAME', $username);
     Session::setValue('NAME', $name);
     Session::setValue('ID', $id);
     Session::setValue('ACCESS_MENU', $accessM);
     Session::setValue('ACCESS_SUBMENU', $accessSM);
 }
Esempio n. 3
0
 public static function redirect($route = '')
 {
     /**
      * Store the $_POST data so it can be
      * used on the next request.
      */
     Session::setValue('POST_DATA', $_POST);
     header('Location: ' . Tools::getURI($route));
     exit;
 }
Esempio n. 4
0
 public static function addMessages($status, $messages)
 {
     switch ($status) {
         case Log::MESSAGE:
             Session::setValue('messages', array_merge((array) Session::getValue('message'), $messages));
             break;
         case Log::ALERT:
             Session::setValue('alerts', array_merge((array) Session::getValue('alerts'), $messages));
             break;
         case Log::ERROR:
             Session::setValue('errors', array_merge((array) Session::getValue('errors'), $messages));
             break;
     }
 }
 function processPetition()
 {
     /* Falta la comprobación del acceso */
     $user_id = $this->getSessionElement('userinfo', 'user_id');
     $course_id = 0;
     if ($this->issetViewVariable('course')) {
         $course_id = $this->getViewVariable('course');
         if ($this->issetViewVariable('item') && $this->issetViewVariable('act')) {
             $item_id = $this->getViewVariable('item');
             if ($this->getViewVariable('act') == 'on') {
                 $this->obj_data->setBottonVisibility($course_id, $item_id, '1');
             } else {
                 $this->obj_data->setBottonVisibility($course_id, $item_id, '0');
             }
         }
     }
     if (miguel_CourseInfo::isCourseAdmin($this->obj_data, $course_id, $user_id)) {
         $this->setViewVariable('isCourseAdmin', true);
         Session::setValue('isCourseAdmin', true);
         $courseAccess = true;
     } else {
         $this->setViewVariable('isCourseAdmin', false);
         $courseAccess = miguel_CourseInfo::hasAccess($this->obj_data, $course_id, $user_id);
     }
     if ($courseAccess) {
         $infoCourse = miguel_CourseInfo::getInfo($this->obj_data, $course_id);
         //Debug::oneVar($infoCourse, __FILE__,__LINE__);
         $this->setViewVariable('infoCourse', $infoCourse);
         $this->setViewVariable('courseId', $course_id);
         $this->setViewVariable('visual_array', $this->obj_data->getCourseItems($course_id));
         //Debug::oneVar($this->getViewVariable('visual_array'),__FILE__, __LINE__);
         $this->addNavElement(Util::format_URLPath("course/index.php", "course=" . $course_id), $infoCourse['name']);
         $this->setCacheFile('miguel_VCourse_' . $course_id . '_' . $this->getSessionElement("userinfo", "user_id"));
         $this->setPageTitle("miguelOO Curso: " . $infoCourse['name']);
         $this->setMessage('Bienvenido al curso "' . $infoCourse['name'] . '"');
         $this->setHelp("EducContent");
     } else {
         $this->setPageTitle("miguelOO Curso: " . agt('miguel_courseNoAccess'));
         $this->setMessage(agt('miguel_courseNoAccess'));
         $this->setHelp("EducContent");
         $this->setError('miguel_VNoAccess');
     }
 }
Esempio n. 6
0
 public function login($email, $pass)
 {
     $query = $this->db->select('ASP_ID, ASP_STAT, ASP_PASS', 'SSP_ASPIRANTE', "ASP_EMAP='" . $email . "'", PDO::FETCH_NUM);
     if (!$query) {
         $output = ["STATUS" => "FAIL", "MSG" => "<i class=\"material-icons red-text\">error</i> &nbsp; Usuario no registrado"];
     } else {
         if (password_verify($pass, $query[0][2])) {
             if ($query[0][1] === 'A') {
                 Session::setValue("idASP", $query[0][0]);
                 Session::setValue("emailASP", $email);
                 $output = ["STATUS" => "SUCCESS", "MSG" => "<i class=\"material-icons green-text\">done</i> &nbsp; Has iniciado sesión correctamente"];
             }
             if ($query[0][1] === 'I') {
                 $output = ["STATUS" => "FAIL", "MSG" => "<i class=\"material-icons\">highlight_off</i> &nbsp; ¡Esta cuenta no se encuentra habilitada! Por favor, debe activar su cuenta."];
             }
         } else {
             $output = ["STATUS" => "FAIL", "MSG" => "<i class=\"material-icons red-text\">error</i> &nbsp; Credenciales incorrectas"];
         }
     }
     return json_encode($output);
 }
 /**
  * Permite asignar un nuevo elemento (variable) a los datos de sesión partiendo de un array.
  * Genera elementos de sesión, uno por cada elemento del array.
  * @param string $str_name Nombre del elemento (variable).
  * @param array $arr_value Valor asociado en un array.
  */
 function setSessionArray($str_name, $arr_value)
 {
     if (is_string($str_name)) {
         if (is_array($arr_value)) {
             foreach ($arr_value as $key => $val) {
                 Session::setValue($str_name . '_' . $key, $val);
             }
         }
     }
 }
 /**
  * Libera todos los recursos asociados a la sesión.
  */
 function close()
 {
     //Bloqueamos la sesión actual
     //session_start();
     Session::setValue('session', false);
     //Guardamos el la sesión
     session_write_close();
     //Creamos una nueva sesión, cambiando el nombre a la actual.
     session_id(md5(time()));
     //La "limpiamos"
     Session::clear();
     //Y la activamos
     Session::setValue('session', true);
 }
Esempio n. 9
0
 public function perfil_aspirante()
 {
     if (isset($_POST['id'])) {
         Session::setValue("GUEST", $_POST['id']);
         echo true;
     } else {
         $this->index_management();
     }
 }
Esempio n. 10
0
    $gSystemComponent->readDataByColumns(array('com_type' => 'SYSTEM', 'com_name_intern' => 'CORE'));
    $gCurrentSession->addObject('gSystemComponent', $gSystemComponent);
    // create object of the organization of config file with their preferences
    if ($gCurrentSession->getOrganizationId() > 0) {
        $gCurrentOrganization = new Organization($gDb, $gCurrentSession->getOrganizationId());
    } else {
        $gCurrentOrganization = new Organization($gDb, $g_organization);
    }
    if ($gCurrentOrganization->getValue('org_id') === 0) {
        // organization not found
        exit('<div style="color: #cc0000;">Error: The organization of the config.php could not be found in the database!</div>');
    }
    // add the organization to the session
    $gPreferences = $gCurrentOrganization->getPreferences();
    $gCurrentSession->addObject('gCurrentOrganization', $gCurrentOrganization);
    $gCurrentSession->setValue('ses_org_id', $gCurrentOrganization->getValue('org_id'));
    // create a language data object and assign it to the language object
    $gLanguageData = new LanguageData($gPreferences['system_language']);
    $gL10n->addLanguageData($gLanguageData);
    $gCurrentSession->addObject('gLanguageData', $gLanguageData);
    // delete old entries in session table
    $gCurrentSession->tableCleanup($gPreferences['logout_minutes']);
}
// now if auto login is done, read global user data
if ($gCurrentSession->hasObject('gCurrentUser')) {
    $gProfileFields =& $gCurrentSession->getObject('gProfileFields');
    $gCurrentUser =& $gCurrentSession->getObject('gCurrentUser');
    $gCurrentUser->mProfileFieldsData->setDatabase($gDb);
    // checks if user in database session is the same as in php session
    if ($gCurrentUser->getValue('usr_id') !== $gCurrentSession->getValue('ses_usr_id')) {
        $gCurrentUser->clear();
 function _menuFile()
 {
     if (Session::getValue('USERINFO_USER_ID') != null) {
         $file_name = Session::getValue('menufile');
         if (empty($file_name)) {
             $file_name = 'menu_item_' . Session::getValue('USERINFO_USER_ID') . '_' . date("YmdHis") . '.js';
         }
         $menuFile = Util::formatPath(MIGUELBASE_CACHE_DIR . '/' . $file_name);
         if (file_exists($menuFile) && time() - filemtime($menuFile) < MIGUELBASE_CACHE_TIME) {
             File::Touch($menuFile);
         } else {
             //Si existe, se borra
             if (file_exists($menuFile)) {
                 File::Delete($menuFile);
             }
             //Se crea, según el perfil de usuario
             switch (Session::getValue('USERINFO_PROFILE_ID')) {
                 case 1:
                     $strFile = 'menu_admin';
                     break;
                 case 2:
                 case 3:
                     $strFile = 'menu_profesor';
                     break;
                 case 4:
                     $strFile = 'menu_alumno';
                     break;
                 case 5:
                     $strFile = 'menu_secretaria';
                     break;
                 default:
                     $strFile = 'menu';
                     break;
             }
             include_once Util::app_Path("common/control/classes/miguel_menubar.class.php");
             $menubar = new miguel_MenuBar($strFile . '.xml');
             $str_content = 'var MENU_ITEMS = [';
             for ($i = 0; $i < $menubar->countMenu(); $i++) {
                 $str_content .= $menubar->getMenuCode($i, $superior);
             }
             $str_content .= '];';
             if (file_exists($menuFile)) {
                 File::Delete($menuFile);
             }
             File::Write($menuFile, $str_content);
         }
         $this->setViewVariable('menufile', MIGUEL_URLDIR . 'var/cache/' . "{$file_name}");
         Session::setValue('menufile', $file_name);
     }
 }
Esempio n. 12
0
 /**
  * Constructor.
  * Nunca debe ser llamado. Debe usarse el método anterior: &start()
  *
  * @param optional integer $session_flags  Paráetros de sesión
  *
  * @access private
  */
 function Registry($session_flags = 0)
 {
     //Inicia el contexto de la clase
     $this->_initContext();
     //Prepara el sistema de localización/internacionalización
     include_once Util::base_Path('include/classes/nls.class.php');
     NLS::setLang();
     NLS::setTextdomain('miguel', Util::formatPath(MIGUELGETTEXT_DIR), NLS::getCharset());
     Session::setValue('gettext', 'miguel');
     if ($this->modules['main']['status'] == 'inactive') {
         $this->_app_active = false;
     }
     foreach (array_keys($this->services) as $appName) {
         $app =& $this->services[$appName];
         if ($this->modules[$app['module']]['status'] == 'inactive') {
             continue;
         }
         $this->_interfaces[$appName] = $app;
     }
 }
Esempio n. 13
0
 public function createSession($email, $id, $nombreCompleto)
 {
     Session::setValue('U_EMAIL', $email);
     Session::setValue('U_ID', $id);
     Session::setValue('U_NOMBRE', $nombreCompleto);
 }