function updateRoomLog($roomid)
    {
        $xml_answer = false;
        $bw_code = Get::user_acceptlang();
        $request = '<?xml version="1.0" encoding="utf-8"?' . '>
		<ews type="10" lang="' . $bw_code . '">
			<clientcode>' . Get::sett('code_teleskill') . '</clientcode>
			<roomid>' . $roomid . '</roomid>
			<complete>1</complete>
			</ews>';
        $xml_answer = $this->_sendXmlRequest($request);
        if ($xml_answer === false || $xml_answer === '') {
            return array('errorcode' => -1, 'errormessage' => '', 'roomid' => '');
        }
        //Test Answer
        /*$xml_answer =	'<?xml version="1.0" encoding="utf-8"?'.'>'
        		 .'<ews>'
        		.'<errorcode>0</errorcode>'
        		.'<errormessage></errormessage>'
        		.'<sessions>'
        		.'<session sid="1" uid="1039" role="2" date="2008-09-30 11:00:13" duration="3565"/>'
        		.'<session sid="2" uid="1097" role="1" date="2008-09-30 11:05:54" duration="3254"/>'
        		.'<session sid="3" uid="1098" role="1" date="2008-09-30 11:01:18" duration="3148"/>'
        		.'<session sid="4" uid="1099" role="1" date="2008-09-30 11:07:25" duration="3297"/>'
        		.'</sessions>'
        		.'</ews>';*/
        $dom_answer = new DoceboDOMDocument();
        $dom_answer->loadXML(trim($xml_answer));
        $dlist_code = $dom_answer->getElementsByTagName('errorcode');
        $dlist_msg = $dom_answer->getElementsByTagName('errormessage');
        $dnode_code = $dlist_code->item(0);
        $dnode_msg = $dlist_msg->item(0);
        $e_code = $dnode_code->textContent;
        $e_msg = $dnode_msg->textContent;
        if ($e_code == 0) {
            $this->clearRoomLog($roomid);
            $dlist_sessions = $dom_answer->getElementsByTagName('session');
            if ($dlist_sessions->length > 0) {
                $array_element = array();
                for ($i = 0; $i < $dlist_sessions->length; $i++) {
                    $node = $dlist_sessions->item($i);
                    if ((int) $node->getAttribute('uid') != 0) {
                        $gmt = date('P', fromDatetimeToTimestamp($node->getAttribute('date')));
                        $gmt_split = explode(':', $gmt);
                        $gmt_offset = (int) $gmt_split[0];
                        if (isset($array_element[$node->getAttribute('uid')])) {
                            $array_element[$node->getAttribute('uid')]['duration'] += $node->getAttribute('duration');
                            $array_element[$node->getAttribute('uid')]['role'] = $node->getAttribute('role');
                            $array_element[$node->getAttribute('uid')]['access']++;
                        } else {
                            $array_element[$node->getAttribute('uid')]['role'] = $node->getAttribute('role');
                            $array_element[$node->getAttribute('uid')]['date'] = date('Y-m-d H:i:s', fromDatetimeToTimestamp($node->getAttribute('date')) + $gmt_offset * 3600);
                            $array_element[$node->getAttribute('uid')]['duration'] = $node->getAttribute('duration');
                            $array_element[$node->getAttribute('uid')]['access'] = 1;
                        }
                    }
                }
                $query = "INSERT INTO " . $GLOBALS['prefix_scs'] . "_teleskill_log (roomid, idUser, role, date, duration, access)" . " VALUES";
                $first = true;
                foreach ($array_element as $id_user => $values) {
                    if (!$first) {
                        $query .= ", ";
                    } else {
                        $first = false;
                    }
                    $query .= " ('" . $roomid . "',\r\n\t\t\t\t\t\t\t\t'" . (int) $id_user . "',\r\n\t\t\t\t\t\t\t\t'" . $values['role'] . "',\r\n\t\t\t\t\t\t\t\t'" . $values['date'] . "',\r\n\t\t\t\t\t\t\t\t'" . $values['duration'] . "',\r\n\t\t\t\t\t\t\t\t'" . $values['access'] . "')";
                }
                $result = sql_query($query);
                return $result;
            }
            return true;
        }
        return array('errorcode' => $e_code, 'errormessage' => $e_msg, 'roomid' => '');
    }
Beispiel #2
0
 /**
  * Return the current language, the following policy is followed
  * if a session preference is found, that one will be used, otherwise :
  * if the user is logged in we find and setup it's default language
  * if the user is anonymous we try to select the languagfe using the browser list of language preferences
  * if all of the previous fail we will use the default setted language
  * @return string
  */
 public static function get($reset = false)
 {
     if ($reset && isset($_SESSION['current_lang'])) {
         unset($_SESSION['current_lang']);
     }
     if (!isset($_SESSION['current_lang'])) {
         $_SESSION['current_lang'] = self::getDefault();
         // we if (!Get::cfg('demo_mode', false) && !Docebo::user()->isAnonymous()) {don't know which language we need
         if (!Get::cfg('demo_mode', false) && !Docebo::user()->isAnonymous()) {
             // load the language from the user setting
             $_SESSION['current_lang'] = Docebo::user()->preference->getLanguage();
         } else {
             // find the user language looking into the browser info
             $langadm = new LangAdm();
             $all_language = $langadm->getLangListNoStat();
             $browser_lang = Get::user_acceptlang(false);
             foreach ($browser_lang as $code) {
                 foreach ($all_language as $lang) {
                     if (strpos($lang->lang_browsercode, $code) !== false) {
                         $_SESSION['current_lang'] = $lang->lang_code;
                         return $_SESSION['current_lang'];
                     }
                 }
                 // end foreach
             }
             // end foreach
         }
     }
     return $_SESSION['current_lang'];
 }