예제 #1
0
 function RequestFileUpload($_user, $_filename)
 {
     $fileid = md5(namebase($_filename) . $this->UserId . $this->BrowserId);
     $filemask = $this->UserId . "_" . $fileid;
     $fileurid = EX_FILE_UPLOAD_REQUEST . "_" . $fileid;
     $request = new FileUploadRequest($fileurid, $this->DesiredChatPartner);
     $request->SenderUserId = $this->UserId;
     $request->FileName = namebase($_filename);
     $request->FileMask = $filemask;
     $request->FileId = $fileid;
     $request->SenderBrowserId = $this->BrowserId;
     if (dataSetExists($request->TargetFile)) {
         $request->Load();
         if ($request->Permission == PERMISSION_FULL) {
             $_user->AddFunctionCall("top.lz_chat_file_start_upload('" . $_filename . "');", false);
         } else {
             if ($request->Permission == PERMISSION_NONE) {
                 $_user->AddFunctionCall("top.lz_chat_file_stop();", false);
                 $_user->AddFunctionCall("top.lz_chat_file_error(1);", false);
                 $request->Destroy();
             }
         }
     } else {
         if (!dataSetExists($request->TargetFile)) {
             if (!isValidUploadFile($_filename)) {
                 $_user->AddFunctionCall("top.lz_chat_file_error(2);", false);
             } else {
                 $request->Save();
             }
         }
     }
     return $_user;
 }