コード例 #1
0
 /**
  * @param ilChatRoom $room
  * @param int        $scope
  * @param ilObjUser  $inviter
  * @param int        $invited_id
  * @return array
  */
 public function inviteToPrivateRoom(ilChatRoom $room, $scope, ilObjUser $inviter, $invited_id)
 {
     $chat_user = new ilChatroomUser($inviter, $room);
     $user_id = $chat_user->getUserId();
     if ($scope) {
         $room->inviteUserToPrivateRoom($invited_id, $scope);
         $message = json_encode(array('type' => 'private_room_created', 'users' => $invited_id, 'timestamp' => date('c'), 'public' => 0, 'title' => ilChatroom::lookupPrivateRoomTitle($scope), 'proom_id' => $scope, 'message' => array('public' => '0', 'user' => 'system', 'owner' => $user_id)));
         $this->sendMessage($room->getRoomId(), $message, array('public' => 0, 'recipients' => $invited_id));
     }
     if ($room->isSubscribed($user_id)) {
         $message = json_encode(array('type' => 'user_invited', 'title' => ilChatroom::lookupPrivateRoomTitle($scope), 'proom_id' => $scope, 'inviter' => $inviter->getId(), 'invited' => $invited_id));
         $this->sendMessage($room->getRoomId(), $message, array('public' => 0, 'recipients' => $invited_id));
     }
     return array('success' => true, 'message' => 'users invited');
 }
コード例 #2
0
 /**
  * Saves settings fetched from $_POST.
  */
 public function saveGeneral()
 {
     /**
      * @var $ilCtrl ilCtrl
      * @var $lng    ilLanguage
      */
     global $ilCtrl, $lng;
     $formFactory = new ilChatroomFormFactory();
     $settingsForm = $formFactory->getSettingsForm();
     if (!$settingsForm->checkInput()) {
         $this->general($settingsForm);
     } else {
         $this->gui->object->setTitle($settingsForm->getInput('title'));
         $this->gui->object->setDescription($settingsForm->getInput('desc'));
         $this->gui->object->update();
         // @todo: Do not rely on raw post data
         $settings = $_POST;
         $room = ilChatRoom::byObjectId($this->gui->object->getId());
         if (!$room) {
             $room = new ilChatRoom();
             $settings['object_id'] = $this->gui->object->getId();
         }
         $room->saveSettings($settings);
         ilUtil::sendSuccess($lng->txt('saved_successfully'), true);
         $ilCtrl->redirect($this->gui, 'settings-general');
     }
 }
コード例 #3
0
 /**
  * Saves settings fetched from $_POST.
  *
  * @global ilCtrl2 $ilCtrl
  */
 public function saveGeneral()
 {
     global $ilCtrl, $lng;
     $formFactory = new ilChatroomFormFactory();
     $settingsForm = $formFactory->getSettingsForm();
     if (!$settingsForm->checkInput()) {
         $this->general($settingsForm);
     } else {
         $this->gui->object->setTitle($_POST['title']);
         $this->gui->object->setDescription($_POST['desc']);
         $this->gui->object->update();
         $settings = $_POST;
         $room = ilChatRoom::byObjectId($this->gui->object->getId());
         if (!$room) {
             $room = new ilChatRoom();
             $settings['object_id'] = $this->gui->object->getId();
         }
         //var_dump($settings);exit;
         $room->saveSettings($settings);
         ilUtil::sendSuccess($lng->txt('saved_successfully'), true);
         $ilCtrl->redirect($this->gui, 'settings-general');
     }
 }