close_chat_window() '; } else { api_protect_course_script(); } // if we have the session set up if (!empty($course) && !empty($_user['user_id'])) { include_once(api_get_path(LIBRARY_PATH).'document.lib.php'); include_once(api_get_path(LIBRARY_PATH).'text.lib.php'); include_once (api_get_path(LIBRARY_PATH).'fileUpload.lib.php'); /* ----------------------------------------------------------- Constants and variables ----------------------------------------------------------- */ $tbl_user = Database::get_main_table(TABLE_MAIN_USER); $sent = $_REQUEST['sent']; /* ============================================================================== MAIN CODE ============================================================================== */ $query="SELECT lastname, firstname, username FROM $tbl_user WHERE user_id='".$_user['user_id']."'"; $result=Database::query($query,__FILE__,__LINE__); list($pseudoUser)=Database::fetch_row($result); $isAllowed=(empty($pseudoUser) || !$_cid)?false:true; $isMaster=$is_courseAdmin?true:false; $firstname=Database::result($result,0,'firstname'); $lastname=Database::result($result,0,'lastname'); $dateNow=date('Y-m-d'); $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; $chatPath=$documentPath.'chat_files/'; $TABLEITEMPROPERTY= Database::get_course_table(TABLE_ITEM_PROPERTY); if(!is_dir($chatPath)) { if(is_file($chatPath)) { @unlink($chatPath); } if (!api_is_anonymous()) { $perm = api_get_setting('permissions_for_new_directories'); $perm = octdec(!empty($perm)?$perm:'0770'); @mkdir($chatPath,$perm); @chmod($chatPath,$perm); $doc_id=add_document($_course,'/chat_files','folder',0,'chat_files'); $sql_insert = "INSERT INTO ".$TABLEITEMPROPERTY . " (tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ('document',1,NOW(),NOW(),$doc_id,'DocumentAdded',1,0,NULL,0)"; Database::query($sql_insert ,__FILE__,__LINE__); } } include('header_frame.inc.php'); $chat_size=0; //define emoticons $emoticon_text1=':-)'; $emoticon_img1= ''.get_lang('Smile').''; $emoticon_text2=':-D'; $emoticon_img2= ''.get_lang('BigGrin').''; $emoticon_text3=';-)'; $emoticon_img3= ''.get_lang('Wink').''; $emoticon_text4=':-P'; $emoticon_img4= ''.get_lang('Avid').''; $emoticon_text5='8-)'; $emoticon_img5= ''.get_lang('Cool').''; $emoticon_text6=':-o)'; $emoticon_img6= ''.get_lang('Surprised').''; $emoticon_text7='=;'; $emoticon_img7= ''.get_lang('Hand').''; $emoticon_text8='=8-o'; $emoticon_img8= ''.get_lang('Amazing').''; $emoticon_text9=':-|)'; $emoticon_img9= ''.get_lang('Neutral').''; $emoticon_text8=':-k'; $emoticon_img8= ''.get_lang('Think').''; $emoticon_text11=':-?'; $emoticon_img11= ''.get_lang('Confused').''; $emoticon_text12=':-8'; $emoticon_img12= ''.get_lang('Redface').''; $emoticon_text13=':-='; $emoticon_img13= ''.get_lang('Silence').''; $emoticon_text14=':-#)'; $emoticon_img14= ''.get_lang('Silenced').''; $emoticon_text15=':-('; $emoticon_img15= ''.get_lang('Sad').''; $emoticon_text16=':-[8'; $emoticon_img16= ''.get_lang('Angry').''; $emoticon_text17='--)'; $emoticon_img17= ''.get_lang('Arrow').''; $emoticon_text18=':!:'; $emoticon_img18= ''.get_lang('Exclamation').''; $emoticon_text19=':?:'; $emoticon_img19= ''.get_lang('Question').''; $emoticon_text20='0-'; $emoticon_img20= ''.get_lang('Idea').''; // $emoticon_text201='*'; $emoticon_img201= ''.get_lang('AskPermissionSpeak').''; $emoticon_text202=':speak:'; $emoticon_img202= ''.get_lang('GiveTheFloorTo').''; $emoticon_text203=':pause:'; $emoticon_img203= ''.get_lang('Pause').''; $emoticon_text204=':stop:'; $emoticon_img204= ''.get_lang('Stop').''; if($sent) { $message=trim(htmlspecialchars(stripslashes($_POST['message']),ENT_QUOTES,$charset)); $message=str_replace($emoticon_text1, $emoticon_img1, $message); $message=str_replace($emoticon_text2, $emoticon_img2, $message); $message=str_replace($emoticon_text3, $emoticon_img3, $message); $message=str_replace($emoticon_text4, $emoticon_img4, $message); $message=str_replace($emoticon_text5, $emoticon_img5, $message); $message=str_replace($emoticon_text6, $emoticon_img6, $message); $message=str_replace($emoticon_text7, $emoticon_img7, $message); $message=str_replace($emoticon_text8, $emoticon_img8, $message); $message=str_replace($emoticon_text9, $emoticon_img9, $message); $message=str_replace($emoticon_text10, $emoticon_img10, $message); $message=str_replace($emoticon_text11, $emoticon_img11, $message); $message=str_replace($emoticon_text12, $emoticon_img12, $message); $message=str_replace($emoticon_text13, $emoticon_img13, $message); $message=str_replace($emoticon_text14, $emoticon_img14, $message); $message=str_replace($emoticon_text15, $emoticon_img15, $message); $message=str_replace($emoticon_text16, $emoticon_img16, $message); $message=str_replace($emoticon_text17, $emoticon_img17, $message); $message=str_replace($emoticon_text18, $emoticon_img18, $message); $message=str_replace($emoticon_text19, $emoticon_img19, $message); $message=str_replace($emoticon_text20, $emoticon_img20, $message); // $message=str_replace($emoticon_text201, $emoticon_img201, $message); $message=str_replace($emoticon_text202, $emoticon_img202, $message); $message=str_replace($emoticon_text203, $emoticon_img203, $message); $message=str_replace($emoticon_text204, $emoticon_img204, $message); $timeNow=date('d/m/y H:i:s'); if (!api_is_anonymous()) { if(!empty($message)) { $message=make_clickable($message); if(!file_exists($chatPath.'messages-'.$dateNow.'.log.html')) { $doc_id=add_document($_course,'/chat_files/messages-'.$dateNow.'.log.html','file',0,'messages-'.$dateNow.'.log.html'); api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id']); item_property_update_on_folder($_course,'/chat_files', $_user['user_id']); } else { $doc_id = DocumentManager::get_document_id($_course,'/chat_files/messages-'.$dateNow.'.log.html'); } $fp=fopen($chatPath.'messages-'.$dateNow.'.log.html','a'); if($isMaster) { $photo= ''.get_lang('Teacher').''; fputs($fp,'['.$timeNow.']'.$photo.' '.api_get_person_name($firstname, $lastname).' : '.$message.'
'."\n"); } else { $photo= ''.get_lang('Student').''; fputs($fp,'['.$timeNow.']'.$photo.' '.api_get_person_name($firstname, $lastname).' : '.$message.'
'."\n"); } fclose($fp); $chat_size=filesize($chatPath.'messages-'.$dateNow.'.log.html'); update_existing_document($_course, $doc_id,$chat_size); item_property_update_on_folder($_course,'/chat_files', $_user['user_id']); } } } ?>
" class="background_submit">
".$emoticon_img1.""; echo "".$emoticon_img2.""; echo "".$emoticon_img3.""; echo "".$emoticon_img4.""; echo "".$emoticon_img5.""; echo "".$emoticon_img6.""; echo "".$emoticon_img7.""; echo "".$emoticon_img8.""; echo "".$emoticon_img9.""; echo "".$emoticon_img10.""; echo "".$emoticon_img11.""; echo "".$emoticon_img12.""; echo "".$emoticon_img13.""; echo "".$emoticon_img14.""; echo "".$emoticon_img15.""; echo "".$emoticon_img16.""; echo "".$emoticon_img17.""; echo "".$emoticon_img18.""; echo "".$emoticon_img19.""; echo "".$emoticon_img20.""; ?> ".$emoticon_img201.""; echo "".$emoticon_img202.""; echo "".$emoticon_img203.""; echo "".$emoticon_img204.""; ?>