Ejemplo n.º 1
0
 /**
  * Adds video clip
  *
  * @return boolean
  */
 public function process()
 {
     $values = $this->getValues();
     $clipService = VIDEO_BOL_ClipService::getInstance();
     $clip = new VIDEO_BOL_Clip();
     $clip->title = htmlspecialchars($values['title']);
     $description = UTIL_HtmlTag::stripJs($values['description']);
     $description = UTIL_HtmlTag::stripTags($description, array('frame', 'style'), array(), true);
     $description = nl2br($description, true);
     $clip->description = $description;
     $clip->userId = OW::getUser()->getId();
     $clip->code = '<iframe src="' . (OW::getRouter()->getBaseUrl() . 'spvideo/proxy/Allmyvideos/pending/') . $values['token'] . '" width="540" height="315" frameborder="0"></iframe>';
     $privacy = OW::getEventManager()->call('plugin.privacy.get_privacy', array('ownerId' => $clip->userId, 'action' => 'video_view_video'));
     $clip->provider = 'allmyvideos';
     $clip->addDatetime = time();
     $clip->status = 'approved';
     $clip->privacy = mb_strlen($privacy) ? $privacy : 'everybody';
     $eventParams = array('pluginKey' => 'video', 'action' => 'add_video');
     if (OW::getEventManager()->call('usercredits.check_balance', $eventParams) === true) {
         OW::getEventManager()->call('usercredits.track_action', $eventParams);
     }
     if ($clipService->addClip($clip)) {
         SPVIDEOLITE_PRO_ALLMYVIDEOS_CLASS_Processing::processTemporaryUpload($values['token'], $values['filename']);
         BOL_TagService::getInstance()->updateEntityTags($clip->id, 'video', $values['tags']);
         return array('result' => true, 'id' => $clip->id);
     }
     return false;
 }
Ejemplo n.º 2
0
 public function addVideo($userId, $embed, $title, $description, $thumbnailUrl, $text, $addToFeed = true)
 {
     if (!$this->isActive()) {
         return null;
     }
     $title = empty($title) ? $text : $title;
     $title = empty($title) ? '' : $title;
     $description = empty($description) ? '' : $description;
     $clipService = VIDEO_BOL_ClipService::getInstance();
     $clip = new VIDEO_BOL_Clip();
     $clip->title = $title;
     $description = UTIL_HtmlTag::stripJs($description);
     $description = UTIL_HtmlTag::stripTags($description, array('frame', 'style'), array(), true);
     $clip->description = $description;
     $clip->userId = $userId;
     $clip->code = UTIL_HtmlTag::stripJs($embed);
     $prov = new VideoProviders($clip->code);
     $privacy = OW::getEventManager()->call('plugin.privacy.get_privacy', array('ownerId' => $clip->userId, 'action' => 'video_view_video'));
     $clip->provider = $prov->detectProvider();
     $clip->addDatetime = time();
     $clip->status = 'approved';
     $clip->privacy = mb_strlen($privacy) ? $privacy : 'everybody';
     $thumbUrl = empty($thumbnailUrl) ? $prov->getProviderThumbUrl($clip->provider) : $thumbnailUrl;
     if ($thumbUrl != VideoProviders::PROVIDER_UNDEFINED) {
         $clip->thumbUrl = $thumbUrl;
     }
     $clip->thumbCheckStamp = time();
     $clipId = $clipService->addClip($clip);
     if ($addToFeed) {
         // Newsfeed
         $event = new OW_Event('feed.action', array('pluginKey' => 'video', 'entityType' => 'video_comments', 'entityId' => $clipId, 'userId' => $clip->userId), array("content" => array("vars" => array("status" => $text))));
         OW::getEventManager()->trigger($event);
     }
     return $clipId;
 }
Ejemplo n.º 3
0
 public function logMsg()
 {
     $service = AJAXIM_BOL_Service::getInstance();
     if ($errorMessage = $service->checkPermissions()) {
         exit(json_encode(array('error' => $errorMessage)));
     }
     if (empty($_POST['to'])) {
         exit(json_encode(array('error' => "Receiver is not defined")));
     }
     if (empty($_POST['message'])) {
         exit(json_encode(array('error' => "Message is empty")));
     }
     $message = UTIL_HtmlTag::stripTags(UTIL_HtmlTag::stripJs($_POST['message']));
     $dto = new AJAXIM_BOL_Message();
     $dto->setFrom(OW::getUser()->getId());
     $dto->setTo($_POST['to']);
     $dto->setMessage($message);
     $dto->setTimestamp(time());
     $dto->setRead(0);
     AJAXIM_BOL_Service::getInstance()->save($dto);
     //$message = AJAXIM_BOL_Service::getInstance()->splitLongMessages($message);
     //$dto->setMessage(UTIL_HtmlTag::autoLink($message));
     $dto->setTimestamp($dto->getTimestamp() * 1000);
     exit(json_encode($dto));
 }
Ejemplo n.º 4
0
 public static function processSettingList($settings, $place)
 {
     if ($place != BOL_ComponentService::PLACE_DASHBOARD && !OW::getUser()->isAdmin()) {
         $settings['content'] = UTIL_HtmlTag::stripJs($settings['content']);
         $settings['content'] = UTIL_HtmlTag::stripTags($settings['content'], array('frame'), array(), true, true);
     } else {
         $settings['content'] = UTIL_HtmlTag::sanitize($settings['content']);
     }
     return $settings;
 }
Ejemplo n.º 5
0
 public function process()
 {
     $language = OW::getLanguage();
     $conversationService = MAILBOX_BOL_ConversationService::getInstance();
     $values = $this->getValues();
     $userId = OW::getUser()->getId();
     $actionName = 'send_message';
     $isAuthorized = OW::getUser()->isAuthorized('mailbox', $actionName);
     if (!$isAuthorized) {
         $status = BOL_AuthorizationService::getInstance()->getActionStatus('mailbox', $actionName);
         if ($status['status'] != BOL_AuthorizationService::STATUS_AVAILABLE) {
             return array('result' => false, 'error' => $language->text('mailbox', 'send_message_permission_denied'));
         }
     }
     $checkResult = $conversationService->checkUser($userId, $values['opponentId']);
     if ($checkResult['isSuspended']) {
         return array('result' => false, 'error' => $checkResult['suspendReasonMessage']);
     }
     $values['message'] = UTIL_HtmlTag::stripTags(UTIL_HtmlTag::stripJs($values['message']));
     $event = new OW_Event('mailbox.before_create_conversation', array('senderId' => $userId, 'recipientId' => $values['opponentId'], 'message' => $values['message'], 'subject' => $values['subject']), array('result' => true, 'error' => '', 'message' => $values['message'], 'subject' => $values['subject']));
     OW::getEventManager()->trigger($event);
     $data = $event->getData();
     if (empty($data['result'])) {
         return array('result' => false, 'error' => $data['error']);
     }
     if (!trim(strip_tags($values['subject']))) {
         return array('result' => false, 'error' => $language->text('mailbox', 'subject_is_required'));
     }
     $values['subject'] = $data['subject'];
     $values['message'] = $data['message'];
     $conversation = $conversationService->createConversation($userId, $values['opponentId'], $values['subject'], $values['message']);
     $message = $conversationService->getLastMessage($conversation->id);
     if (!empty($_FILES['attachment']["tmp_name"])) {
         $attachmentService = BOL_AttachmentService::getInstance();
         $uid = $_POST['uid'];
         $maxUploadSize = OW::getConfig()->getValue('base', 'attch_file_max_size_mb');
         $validFileExtensions = json_decode(OW::getConfig()->getValue('base', 'attch_ext_list'), true);
         $dtoArr = $attachmentService->processUploadedFile('mailbox', $_FILES['attachment'], $uid, $validFileExtensions, $maxUploadSize);
         $files = $attachmentService->getFilesByBundleName('mailbox', $uid);
         if (!empty($files)) {
             $conversationService->addMessageAttachments($message->id, $files);
         }
     }
     BOL_AuthorizationService::getInstance()->trackAction('mailbox', $actionName);
     return array('result' => true, 'conversationId' => $message->conversationId);
 }
Ejemplo n.º 6
0
 public function transferCredits($userId, $receiveUser, $creditValue)
 {
     $debitValue = $creditValue * -1;
     $userCreditsService = USERCREDITS_BOL_CreditsService::getInstance();
     $creditsService = CREDITS_BOL_Service::getInstance();
     $sendItem = $this->logAction($creditsService->getSentActionId(), $userId, $debitValue);
     $receiveItem = $this->logAction($creditsService->getReceiveActionId(), $receiveUser, $creditValue);
     $userCreditsService->increaseBalance($receiveUser, $creditValue);
     $userCreditsService->decreaseBalance($userId, $creditValue);
     $sqlInsert = "INSERT INTO " . OW_DB_PREFIX . "credits_sent_log(senderItem, receiverItem, sender, receiver) \n                             VALUES(:sendItem, :receiveItem, :userId, :receiveUser)";
     $qParams = array('sendItem' => $sendItem, 'receiveItem' => $receiveItem, 'userId' => $userId, 'receiveUser' => $receiveUser);
     OW::getDbo()->query($sqlInsert, $qParams);
     $service = BOL_UserService::getInstance();
     $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($userId, $receiveUser));
     $names = $service->getDisplayNamesForList(array($userId, $receiveUser));
     $uUrls = $service->getUserUrlsForList(array($userId, $receiveUser));
     if (OW::getConfig()->getValue('credits', 'enableNotification') == '1') {
         //Send notification to receiver
         $avatar = $avatars[$userId];
         $notificationParams = array('pluginKey' => 'credits', 'action' => 'credits-received', 'entityType' => 'received', 'entityId' => $receiveItem, 'userId' => $receiveUser, 'time' => time());
         $sender = '<a href="' . $uUrls[$userId] . '" target="_blank" >' . $names[$userId] . '</a>';
         $notificationData = array('string' => array('key' => 'credits+notify_credits_received', 'vars' => array('sender' => $sender, 'credits' => $creditValue)), 'avatar' => $avatar, 'url' => $uUrls[$userId]);
         $event = new OW_Event('notifications.add', $notificationParams, $notificationData);
         OW::getEventManager()->trigger($event);
     }
     $subject = OW::getLanguage()->text('credits', 'credits_email_subject', array('requester_name' => $names[$userId], 'credits' => $creditValue));
     $content = OW::getLanguage()->text('credits', 'credits_email_content', array('requester_name' => $names[$userId], 'requester_url' => $uUrls[$userId], 'credits' => $creditValue, 'user_url' => $uUrls[$receiveUser], 'name' => $names[$receiveUser]));
     if (OW::getConfig()->getValue('credits', 'enableEmail') == '1') {
         $tmpUser = $service->findUserById($receiveUser);
         $sitemail = OW::getConfig()->getValue('base', 'site_email');
         $sitename = OW::getConfig()->getValue('base', 'site_name');
         $mail = OW::getMailer()->createMail();
         $mail->addRecipientEmail($tmpUser->getEmail());
         $mail->setSender($sitemail, $sitename);
         $mail->setSenderSuffix(true);
         $mail->setSubject($subject);
         $mail->setHtmlContent($content);
         $mail->setTextContent(UTIL_HtmlTag::stripTags($content));
         OW::getMailer()->addToQueue($mail);
     }
     if (OW::getConfig()->getValue('credits', 'enablePM') == '1') {
         $conversation = MAILBOX_BOL_ConversationService::getInstance()->createConversation($userId, $receiveUser, $subject, $content);
     }
     return true;
 }
Ejemplo n.º 7
0
 /**
  * Validates provided video code, stripping all restricted tags.
  *
  * @param string $code
  * @return string
  */
 public function validateVideoCode($code)
 {
     return UTIL_HtmlTag::stripTags($code, $this->videoParams['tags'], $this->videoParams['attrs']);
 }
Ejemplo n.º 8
0
 public function postMessage($params)
 {
     $conversationService = MAILBOX_BOL_ConversationService::getInstance();
     $language = OW::getLanguage();
     if ($errorMessage = $conversationService->checkPermissions()) {
         return array('error' => $errorMessage);
     }
     $userId = OW::getUser()->getId();
     //        $userSendMessageIntervalOk = $conversationService->checkUserSendMessageInterval($userId);
     //        if (!$userSendMessageIntervalOk)
     //        {
     //            $send_message_interval = (int)OW::getConfig()->getValue('mailbox', 'send_message_interval');
     //            return array('error'=>$language->text('mailbox', 'feedback_send_message_interval_exceed', array('send_message_interval'=>$send_message_interval)));
     //        }
     $conversationId = $params['convId'];
     if (!isset($conversationId)) {
         return array('error' => "Conversation is not defined");
     }
     if (empty($params['text'])) {
         return array('error' => $language->text('mailbox', 'chat_message_empty'));
     }
     if (mb_strlen($params['text']) > self::MAX_MESSAGE_TEXT_LENGTH) {
         return array('error' => $language->text('mailbox', 'message_too_long_error', array('maxLength' => self::MAX_MESSAGE_TEXT_LENGTH)));
     }
     $conversation = $conversationService->getConversation($conversationId);
     if (empty($conversation)) {
         $uidParams = explode('_', $params['uid']);
         if (count($uidParams) == 5 && $uidParams[0] == 'mailbox' && $uidParams[1] == 'dialog') {
             $opponentId = (int) $uidParams[3];
             $conversationId = $conversationService->getChatConversationIdWithUserById($userId, $opponentId);
             if ($conversationId != 0) {
                 $conversation = $conversationService->getConversation($conversationId);
             }
         }
     }
     if (empty($conversation)) {
         $conversation = $conversationService->createChatConversation($userId, $opponentId);
         $conversationId = $conversation->getId();
     }
     $opponentId = $conversation->initiatorId == $userId ? $conversation->interlocutorId : $conversation->initiatorId;
     $checkResult = $conversationService->checkUser($userId, $opponentId);
     MAILBOX_BOL_ConversationService::getInstance()->resetUserLastData($opponentId);
     if ($checkResult['isSuspended']) {
         return array('error' => $checkResult['suspendReasonMessage']);
     }
     $mode = $conversationService->getConversationMode($conversationId);
     $actionName = '';
     switch ($mode) {
         case 'chat':
             $firstMessage = $conversationService->getFirstMessage($conversationId);
             if (empty($firstMessage)) {
                 $actionName = 'send_chat_message';
             } else {
                 $actionName = 'reply_to_chat_message';
             }
             $isAuthorized = OW::getUser()->isAuthorized('mailbox', $actionName);
             if (!$isAuthorized) {
                 $status = BOL_AuthorizationService::getInstance()->getActionStatus('mailbox', $actionName);
                 if ($status['status'] != BOL_AuthorizationService::STATUS_AVAILABLE) {
                     //                        return array('error'=>$language->text('mailbox', $actionName.'_permission_denied'));
                     return array('error' => $status['msg']);
                 }
             }
             $params['text'] = UTIL_HtmlTag::stripTags(UTIL_HtmlTag::stripJs($params['text']));
             $params['text'] = nl2br($params['text']);
             break;
         case 'mail':
             $actionName = 'reply_to_message';
             $isAuthorized = OW::getUser()->isAuthorized('mailbox', $actionName);
             if (!$isAuthorized) {
                 $status = BOL_AuthorizationService::getInstance()->getActionStatus('mailbox', $actionName);
                 if ($status['status'] != BOL_AuthorizationService::STATUS_AVAILABLE) {
                     //                        return array('error'=>$language->text('mailbox', $actionName.'_permission_denied'));
                     return array('error' => $status['msg']);
                 }
             }
             $params['text'] = UTIL_HtmlTag::stripJs($params['text']);
             break;
     }
     $event = new OW_Event('mailbox.before_send_message', array('senderId' => $userId, 'recipientId' => $opponentId, 'conversationId' => $conversation->id, 'message' => $params['text']), array('result' => true, 'error' => '', 'message' => $params['text']));
     OW::getEventManager()->trigger($event);
     $data = $event->getData();
     if (!$data['result']) {
         return $data;
     }
     $text = $data['message'];
     try {
         $message = $conversationService->createMessage($conversation, $userId, $text);
         $files = BOL_AttachmentService::getInstance()->getFilesByBundleName('mailbox', $params['uid']);
         if (!empty($files)) {
             $conversationService->addMessageAttachments($message->id, $files);
         }
         if (!empty($params['embedAttachments'])) {
             $oembedParams = json_decode($params['embedAttachments'], true);
             $oembedParams['message'] = $text;
             $messageParams = array('entityType' => 'mailbox', 'eventName' => 'renderOembed', 'params' => $oembedParams);
             $message->isSystem = true;
             $message->text = json_encode($messageParams);
             $conversationService->saveMessage($message);
         }
     } catch (InvalidArgumentException $e) {
         return array('error' => $e->getMessage());
     }
     if (!empty($actionName)) {
         BOL_AuthorizationService::getInstance()->trackAction('mailbox', $actionName);
     }
     $item = $conversationService->getMessageData($message);
     return array('message' => $item);
 }
Ejemplo n.º 9
0
 public function addClip($clipInfo)
 {
     $clip = new VIDEO_BOL_Clip();
     $clip->title = htmlspecialchars($clipInfo["title"]);
     $description = UTIL_HtmlTag::stripJs($clipInfo["desc"]);
     $description = UTIL_HtmlTag::stripTags($description, array('frame', 'style'), array(), true);
     $description = nl2br($description, true);
     $clip->description = $description;
     $clip->userId = OW::getUser()->getId();
     $clip->thumbUrl = preg_replace("#(http://|https://)#i", "//", $clipInfo["thumbnail"]);
     $clip->code = UTIL_HtmlTag::stripJs($clipInfo["code"]);
     $prov = new VideoProviders($clip->code);
     $privacy = OW::getEventManager()->call('plugin.privacy.get_privacy', array('ownerId' => $clip->userId, 'action' => 'video_view_video'));
     $clip->provider = $prov->detectProvider();
     $clip->addDatetime = time();
     $clip->status = 'approved';
     $clip->privacy = mb_strlen($privacy) ? $privacy : 'everybody';
     $eventParams = array('pluginKey' => 'video', 'action' => 'add_video');
     if (OW::getEventManager()->call('usercredits.check_balance', $eventParams) === true) {
         OW::getEventManager()->call('usercredits.track_action', $eventParams);
     }
     if ($this->clipService->addClip($clip)) {
         if (isset($clipInfo['tags'])) {
             BOL_TagService::getInstance()->updateEntityTags($clip->id, 'video', explode(',', $clipInfo['tags']));
         }
         // Newsfeed
         $event = new OW_Event('feed.action', array('pluginKey' => 'video', 'entityType' => 'video_comments', 'entityId' => $clip->id, 'userId' => $clip->userId));
         OW::getEventManager()->trigger($event);
         return $clip->id;
     }
     return false;
 }
Ejemplo n.º 10
0
 public function edit($params)
 {
     $event = $this->getEventForParams($params);
     $language = OW::getLanguage();
     $modPermissions = OW::getUser()->isAuthorized('eventx');
     $ownerMode = $event->getUserId() == OW::getUser()->getId();
     if (!$ownerMode && !$modPermissions) {
         $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
         return;
     }
     $form = new EventAddForm('event_edit');
     $form->getElement('title')->setValue($event->getTitle());
     $form->getElement('desc')->setValue($event->getDescription());
     $form->getElement('location')->setValue($event->getLocation());
     $form->getElement('who_can_view')->setValue($event->getWhoCanView());
     $form->getElement('who_can_invite')->setValue($event->getWhoCanInvite());
     $form->getElement('who_can_invite')->setValue($event->getWhoCanInvite());
     $form->getElement('max_invites')->setValue($event->getMaxInvites());
     if (OW::getConfig()->getValue('eventx', 'enableCategoryList') == '1') {
         $catIds = $this->eventService->getItemCategoryId($event->id);
         $eventCategories = array();
         foreach ($catIds as $categoryObj) {
             $eventCategories[] = $categoryObj->categoryId;
         }
         if (OW::getConfig()->getValue('eventx', 'enableMultiCategories') == 1) {
             $form->getElement('event_category')->setValue($eventCategories);
         } else {
             $form->getElement('event_category')->setValue($eventCategories[0]);
         }
     }
     if (OW::getConfig()->getValue('eventx', 'enableTagsList') == '1') {
         $entityTags = BOL_TagService::getInstance()->findEntityTags($event->getId(), 'eventx');
         if ($entityTags) {
             $tags = array();
             foreach ($entityTags as $entityTag) {
                 $tags[] = $entityTag->getLabel();
             }
             $form->getElement('tags')->setValue($tags);
         }
     }
     $startTimeArray = array('hour' => date('G', $event->getStartTimeStamp()), 'minute' => date('i', $event->getStartTimeStamp()));
     $form->getElement('start_time')->setValue($startTimeArray);
     $startDate = date('Y', $event->getStartTimeStamp()) . '/' . date('n', $event->getStartTimeStamp()) . '/' . date('j', $event->getStartTimeStamp());
     $form->getElement('start_date')->setValue($startDate);
     if ($event->getEndTimeStamp() !== null) {
         $endTimeArray = array('hour' => date('G', $event->getEndTimeStamp()), 'minute' => date('i', $event->getEndTimeStamp()));
         $form->getElement('end_time')->setValue($endTimeArray);
         $endTimeStamp = $event->getEndTimeStamp();
         if ($event->getEndTimeDisable()) {
             $endTimeStamp = strtotime("-1 day", $endTimeStamp);
         }
         $endDate = date('Y', $endTimeStamp) . '/' . date('n', $endTimeStamp) . '/' . date('j', $endTimeStamp);
         $form->getElement('end_date')->setValue($endDate);
     }
     if ($event->getStartTimeDisable()) {
         $form->getElement('start_time')->setValue('all_day');
     }
     if ($event->getEndTimeDisable()) {
         $form->getElement('end_time')->setValue('all_day');
     }
     $form->getSubmitElement('submit')->setValue(OW::getLanguage()->text('eventx', 'edit_form_submit_label'));
     $checkboxId = UTIL_HtmlTag::generateAutoId('chk');
     $tdId = UTIL_HtmlTag::generateAutoId('td');
     $this->assign('tdId', $tdId);
     $this->assign('chId', $checkboxId);
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin("eventx")->getStaticJsUrl() . 'eventx.js');
     $enableMapSuggestion = OW::getConfig()->getValue('eventx', 'enableMapSuggestion');
     if ($enableMapSuggestion == '1') {
         OW::getDocument()->addScript("http://maps.googleapis.com/maps/api/js?sensor=false&amp;libraries=places");
         OW::getDocument()->addScript(OW::getPluginManager()->getPlugin("eventx")->getStaticJsUrl() . 'jquery.geocomplete.min.js');
     }
     $this->assign('enableMapSuggestion', $enableMapSuggestion);
     OW::getDocument()->addOnloadScript("new eventAddForm(" . json_encode(array('checkbox_id' => $checkboxId, 'end_date_id' => $form->getElement('end_date')->getId(), 'tdId' => $tdId)) . ")");
     if ($event->getImage()) {
         $this->assign('imgsrc', $this->eventService->generateImageUrl($event->getImage(), true));
     }
     $endDateFlag = $event->getEndDateFlag();
     if (OW::getRequest()->isPost()) {
         $endDateFlag = !empty($_POST['endDateFlag']);
         if ($form->isValid($_POST)) {
             $data = $form->getValues();
             $serviceEvent = new OW_Event(EVENTX_BOL_EventService::EVENTX_BEFORE_EVENTX_EDIT, array('eventId' => $event->id), $data);
             OW::getEventManager()->trigger($serviceEvent);
             $data = $serviceEvent->getData();
             $dateArray = explode('/', $data['start_date']);
             $startStamp = mktime(0, 0, 0, $dateArray[1], $dateArray[2], $dateArray[0]);
             if ($data['start_time'] != 'all_day') {
                 $startStamp = mktime($data['start_time']['hour'], $data['start_time']['minute'], 0, $dateArray[1], $dateArray[2], $dateArray[0]);
             }
             if (!empty($_POST['endDateFlag']) && !empty($data['end_date'])) {
                 $dateArray = explode('/', $data['end_date']);
                 $endStamp = mktime(0, 0, 0, $dateArray[1], $dateArray[2], $dateArray[0]);
                 $endStamp = strtotime("+1 day", $endStamp);
                 if ($data['end_time'] != 'all_day') {
                     $hour = 0;
                     $min = 0;
                     if ($data['end_time'] != 'all_day') {
                         $hour = $data['end_time']['hour'];
                         $min = $data['end_time']['minute'];
                     }
                     $dateArray = explode('/', $data['end_date']);
                     $endStamp = mktime($hour, $min, 0, $dateArray[1], $dateArray[2], $dateArray[0]);
                 }
             }
             $event->setStartTimeStamp($startStamp);
             if (empty($endStamp)) {
                 $endStamp = strtotime("+1 day", $startStamp);
                 $endStamp = mktime(0, 0, 0, date('n', $endStamp), date('j', $endStamp), date('Y', $endStamp));
             }
             if ($startStamp > $endStamp) {
                 OW::getFeedback()->error($language->text('eventx', 'add_form_invalid_end_date_error_message'));
                 $this->redirect();
             } else {
                 $event->setEndTimeStamp($endStamp);
                 if (!empty($_FILES['image']['name'])) {
                     if ((int) $_FILES['image']['error'] !== 0 || !is_uploaded_file($_FILES['image']['tmp_name']) || !UTIL_File::validateImage($_FILES['image']['name'])) {
                         OW::getFeedback()->error($language->text('base', 'not_valid_image'));
                         $this->redirect();
                     } else {
                         $event->setImage(uniqid());
                         $this->eventService->saveEventImage($_FILES['image']['tmp_name'], $event->getImage());
                     }
                 }
                 $event->setTitle(htmlspecialchars($data['title']));
                 $event->setLocation(UTIL_HtmlTag::autoLink(strip_tags($data['location'])));
                 $event->setWhoCanView((int) $data['who_can_view']);
                 $event->setWhoCanInvite((int) $data['who_can_invite']);
                 $event->setDescription($data['desc']);
                 $event->setEndDateFlag(!empty($_POST['endDateFlag']));
                 $event->setStartTimeDisable($data['start_time'] == 'all_day');
                 $event->setEndTimeDisable($data['end_time'] == 'all_day');
                 $event->setMaxInvites($data['max_invites']);
                 $this->eventService->saveEvent($event);
                 $eventCategory = isset($data['event_category']) ? $data['event_category'] : 1;
                 $this->eventService->setItemCategories($event->getId(), $eventCategory);
                 if (isset($data['tags'])) {
                     $tags = array();
                     $tags = $data['tags'];
                     foreach ($tags as $id => $tag) {
                         $tags[$id] = UTIL_HtmlTag::stripTags($tag);
                     }
                     BOL_TagService::getInstance()->updateEntityTags($event->id, 'eventx', $tags);
                 }
                 $e = new OW_Event(EVENTX_BOL_EventService::EVENTX_AFTER_EVENTX_EDIT, array('eventId' => $event->id));
                 OW::getEventManager()->trigger($e);
                 OW::getFeedback()->info($language->text('eventx', 'edit_form_success_message'));
                 $this->redirect(OW::getRouter()->urlForRoute('eventx.view', array('eventId' => $event->getId())));
             }
         }
     }
     if (!$endDateFlag) {
         $form->getElement('end_date')->addAttribute('disabled', 'disabled');
         $form->getElement('end_date')->addAttribute('style', 'display:none;');
         $form->getElement('end_time')->addAttribute('disabled', 'disabled');
         $form->getElement('end_time')->addAttribute('style', 'display:none;');
     }
     $this->assign('endDateFlag', $endDateFlag);
     $this->setPageHeading($language->text('eventx', 'edit_page_heading'));
     $this->setPageTitle($language->text('eventx', 'edit_page_title'));
     $this->addForm($form);
 }
Ejemplo n.º 11
0
 /**
  * Adds video clip
  *
  * @return boolean
  */
 public function process()
 {
     $values = $this->getValues();
     $clipService = VIDEO_BOL_ClipService::getInstance();
     $clip = new VIDEO_BOL_Clip();
     $clip->title = htmlspecialchars($values['title']);
     $description = UTIL_HtmlTag::stripJs($values['description']);
     $description = UTIL_HtmlTag::stripTags($description, array('frame', 'style'), array(), true);
     $clip->description = $description;
     $clip->userId = OW::getUser()->getId();
     $clip->code = UTIL_HtmlTag::stripJs($values['code']);
     $prov = new VideoProviders($clip->code);
     $privacy = OW::getEventManager()->call('plugin.privacy.get_privacy', array('ownerId' => $clip->userId, 'action' => 'video_view_video'));
     $clip->provider = $prov->detectProvider();
     $clip->addDatetime = time();
     $clip->status = 'approved';
     $clip->privacy = mb_strlen($privacy) ? $privacy : 'everybody';
     $thumbUrl = $prov->getProviderThumbUrl($clip->provider);
     if ($thumbUrl != VideoProviders::PROVIDER_UNDEFINED) {
         $clip->thumbUrl = $thumbUrl;
     }
     $clip->thumbCheckStamp = time();
     $eventParams = array('pluginKey' => 'video', 'action' => 'add_video');
     if (OW::getEventManager()->call('usercredits.check_balance', $eventParams) === true) {
         OW::getEventManager()->call('usercredits.track_action', $eventParams);
     }
     if ($clipService->addClip($clip)) {
         BOL_TagService::getInstance()->updateEntityTags($clip->id, 'video', $values['tags']);
         // Newsfeed
         $event = new OW_Event('feed.action', array('pluginKey' => 'video', 'entityType' => 'video_comments', 'entityId' => $clip->id, 'userId' => $clip->userId));
         OW::getEventManager()->trigger($event);
         return array('result' => true, 'id' => $clip->id);
     }
     return false;
 }
Ejemplo n.º 12
0
 /**
  * Updates video clip
  *
  * @return boolean
  */
 public function process()
 {
     $values = $this->getValues();
     $clipService = VIDEO_BOL_ClipService::getInstance();
     if ($values['id']) {
         $clip = $clipService->findClipById($values['id']);
         if ($clip) {
             $clip->title = htmlspecialchars($values['title']);
             $description = UTIL_HtmlTag::stripJs($values['description']);
             $description = UTIL_HtmlTag::stripTags($description, array('frame', 'style'), array(), true);
             $clip->description = $description;
             if ($clip->code != $values['code']) {
                 $prov = new VideoProviders($values['code']);
                 $clip->provider = $prov->detectProvider();
                 $thumbUrl = $prov->getProviderThumbUrl($clip->provider);
                 if ($thumbUrl != VideoProviders::PROVIDER_UNDEFINED) {
                     $clip->thumbUrl = $thumbUrl;
                 }
                 $clip->thumbCheckStamp = time();
             }
             $clip->code = UTIL_HtmlTag::stripJs($values['code']);
             if ($clipService->updateClip($clip)) {
                 BOL_TagService::getInstance()->updateEntityTags($clip->id, 'video', $values['tags']);
                 return array('result' => true, 'id' => $clip->id);
             }
         }
     } else {
         return array('result' => false, 'id' => null);
     }
     return false;
 }
Ejemplo n.º 13
0
 public function process($ctrl)
 {
     OW::getCacheManager()->clean(array(PostDao::CACHE_TAG_POST_COUNT));
     $service = PostService::getInstance();
     /* @var $postDao PostService */
     $data = $this->getValues();
     $data['title'] = UTIL_HtmlTag::stripJs($data['title']);
     $postIsNotPublished = $this->post->getStatus() == 2;
     $text = UTIL_HtmlTag::sanitize($data['post']);
     /* @var $post Post */
     $this->post->setTitle($data['title']);
     $this->post->setPost($text);
     $this->post->setIsDraft($_POST['command'] == 'draft');
     $isCreate = empty($this->post->id);
     if ($isCreate) {
         $this->post->setTimestamp(time());
         //Required to make #698 and #822 work together
         if ($_POST['command'] == 'draft') {
             $this->post->setIsDraft(2);
         }
         BOL_AuthorizationService::getInstance()->trackAction('blogs', 'add_blog');
     } else {
         //If post is not new and saved as draft, remove their item from newsfeed
         if ($_POST['command'] == 'draft') {
             OW::getEventManager()->trigger(new OW_Event('feed.delete_item', array('entityType' => 'blog-post', 'entityId' => $this->post->id)));
         } else {
             if ($postIsNotPublished) {
                 // Update timestamp if post was published for the first time
                 $this->post->setTimestamp(time());
             }
         }
     }
     $service->save($this->post);
     $tags = array();
     if (intval($this->post->getId()) > 0) {
         $tags = $data['tf'];
         foreach ($tags as $id => $tag) {
             $tags[$id] = UTIL_HtmlTag::stripTags($tag);
         }
     }
     $tagService = BOL_TagService::getInstance();
     $tagService->updateEntityTags($this->post->getId(), 'blog-post', $tags);
     if ($this->post->isDraft()) {
         $tagService->setEntityStatus('blog-post', $this->post->getId(), false);
         if ($isCreate) {
             OW::getFeedback()->info(OW::getLanguage()->text('blogs', 'create_draft_success_msg'));
         } else {
             OW::getFeedback()->info(OW::getLanguage()->text('blogs', 'edit_draft_success_msg'));
         }
     } else {
         $tagService->setEntityStatus('blog-post', $this->post->getId(), true);
         //Newsfeed
         $event = new OW_Event('feed.action', array('pluginKey' => 'blogs', 'entityType' => 'blog-post', 'entityId' => $this->post->getId(), 'userId' => $this->post->getAuthorId()));
         OW::getEventManager()->trigger($event);
         if ($isCreate) {
             OW::getFeedback()->info(OW::getLanguage()->text('blogs', 'create_success_msg'));
             OW::getEventManager()->trigger(new OW_Event(PostService::EVENT_AFTER_ADD, array('postId' => $this->post->getId())));
         } else {
             OW::getFeedback()->info(OW::getLanguage()->text('blogs', 'edit_success_msg'));
             OW::getEventManager()->trigger(new OW_Event(PostService::EVENT_AFTER_EDIT, array('postId' => $this->post->getId())));
         }
         $ctrl->redirect(OW::getRouter()->urlForRoute('post', array('id' => $this->post->getId())));
     }
 }
Ejemplo n.º 14
0
 public function process()
 {
     $values = $this->getValues();
     $videoService = IVIDEO_BOL_Service::getInstance();
     $language = OW::getLanguage();
     if ($values['id']) {
         $video = $videoService->findVideoById($values['id']);
         if ($video) {
             $video->name = htmlspecialchars($values['name']);
             $description = UTIL_HtmlTag::stripJs($values['description']);
             $description = UTIL_HtmlTag::stripTags($description, array('frame', 'style'), array(), true);
             $video->description = $description;
             if ($videoService->updateVideo($video)) {
                 BOL_TagService::getInstance()->updateEntityTags($video->id, 'ivideo-video', TagsField::getTags($values['tags']));
                 return array('result' => true, 'id' => $video->id);
             }
         }
     } else {
         return array('result' => false, 'id' => $video->id);
     }
     return false;
 }
Ejemplo n.º 15
0
 /**
  * Updates vwls clip
  *
  * @return boolean
  */
 public function process()
 {
     $values = $this->getValues();
     $clipService = VWLS_BOL_ClipService::getInstance();
     $language = OW::getLanguage();
     if ($values['id']) {
         $clip = $clipService->findClipById($values['id']);
         if ($clip) {
             $clip->title = htmlspecialchars($values['room_name']);
             $clip->roomLimit = $values['room_limit'];
             $clip->user_list = $values['user_list'];
             $clip->moderator_list = $values['moderator_list'];
             $clip->welcome = htmlspecialchars($values['welcome']);
             $cam = $values['resolution'];
             $camArr = explode("x", $cam);
             $clip->camWidth = $camArr[0];
             $clip->camHeight = $camArr[1];
             $clip->camFPS = $values['camera_fps'];
             $clip->micRate = $values['microphone_rate'];
             $clip->soundQuality = $values['soundQuality'];
             $clip->camBandwidth = $values['bandwidth'];
             $clip->floodProtection = $values['flood_protection'];
             $clip->labelColor = $values['label_color'];
             $clip->layoutCode = $values['layout_code'];
             $clip->welcome2 = htmlspecialchars($values['welcome2']);
             $clip->offlineMessage = htmlspecialchars($values['offline_message']);
             $clip->floodProtection2 = $values['flood_protection2'];
             $clip->layoutCode2 = htmlspecialchars($values['layout_code2']);
             $clip->filterRegex = $values['filter_regex'];
             $clip->filterReplace = $values['filter_replace'];
             $permission = $values['show_camera_settings'] . "|";
             $permission .= $values['advanced_camera_settings'] . "|";
             $permission .= $values['configure_source'] . "|";
             $permission .= $values['only_video'] . "|";
             $permission .= $values['no_video'] . "|";
             $permission .= $values['no_embeds'] . "|";
             $permission .= $values['show_timer'] . "|";
             $permission .= $values['write_text'] . "|";
             $permission .= $values['private_textchat'] . "|";
             $permission .= $values['fill_window'] . "|";
             $permission .= $values['write_text2'] . "|";
             $permission .= $values['enable_video'] . "|";
             $permission .= $values['enable_chat'] . "|";
             $permission .= $values['enable_users'] . "|";
             $permission .= $values['fill_window2'] . "|";
             $permission .= $values['verbose_level'] . "|";
             $clip->permission = $permission;
             $clip->online = "no";
             $clip->onlineCount = 0;
             $clip->onlineUser = "******";
             $clip->onlineUsers = "0";
             $description = UTIL_HtmlTag::stripJs($values['description']);
             $description = UTIL_HtmlTag::stripTags($description, array('frame', 'style'), array(), true);
             $clip->description = $description;
             $clip->modifDatetime = time();
             if ($clipService->updateClip($clip)) {
                 BOL_TagService::getInstance()->updateEntityTags($clip->id, 'vwls', TagsField::getTags($values['tags']));
                 return array('result' => true, 'id' => $clip->id);
             }
         }
     } else {
         return array('result' => false, 'id' => $clip->id);
     }
     return false;
 }
Ejemplo n.º 16
0
 /**
  * Updates vwvr clip
  *
  * @return boolean
  */
 public function process()
 {
     $values = $this->getValues();
     $clipService = VWVR_BOL_ClipService::getInstance();
     $language = OW::getLanguage();
     if ($values['id']) {
         $clip = $clipService->findClipById($values['id']);
         if ($clip) {
             $clip->room_name = htmlspecialchars($values['room_name']);
             $description = UTIL_HtmlTag::stripJs($values['description']);
             $description = UTIL_HtmlTag::stripTags($description, array('frame', 'style'), array(), true);
             $clip->description = $description;
             if ($clipService->updateClip($clip)) {
                 BOL_TagService::getInstance()->updateEntityTags($clip->id, 'vwvr', TagsField::getTags($values['tags']));
                 return array('result' => true, 'id' => $clip->id);
             }
         }
     } else {
         return array('result' => false, 'id' => $clip->id);
     }
     return false;
 }
Ejemplo n.º 17
0
 /**
  * Adds vwvc clip
  *
  * @return boolean
  */
 public function process()
 {
     $values = $this->getValues();
     $clipService = VWVC_BOL_ClipService::getInstance();
     $clip = new VWVC_BOL_Clip();
     $clip->title = htmlspecialchars($values['room_name']);
     $clip->description = htmlspecialchars($values['description']);
     $clip->welcome = htmlspecialchars($values['welcome']);
     $cam = $values['resolution'];
     $camArr = explode("x", $cam);
     $clip->camWidth = $camArr[0];
     $clip->camHeight = $camArr[1];
     $clip->camFPS = $values['camera_fps'];
     $clip->micRate = $values['microphone_rate'];
     $clip->soundQuality = $values['soundQuality'];
     $clip->camBandwidth = $values['bandwidth'];
     $clip->background_url = $values['background_url'];
     $clip->layoutCode = htmlspecialchars($values['layout_code']);
     $permission = $values['fill_window'] . "|";
     $permission .= $values['show_camera_settings'] . "|";
     $permission .= $values['advanced_camera_settings'] . "|";
     $permission .= $values['configure_source'] . "|";
     $permission .= $values['disable_video'] . "|";
     $permission .= $values['disable_sound'] . "|";
     $permission .= $values['panel_rooms'] . "|";
     $permission .= $values['panel_users'] . "|";
     $permission .= $values['panel_files'] . "|";
     $permission .= $values['file_upload'] . "|";
     $permission .= $values['file_delete'] . "|";
     $permission .= $values['tutorial'] . "|";
     $permission .= $values['auto_view_cameras'] . "|";
     $permission .= $values['show_timer'] . "|";
     $permission .= $values['write_text'] . "|";
     $permission .= $values['regular_watch'] . "|";
     $permission .= $values['new_watch'] . "|";
     $permission .= $values['private_textchat'] . "|";
     $permission .= $values['administrator'] . "|";
     $permission .= $values['verbose_level'] . "|";
     $clip->permission = $permission;
     $clip->floodProtection = $values['flood_protection'];
     $clip->filterRegex = $values['filter_regex'];
     $clip->filterReplace = $values['filter_replace'];
     $clip->user_list = $values['user_list'];
     $clip->moderator_list = $values['moderator_list'];
     $clip->online = "no";
     $clip->onlineCount = 0;
     $clip->onlineUser = "******";
     $clip->onlineUsers = "0";
     $description = UTIL_HtmlTag::stripJs($values['description']);
     $description = UTIL_HtmlTag::stripTags($description, array('frame', 'style'), array(), true);
     $clip->description = $description;
     $clip->userId = OW::getUser()->getId();
     //        $clip->code = UTIL_HtmlTag::stripJs($values['code']);
     //        $prov = new VideoProviders($clip->code);
     $privacy = OW::getEventManager()->call('plugin.privacy.get_privacy', array('ownerId' => $clip->userId, 'action' => 'videoconference_view_video'));
     //        $clip->provider = $prov->detectProvider();
     $clip->addDatetime = time();
     $clip->modifDatetime = time();
     $config = OW::getConfig();
     $status = $config->getValue('vwvc', 'status');
     $clip->status = $status;
     $clip->privacy = mb_strlen($privacy) ? $privacy : 'everybody';
     $eventParams = array('pluginKey' => 'vwvc', 'action' => 'add_vwvc');
     if (OW::getEventManager()->call('usercredits.check_balance', $eventParams) === true) {
         OW::getEventManager()->call('usercredits.track_action', $eventParams);
     }
     if ($clipService->addClip($clip)) {
         BOL_TagService::getInstance()->updateEntityTags($clip->id, 'vwvc', TagsField::getTags($values['tags']));
         // Newsfeed
         $event = new OW_Event('feed.action', array('pluginKey' => 'vwvc', 'entityType' => 'vwvc_comments', 'entityId' => $clip->id, 'userId' => $clip->userId));
         OW::getEventManager()->trigger($event);
         return array('result' => true, 'id' => $clip->id);
     }
     return false;
 }
Ejemplo n.º 18
0
    /**
     * Controller's default action
     *
     * @param array $params
     * @throws AuthorizationException
     * @throws AuthenticateException
     */
    public function index(array $params = null)
    {
        $groupId = isset($params['groupId']) && (int) $params['groupId'] ? (int) $params['groupId'] : 0;
        $forumService = FORUM_BOL_ForumService::getInstance();
        $forumGroup = $forumService->getGroupInfo($groupId);
        if ($forumGroup) {
            $forumSection = $forumService->findSectionById($forumGroup->sectionId);
            $isHidden = $forumSection->isHidden;
        } else {
            $isHidden = false;
        }
        if (!OW::getUser()->isAuthenticated()) {
            throw new AuthenticateException();
        }
        $userId = OW::getUser()->getId();
        $this->assign('authMsg', null);
        if ($isHidden && isset($forumSection)) {
            $eventParams = array('entity' => $forumSection->entity, 'entityId' => $forumGroup->entityId, 'action' => 'add_topic');
            $event = new OW_Event('forum.check_permissions', $eventParams);
            OW::getEventManager()->trigger($event);
            if (!$event->getData()) {
                throw new AuthorizationException();
            }
            if (!OW::getUser()->isAuthorized($forumSection->entity, 'add_topic')) {
                $status = BOL_AuthorizationService::getInstance()->getActionStatus($forumSection->entity, 'add_topic');
                throw new AuthorizationException($status['msg']);
            }
            $event = new OW_Event('forum.find_forum_caption', array('entity' => $forumSection->entity, 'entityId' => $forumGroup->entityId));
            OW::getEventManager()->trigger($event);
            $eventData = $event->getData();
            /** @var OW_Component $componentForumCaption */
            $componentForumCaption = $eventData['component'];
            if (!empty($componentForumCaption)) {
                $this->assign('componentForumCaption', $componentForumCaption->render());
            } else {
                $componentForumCaption = false;
                $this->assign('componentForumCaption', $componentForumCaption);
            }
            $bcItems = array(array('href' => OW::getRouter()->urlForRoute('group-default', array('groupId' => $forumGroup->getId())), 'label' => OW::getLanguage()->text($forumSection->entity, 'view_all_topics')));
            $breadCrumbCmp = new BASE_CMP_Breadcrumb($bcItems);
            $this->addComponent('breadcrumb', $breadCrumbCmp);
            OW::getNavigation()->deactivateMenuItems(OW_Navigation::MAIN);
            OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, $forumSection->entity, $eventData['key']);
            $groupSelect = array(array('label' => $forumGroup->name, 'value' => $forumGroup->getId(), 'disabled' => false));
            OW::getDocument()->setHeading(OW::getLanguage()->text($forumSection->entity, 'create_new_topic', array('group' => $forumGroup->name)));
        } else {
            $canEdit = OW::getUser()->isAuthorized('forum', 'edit');
            if (!$userId) {
                throw new AuthorizationException();
            } else {
                if (!$canEdit) {
                    $status = BOL_AuthorizationService::getInstance()->getActionStatus('forum', 'edit');
                    throw new AuthorizationException($status['msg']);
                }
            }
            if (!OW::getRequest()->isAjax()) {
                OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'forum', 'forum');
            }
            $groupSelect = $forumService->getGroupSelectList(0, false, $userId);
            OW::getDocument()->setHeading(OW::getLanguage()->text('forum', 'create_new_topic'));
        }
        OW::getDocument()->setDescription(OW::getLanguage()->text('forum', 'meta_description_add_topic'));
        OW::getDocument()->setTitle(OW::getLanguage()->text('forum', 'meta_title_add_topic'));
        OW::getDocument()->setHeadingIconClass('ow_ic_write');
        $this->assign('isHidden', $isHidden);
        $uid = uniqid();
        $form = $this->generateForm($groupSelect, $groupId, $isHidden, $uid);
        OW::getDocument()->addStyleDeclaration('
			.disabled_option {
				color: #9F9F9F;
    		}
		');
        $enableAttachments = OW::getConfig()->getValue('forum', 'enable_attachments');
        if ($enableAttachments) {
            $attachmentCmp = new BASE_CLASS_FileAttachment('forum', $uid);
            $this->addComponent('attachments', $attachmentCmp);
        }
        $this->assign('enableAttachments', $enableAttachments);
        if (OW::getRequest()->isPost() && $form->isValid($_POST)) {
            $data = $form->getValues();
            if ($data['group']) {
                $topicDto = new FORUM_BOL_Topic();
                $topicDto->userId = $userId;
                $topicDto->groupId = $data['group'];
                $topicDto->title = strip_tags($data['title']);
                $forumService->addTopic($topicDto);
                $postDto = new FORUM_BOL_Post();
                $postDto->topicId = $topicDto->id;
                $postDto->userId = $userId;
                $postDto->text = UTIL_HtmlTag::stripJs(UTIL_HtmlTag::stripTags($data['text'], array('form', 'input', 'button'), null, true));
                $postDto->createStamp = time();
                $forumService->saveOrUpdatePost($postDto);
                $topicDto->lastPostId = $postDto->getId();
                $forumService->saveOrUpdateTopic($topicDto);
                // subscribe author to new posts
                if ($data['subscribe']) {
                    $subService = FORUM_BOL_SubscriptionService::getInstance();
                    $subs = new FORUM_BOL_Subscription();
                    $subs->userId = $userId;
                    $subs->topicId = $topicDto->id;
                    $subService->addSubscription($subs);
                }
                if ($enableAttachments) {
                    $filesArray = BOL_AttachmentService::getInstance()->getFilesByBundleName('forum', $data['attachmentUid']);
                    if ($filesArray) {
                        $attachmentService = FORUM_BOL_PostAttachmentService::getInstance();
                        $skipped = 0;
                        foreach ($filesArray as $file) {
                            $attachmentDto = new FORUM_BOL_PostAttachment();
                            $attachmentDto->postId = $postDto->id;
                            $attachmentDto->fileName = $file['dto']->origFileName;
                            $attachmentDto->fileNameClean = $file['dto']->fileName;
                            $attachmentDto->fileSize = $file['dto']->size * 1024;
                            $attachmentDto->hash = uniqid();
                            $added = $attachmentService->addAttachment($attachmentDto, $file['path']);
                            if (!$added) {
                                $skipped++;
                            }
                        }
                        BOL_AttachmentService::getInstance()->deleteAttachmentByBundle('forum', $data['attachmentUid']);
                        if ($skipped) {
                            OW::getFeedback()->warning(OW::getLanguage()->text('forum', 'not_all_attachments_added'));
                        }
                    }
                }
                $topicUrl = OW::getRouter()->urlForRoute('topic-default', array('topicId' => $topicDto->id));
                //Newsfeed
                $params = array('pluginKey' => 'forum', 'entityType' => 'forum-topic', 'entityId' => $topicDto->id, 'userId' => $topicDto->userId);
                $event = new OW_Event('feed.action', $params);
                OW::getEventManager()->trigger($event);
                if ($isHidden && isset($forumSection)) {
                    BOL_AuthorizationService::getInstance()->trackAction($forumSection->entity, 'add_topic');
                    $params = array('topicId' => $topicDto->id, 'entity' => $forumSection->entity, 'entityId' => $forumGroup->entityId, 'userId' => $topicDto->userId, 'topicUrl' => $topicUrl, 'topicTitle' => $topicDto->title, 'postText' => $postDto->text);
                    $event = new OW_Event('forum.topic_add', $params);
                    OW::getEventManager()->trigger($event);
                } else {
                    BOL_AuthorizationService::getInstance()->trackAction('forum', 'edit');
                }
                OW::getEventManager()->trigger(new OW_Event(FORUM_BOL_ForumService::EVENT_AFTER_TOPIC_ADD, array('topicId' => $topicDto->id)));
                $this->redirect($topicUrl);
            } else {
                $form->getElement('group')->addError(OW::getLanguage()->text('forum', 'select_group_error'));
            }
        }
    }
Ejemplo n.º 19
0
 public function addClip(OW_Event $e)
 {
     $params = $e->getParams();
     if (empty($params['userId']) || empty($params['title']) || empty($params['code'])) {
         $e->setData(array('result' => false));
     } else {
         $clipService = VIDEO_BOL_ClipService::getInstance();
         $clip = new VIDEO_BOL_Clip();
         $clip->title = htmlspecialchars($params['title']);
         if (!empty($params['description'])) {
             $clip->description = UTIL_HtmlTag::stripJs($params['description']);
             $clip->description = UTIL_HtmlTag::stripTags($clip->description, array('frame', 'style'), array(), true);
         }
         $clip->userId = $params['userId'];
         $privacy = OW::getEventManager()->call('plugin.privacy.get_privacy', array('ownerId' => $clip->userId, 'action' => 'video_view_video'));
         $clip->privacy = mb_strlen($privacy) ? $privacy : 'everybody';
         $prov = new VideoProviders($params['code']);
         $clip->provider = $prov->detectProvider();
         $clip->addDatetime = time();
         $clip->status = 'approved';
         $thumbUrl = $prov->getProviderThumbUrl($clip->provider);
         if ($thumbUrl != VideoProviders::PROVIDER_UNDEFINED) {
             $clip->thumbUrl = $thumbUrl;
         }
         $clip->thumbCheckStamp = time();
         $clip->code = $clipService->validateClipCode($params['code'], $clip->provider);
         if ($clipService->addClip($clip)) {
             BOL_AuthorizationService::getInstance()->trackAction('video', 'add');
             if (!empty($params['tags'])) {
                 BOL_TagService::getInstance()->updateEntityTags($clip->id, 'video', $params['tags']);
             }
             // Newsfeed
             $event = new OW_Event('feed.action', array('pluginKey' => 'video', 'entityType' => VIDEO_BOL_ClipService::ENTITY_TYPE, 'entityId' => $clip->id, 'userId' => $clip->userId));
             OW::getEventManager()->trigger($event);
             OW::getEventManager()->trigger(new OW_Event(VIDEO_BOL_ClipService::EVENT_AFTER_ADD, array('clipId' => $clip->id)));
             $status = $clipService->findClipById($clip->id)->status;
             $e->setData(array('result' => true, 'id' => $clip->id, "status" => $status));
         }
     }
 }
Ejemplo n.º 20
0
 public function process()
 {
     OW::getCacheManager()->clean(array(LinkDao::CACHE_TAG_LINK_COUNT));
     $service = LinkService::getInstance();
     $data = $this->getValues();
     $data['title'] = UTIL_HtmlTag::stripJs($data['title']);
     $url = mb_ereg_match('^http(s)?:\\/\\/', $data['url']) ? $data['url'] : 'http://' . $data['url'];
     $this->link->setTimestamp(time())->setUrl($url)->setDescription($data['description'])->setTitle(UTIL_HtmlTag::stripTags($data['title'], $service->getAllowedHtmlTags(), array('*')));
     $tags = array();
     $isNew = empty($this->link->id);
     $service->save($this->link);
     if (intval($this->link->getId()) > 0) {
         $tags = $data['tags'];
     }
     $tagService = BOL_TagService::getInstance();
     $tagService->updateEntityTags($this->link->getId(), 'link', $tags);
     if (!$isNew) {
         $event = new OW_Event(LinkService::EVENT_EDIT, array('id' => $this->link->getId()));
         OW::getEventManager()->trigger($event);
         return;
     }
     $eventParams = array('pluginKey' => 'links', 'action' => 'add_link');
     if (OW::getEventManager()->call('usercredits.check_balance', $eventParams) === true) {
         OW::getEventManager()->call('usercredits.track_action', $eventParams);
     }
     //Newsfeed
     $event = new OW_Event('feed.action', array('pluginKey' => 'links', 'entityType' => 'link', 'entityId' => $this->link->getId(), 'userId' => $this->link->getUserId()));
     OW::getEventManager()->trigger($event);
 }
Ejemplo n.º 21
0
 /**
  * Updates vwvc clip
  *
  * @return boolean
  */
 public function process()
 {
     $values = $this->getValues();
     $clipService = VWVC_BOL_ClipService::getInstance();
     $language = OW::getLanguage();
     if ($values['id']) {
         $clip = $clipService->findClipById($values['id']);
         if ($clip) {
             $clip->title = htmlspecialchars($values['room_name']);
             $clip->description = htmlspecialchars($values['description']);
             $clip->welcome = htmlspecialchars($values['welcome']);
             $cam = $values['resolution'];
             $camArr = explode("x", $cam);
             $clip->camWidth = $camArr[0];
             $clip->camHeight = $camArr[1];
             $clip->camFPS = $values['camera_fps'];
             $clip->micRate = $values['microphone_rate'];
             $clip->soundQuality = $values['soundQuality'];
             $clip->camBandwidth = $values['bandwidth'];
             $clip->background_url = $values['background_url'];
             $clip->layoutCode = htmlspecialchars($values['layout_code']);
             $permission = $values['fill_window'] . "|";
             $permission .= $values['show_camera_settings'] . "|";
             $permission .= $values['advanced_camera_settings'] . "|";
             $permission .= $values['configure_source'] . "|";
             $permission .= $values['disable_video'] . "|";
             $permission .= $values['disable_sound'] . "|";
             $permission .= $values['panel_rooms'] . "|";
             $permission .= $values['panel_users'] . "|";
             $permission .= $values['panel_files'] . "|";
             $permission .= $values['file_upload'] . "|";
             $permission .= $values['file_delete'] . "|";
             $permission .= $values['tutorial'] . "|";
             $permission .= $values['auto_view_cameras'] . "|";
             $permission .= $values['show_timer'] . "|";
             $permission .= $values['write_text'] . "|";
             $permission .= $values['regular_watch'] . "|";
             $permission .= $values['new_watch'] . "|";
             $permission .= $values['private_textchat'] . "|";
             $permission .= $values['administrator'] . "|";
             $permission .= $values['verbose_level'] . "|";
             $clip->permission = $permission;
             $clip->floodProtection = $values['flood_protection'];
             $clip->filterRegex = $values['filter_regex'];
             $clip->filterReplace = $values['filter_replace'];
             $clip->user_list = $values['user_list'];
             $clip->moderator_list = $values['moderator_list'];
             $clip->modifDatetime = time();
             $description = UTIL_HtmlTag::stripJs($values['description']);
             $description = UTIL_HtmlTag::stripTags($description, array('frame', 'style'), array(), true);
             $clip->description = $description;
             if ($clipService->updateClip($clip)) {
                 BOL_TagService::getInstance()->updateEntityTags($clip->id, 'vwvc', TagsField::getTags($values['tags']));
                 return array('result' => true, 'id' => $clip->id);
             }
         }
     } else {
         return array('result' => false, 'id' => $clip->id);
     }
     return false;
 }
Ejemplo n.º 22
0
 private function getData($case, $first, $count)
 {
     $service = PostService::getInstance();
     $list = array();
     $itemsCount = 0;
     switch ($case) {
         case 'most-discussed':
             OW::getDocument()->setTitle(OW::getLanguage()->text('blogs', 'most_discussed_title'));
             OW::getDocument()->setDescription(OW::getLanguage()->text('blogs', 'most_discussed_description'));
             $commentService = BOL_CommentService::getInstance();
             $info = array();
             $info = $commentService->findMostCommentedEntityList('blog-post', $first, $count);
             $idList = array();
             foreach ($info as $item) {
                 $idList[] = $item['id'];
             }
             if (empty($idList)) {
                 break;
             }
             $dtoList = $service->findListByIdList($idList);
             foreach ($dtoList as $dto) {
                 if ($dto->isDraft()) {
                     continue;
                 }
                 $info[$dto->id]['dto'] = $dto;
                 $list[] = array('dto' => $dto, 'commentCount' => $info[$dto->id]['commentCount']);
             }
             function sortMostCommented($e, $e2)
             {
                 return $e['commentCount'] < $e2['commentCount'];
             }
             usort($list, 'sortMostCommented');
             $itemsCount = $commentService->findCommentedEntityCount('blog-post');
             break;
         case 'top-rated':
             OW::getDocument()->setTitle(OW::getLanguage()->text('blogs', 'top_rated_title'));
             OW::getDocument()->setDescription(OW::getLanguage()->text('blogs', 'top_rated_description'));
             $info = array();
             $info = BOL_RateService::getInstance()->findMostRatedEntityList('blog-post', $first, $count);
             $idList = array();
             foreach ($info as $item) {
                 $idList[] = $item['id'];
             }
             if (empty($idList)) {
                 break;
             }
             $dtoList = $service->findListByIdList($idList);
             foreach ($dtoList as $dto) {
                 if ($dto->isDraft()) {
                     continue;
                 }
                 $list[] = array('dto' => $dto, 'avgScore' => $info[$dto->id]['avgScore'], 'ratesCount' => $info[$dto->id]['ratesCount']);
             }
             function sortTopRated($e, $e2)
             {
                 if ($e['avgScore'] == $e2['avgScore']) {
                     if ($e['ratesCount'] == $e2['ratesCount']) {
                         return 0;
                     }
                     return $e['ratesCount'] < $e2['ratesCount'];
                 }
                 return $e['avgScore'] < $e2['avgScore'];
             }
             usort($list, 'sortTopRated');
             $itemsCount = BOL_RateService::getInstance()->findMostRatedEntityCount('blog-post');
             break;
         case 'browse-by-tag':
             if (empty($_GET['tag'])) {
                 $mostPopularTagsArray = BOL_TagService::getInstance()->findMostPopularTags('blog-post', 20);
                 $mostPopularTags = "";
                 foreach ($mostPopularTagsArray as $tag) {
                     $mostPopularTags .= $tag['label'] . ", ";
                 }
                 OW::getDocument()->setTitle(OW::getLanguage()->text('blogs', 'browse_by_tag_title'));
                 OW::getDocument()->setDescription(OW::getLanguage()->text('blogs', 'browse_by_tag_description', array('tags' => $mostPopularTags)));
                 break;
             }
             $info = BOL_TagService::getInstance()->findEntityListByTag('blog-post', UTIL_HtmlTag::stripTags($_GET['tag']), $first, $count);
             $itemsCount = BOL_TagService::getInstance()->findEntityCountByTag('blog-post', UTIL_HtmlTag::stripTags($_GET['tag']));
             foreach ($info as $item) {
                 $idList[] = $item;
             }
             if (empty($idList)) {
                 break;
             }
             $dtoList = $service->findListByIdList($idList);
             function sortByTimestamp($post1, $post2)
             {
                 return $post1->timestamp < $post2->timestamp;
             }
             usort($dtoList, 'sortByTimestamp');
             foreach ($dtoList as $dto) {
                 if ($dto->isDraft()) {
                     continue;
                 }
                 $list[] = array('dto' => $dto);
             }
             OW::getDocument()->setTitle(OW::getLanguage()->text('blogs', 'browse_by_tag_item_title', array('tag' => UTIL_HtmlTag::stripTags($_GET['tag']))));
             OW::getDocument()->setDescription(OW::getLanguage()->text('blogs', 'browse_by_tag_item_description', array('tag' => UTIL_HtmlTag::stripTags($_GET['tag']))));
             break;
         case 'latest':
             OW::getDocument()->setTitle(OW::getLanguage()->text('blogs', 'latest_title'));
             OW::getDocument()->setDescription(OW::getLanguage()->text('blogs', 'latest_description'));
             $arr = $service->findList($first, $count);
             foreach ($arr as $item) {
                 $list[] = array('dto' => $item);
             }
             $itemsCount = $service->countPosts();
             break;
     }
     return array($list, $itemsCount);
 }
Ejemplo n.º 23
0
 /**
  *
  * @param GROUPS_BOL_Group $group
  * @return GROUPS_BOL_Group
  */
 public function processGroup(GROUPS_BOL_Group $group)
 {
     $values = $this->getValues();
     $service = GROUPS_BOL_Service::getInstance();
     if ($values['image']) {
         if (!empty($group->imageHash)) {
             OW::getStorage()->removeFile($service->getGroupImagePath($group));
             OW::getStorage()->removeFile($service->getGroupImagePath($group, GROUPS_BOL_Service::IMAGE_SIZE_BIG));
         }
         $group->imageHash = uniqid();
     }
     $group->title = strip_tags($values['title']);
     $values['description'] = UTIL_HtmlTag::stripJs($values['description']);
     $values['description'] = UTIL_HtmlTag::stripTags($values['description'], array('frame'), array(), true);
     $group->description = $values['description'];
     $group->whoCanInvite = $values['whoCanInvite'];
     $group->whoCanView = $values['whoCanView'];
     $service->saveGroup($group);
     if (!empty($values['image'])) {
         $this->saveImages($values['image'], $group);
     }
     return $group;
 }
Ejemplo n.º 24
0
 /**
  * Controller's default action
  *
  * @param array $params
  * @throws AuthorizationException
  * @throws Redirect404Exception
  */
 public function index(array $params = null)
 {
     $forumService = FORUM_BOL_ForumService::getInstance();
     if (!isset($params['id']) || !($topicId = (int) $params['id'])) {
         throw new Redirect404Exception();
     }
     $topicDto = $forumService->findTopicById($topicId);
     if (!$topicDto) {
         throw new Redirect404Exception();
     }
     $forumGroup = $forumService->getGroupInfo($topicDto->groupId);
     $forumSection = $forumService->findSectionById($forumGroup->sectionId);
     $isHidden = $forumSection->isHidden;
     $userId = OW::getUser()->getId();
     if ($isHidden) {
         $isModerator = OW::getUser()->isAuthorized($forumSection->entity);
         $eventParams = array('entity' => $forumSection->entity, 'entityId' => $forumGroup->entityId, 'action' => 'add_topic');
         $event = new OW_Event('forum.check_permissions', $eventParams);
         OW::getEventManager()->trigger($event);
         $canPost = $event->getData();
         //check permissions
         $canEdit = OW::getUser()->isAuthorized($forumSection->entity, 'add_topic') && $userId == $topicDto->userId;
         if (!$isModerator) {
             if (!$canPost) {
                 throw new AuthorizationException();
             } else {
                 if (!$canEdit) {
                     $status = BOL_AuthorizationService::getInstance()->getActionStatus($forumSection->entity, 'add_topic');
                     throw new AuthorizationException($status['msg']);
                 }
             }
         }
     } else {
         $isModerator = OW::getUser()->isAuthorized('forum');
         $canEdit = OW::getUser()->isAuthorized('forum', 'edit') && $userId == $topicDto->userId;
         if (!$canEdit && !$isModerator) {
             throw new AuthorizationException();
         }
     }
     // first topic's post
     $postDto = $forumService->findTopicFirstPost($topicId);
     $this->assign('post', $postDto);
     $uid = uniqid();
     $editTopicForm = $this->generateEditTopicForm($topicDto, $postDto, $uid);
     $this->addForm($editTopicForm);
     $lang = OW::getLanguage();
     $router = OW::getRouter();
     $topicInfo = $forumService->getTopicInfo($topicId);
     $groupUrl = $router->urlForRoute('group-default', array('groupId' => $topicDto->groupId));
     $topicUrl = $router->urlForRoute('topic-default', array('topicId' => $topicDto->id));
     $lang->addKeyForJs('forum', 'confirm_delete_attachment');
     $attachmentService = FORUM_BOL_PostAttachmentService::getInstance();
     $enableAttachments = OW::getConfig()->getValue('forum', 'enable_attachments');
     $this->assign('enableAttachments', $enableAttachments);
     if ($enableAttachments) {
         $attachments = $attachmentService->findAttachmentsByPostIdList(array($postDto->id));
         $this->assign('attachments', $attachments);
         $attachmentCmp = new BASE_CLASS_FileAttachment('forum', $uid);
         $this->addComponent('attachmentsCmp', $attachmentCmp);
     }
     if (OW::getRequest()->isPost() && $editTopicForm->isValid($_POST)) {
         $values = $editTopicForm->getValues();
         $topicId = (int) $values['topic-id'];
         $postId = (int) $values['post-id'];
         $title = trim($values['title']);
         $text = trim($values['text']);
         $topicDto = $forumService->findTopicById($topicId);
         $postDto = $forumService->findPostById($postId);
         if ($topicDto === null || $postDto === null || $topicDto->userId != $userId && !$isModerator) {
             exit;
         }
         //save topic
         $topicDto->title = strip_tags($title);
         $forumService->saveOrUpdateTopic($topicDto);
         //save post
         $postDto->text = UTIL_HtmlTag::stripJs(UTIL_HtmlTag::stripTags($text, array('form', 'input', 'button'), null, true));
         $forumService->saveOrUpdatePost($postDto);
         //save post edit info
         $editPostDto = $forumService->findEditPost($postId);
         if ($editPostDto === null) {
             $editPostDto = new FORUM_BOL_EditPost();
         }
         $editPostDto->postId = $postId;
         $editPostDto->userId = $userId;
         $editPostDto->editStamp = time();
         $forumService->saveOrUpdateEditPost($editPostDto);
         if ($enableAttachments) {
             $filesArray = BOL_AttachmentService::getInstance()->getFilesByBundleName('forum', $values['attachmentUid']);
             if ($filesArray) {
                 $attachmentService = FORUM_BOL_PostAttachmentService::getInstance();
                 $skipped = 0;
                 foreach ($filesArray as $file) {
                     $attachmentDto = new FORUM_BOL_PostAttachment();
                     $attachmentDto->postId = $postDto->id;
                     $attachmentDto->fileName = $file['dto']->origFileName;
                     $attachmentDto->fileNameClean = $file['dto']->fileName;
                     $attachmentDto->fileSize = $file['dto']->size * 1024;
                     $attachmentDto->hash = uniqid();
                     $added = $attachmentService->addAttachment($attachmentDto, $file['path']);
                     if (!$added) {
                         $skipped++;
                     }
                 }
                 BOL_AttachmentService::getInstance()->deleteAttachmentByBundle('forum', $values['attachmentUid']);
                 if ($skipped) {
                     OW::getFeedback()->warning(OW::getLanguage()->text('forum', 'not_all_attachments_added'));
                 }
             }
         }
         OW::getEventManager()->trigger(new OW_Event('feed.action', array('pluginKey' => 'forum', 'entityType' => 'forum-topic', 'entityId' => $topicDto->id, 'userId' => $topicDto->userId, 'time' => $postDto->createStamp)));
         OW::getEventManager()->trigger(new OW_Event(FORUM_BOL_ForumService::EVENT_AFTER_TOPIC_EDIT, array('topicId' => $topicDto->id)));
         $this->redirect($topicUrl);
     }
     OW::getDocument()->setHeading(OW::getLanguage()->text('forum', 'edit_topic_title'));
     OW::getDocument()->setHeadingIconClass('ow_ic_edit');
     $this->assign('isHidden', $isHidden);
     if ($isHidden) {
         $event = new OW_Event('forum.find_forum_caption', array('entity' => $forumSection->entity, 'entityId' => $forumGroup->entityId));
         OW::getEventManager()->trigger($event);
         $eventData = $event->getData();
         /** @var OW_Component $componentForumCaption */
         $componentForumCaption = $eventData['component'];
         if (!empty($componentForumCaption)) {
             $this->assign('componentForumCaption', $componentForumCaption->render());
         } else {
             $componentForumCaption = false;
             $this->assign('componentForumCaption', $componentForumCaption);
         }
         $bcItems = array(array('href' => OW::getRouter()->urlForRoute('topic-default', array('topicId' => $topicId)), 'label' => OW::getLanguage()->text('forum', 'back_to_topic')));
         $breadCrumbCmp = new BASE_CMP_Breadcrumb($bcItems);
         $this->addComponent('breadcrumb', $breadCrumbCmp);
         OW::getNavigation()->deactivateMenuItems(OW_Navigation::MAIN);
         OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, $forumSection->entity, $eventData['key']);
     } else {
         $bcItems = array(array('href' => $router->urlForRoute('forum-default'), 'label' => $lang->text('forum', 'forum_index')), array('href' => $router->urlForRoute('forum-default') . '#section-' . $topicInfo['sectionId'], 'label' => $topicInfo['sectionName']), array('href' => $groupUrl, 'label' => $topicInfo['groupName']), array('href' => $topicUrl, 'label' => htmlspecialchars($topicDto->title)));
         $breadCrumbCmp = new BASE_CMP_Breadcrumb($bcItems, $lang->text('forum', 'topic_location'));
         $this->addComponent('breadcrumb', $breadCrumbCmp);
         OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'forum', 'forum');
     }
 }
Ejemplo n.º 25
0
 public function getNewsfeedLinkData($entityId, $type)
 {
     $feedData = $this->getFeedData($entityId);
     switch ($type) {
         case 'title':
             return UTIL_HtmlTag::stripTags($feedData['data']['status']);
             break;
         case 'photo':
             $photoUrl = '';
             if (isset($feedData['attachment']['oembed']['thumbnail_url'])) {
                 $photoUrl = $feedData['attachment']['oembed']['thumbnail_url'];
             }
             return $photoUrl;
             break;
         default:
             break;
     }
 }
Ejemplo n.º 26
0
 public function ajaxUpdateVideo()
 {
     if (OW::getRequest()->isAjax()) {
         $clipId = (int) $_POST['id'];
         $form = new GVIDEOVIEWER_CLASS_EditForm($clipId);
         if ($form->isValid($_POST)) {
             $values = $form->getValues();
             $clip = $this->clipService->findClipById($clipId);
             if ($clip) {
                 $clip->title = htmlspecialchars($values['title']);
                 $description = UTIL_HtmlTag::stripJs($values['description']);
                 $description = UTIL_HtmlTag::stripTags($description, array('frame', 'style'), array(), true);
                 $clip->description = $description;
                 $clip->code = $values['code'];
                 if ($this->clipService->updateClip($clip)) {
                     BOL_TagService::getInstance()->updateEntityTags($clip->id, 'video', $values['tags']);
                     exit(json_encode(array('result' => true, 'id' => $clip->id)));
                 }
             }
         }
     }
 }
Ejemplo n.º 27
0
 public function getConversationPreviewTextForApi($conversation)
 {
     $convPreview = '';
     switch ($conversation['mode']) {
         case 'mail':
             $authActionName = 'read_message';
             break;
         case 'chat':
             $authActionName = 'read_chat_message';
             break;
     }
     $status = BOL_AuthorizationService::getInstance()->getActionStatus('mailbox', $authActionName);
     $readMessageAuthorized = true;
     if ((int) $conversation['lastMessageSenderId'] != OW::getUser()->getId() && !$conversation['lastMessageWasAuthorized']) {
         if ($status['status'] == BOL_AuthorizationService::STATUS_AVAILABLE) {
             if ($status['authorizedBy'] == 'usercredits') {
                 $readMessageAuthorized = false;
                 $convPreview = OW::getLanguage()->text('mailbox', 'click_to_read_messages');
             } else {
                 $readMessageAuthorized = true;
                 $this->markMessageAuthorizedToRead($conversation['lastMessageId']);
             }
         } else {
             if ($status['status'] == BOL_AuthorizationService::STATUS_PROMOTED) {
                 $readMessageAuthorized = false;
                 $convPreview = UTIL_HtmlTag::stripTags($status['msg']);
             } else {
                 $readMessageAuthorized = false;
                 $convPreview = OW::getLanguage()->text('mailbox', 'read_permission_denied');
             }
         }
     }
     if ($readMessageAuthorized) {
         if ($conversation['isSystem']) {
             $eventParams = json_decode($conversation['text'], true);
             $eventParams['params']['messageId'] = (int) $conversation['lastMessageId'];
             $eventParams['params']['getPreview'] = true;
             $event = new OW_Event($eventParams['entityType'] . '.' . $eventParams['eventName'], $eventParams['params']);
             OW::getEventManager()->trigger($event);
             $data = $event->getData();
             if (!empty($data)) {
                 $convPreview = $data;
             } else {
                 $convPreview = OW::getLanguage()->text('mailbox', 'can_not_display_entitytype_message', array('entityType' => $eventParams['entityType']));
             }
         } else {
             $short = mb_strlen($conversation['text']) > 50 ? mb_substr($conversation['text'], 0, 50) . '...' : $conversation['text'];
             //                        $short = UTIL_HtmlTag::autoLink($short);
             $event = new OW_Event('mailbox.message_render', array('conversationId' => $conversation['id'], 'messageId' => $conversation['lastMessageId'], 'senderId' => $conversation['lastMessageSenderId'], 'recipientId' => $conversation['lastMessageRecipientId']), array('short' => $short, 'full' => $conversation['text']));
             OW::getEventManager()->trigger($event);
             $eventData = $event->getData();
             $convPreview = strip_tags($eventData['short']);
         }
     }
     return $convPreview;
 }
Ejemplo n.º 28
0
 /**
  * Validate clip code integrity
  *
  * @param string $code
  * @param null $provider
  * @return string
  */
 public function validateClipCode($code, $provider = null)
 {
     $textService = BOL_TextFormatService::getInstance();
     $code = UTIL_HtmlTag::stripJs($code);
     $code = UTIL_HtmlTag::stripTags($code, $textService->getVideoParamList('tags'), $textService->getVideoParamList('attrs'));
     $objStart = '<object';
     $objEnd = '</object>';
     $objEndS = '/>';
     $posObjStart = stripos($code, $objStart);
     $posObjEnd = stripos($code, $objEnd);
     $posObjEnd = $posObjEnd ? $posObjEnd : stripos($code, $objEndS);
     if ($posObjStart !== false && $posObjEnd !== false) {
         $posObjEnd += strlen($objEnd);
         return substr($code, $posObjStart, $posObjEnd - $posObjStart);
     } else {
         $embStart = '<embed';
         $embEnd = '</embed>';
         $embEndS = '/>';
         $posEmbStart = stripos($code, $embStart);
         $posEmbEnd = stripos($code, $embEnd) ? stripos($code, $embEnd) : stripos($code, $embEndS);
         if ($posEmbStart !== false && $posEmbEnd !== false) {
             $posEmbEnd += strlen($embEnd);
             return substr($code, $posEmbStart, $posEmbEnd - $posEmbStart);
         } else {
             $frmStart = '<iframe ';
             $frmEnd = '</iframe>';
             $posFrmStart = stripos($code, $frmStart);
             $posFrmEnd = stripos($code, $frmEnd);
             if ($posFrmStart !== false && $posFrmEnd !== false) {
                 $posFrmEnd += strlen($frmEnd);
                 $code = substr($code, $posFrmStart, $posFrmEnd - $posFrmStart);
                 preg_match('/src=(["\'])(.*?)\\1/', $code, $match);
                 if (!empty($match[2])) {
                     $src = $match[2];
                     if (mb_substr($src, 0, 2) == '//') {
                         $src = 'http:' . $src;
                     }
                     $urlArr = parse_url($src);
                     $parts = explode('.', $urlArr['host']);
                     if (count($parts) < 2) {
                         return '';
                     }
                     $d1 = array_pop($parts);
                     $d2 = array_pop($parts);
                     $host = $d2 . '.' . $d1;
                     $resourceList = BOL_TextFormatService::getInstance()->getMediaResourceList();
                     if (!in_array($host, $resourceList) && !in_array($urlArr['host'], $resourceList)) {
                         return '';
                     }
                 }
                 return $code;
             } else {
                 return '';
             }
         }
     }
 }
Ejemplo n.º 29
0
 /**
  * This action adds a post and after execution redirects to default action
  *
  * @param array $params
  * @throws Redirect404Exception
  * @throws AuthenticateException
  */
 public function addPost(array $params)
 {
     if (!isset($params['topicId']) || !($topicId = (int) $params['topicId'])) {
         throw new Redirect404Exception();
     }
     $topicDto = $this->forumService->findTopicById($topicId);
     if (!$topicDto) {
         throw new Redirect404Exception();
     }
     $uid = $params['uid'];
     $addPostForm = $this->generateAddPostForm($topicId, $uid);
     if (OW::getRequest()->isPost() && $addPostForm->isValid($_POST)) {
         $data = $addPostForm->getValues();
         if ($data['topic'] && $data['topic'] == $topicDto->id && !$topicDto->locked) {
             if (!OW::getUser()->getId()) {
                 throw new AuthenticateException();
             }
             $postDto = new FORUM_BOL_Post();
             $postDto->topicId = $data['topic'];
             $postDto->userId = OW::getUser()->getId();
             $postDto->text = UTIL_HtmlTag::stripJs(UTIL_HtmlTag::stripTags($data['text'], array('form', 'input', 'button'), null, true));
             $postDto->createStamp = time();
             $this->forumService->saveOrUpdatePost($postDto);
             $topicDto->lastPostId = $postDto->getId();
             $this->forumService->saveOrUpdateTopic($topicDto);
             $this->forumService->deleteByTopicId($topicId);
             $enableAttachments = OW::getConfig()->getValue('forum', 'enable_attachments');
             if ($enableAttachments) {
                 $filesArray = BOL_AttachmentService::getInstance()->getFilesByBundleName('forum', $data['attachmentUid']);
                 if ($filesArray) {
                     $attachmentService = FORUM_BOL_PostAttachmentService::getInstance();
                     $skipped = 0;
                     foreach ($filesArray as $file) {
                         $attachmentDto = new FORUM_BOL_PostAttachment();
                         $attachmentDto->postId = $postDto->id;
                         $attachmentDto->fileName = $file['dto']->origFileName;
                         $attachmentDto->fileNameClean = $file['dto']->fileName;
                         $attachmentDto->fileSize = $file['dto']->size * 1024;
                         $attachmentDto->hash = uniqid();
                         $added = $attachmentService->addAttachment($attachmentDto, $file['path']);
                         if (!$added) {
                             $skipped++;
                         }
                     }
                     BOL_AttachmentService::getInstance()->deleteAttachmentByBundle('forum', $data['attachmentUid']);
                     if ($skipped) {
                         OW::getFeedback()->warning(OW::getLanguage()->text('forum', 'not_all_attachments_added'));
                     }
                 }
             }
             $postUrl = $this->forumService->getPostUrl($topicId, $postDto->id);
             $event = new OW_Event('forum.add_post', array('postId' => $postDto->id, 'topicId' => $topicId, 'userId' => $postDto->userId));
             OW::getEventManager()->trigger($event);
             $forumGroup = $this->forumService->findGroupById($topicDto->groupId);
             if ($forumGroup) {
                 $forumSection = $this->forumService->findSectionById($forumGroup->sectionId);
                 if ($forumSection) {
                     $pluginKey = $forumSection->isHidden ? $forumSection->entity : 'forum';
                     $action = $forumSection->isHidden ? 'add_topic' : 'edit';
                     BOL_AuthorizationService::getInstance()->trackAction($pluginKey, $action);
                 }
             }
             $this->redirect($postUrl);
         }
     } else {
         $this->redirect(OW::getRouter()->urlForRoute('topic-default', array('topicId' => $topicId)));
     }
 }
Ejemplo n.º 30
0
 private function getData($first, $count)
 {
     $service = LinkService::getInstance();
     $list = array();
     $itemCount = 0;
     $case = $this->getCase();
     switch ($case) {
         case 'most-discussed':
             $commentService = BOL_CommentService::getInstance();
             $info = array();
             $info = $commentService->findMostCommentedEntityList('link', $first, $count);
             $idList = array();
             foreach ($info as $item) {
                 $idList[] = $item['id'];
             }
             if (empty($idList)) {
                 break;
             }
             $dtoList = $service->findListByIdList($idList);
             foreach ($dtoList as $dto) {
                 $list[] = array('dto' => $dto, 'commentCount' => $info[$dto->id]['commentCount']);
             }
             function sortMostCommented($e, $e2)
             {
                 return $e['commentCount'] < $e2['commentCount'];
             }
             usort($list, 'sortMostCommented');
             $itemsCount = $commentService->findCommentedEntityCount('link');
             OW::getDocument()->setTitle(OW::getLanguage()->text('links', 'most_discussed_title'));
             OW::getDocument()->setDescription(OW::getLanguage()->text('links', 'most_discussed_description'));
             break;
         case 'top-rated':
             $info = array();
             $info = BOL_VoteService::getInstance()->findMostVotedEntityList('link', $first, $count);
             $idList = array();
             foreach ($info as $item) {
                 $idList[] = $item['id'];
             }
             if (empty($idList)) {
                 break;
             }
             $dtoList = $service->findListByIdList($idList);
             foreach ($dtoList as $dto) {
                 $list[] = array('dto' => $dto, 'sum' => $info[$dto->id]['sum']);
             }
             function sortTopRated($e, $e2)
             {
                 return $e['sum'] < $e2['sum'];
             }
             usort($list, 'sortTopRated');
             $itemCount = BOL_VoteService::getInstance()->findMostVotedEntityCount('link');
             OW::getDocument()->setTitle(OW::getLanguage()->text('links', 'top_rated_title'));
             OW::getDocument()->setDescription(OW::getLanguage()->text('links', 'top_rated_description'));
             break;
         case 'browse-by-tag':
             if (empty($_GET['tag'])) {
                 $mostPopularTagsArray = BOL_TagService::getInstance()->findMostPopularTags('link', 20);
                 $mostPopularTags = "";
                 foreach ($mostPopularTagsArray as $tag) {
                     $mostPopularTags .= $tag['label'] . ", ";
                 }
                 OW::getDocument()->setTitle(OW::getLanguage()->text('links', 'browse_by_tag_title'));
                 OW::getDocument()->setDescription(OW::getLanguage()->text('links', 'browse_by_tag_description', array('tags' => $mostPopularTags)));
                 break;
             }
             $info = BOL_TagService::getInstance()->findEntityListByTag('link', UTIL_HtmlTag::stripTags($_GET['tag']), $first, $count);
             $itemCount = BOL_TagService::getInstance()->findEntityCountByTag('link', UTIL_HtmlTag::stripTags($_GET['tag']));
             foreach ($info as $item) {
                 $idList[] = $item;
             }
             if (empty($idList)) {
                 break;
             }
             $dtoList = $service->findListByIdList($idList);
             foreach ($dtoList as $dto) {
                 $dto->setUrl(strip_tags($dto->getUrl()));
                 $dto->setTitle(strip_tags($dto->getTitle()));
                 $dto->setDescription(BASE_CMP_TextFormatter::fromBBtoHtml($dto->getDescription()));
                 $list[] = array('dto' => $dto);
             }
             OW::getDocument()->setTitle(OW::getLanguage()->text('links', 'browse_by_tag_item_title', array('tag' => htmlspecialchars(UTIL_HtmlTag::stripTags($_GET['tag'])))));
             OW::getDocument()->setDescription(OW::getLanguage()->text('links', 'browse_by_tag_item_description', array('tag' => htmlspecialchars(UTIL_HtmlTag::stripTags($_GET['tag'])))));
             break;
         case false !== strstr($_SERVER['REQUEST_URI'], 'latest'):
         default:
             $dtoList = $service->findList($first, $count);
             $itemCount = $service->countLinks();
             foreach ($dtoList as $dto) {
                 $list[] = array('dto' => $dto);
             }
             OW::getDocument()->setTitle(OW::getLanguage()->text('links', 'latest_title'));
             OW::getDocument()->setDescription(OW::getLanguage()->text('links', 'latest_description'));
             break;
     }
     return array($list, $itemCount);
 }