ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilChatroomClearTask.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4
14{
15
16 private $gui;
17
26 {
27 $this->gui = $gui;
28 }
29
36 public function executeDefault($method)
37 {
38 global $ilUser, $ilCtrl;
39
40 require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
41 require_once 'Modules/Chatroom/classes/class.ilChatroomUser.php';
42
43 if ( !ilChatroom::checkUserPermissions( array('moderate') , $this->gui->ref_id ) )
44 {
45 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", ROOT_FOLDER_ID);
46 $ilCtrl->redirectByClass("ilrepositorygui", "");
47 }
48
49 $room = ilChatroom::byObjectId( $this->gui->object->getId() );
50
51 if( $room )
52 {
53 // if user is in scope
54 $scope = $room->getRoomId();
55
56 $chat_user = new ilChatroomUser( $ilUser, $room );
57
58 $message = json_encode( $this->buildMessage(
59 ilUtil::stripSlashes( (int)$_REQUEST['sub'] ), $chat_user
60 ) );
61
62 $params = array(
63 'message' => $message,
64 );
65
66 $query = http_build_query( $params );
67 $connector = $this->gui->getConnector();
68 $response = $connector->post( $scope, $query );
69 $responseObject = json_decode( $response );
70
71 $room->clearMessages($_REQUEST['sub']);
72 }
73 else
74 {
75 $response = json_encode( array(
76 'success' => false,
77 'reason' => 'unkown room'
78 ) );
79 }
80
81 echo $response;
82 exit;
83 }
84
93 private function buildMessage($messageString, ilChatroomUser $chat_user)
94 {
95 $data = new stdClass();
96
97 $data->user = $this->gui->object->getPersonalInformation( $chat_user );
98 $data->timestamp = date( 'c' );
99 $data->type = 'clear';
100 $data->sub = $messageString;
101
102 return $data;
103 }
104}
105
106?>
Class ilChatroomKickTask.
__construct(ilChatroomObjectGUI $gui)
Constructor.
buildMessage($messageString, ilChatroomUser $chat_user)
Instantiates stdClass, sets $data->user and $data->userToKick using given $messageString and $chat_us...
executeDefault($method)
Displays window box to kick a user fetched from $_REQUEST['user'].
Class ilChatroomUser.
static byObjectId($object_id)
Returns ilChatroom object by given $object_id.
static checkUserPermissions($permissions, $ref_id, $send_info=true)
Checks user permissions by given array and ref_id.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$data
$params
Definition: example_049.php:96
global $ilCtrl
Definition: ilias.php:18
exit
Definition: login.php:54
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
global $ilUser
Definition: imgupload.php:15