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, $isAdmin)
 {
     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 parent::processSettingList($settings, $place, $isAdmin);
 }
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 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.º 7
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.º 8
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.º 9
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.º 10
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.º 11
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.º 12
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.º 13
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.º 14
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.º 15
0
 protected function sendMessage($userId, $opponentId, $subject, $message, $files = array())
 {
     $conversationService = MAILBOX_BOL_ConversationService::getInstance();
     $checkResult = $conversationService->checkUser($userId, $opponentId);
     if ($checkResult['isSuspended']) {
         return array('result' => false, 'error' => $checkResult['suspendReasonMessage']);
     }
     //        $message = UTIL_HtmlTag::stripTags(UTIL_HtmlTag::stripJs($message));
     $message = UTIL_HtmlTag::stripJs($message);
     //        $message = nl2br($message);
     $event = new OW_Event('mailbox.before_create_conversation', array('senderId' => $userId, 'recipientId' => $opponentId, 'message' => $message, 'subject' => $subject), array('result' => true, 'error' => '', 'message' => $message, 'subject' => $subject));
     OW::getEventManager()->trigger($event);
     $data = $event->getData();
     if (empty($data['result'])) {
         return array('result' => 'permission_denied', 'message' => $data['error']);
     }
     if (!trim(strip_tags($data['subject']))) {
         return array('result' => false, 'error' => OW::getLanguage()->text('mailbox', 'subject_is_required'));
     }
     $subject = $data['subject'];
     $message = $data['message'];
     $conversation = $conversationService->createConversation($userId, $opponentId, $subject, $message);
     $messageDto = $conversationService->getLastMessage($conversation->id);
     if (!empty($files)) {
         $conversationService->addMessageAttachments($messageDto->id, $files);
     }
     BOL_AuthorizationService::getInstance()->trackAction('mailbox', 'send_message');
     $conversationService->resetUserLastData($userId);
     $conversationService->resetUserLastData($opponentId);
     return array('result' => true, 'lastMessageTimestamp' => $messageDto->timeStamp);
 }
Ejemplo n.º 16
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.º 17
0
 public function feedBeforeStatusUpdate(OW_Event $e)
 {
     $params = $e->getParams();
     if ($params['type'] != 'video') {
         return;
     }
     $auth = BOL_AuthorizationService::getInstance()->getActionStatus('video', 'add');
     if ($auth['status'] != BOL_AuthorizationService::STATUS_AVAILABLE) {
         return;
     }
     $data = $params['data'];
     $addClipParams = array('userId' => $params['userId'], 'title' => isset($data['title']) ? $data['title'] : $params['status'], 'description' => isset($data['description']) ? $data['description'] : null, 'code' => UTIL_HtmlTag::stripJs($data['html']));
     $event = new OW_Event(self::EVENT_VIDEO_ADD, $addClipParams);
     OW::getEventManager()->trigger($event);
     $addClipData = $event->getData();
     if ($addClipData["status"] == "approval") {
         $e->setData(array("message" => OW::getLanguage()->text("video", "pending_approval_feedback")));
         return;
     }
     if (!empty($addClipData['id'])) {
         $e->setData(array('entityType' => 'video_comments', 'entityId' => $addClipData['id']));
     }
 }
Ejemplo n.º 18
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.º 19
0
 public function addPoint($location, $title = '', $windowContent = '', $isOpen = false)
 {
     if (!empty($location)) {
         $this->points[] = array('location' => $location, 'title' => UTIL_HtmlTag::stripJs($title), 'content' => UTIL_HtmlTag::stripJs($windowContent), 'isOpen' => (bool) $isOpen);
     }
 }
Ejemplo n.º 20
0
 protected function sendMessage($userId, $opponentId, $subject, $message, $files = array())
 {
     $language = OW::getLanguage();
     $conversationService = MAILBOX_BOL_ConversationService::getInstance();
     $userSendMessageIntervalOk = $conversationService->checkUserSendMessageInterval($userId);
     if (!$userSendMessageIntervalOk) {
         $send_message_interval = (int) OW::getConfig()->getValue('mailbox', 'send_message_interval');
         return array('result' => false, 'error' => $language->text('mailbox', 'feedback_send_message_interval_exceed', array('send_message_interval' => $send_message_interval)));
     }
     $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', $actionName . '_permission_denied'));
         }
     }
     $checkResult = $conversationService->checkUser($userId, $opponentId);
     if ($checkResult['isSuspended']) {
         return array('result' => false, 'error' => $checkResult['suspendReasonMessage']);
     }
     //        $message = UTIL_HtmlTag::stripTags(UTIL_HtmlTag::stripJs($message));
     $message = UTIL_HtmlTag::stripJs($message);
     //        $message = nl2br($message);
     $event = new OW_Event('mailbox.before_create_conversation', array('senderId' => $userId, 'recipientId' => $opponentId, 'message' => $message, 'subject' => $subject), array('result' => true, 'error' => '', 'message' => $message, 'subject' => $subject));
     OW::getEventManager()->trigger($event);
     $data = $event->getData();
     if (empty($data['result'])) {
         return array('result' => 'permission_denied', 'message' => $data['error']);
     }
     $subject = $data['subject'];
     $message = $data['message'];
     $conversation = $conversationService->createConversation($userId, $opponentId, htmlspecialchars($subject), $message);
     $messageDto = $conversationService->getLastMessage($conversation->id);
     if (!empty($files)) {
         $conversationService->addMessageAttachments($messageDto->id, $files);
     }
     BOL_AuthorizationService::getInstance()->trackAction('mailbox', 'send_message');
     $conversationService->resetUserLastData($userId);
     $conversationService->resetUserLastData($opponentId);
     return array('result' => true, 'lastMessageTimestamp' => $messageDto->timeStamp);
 }
Ejemplo n.º 21
0
 private function processHtml($text)
 {
     $searchArray = array();
     $replaceArray = array();
     $index = 1;
     while (mb_strstr($text, '<span class="ow_ws_html">')) {
         $openSearchStr = '<span class="ow_ws_html">';
         $closeSearchStr = '</span>';
         $openPos = mb_stripos($text, $openSearchStr);
         $closePos = mb_stripos($text, $closeSearchStr, $openPos) + mb_strlen($closeSearchStr);
         $code = mb_substr($text, $openPos, $closePos - $openPos);
         $subCode = mb_substr($code, mb_strlen($openSearchStr));
         $subCode = mb_substr($subCode, 0, mb_strlen($subCode) - mb_strlen($closeSearchStr));
         $ph = '#h#' . $index . '#h#';
         $text = str_replace($code, $ph, $text);
         $searchArray[$index] = $ph;
         $replaceArray[$index] = $openSearchStr . UTIL_HtmlTag::stripJs($subCode) . $closeSearchStr;
         $index++;
     }
     return array('text' => $text, 'search' => $searchArray, 'replace' => $replaceArray);
 }
Ejemplo n.º 22
0
 public static function processSettingList($settingList, $place, $isAdmin)
 {
     if (isset($settingList['title'])) {
         $settingList['title'] = UTIL_HtmlTag::stripJs($settingList['title']);
     }
     return $settingList;
 }
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 edit(array $params)
 {
     if (empty($params['id'])) {
         throw new Redirect404Exception();
     }
     $projectId = (int) $params['id'];
     $service = OCSFUNDRAISING_BOL_Service::getInstance();
     $project = $service->getGoalById($projectId);
     if (!$project) {
         throw new Redirect404Exception();
     }
     $viewerId = OW::getUser()->getId();
     $isOwner = $viewerId && $project['dto']->ownerId == $viewerId;
     if (!$isOwner) {
         throw new Redirect404Exception();
     }
     $lang = OW::getLanguage();
     $form = new OCSFUNDRAISING_CLASS_GoalEditForm();
     $this->addForm($form);
     $service = OCSFUNDRAISING_BOL_Service::getInstance();
     $goal = $service->getGoalById($projectId);
     if (OW::getRequest()->isPost() && $form->isValid($_POST)) {
         $values = $form->getValues();
         $goal = $goal['dto'];
         $goal->name = trim($values['name']);
         $goal->description = UTIL_HtmlTag::stripJs($values['description']);
         $goal->amountMin = floatval($values['min']);
         $goal->amountTarget = floatval($values['target']);
         $goal->ownerType = 'user';
         $goal->ownerId = OW::getUser()->getId();
         $date = explode('/', $values['end']);
         if (!empty($date[1]) && !empty($date[2]) && !empty($date[0])) {
             $goal->endStamp = mktime(0, 0, 0, $date[1], $date[2], $date[0]);
         }
         $goal->categoryId = (int) $values['category'];
         $imageValid = true;
         $imagePosted = false;
         if (!empty($_FILES['image']['name'])) {
             if ((int) $_FILES['image']['error'] !== 0 || !is_uploaded_file($_FILES['image']['tmp_name']) || !UTIL_File::validateImage($_FILES['image']['name'])) {
                 $imageValid = false;
                 OW::getFeedback()->error($lang->text('base', 'not_valid_image'));
             } else {
                 $imagePosted = true;
             }
         }
         if ($imagePosted && $imageValid) {
             $service->saveImage($goal->id, $_FILES['image']['tmp_name'], $goal->image);
         }
         $service->update($goal);
         OW::getFeedback()->info($lang->text('ocsfundraising', 'goal_updated'));
         $this->redirect(OW::getRouter()->urlForRoute('ocsfundraising.project', array('id' => $projectId)));
     }
     $form->getElement('projectId')->setValue($projectId);
     $form->getElement('name')->setValue($goal['dto']->name);
     $form->getElement('description')->setValue($goal['dto']->description);
     $form->getElement('target')->setValue($goal['dto']->amountTarget);
     $form->getElement('min')->setValue(floatval($goal['dto']->amountMin));
     $form->getElement('category')->setValue(floatval($goal['dto']->categoryId));
     if ($goal['dto']->endStamp) {
         $date = date('Y/m/d', $goal['dto']->endStamp);
         $form->getElement('end')->setValue($date);
     }
     $image = $goal['dto']->image ? $service->generateImageUrl($goal['dto']->image, true) : null;
     $this->assign('image', $image);
     $this->setPageHeading($lang->text('ocsfundraising', 'edit_project'));
     $this->setPageTitle($lang->text('ocsfundraising', 'edit_project'));
     OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'ocsfundraising', 'projects');
 }
Ejemplo n.º 26
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.º 27
0
 public function addPoint($location, $title = '', $windowContent = '', $isOpen = false)
 {
     if (!empty($location)) {
         $this->points[] = array('location' => $location, 'title' => UTIL_HtmlTag::stripJs($title), 'content' => UTIL_HtmlTag::stripJs($windowContent), 'isOpen' => (bool) $isOpen, 'icon' => GOOGLELOCATION_BOL_LocationService::getInstance()->getDefaultMarkerIcon());
     }
 }
Ejemplo n.º 28
0
 public function edit($params)
 {
     if (!isset($params['id']) || !($id = (int) $params['id'])) {
         throw new Redirect404Exception();
         return;
     }
     $catItem = EVENTX_BOL_EventService::getInstance()->findCategoryById($id);
     if (!$catItem) {
         throw new Redirect404Exception();
         return;
     }
     $categories = EVENTX_BOL_EventService::getInstance()->getCategoriesList(true);
     $adminForm = new Form('categoriesForm');
     $language = OW::getLanguage();
     $element = new TextField('categoryName');
     $element->setRequired();
     $element->setLabel($language->text('eventx', 'admin_category_name'));
     $element->setValue($catItem->name);
     $adminForm->addElement($element);
     $element = new TextField('categoryDesc');
     $element->setRequired();
     $element->setLabel($language->text('eventx', 'admin_category_desc'));
     $element->setValue($catItem->description);
     $adminForm->addElement($element);
     $element = new Submit('editCategory');
     $element->setValue($language->text('eventx', 'admin_edit_category'));
     $adminForm->addElement($element);
     if (OW::getRequest()->isPost()) {
         if ($adminForm->isValid($_POST)) {
             $values = $adminForm->getValues();
             $name = UTIL_HtmlTag::stripJs($values['categoryName']);
             $desc = UTIL_HtmlTag::stripJs($values['categoryDesc']);
             $catItem->name = $name;
             $catItem->description = $desc;
             if (EVENTX_BOL_EventService::getInstance()->addCategory($catItem)) {
                 OW::getFeedback()->info($language->text('eventx', 'admin_edit_category_success'));
             } else {
                 OW::getFeedback()->error($language->text('eventx', 'admin_edit_category_error'));
             }
         }
         $this->redirect(OW::getRouter()->urlForRoute('eventx_admin_categories'));
     }
     $this->addForm($adminForm);
     $this->setPageHeading(OW::getLanguage()->text('eventx', 'admin_edit_category_title'));
     $this->setPageTitle(OW::getLanguage()->text('eventx', 'admin_edit_category_title'));
     $this->setPageHeadingIconClass('ow_ic_gear_wheel');
 }
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
 /**
  * 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;
 }