public function showAction()
 {
     $this->logger->entering();
     $this->logger->info('Loading conversation');
     $conversations = new Conversation();
     $conversation = $conversations->find($this->_getParam('id'))->current();
     $this->logger->info('Loading Item');
     $item = $conversation->findParentItem();
     $this->logger->info('Ensure authorized to view');
     if ($this->session->user_id != $conversation->user_id && $this->session->user_id != $item->owner_id) {
         $this->flash->notice = "Invalid Action";
         $this->_redirect('/');
     }
     $this->logger->info('Loading Messages');
     $messageRows = $conversation->findMessage();
     foreach ($messageRows as $messageRow) {
         $message = $messageRow->toArray();
         $message['user'] = $messageRow->findParentUser()->toArray();
         $messages[] = $message;
     }
     $this->logger->info('Loading View');
     $this->view->assign(array('conversation' => $conversation, 'messages' => $messages, 'item' => $item));
     $this->logger->info('Rendering view');
     $this->render();
     $this->logger->exiting();
 }
 public function ConversationsToHTML()
 {
     global $conversationsInfos;
     $myDBConnector = new DBConnector();
     $dbARY = $myDBConnector->infos();
     $connection = new mysqli($dbARY[0], $dbARY[1], $dbARY[2], $dbARY[3]);
     if ($connection->connect_error) {
         echo "Database bağlantı hatası";
     } else {
         $query = "SELECT * FROM conversations WHERE (user1=\"" . $conversationsInfos["Pour Qui"] . "\" OR user2=\"" . $conversationsInfos["Pour Qui"] . "\") ORDER BY lastDate DESC ";
         $results = $connection->query($query);
         if ($results->num_rows == 0) {
             echo "<div style=\"margin:2%;background-color:#e6e6e6;color:#6e6e6e;font-size:18px;font-family: Verdana,Geneva,sans-serif;\">";
             echo "Henüz mesajlaşmamışsınz.";
             echo "</div>";
         } else {
             while ($curResult = $results->fetch_assoc()) {
                 if ($curResult["user1"] == $conversationsInfos["Pour Qui"]) {
                     $other = $curResult["user2"];
                 } else {
                     $other = $curResult["user1"];
                 }
                 $ary = array($other, $conversationsInfos["Pour Qui"], $conversationsInfos["Pour Qui"]);
                 $myConversation = new Conversation($ary);
                 $myConversation->ConversationToHTML();
             }
         }
         $connection->close();
     }
 }
 /**
  * @param array $values
  * @return \HorseStories\Models\Conversations\Conversation
  */
 public function create($values)
 {
     $conversation = new Conversation();
     $conversation->subject = $values['subject'];
     $conversation->save();
     return $conversation;
 }
Пример #4
0
 public function testFetchWithParticipant()
 {
     $usersConvsIds = array(1, 2, 3, 4, 5);
     $conversation = new Conversation();
     $conversation->criteriaWithParticipants(1);
     $result = $conversation->findAll();
     foreach ($result as $key => $conv) {
         $this->assertTrue(in_array($conv->id, $usersConvsIds));
     }
 }
 public function testsSendNotificationOnNewComment()
 {
     $super = User::getByUsername('super');
     $steven = User::getByUsername('steven');
     $jack = User::getByUsername('jack');
     $conversation = new Conversation();
     $conversation->owner = Yii::app()->user->userModel;
     $conversation->subject = 'My test subject2';
     $conversation->description = 'My test description2';
     $this->assertTrue($conversation->save());
     $comment = new Comment();
     $comment->description = 'This is the 1st test comment';
     //Confirm no email notifications are sitting in the queue
     $this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
     //Confirm there is no inbox notification
     $this->assertEquals(0, Notification::getCount());
     //No message was sent because Steven and Jack don't have primary email address
     CommentsUtil::sendNotificationOnNewComment($conversation, $comment, array($steven, $jack));
     $this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
     //Two inbox notifications sent
     $this->assertEquals(2, Notification::getCount());
     $super->primaryEmail->emailAddress = '*****@*****.**';
     $steven->primaryEmail->emailAddress = '*****@*****.**';
     $jack->primaryEmail->emailAddress = '*****@*****.**';
     $this->assertTrue($super->save());
     $this->assertTrue($steven->save());
     $this->assertTrue($jack->save());
     //Two email message were sent one to Steven and one to Jack
     CommentsUtil::sendNotificationOnNewComment($conversation, $comment, array($steven, $jack));
     $this->assertEquals(2, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
     $emailMessages = EmailMessage::getAll();
     $emailMessage1 = $emailMessages[0];
     $emailMessage2 = $emailMessages[1];
     $this->assertCount(1, $emailMessage1->recipients);
     $this->assertCount(1, $emailMessage2->recipients);
     //Two inbox notifications created
     $this->assertEquals(4, Notification::getCount());
     //One email message was sent to Super but not to Steven
     //One inbox notification to Steven but not to Super
     NotificationTestHelper::setNotificationSettingsForUser($steven, 'ConversationNewComment', true, false);
     NotificationTestHelper::setNotificationSettingsForUser($super, 'ConversationNewComment', false, true);
     CommentsUtil::sendNotificationOnNewComment($conversation, $comment, array($steven, $super));
     $this->assertEquals(3, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
     $emailMessages = EmailMessage::getAll();
     $emailMessage = $emailMessages[2];
     $this->assertEquals(1, count($emailMessage->recipients));
     $this->assertEquals(5, Notification::getCount());
     $notifications = Notification::getAll();
     $notification = $notifications[4];
     $this->assertEquals(strval($steven), strval($notification->owner));
 }
 public function run(User $userToSendTo, $messageLogger)
 {
     $conversation = new Conversation();
     $conversation->owner = Yii::app()->user->userModel;
     $conversation->subject = 'My test subject';
     $conversation->description = 'My test description';
     if (!$conversation->save()) {
         throw new FailedToSaveModelException();
     }
     ConversationParticipantsUtil::sendEmailInviteToParticipant($conversation, $userToSendTo);
     $messageLogger->addInfoMessage('Sending conversation invite message');
 }
 /**
  * Store a newly created conversation in storage.
  *
  * @return Response
  */
 public function store()
 {
     $rules = array('users' => 'required|array', 'body' => 'required');
     $validator = Validator::make(Input::only('users', 'body'), $rules);
     if ($validator->fails()) {
         return Response::json(['success' => false, 'result' => $validator->messages()]);
     }
     // Create Conversation
     $params = array('created_at' => new DateTime(), 'name' => str_random(30), 'author_id' => Auth::user()->id);
     $conversation = Conversation::create($params);
     $conversation->users()->attach(Input::get('users'));
     $conversation->users()->attach(array(Auth::user()->id));
     // Create Message
     $params = array('conversation_id' => $conversation->id, 'body' => Input::get('body'), 'user_id' => Auth::user()->id, 'created_at' => new DateTime());
     $message = Message::create($params);
     // Create Message Notifications
     $messages_notifications = array();
     foreach (Input::get('users') as $user_id) {
         array_push($messages_notifications, new MessageNotification(array('user_id' => $user_id, 'read' => false, 'conversation_id' => $conversation->id)));
         // Publish Data To Redis
         $data = array('room' => $user_id, 'message' => array('conversation_id' => $conversation->id));
         Event::fire(ChatConversationsEventHandler::EVENT, array(json_encode($data)));
     }
     $message->messages_notifications()->saveMany($messages_notifications);
     return Redirect::route('chat.index', array('conversation', $conversation->name));
 }
Пример #8
0
 /**
  * Called every time a member is added/removed from a team
  *
  * @param TeamAbandonEvent|TeamJoinEvent|TeamKickEvent $event The event
  * @param string $type The type of the event
  */
 public function onTeamMembershipChange(Event $event, $type)
 {
     $query = \Conversation::getQueryBuilder()->forTeam($event->getTeam());
     foreach ($query->getModels() as $conversation) {
         \ConversationEvent::storeEvent($conversation->getId(), $event, $type);
     }
 }
 /**
  * For initializing members of the class.
  *
  * @param array $argarray misc. arguments
  *
  * @return boolean true
  */
 function prepare($argarray)
 {
     parent::prepare($argarray);
     $convId = $this->trimmed('id');
     if (empty($convId)) {
         // TRANS: Client exception thrown when no conversation ID is given.
         throw new ClientException(_('No conversation ID.'));
     }
     $this->conversation = Conversation::staticGet('id', $convId);
     if (empty($this->conversation)) {
         // TRANS: Client exception thrown when referring to a non-existing conversation ID (%d).
         $this->clientError(_('No conversation ID found'), 404);
         return false;
     }
     $profile = Profile::current();
     $stream = new ConversationNoticeStream($convId, $profile);
     $notice = $stream->getNotices(($this->page - 1) * $this->count, $this->count, $this->since_id, $this->max_id);
     $this->notices = $notice->fetchAll();
     $originalConversation = new Notice();
     $originalConversation->whereAdd('conversation=' . $convId);
     $originalConversation->limit(1);
     $originalConversation->orderBy('created');
     $originalConversation->find();
     if ($originalConversation->fetch()) {
         $this->originalNotice = $originalConversation;
     }
     return true;
 }
Пример #10
0
 public function SendEmail()
 {
     /*
      * validate the Inputs sent
      */
     $rules = array('email_cc' => "required_if:email_to,''|required_if:email_bcc,''", 'email_to' => "required_if:email_cc,''|required_if:email_bcc,''", 'email_bcc' => "required_if:email_cc,''|required_if:email_to,''", 'message' => 'required', 'subject' => 'required');
     $messages = array("required_without" => "Please select atleast one recipient", "subject.required" => "Please enter message subject", "message.required" => "Please enter message to send");
     $validator = Validator::make(Input::all(), $rules, $messages);
     $messages = $validator->messages();
     if ($validator->fails()) {
         return Redirect::to(URL::previous())->withErrors($validator)->withInput();
     } else {
         if (Conversation::saveEmail()) {
             Session::flash('_feedback', '<div class="alert alert-info alert-dismissable">
                             <i class="fa fa-info"></i>
                             <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><b>Alert!</b>
                             Email has been successfully queued for sending</div>');
             //Helpers::uploadCampaignFile(Input::file('attachment'), $attachment_ref);
             return Redirect::to(URL::route('conversation'));
         } else {
             Session::flash('_feedback', '<div class="alert alert-info alert-dismissable">
                             <i class="fa fa-info"></i>
                             <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><b>Alert!</b>
                             Error occured, please try again later</div>');
             return Redirect::to(URL::route('conversation'));
         }
     }
 }
Пример #11
0
 /**
  * {@inheritdoc}
  */
 public function unserialize($data)
 {
     $data = unserialize($data);
     $conversation = \Conversation::get($data['conversation']);
     $players = \Player::arrayIdToModel($data['players']);
     $teams = \Team::arrayIdToModel($data['teams']);
     $this->__construct($conversation, array_merge($players, $teams));
 }
Пример #12
0
 public static function getChats($message_hash, $data)
 {
     if ($data == '') {
         Conversation::updateConversation($message_hash);
     }
     $result = DB::Select("SELECT target_user_id as recipient_id,source_user_id as sender_id,(SELECT CONCAT(firstname,' ', lastname) \n                FROM accounts_dbx WHERE account_id = mradi_messages.source_user_id)  AS sender,CONCAT(firstname,' ', lastname) as recipient,\n                `time_sent`,`mradi_messages`.`message`,(case when time_read is not null then 1 else 0 end)as time_read FROM `mradi_messages` \n                LEFT JOIN `accounts_dbx` ON `accounts_dbx`.`account_id` = `mradi_messages`.`target_user_id`\n                WHERE message_hash = ? AND `mradi_messages`.`status` IN (0,1) order by time_sent asc", array($message_hash));
     return $result;
 }
Пример #13
0
 public function index()
 {
     $this->template->title = "Test Controller";
     Conversation::factory();
     Conversation::last_conversation()->view();
     $this->template->content = Conversation::last_conversation()->flushBuffer();
     $form = new Forge();
     print_r(class_parents($form));
 }
Пример #14
0
 /**
  * Factory method for creating a new conversation
  *
  * @return Conversation the new conversation DO
  */
 static function create()
 {
     $conv = new Conversation();
     $conv->created = common_sql_now();
     $id = $conv->insert();
     if (empty($id)) {
         common_log_db_error($conv, 'INSERT', __FILE__);
         return null;
     }
     $orig = clone $conv;
     $orig->uri = common_local_url('conversation', array('id' => $id), null, null, false);
     $result = $orig->update($conv);
     if (empty($result)) {
         common_log_db_error($conv, 'UPDATE', __FILE__);
         return null;
     }
     return $conv;
 }
Пример #15
0
 /**
  * Only return messages that are sent from/to a specific player
  *
  * @param  Player $player The player related to the messages
  * @return self
  */
 public function forPlayer($player)
 {
     $this->extras .= '
         LEFT JOIN player_conversations ON player_conversations.conversation=conversations.id
     ';
     $this->column('player_conversations.player')->is($player);
     $this->column('conversations.status')->isOneOf(Conversation::getActiveStatuses());
     return $this;
 }
 /**
  * Display a listing of user conversations.
  *
  * @return Response
  */
 public function index($user_id)
 {
     $conversations_users = ConversationUser::where('user_id', $user_id)->lists('conversation_id');
     $conversations = array();
     if ($conversations_users) {
         $conversations = Conversation::whereIn('id', $conversations_users)->get();
     }
     return Response::json(['success' => true, 'result' => $conversations]);
 }
 /**
  * @param DemoDataHelper $demoDataHelper
  */
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     assert('$demoDataHelper->isSetRange("User")');
     assert('$demoDataHelper->isSetRange("Account")');
     $conversations = array();
     foreach (self::getConversationData() as $randomConversationData) {
         $postData = array();
         $conversation = new Conversation();
         $conversation->setScenario('importModel');
         $conversation->owner = $demoDataHelper->getRandomByModelName('User');
         $conversation->createdByUser = $conversation->owner;
         $conversation->conversationItems->add($demoDataHelper->getRandomByModelName('Account'));
         $conversation->subject = $randomConversationData['subject'];
         $conversation->description = $randomConversationData['description'];
         //Add some comments
         foreach ($randomConversationData['comments'] as $commentDescription) {
             $comment = new Comment();
             $comment->setScenario('importModel');
             $comment->createdByUser = $demoDataHelper->getRandomByModelName('User');
             $comment->description = $commentDescription;
             $conversation->comments->add($comment);
             self::addItemIdToPostData($postData, $comment->createdByUser->getClassId('Item'));
         }
         //Add Super user
         $comment = new Comment();
         $comment->description = 'Great idea guys. Keep it coming.';
         $conversation->comments->add($comment);
         self::addItemIdToPostData($postData, Yii::app()->user->userModel->getClassId('Item'));
         $saved = $conversation->save();
         assert('$saved');
         //any user who has made a comment should be added as a participant and resolve permissions
         $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($conversation);
         ConversationParticipantsUtil::resolveConversationHasManyParticipantsFromPost($conversation, $postData, $explicitReadWriteModelPermissions);
         $saved = $conversation->save();
         assert('$saved');
         $success = ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($conversation, $explicitReadWriteModelPermissions);
         $saved = $conversation->save();
         assert('$success');
         $conversations[] = $conversation->id;
     }
     $demoDataHelper->setRangeByModelName('Conversation', $conversations[0], $conversations[count($conversations) - 1]);
 }
Пример #18
0
 /**
  * Called every time a member is added/removed from a team
  *
  * @param TeamAbandonEvent|TeamJoinEvent|TeamKickEvent $event The event
  * @param string $type The type of the event
  */
 public function onTeamMembershipChange(Event $event, $type)
 {
     $query = \Conversation::getQueryBuilder()->forTeam($event->getTeam());
     foreach ($query->getModels() as $conversation) {
         \ConversationEvent::storeEvent($conversation->getId(), $event, $type);
         if ($type === 'team.join') {
             $conversation->addMember($event->getPlayer(), $distinct = false);
         }
     }
 }
Пример #19
0
 /**
  * Initialization.
  *
  * @param array $args Web and URL arguments
  *
  * @return boolean false if id not passed in
  */
 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     $convId = $this->int('id');
     $this->conv = Conversation::getKV('id', $convId);
     if (!$this->conv instanceof Conversation) {
         throw new ClientException('Could not find specified conversation');
     }
     return true;
 }
 public function showAll()
 {
     $user = Confide::user();
     $conversations = Conversation::where('sender', '=', $user->id)->orWhere('receiver', '=', $user->id)->orderBy('created_at', 'desc')->get();
     foreach ($conversations as $conversation) {
         $conversation->sender = User::find($conversation->sender);
         $conversation->receiver = User::find($conversation->receiver);
     }
     return View::make('home/conversation/show-all', compact('user', 'conversations'));
 }
Пример #21
0
 public function testsSendNotificationOnNewComment()
 {
     $super = User::getByUsername('super');
     $steven = User::getByUsername('steven');
     $jack = User::getByUsername('jack');
     $conversation = new Conversation();
     $conversation->owner = Yii::app()->user->userModel;
     $conversation->subject = 'My test subject2';
     $conversation->description = 'My test description2';
     $this->assertTrue($conversation->save());
     $comment = new Comment();
     $comment->description = 'This is the 1st test comment';
     //Confirm no email notifications are sitting in the queue
     $this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
     //No message was sent because Steven and Jack don't have primary email address
     CommentsUtil::sendNotificationOnNewComment($conversation, $comment, $super, array($steven, $jack));
     $this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
     $super->primaryEmail->emailAddress = '*****@*****.**';
     $steven->primaryEmail->emailAddress = '*****@*****.**';
     $jack->primaryEmail->emailAddress = '*****@*****.**';
     $this->assertTrue($super->save());
     $this->assertTrue($steven->save());
     $this->assertTrue($jack->save());
     //Two email message were sent one to Steven and one to Jack
     CommentsUtil::sendNotificationOnNewComment($conversation, $comment, $super, array($steven, $jack));
     $this->assertEquals(2, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
     $emailMessages = EmailMessage::getAll();
     $emailMessage1 = $emailMessages[0];
     $emailMessage2 = $emailMessages[1];
     $this->assertCount(1, $emailMessage1->recipients);
     $this->assertCount(1, $emailMessage2->recipients);
     //One email message was sent to Super but not to Steven
     UserConfigurationFormAdapter::setValue($steven, true, 'turnOffEmailNotifications');
     CommentsUtil::sendNotificationOnNewComment($conversation, $comment, $jack, array($steven, $super));
     $this->assertEquals(3, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
     $emailMessages = EmailMessage::getAll();
     $emailMessage = $emailMessages[2];
     $this->assertEquals(1, count($emailMessage->recipients));
 }
Пример #22
0
 public function init()
 {
     $metadata = Conversation::getMetadata();
     $observedModelClassNames = $metadata['Conversation']['conversationItemsModelClassNames'];
     if ($observedModelClassNames == null) {
         return;
     }
     foreach ($observedModelClassNames as $modelClassName) {
         $modelClassName::model()->attachEventHandler('onAfterDelete', array($this, 'deleteConversationItems'));
     }
 }
Пример #23
0
 public function bug($id, $request)
 {
     $ticket = Ticket::find($id);
     $message = "Après étude de votre problème, il en résulte qu'il ne s'agit pas d'un incident isolé mais bien d'un problème technique interne à DreamVids (bug). Nous travaillons actuellement à la détection et à la résolution de ce bug mais nous ne pouvons vous donner de plus amples informations. Nous nous excusons pour la gêne occasionnée et vous remerçions de votre patience.";
     $this->mail($ticket, $message);
     if ($ticket->conv_id != '' && Conversation::exists($ticket->conv_id)) {
         Conversation::find($ticket->conv_id)->removeChannel(User::find(User::getIdByName($ticket->tech))->getMainChannel());
     }
     $ticket->delete();
     return new RedirectResponse(WEBROOT . 'admin/tickets');
 }
Пример #24
0
 /**
  * Using conversation to test this method.
  */
 public function testGetCommentsByRelatedModelTypeIdAndPageSize()
 {
     $super = Yii::app()->user->userModel;
     $comment1 = new Comment();
     $comment1->description = 'Comment 1';
     $comment2 = new Comment();
     $comment2->description = 'Comment 2';
     $comment3 = new Comment();
     $comment3->description = 'Comment 3';
     $conversation = new Conversation();
     $conversation->owner = $super;
     $conversation->subject = 'My test subject';
     $conversation->description = 'My test description';
     $this->assertTrue($conversation->save());
     $conversation->comments->add($comment1);
     $conversation->comments->add($comment2);
     $conversation->comments->add($comment3);
     $this->assertTrue($conversation->save());
     $commentsData = Comment::getCommentsByRelatedModelTypeIdAndPageSize('Conversation', $conversation->id, 5);
     $this->assertEquals(3, count($commentsData));
 }
 /**
  * Runs through relations and makes sure the user can access at least one relation. If at least one is
  * accessible, true is returned.
  */
 public function canUserPerformAction()
 {
     $metadata = Conversation::getMetadata();
     foreach ($metadata['Conversation']['conversationItemsModelClassNames'] as $modelClassName) {
         if (is_subclass_of($modelClassName, 'Item') && $modelClassName::getModuleClassName() != null) {
             if (RightsUtil::canUserAccessModule($modelClassName::getModuleClassName(), $this->user)) {
             }
             return true;
         }
     }
     return false;
 }
Пример #26
0
 public function createAction()
 {
     $this->logger->entering();
     $this->logger->info('Creating a new messsage row');
     $messages = new Message();
     $message = $messages->fetchNew();
     $this->logger->info('Setting message from post parameters');
     $messageParams = $messages->filterColumns($this->_getParam('message'));
     $message->setFromArray($messageParams);
     $date = new Zend_Date();
     $message->created_on = $date->get(Zend_Date::ISO_8601);
     $this->logger->info('Creating a new conversation if necessary');
     if (empty($message->conversation_id)) {
         $conversations = new Conversation();
         $conversation = $conversations->fetchNew();
         $conversationParams = $conversations->filterColumns($this->_getParam('conversation'));
         $conversation->setfromArray($conversationParams);
         $conversation->save();
         $message->conversation_id = $conversation->id;
     }
     $this->logger->info('Saving the message');
     $message->save();
     $item = $conversation->findParentItem();
     $owner = $item->findParentUser();
     $asker = $conversation->findParentUser();
     $mail = new Zend_Mail();
     $mail->setFrom('*****@*****.**', 'Swaplady');
     $mail->addTo($owner->email, $owner->name);
     $mail->setSubject("[Swaplady] New message about {$item->name}");
     $mail->setBodyText($message->body . "\nYou can add to the conversation at http://swaplady.com/conversations/show/{$conversation->id}");
     $mail->send();
     $mail = new Zend_Mail();
     $mail->setFrom('*****@*****.**', 'Swaplady');
     $mail->addTo($asker->email, $asker->name);
     $mail->setSubject("[Swaplady] New message about {$item->name}");
     $mail->setBodyText($message->body . "\nYou can add to the conversation at http://swaplady.com/conversations/show/{$conversation->id}");
     $mail->send();
     $this->logger->info('Redirecting to show the item of the message');
     $this->_redirect('/conversations/show/' . $message->conversation_id);
 }
 public function testAddParicipantAndHaveParticipantRemoveSelf()
 {
     return;
     //Turn on once issue is fixed with SECURITY_OPTIMIZED and this bug.
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $fileModel = ZurmoTestHelper::createFileModel();
     $accounts = Account::getByName('anAccount');
     $steven = UserTestHelper::createBasicUser('steven');
     $conversation = new Conversation();
     $conversation->owner = $super;
     $conversation->subject = 'My test subject';
     $conversation->description = 'My test description';
     $this->assertTrue($conversation->save());
     $sally = UserTestHelper::createBasicUser('sally');
     $conversation->addPermissions($sally, Permission::READ_WRITE_CHANGE_PERMISSIONS_CHANGE_OWNER);
     $conversation->save();
     //Log in as sally, and remove her permission
     Yii::app()->user->userModel = $sally;
     //Breaks because SecurableItem 2 spots using SECURITY_OPTIMIZATION == false, think it is the first spot
     //todo: fix.
     $conversation->removePermissions(Yii::app()->user->userModel, Permission::READ_WRITE_CHANGE_PERMISSIONS_CHANGE_OWNER, Permission::ALLOW);
 }
Пример #28
0
 public static function sendNew($sender, $conversation, $content, $timeOffset = 0)
 {
     $id = Message::generateId(6);
     $timestamp = Utils::tps() + $timeOffset;
     $message = Message::create(array('id' => $id, 'sender_id' => $sender, 'conversation_id' => $conversation, 'content' => $content, 'timestamp' => $timestamp));
     $recep = array();
     $members = explode(';', trim(Conversation::find($conversation)->members_ids, ';'));
     foreach ($members as $id) {
         if ($id != $sender) {
             $recep[] = trim(UserChannel::find($id)->admins_ids, ';');
         }
     }
     $recep = ';' . implode(';', $recep) . ';';
     $recep = ChannelAction::filterReceiver($recep, "pm");
     ChannelAction::create(array('id' => ChannelAction::generateId(6), 'channel_id' => userChannel::find($sender)->id, 'recipients_ids' => $recep, 'type' => 'pm', 'target' => $conversation, 'timestamp' => $timestamp));
     return $message;
 }
Пример #29
0
 protected function loadConversation($cnvID)
 {
     $conversation = \Conversation::getByID($cnvID);
     if (is_object($conversation) && $conversation->getConversationSubscriptionEnabled()) {
         $cp = new \Permissions($conversation);
         if ($cp->canViewConversation()) {
             $u = new \User();
             $this->user = $u;
             $this->conversation = $conversation;
             $this->set('conversation', $conversation);
             $this->set('isSubscribed', $conversation->isUserSubscribed($u));
             $this->setViewObject(new \View('/dialogs/conversation/subscribe'));
         }
     }
     if (!$conversation) {
         throw new \Exception(t('Access Denied.'));
     }
 }
Пример #30
0
 public function deleteUser($user_id)
 {
     $allTheConversations = Conversation::displayConversations($user_id);
     //delete all the conversations with all their messages
     for ($row = 0; $row < count($allTheConversations); $row++) {
         Conversation::deleteConversation($allTheConversations[$row]['conversationId']);
     }
     //get all the apartments of this user in an array
     $apartmentArray = Product::displayOwnerProducts($user_id);
     //delete all the selected apartments
     for ($row = 0; $row < count($apartmentArray); $row++) {
         Product::deleteProduct($apartmentArray[$row]['dwelling_Id'], $user_id);
     }
     //delete the user from the database
     parent::executeSqlQuery("DELETE FROM bannedusers WHERE user_id = '{$user_id}'");
     parent::executeSqlQuery("DELETE FROM users WHERE user_id = '{$user_id}'");
     header("location: adminPanel.php?action=user");
 }