Ejemplo n.º 1
0
 public function __construct(BASE_CLASS_WidgetParameter $param)
 {
     parent::__construct();
     $userId = $param->additionalParamList['entityId'];
     if (isset($param->customParamList['content'])) {
         $content = $param->customParamList['content'];
     } else {
         $settings = BOL_ComponentEntityService::getInstance()->findSettingList($param->widgetDetails->uniqName, $userId, array('content'));
         $content = empty($settings['content']) ? null : $settings['content'];
     }
     if ($param->additionalParamList['entityId'] == OW::getUser()->getId()) {
         $this->assign('ownerMode', true);
         $this->assign('noContent', $content === null);
         $this->addForm(new AboutMeForm($param->widgetDetails->uniqName, $content));
     } else {
         if (empty($content)) {
             $this->setVisible(false);
             return;
         }
         $this->assign('ownerMode', false);
         $content = htmlspecialchars($content);
         $content = UTIL_HtmlTag::autoLink($content);
         $this->assign('contentText', $content);
     }
 }
Ejemplo n.º 2
0
 public function beforeContentAdd(OW_Event $event)
 {
     $params = $event->getParams();
     $data = $event->getData();
     if (!empty($data)) {
         return;
     }
     if (empty($params["status"]) && empty($params["data"])) {
         $event->setData(false);
         return;
     }
     $attachId = null;
     $content = array();
     if (!empty($params["data"])) {
         $content = $params["data"];
         if ($content['type'] == 'photo' && !empty($content['genId'])) {
             $content['url'] = $content['href'] = OW::getEventManager()->call('base.attachment_save_image', array('genId' => $content['genId']));
             $attachId = $content['genId'];
         }
         if ($content['type'] == 'video') {
             $content['html'] = BOL_TextFormatService::getInstance()->validateVideoCode($content['html']);
         }
     }
     $status = UTIL_HtmlTag::autoLink($params["status"]);
     $out = NEWSFEED_BOL_Service::getInstance()->addStatus(OW::getUser()->getId(), $params['feedType'], $params['feedId'], $params['visibility'], $status, array("content" => $content, "attachmentId" => $attachId));
     $event->setData($out);
 }
Ejemplo n.º 3
0
 public function addAllGroupFeed()
 {
     if (OW::getConfig()->getValue('grouprss', 'disablePosting') == '1') {
         return;
     }
     $commentService = BOL_CommentService::getInstance();
     $newsfeedService = NEWSFEED_BOL_Service::getInstance();
     $router = OW::getRouter();
     $displayText = OW::getLanguage()->text('grouprss', 'feed_display_text');
     $location = OW::getConfig()->getValue('grouprss', 'postLocation');
     include_once 'autoloader.php';
     $allFeeds = $this->feeddao->findAll();
     foreach ($allFeeds as $feed) {
         $simplefeed = new SimplePie();
         $simplefeed->set_feed_url($feed->feedUrl);
         $simplefeed->set_stupidly_fast(true);
         $simplefeed->enable_cache(false);
         $simplefeed->init();
         $simplefeed->handle_content_type();
         $items = $simplefeed->get_items(0, $feed->feedCount);
         foreach ($items as $item) {
             $content = UTIL_HtmlTag::autoLink($item->get_content());
             if ($location == 'wall' && !$this->isDuplicateComment($feed->groupId, $content)) {
                 $commentService->addComment('groups_wal', $feed->groupId, 'groups', $feed->userId, $content);
             }
             if (trim($location) == 'newsfeed' && !$this->isDuplicateFeed($feed->groupId, $content)) {
                 $statusObject = $newsfeedService->saveStatus('groups', (int) $feed->groupId, $content);
                 $content = UTIL_HtmlTag::autoLink($content);
                 $action = new NEWSFEED_BOL_Action();
                 $action->entityId = $statusObject->id;
                 $action->entityType = "groups-status";
                 $action->pluginKey = "newsfeed";
                 $data = array("string" => $content, "content" => "[ph:attachment]", "view" => array("iconClass" => "ow_ic_comment"), "attachment" => array("oembed" => null, "url" => null, "attachId" => null), "data" => array("userId" => $feed->userId), "actionDto" => null, "context" => array("label" => $displayText, "url" => $router->urlForRoute('groups-view', array('groupId' => $feed->groupId))));
                 $action->data = json_encode($data);
                 $actionObject = $newsfeedService->saveAction($action);
                 $activity = new NEWSFEED_BOL_Activity();
                 $activity->activityType = NEWSFEED_BOL_Service::SYSTEM_ACTIVITY_CREATE;
                 $activity->activityId = $feed->userId;
                 $activity->actionId = $actionObject->id;
                 $activity->privacy = NEWSFEED_BOL_Service::PRIVACY_EVERYBODY;
                 $activity->userId = $feed->userId;
                 $activity->visibility = NEWSFEED_BOL_Service::VISIBILITY_FULL;
                 $activity->timeStamp = time();
                 $activity->data = json_encode(array());
                 $activityObject = $newsfeedService->saveActivity($activity);
                 $newsfeedService->addActivityToFeed($activity, 'groups', $feed->groupId);
             }
         }
         $simplefeed->__destruct();
         unset($feed);
     }
 }
Ejemplo n.º 4
0
 /**
  * @return BOL_Comment
  */
 public function addComment($entityType, $entityId, $pluginKey, $userId, $message, $attachment = null)
 {
     $commentEntity = $this->commentEntityDao->findByEntityTypeAndEntityId($entityType, $entityId);
     if ($commentEntity === null) {
         $commentEntity = new BOL_CommentEntity();
         $commentEntity->setEntityType(trim($entityType));
         $commentEntity->setEntityId((int) $entityId);
         $commentEntity->setPluginKey($pluginKey);
         $this->commentEntityDao->save($commentEntity);
     }
     //$message = UTIL_HtmlTag::stripTags($message, $this->configs[self::CONFIG_ALLOWED_TAGS], $this->configs[self::CONFIG_ALLOWED_ATTRS]);
     //$message = UTIL_HtmlTag::stripJs($message);
     //$message = UTIL_HtmlTag::stripTags($message, array('frame', 'style'), array(), true);
     if ($attachment !== null && strlen($message) == 0) {
         $message = '';
     } else {
         $message = UTIL_HtmlTag::autoLink(nl2br(htmlspecialchars($message)));
     }
     $comment = new BOL_Comment();
     $comment->setCommentEntityId($commentEntity->getId());
     $comment->setMessage(trim($message));
     $comment->setUserId($userId);
     $comment->setCreateStamp(time());
     if ($attachment !== null) {
         $comment->setAttachment($attachment);
     }
     $this->commentDao->save($comment);
     return $comment;
 }
Ejemplo n.º 5
0
 public function statusUpdate()
 {
     if (empty($_POST['status']) && empty($_FILES['attachment']["tmp_name"])) {
         $this->echoOut($_POST['feedAutoId'], array("error" => OW::getLanguage()->text('base', 'form_validate_common_error_message')));
     }
     if (!OW::getUser()->isAuthenticated()) {
         $this->echoOut($_POST['feedAutoId'], array("error" => "You need to sign in to post."));
     }
     $status = empty($_POST['status']) ? '' : strip_tags($_POST['status']);
     $content = array();
     if (!empty($_FILES['attachment']["tmp_name"])) {
         try {
             $attachment = BOL_AttachmentService::getInstance()->processPhotoAttachment("newsfeed", $_FILES['attachment']);
         } catch (InvalidArgumentException $ex) {
             $this->echoOut($_POST['feedAutoId'], array("error" => $ex->getMessage()));
         }
         $content = array("type" => "photo", "url" => $attachment["url"]);
     }
     $userId = OW::getUser()->getId();
     $event = new OW_Event("feed.before_content_add", array("feedType" => $_POST['feedType'], "feedId" => $_POST['feedId'], "visibility" => $_POST['visibility'], "userId" => $userId, "status" => $status, "type" => empty($content["type"]) ? "text" : $content["type"], "data" => $content));
     OW::getEventManager()->trigger($event);
     $data = $event->getData();
     if (!empty($data)) {
         $item = empty($data["entityType"]) || empty($data["entityId"]) ? null : array("entityType" => $data["entityType"], "entityId" => $data["entityId"]);
         $this->echoOut($_POST['feedAutoId'], array("item" => $item, "message" => empty($data["message"]) ? null : $data["message"], "error" => empty($data["error"]) ? null : $data["error"]));
     }
     $status = UTIL_HtmlTag::autoLink($status);
     $out = NEWSFEED_BOL_Service::getInstance()->addStatus(OW::getUser()->getId(), $_POST['feedType'], $_POST['feedId'], $_POST['visibility'], $status, array("content" => $content, "attachmentId" => $attachment["uid"]));
     $this->echoOut($_POST['feedAutoId'], array("item" => $out));
 }
Ejemplo n.º 6
0
 public function getUserViewQuestions($userId, $adminMode = false, $questionNames = array(), $sectionNames = null)
 {
     $questionService = BOL_QuestionService::getInstance();
     $user = BOL_UserService::getInstance()->findUserById($userId);
     $accountType = $user->accountType;
     $language = OW::getLanguage();
     if (empty($questionNames)) {
         if ($adminMode) {
             $questions = $questionService->findAllQuestionsForAccountType($accountType);
         } else {
             $questions = $questionService->findViewQuestionsForAccountType($accountType);
         }
     } else {
         $questions = $questionService->findQuestionByNameList($questionNames);
         foreach ($questions as &$q) {
             $q = (array) $q;
         }
     }
     $section = null;
     $questionArray = array();
     $questionNameList = array();
     foreach ($questions as $sort => $question) {
         if (!empty($sectionNames) && !in_array($question['sectionName'], $sectionNames)) {
             continue;
         }
         if ($section !== $question['sectionName']) {
             $section = $question['sectionName'];
         }
         $questions[$sort]['hidden'] = false;
         if (!$questions[$sort]['onView']) {
             $questions[$sort]['hidden'] = true;
         }
         $questionArray[$section][$sort] = $questions[$sort];
         $questionNameList[] = $questions[$sort]['name'];
     }
     $questionData = $questionService->getQuestionData(array($userId), $questionNameList);
     $questionLabelList = array();
     // add form fields
     foreach ($questionArray as $sectionKey => $section) {
         foreach ($section as $questionKey => $question) {
             $event = new OW_Event('base.questions_field_get_label', array('presentation' => $question['presentation'], 'fieldName' => $question['name'], 'configs' => $question['custom'], 'type' => 'view'));
             OW::getEventManager()->trigger($event);
             $label = $event->getData();
             $questionLabelList[$question['name']] = !empty($label) ? $label : BOL_QuestionService::getInstance()->getQuestionLang($question['name']);
             $event = new OW_Event('base.questions_field_get_value', array('presentation' => $question['presentation'], 'fieldName' => $question['name'], 'value' => empty($questionData[$userId][$question['name']]) ? null : $questionData[$userId][$question['name']], 'questionInfo' => $question, 'userId' => $userId));
             OW::getEventManager()->trigger($event);
             $eventValue = $event->getData();
             if (!empty($eventValue)) {
                 $questionData[$userId][$question['name']] = $eventValue;
                 continue;
             }
             if (!empty($questionData[$userId][$question['name']])) {
                 switch ($question['presentation']) {
                     case BOL_QuestionService::QUESTION_PRESENTATION_CHECKBOX:
                         if ((int) $questionData[$userId][$question['name']] === 1) {
                             $questionData[$userId][$question['name']] = OW::getLanguage()->text('base', 'yes');
                         } else {
                             unset($questionArray[$sectionKey][$questionKey]);
                         }
                         break;
                     case BOL_QuestionService::QUESTION_PRESENTATION_DATE:
                         $format = OW::getConfig()->getValue('base', 'date_field_format');
                         $value = 0;
                         switch ($question['type']) {
                             case BOL_QuestionService::QUESTION_VALUE_TYPE_DATETIME:
                                 $date = UTIL_DateTime::parseDate($questionData[$userId][$question['name']], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
                                 if (isset($date)) {
                                     $format = OW::getConfig()->getValue('base', 'date_field_format');
                                     $value = mktime(0, 0, 0, $date['month'], $date['day'], $date['year']);
                                 }
                                 break;
                             case BOL_QuestionService::QUESTION_VALUE_TYPE_SELECT:
                                 $value = (int) $questionData[$userId][$question['name']];
                                 break;
                         }
                         if ($format === 'dmy') {
                             $questionData[$userId][$question['name']] = date("d/m/Y", $value);
                         } else {
                             $questionData[$userId][$question['name']] = date("m/d/Y", $value);
                         }
                         break;
                     case BOL_QuestionService::QUESTION_PRESENTATION_BIRTHDATE:
                         $date = UTIL_DateTime::parseDate($questionData[$userId][$question['name']], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
                         $questionData[$userId][$question['name']] = UTIL_DateTime::formatBirthdate($date['year'], $date['month'], $date['day']);
                         break;
                     case BOL_QuestionService::QUESTION_PRESENTATION_AGE:
                         $date = UTIL_DateTime::parseDate($questionData[$userId][$question['name']], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
                         $questionData[$userId][$question['name']] = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']) . " " . $language->text('base', 'questions_age_year_old');
                         break;
                     case BOL_QuestionService::QUESTION_PRESENTATION_RANGE:
                         $range = explode('-', $questionData[$userId][$question['name']]);
                         $questionData[$userId][$question['name']] = $language->text('base', 'form_element_from') . " " . $range[0] . " " . $language->text('base', 'form_element_to') . " " . $range[1];
                         break;
                     case BOL_QuestionService::QUESTION_PRESENTATION_SELECT:
                     case BOL_QuestionService::QUESTION_PRESENTATION_RADIO:
                     case BOL_QuestionService::QUESTION_PRESENTATION_MULTICHECKBOX:
                         $value = "";
                         $multicheckboxValue = (int) $questionData[$userId][$question['name']];
                         $parentName = $question['name'];
                         if (!empty($question['parent'])) {
                             $parent = BOL_QuestionService::getInstance()->findQuestionByName($question['parent']);
                             if (!empty($parent)) {
                                 $parentName = $parent->name;
                             }
                         }
                         $questionValues = BOL_QuestionService::getInstance()->findQuestionValues($parentName);
                         $value = array();
                         foreach ($questionValues as $val) {
                             /* @var $val BOL_QuestionValue */
                             if ((int) $val->value & $multicheckboxValue) {
                                 /* if ( strlen($value) > 0 )
                                                                       {
                                                                       $value .= ', ';
                                                                       }
                                 
                                                                       $value .= $language->text('base', 'questions_question_' . $parentName . '_value_' . ($val->value)); */
                                 $value[$val->value] = BOL_QuestionService::getInstance()->getQuestionValueLang($val->questionName, $val->value);
                             }
                         }
                         if (!empty($value)) {
                             $questionData[$userId][$question['name']] = $value;
                         } else {
                             unset($questionArray[$sectionKey][$questionKey]);
                         }
                         break;
                     case BOL_QuestionService::QUESTION_PRESENTATION_URL:
                     case BOL_QuestionService::QUESTION_PRESENTATION_TEXT:
                     case BOL_QuestionService::QUESTION_PRESENTATION_TEXTAREA:
                         if (!is_string($questionData[$userId][$question['name']])) {
                             break;
                         }
                         $value = trim($questionData[$userId][$question['name']]);
                         if (strlen($value) > 0) {
                             $questionData[$userId][$question['name']] = UTIL_HtmlTag::autoLink(nl2br($value));
                         } else {
                             unset($questionArray[$sectionKey]);
                         }
                         break;
                     default:
                         unset($questionArray[$sectionKey][$questionKey]);
                 }
             } else {
                 unset($questionArray[$sectionKey][$questionKey]);
             }
         }
         if (isset($questionArray[$sectionKey]) && count($questionArray[$sectionKey]) === 0) {
             unset($questionArray[$sectionKey]);
         }
     }
     return array('questions' => $questionArray, 'data' => $questionData, 'labels' => $questionLabelList);
 }
Ejemplo n.º 7
0
 private function renderQuestion($userId, $questionName)
 {
     $language = OW::getLanguage();
     $questionData = BOL_QuestionService::getInstance()->getQuestionData(array($userId), array($questionName));
     if (!isset($questionData[$userId][$questionName])) {
         return null;
     }
     $question = BOL_QuestionService::getInstance()->findQuestionByName($questionName);
     switch ($question->presentation) {
         /*case BOL_QuestionService::QUESTION_PRESENTATION_CHECKBOX:
                         
                         if ( (int) $questionData[$userId][$question->name] === 1 )
                         {
                             $questionData[$userId][$question['name']] = $language->text('base', 'questions_checkbox_value_true');
                         }
                         else
                         {
                             $questionData[$userId][$question['name']] = $language->text('base', 'questions_checkbox_value_false');
                         }
         
                         break;*/
         case BOL_QuestionService::QUESTION_PRESENTATION_DATE:
             $format = OW::getConfig()->getValue('base', 'date_field_format');
             $value = 0;
             switch ($question->type) {
                 case BOL_QuestionService::QUESTION_VALUE_TYPE_DATETIME:
                     $date = UTIL_DateTime::parseDate($questionData[$userId][$question->name], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
                     if (isset($date)) {
                         $format = OW::getConfig()->getValue('base', 'date_field_format');
                         $value = mktime(0, 0, 0, $date['month'], $date['day'], $date['year']);
                     }
                     break;
                 case BOL_QuestionService::QUESTION_VALUE_TYPE_SELECT:
                     $value = (int) $questionData[$userId][$question->name];
                     break;
             }
             if ($format === 'dmy') {
                 $questionData[$userId][$question->name] = date("d/m/Y", $value);
             } else {
                 $questionData[$userId][$question->name] = date("m/d/Y", $value);
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_BIRTHDATE:
             $date = UTIL_DateTime::parseDate($questionData[$userId][$question->name], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             $questionData[$userId][$question->name] = UTIL_DateTime::formatBirthdate($date['year'], $date['month'], $date['day']);
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_AGE:
             $date = UTIL_DateTime::parseDate($questionData[$userId][$question->name], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             $questionData[$userId][$question->name] = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']) . " " . $language->text('base', 'questions_age_year_old');
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_RANGE:
             $range = explode('-', $questionData[$userId][$question->name]);
             $questionData[$userId][$question->name] = $language->text('base', 'form_element_from') . " " . $range[0] . " " . $language->text('base', 'form_element_to') . " " . $range[1];
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_SELECT:
         case BOL_QuestionService::QUESTION_PRESENTATION_RADIO:
         case BOL_QuestionService::QUESTION_PRESENTATION_MULTICHECKBOX:
             $value = "";
             $multicheckboxValue = (int) $questionData[$userId][$question->name];
             $questionValues = BOL_QuestionService::getInstance()->findQuestionValues($question->name);
             foreach ($questionValues as $val) {
                 /* @var $val BOL_QuestionValue */
                 if ((int) $val->value & $multicheckboxValue) {
                     if (strlen($value) > 0) {
                         $value .= ', ';
                     }
                     $value .= $language->text('base', 'questions_question_' . $question->name . '_value_' . $val->value);
                 }
             }
             if (strlen($value) > 0) {
                 $questionData[$userId][$question->name] = $value;
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_URL:
         case BOL_QuestionService::QUESTION_PRESENTATION_TEXT:
         case BOL_QuestionService::QUESTION_PRESENTATION_TEXTAREA:
             // googlemap_location shortcut
             if ($question->name == "googlemap_location" && !empty($questionData[$userId][$question->name]) && is_array($questionData[$userId][$question->name])) {
                 $mapData = $questionData[$userId][$question->name];
                 $value = trim($mapData["address"]);
             } else {
                 $value = trim($questionData[$userId][$question->name]);
             }
             if (strlen($value) > 0) {
                 $questionData[$userId][$question->name] = UTIL_HtmlTag::autoLink(nl2br($value));
             }
             break;
         default:
             $questionData[$userId][$question->name] = null;
     }
     return $questionData[$userId][$question->name];
 }
Ejemplo n.º 8
0
 public function splitLongMessages($string)
 {
     return $string;
     $split_length = 100;
     $delimiter = ' ';
     $string_array = explode(' ', $string);
     foreach ($string_array as $id => $word) {
         if (mb_strlen(trim($word)) > $split_length) {
             $originalWord = $word;
             $autoLinked = UTIL_HtmlTag::autoLink(trim($word));
             if (strlen($autoLinked) != strlen(trim($originalWord))) {
                 //                    $str = mb_substr($originalWord, $split_length);
                 //                    $str = $this->splitLongMessages($str);
                 $string_array[$id] = $originalWord;
                 // '<a href="'.$originalWord.'" target="_blank">'.mb_substr($originalWord, 7, $split_length) . $delimiter . $str."</a>";
             } else {
                 $str = mb_substr($word, $split_length);
                 $str = $this->splitLongMessages($str);
                 $string_array[$id] = mb_substr($word, 0, $split_length) . $delimiter . $str;
             }
         }
     }
     return implode(' ', $string_array);
 }
Ejemplo n.º 9
0
 public function statusUpdate()
 {
     if (empty($_POST['status']) && empty($_FILES['attachment']["tmp_name"])) {
         $this->echoOut($_POST['feedAutoId'], array("error" => OW::getLanguage()->text('base', 'form_validate_common_error_message')));
     }
     if (!OW::getUser()->isAuthenticated()) {
         $this->echoOut($_POST['feedAutoId'], array("error" => "You need to sign in to post."));
     }
     $status = empty($_POST['status']) ? '' : strip_tags($_POST['status']);
     $content = array();
     if (!empty($_FILES['attachment']["tmp_name"])) {
         try {
             $attachment = BOL_AttachmentService::getInstance()->processPhotoAttachment($_FILES['attachment']);
         } catch (InvalidArgumentException $ex) {
             $this->echoOut($_POST['feedAutoId'], array("error" => $ex->getMessage()));
         }
         $content = array("type" => "photo", "url" => $attachment["url"]);
     }
     $status = UTIL_HtmlTag::autoLink($status);
     $out = NEWSFEED_BOL_Service::getInstance()->addStatus(OW::getUser()->getId(), $_POST['feedType'], $_POST['feedId'], $_POST['visibility'], $status, array("content" => $content, "attachmentId" => $attachment["genId"]));
     $this->echoOut($_POST['feedAutoId'], $out);
 }
Ejemplo n.º 10
0
 public function __construct(array $params)
 {
     parent::__construct();
     $id = $params['videoId'];
     $this->clipService = VIDEO_BOL_ClipService::getInstance();
     $clip = $this->clipService->findClipById($id);
     if (!$clip) {
         throw new Redirect404Exception();
     }
     $contentOwner = (int) $this->clipService->findClipOwner($id);
     $language = OW_Language::getInstance();
     $description = $clip->description;
     $clip->description = UTIL_HtmlTag::autoLink($clip->description);
     $this->assign('clip', $clip);
     $is_featured = VIDEO_BOL_ClipFeaturedService::getInstance()->isFeatured($clip->id);
     $this->assign('featured', $is_featured);
     // is moderator
     $modPermissions = OW::getUser()->isAuthorized('video');
     $this->assign('moderatorMode', $modPermissions);
     $userId = OW::getUser()->getId();
     $ownerMode = $contentOwner == $userId;
     $this->assign('ownerMode', $ownerMode);
     if (!$ownerMode && !OW::getUser()->isAuthorized('video', 'view') && !$modPermissions) {
         $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
         return;
     }
     $this->assign('auth_msg', null);
     // permissions check
     if (!$ownerMode && !$modPermissions) {
         $privacyParams = array('action' => 'video_view_video', 'ownerId' => $contentOwner, 'viewerId' => $userId);
         $event = new OW_Event('privacy_check_permission', $privacyParams);
         OW::getEventManager()->trigger($event);
     }
     $cmtParams = new BASE_CommentsParams('video', 'video_comments');
     $cmtParams->setEntityId($id);
     $cmtParams->setOwnerId($contentOwner);
     $cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST);
     $videoCmts = new BASE_CMP_Comments($cmtParams);
     $this->addComponent('comments', $videoCmts);
     $videoRates = new BASE_CMP_Rate('video', 'video_rates', $id, $contentOwner);
     $this->addComponent('rate', $videoRates);
     $videoTags = new BASE_CMP_EntityTagCloud('video');
     $videoTags->setEntityId($id);
     $videoTags->setRouteName('view_tagged_list');
     $this->addComponent('tags', $videoTags);
     $this->assign('canEdit', false);
     $this->assign('canReport', false);
     $this->assign('canMakeFeature', false);
     OW::getLanguage()->addKeyForJs('video', 'tb_edit_clip');
     OW::getLanguage()->addKeyForJs('video', 'confirm_delete');
     OW::getLanguage()->addKeyForJs('video', 'mark_featured');
     OW::getLanguage()->addKeyForJs('video', 'remove_from_featured');
     OW::getLanguage()->addKeyForJs('base', 'approve');
     OW::getLanguage()->addKeyForJs('base', 'disapprove');
     $toolbar = array();
     $toolbarEvent = new BASE_CLASS_EventCollector('video.collect_video_toolbar_items', array('clipId' => $clip->id, 'clipDto' => $clip));
     OW::getEventManager()->trigger($toolbarEvent);
     foreach ($toolbarEvent->getData() as $toolbarItem) {
         array_push($toolbar, $toolbarItem);
     }
     if (OW::getUser()->isAuthenticated() && !$ownerMode) {
         array_push($toolbar, array('href' => 'javascript://', 'id' => 'btn-video-flag', 'label' => $language->text('base', 'flag')));
         $this->assign('canReport', true);
     }
     if ($ownerMode || $modPermissions) {
         array_push($toolbar, array('href' => OW::getRouter()->urlForRoute('edit_clip', array('id' => $clip->id)), 'label' => $language->text('base', 'edit')));
         array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-delete', 'label' => $language->text('base', 'delete')));
         $this->assign('canEdit', true);
     }
     if ($modPermissions) {
         if ($is_featured) {
             array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-mark-featured', 'rel' => 'remove_from_featured', 'label' => $language->text('video', 'remove_from_featured')));
             $this->assign('isFeature', true);
         } else {
             array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-mark-featured', 'rel' => 'mark_featured', 'label' => $language->text('video', 'mark_featured')));
             $this->assign('isFeature', false);
         }
         $this->assign('canMakeFeature', true);
         /*
         if ( $clip->status == 'approved' )
         {
             array_push($toolbar, array(
                 'href' => 'javascript://',
                 'id' => 'clip-set-approval-staus',
                 'rel' => 'disapprove',
                 'label' => $language->text('base', 'disapprove')
             ));
         }
         else
         {
             array_push($toolbar, array(
                 'href' => 'javascript://',
                 'id' => 'clip-set-approval-staus',
                 'rel' => 'approve',
                 'label' => $language->text('base', 'approve')
             ));
         }
         */
     }
     $this->assign('toolbar', $toolbar);
     /*
             $js = UTIL_JsGenerator::newInstance()
                     ->jQueryEvent('#btn-video-flag', 'click', 'OW.flagContent(e.data.entity, e.data.id, e.data.title, e.data.href, "video+flags");', array('e'),
                         array('entity' => 'video_clip', 'id' => $clip->id, 'title' => $clip->title, 'href' => OW::getRouter()->urlForRoute('view_clip', array('id' => $clip->id))
                     ));
     
             OW::getDocument()->addOnloadScript($js, 1001);
     */
     //avatar
     $avatar = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($contentOwner), true, true, true, false);
     $this->assign('avatar', $avatar[$contentOwner]);
     /*
             $config = OW::getConfig();
             $lang = OW::getLanguage();
     
             $this->videoService = VIDEO_BOL_VideoService::getInstance();
             $this->videoAlbumService = VIDEO_BOL_VideoAlbumService::getInstance();
     
             $video = $this->videoService->findVideoById($videoId);
             $album = $this->videoAlbumService->findAlbumById($video->albumId);
             $this->assign('album', $album);
     $this->assign('video', $video);
     
             // is owner
             $contentOwner = $this->videoService->findVideoOwner($video->id);
             $userId = OW::getUser()->getId();
             $ownerMode = $contentOwner == $userId;
             $this->assign('ownerMode', $ownerMode);
     
             // is moderator
             $modPermissions = OW::getUser()->isAuthorized('video');
             $this->assign('moderatorMode', $modPermissions);
     
             $canView = true;
             if ( !$ownerMode && !$modPermissions && !OW::getUser()->isAuthorized('video', 'view') )
             {
                 $canView = false;
             }
     
             $this->assign('canView', $canView);
     $this->assign('canDownload', $config->getValue('gvideoviewer', 'can_users_to_download_videos'));
     
             $cmtParams = new BASE_CommentsParams('video', 'video_comments');
             $cmtParams->setEntityId($video->id);
             $cmtParams->setOwnerId($contentOwner);
             $cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST);
     
             $videoCmts = new BASE_CMP_Comments($cmtParams);
             $this->addComponent('comments', $videoCmts);
     
             $videoRates = new BASE_CMP_Rate('video', 'video_rates', $video->id, $contentOwner);
             $this->addComponent('rate', $videoRates);
     
             $videoTags = new BASE_CMP_EntityTagCloud('video');
             $videoTags->setEntityId($video->id);
             $videoTags->setRouteName('view_tagged_video_list');
             $this->addComponent('tags', $videoTags);
     
             $description = $video->description;
             $video->description = UTIL_HtmlTag::autoLink($video->description);
     
             $this->assign('video', $video);
             $this->assign('url', $this->videoService->getVideoUrl($video->id));
             $this->assign('ownerName', BOL_UserService::getInstance()->getUserName($album->userId));
     
             $is_featured = VIDEO_BOL_VideoFeaturedService::getInstance()->isFeatured($video->id);
     
             if ( (int) $config->getValue('video', 'store_fullsize') && $video->hasFullsize )
             {
                 $this->assign('fullsizeUrl', $this->videoService->getVideoFullsizeUrl($video->id));
             }
             else
             {
                 $this->assign('fullsizeUrl', null);
             }
     
             $action = new BASE_ContextAction();
             $action->setKey('video-moderate');
     
             $context = new BASE_CMP_ContextAction();
             $context->addAction($action);
     
             $contextEvent = new BASE_CLASS_EventCollector('video.collect_video_context_actions', array(
                 'videoId' => $videoId,
                 'videoDto' => $video
             ));
     
             OW::getEventManager()->trigger($contextEvent);
     $this->assign('canEdit', false);
     $this->assign('canReport', false);
     $this->assign('canMakeFeature', false);
             foreach ( $contextEvent->getData() as $contextAction )
             {
     	
                 $action = new BASE_ContextAction();
                 $action->setKey(empty($contextAction['key']) ? uniqid() : $contextAction['key']);
                 $action->setParentKey('video-moderate');
                 $action->setLabel($contextAction['label']);
     
                 if ( !empty($contextAction['id']) )
                 {
                     $action->setId($contextAction['id']);
                 }
     
                 if ( !empty($contextAction['order']) )
                 {
                     $action->setOrder($contextAction['order']);
                 }
     
                 if ( !empty($contextAction['class']) )
                 {
                     $action->setClass($contextAction['class']);
                 }
     
                 if ( !empty($contextAction['url']) )
                 {
                     $action->setUrl($contextAction['url']);
                 }
     
                 $attributes = empty($contextAction['attributes']) ? array() : $contextAction['attributes'];
                 foreach ( $attributes as $key => $value )
                 {
                     $action->addAttribute($key, $value);
                 }
     
                 $context->addAction($action);
             }
     
             if ( $userId && !$ownerMode )
             {
                 $action = new BASE_ContextAction();
                 $action->setKey('flag');
                 $action->setParentKey('video-moderate');
                 $action->setLabel($lang->text('base', 'flag'));
                 $action->setId('btn-video-flag');
                 $action->addAttribute('rel', $videoId);
                 $action->addAttribute('url', OW::getRouter()->urlForRoute('view_video', array('id' => $video->id)));
     
                 $context->addAction($action);
     	$this->assign('canReport', true);
             }
     
             if ( $ownerMode || $modPermissions )
             {
                 $action = new BASE_ContextAction();
                 $action->setKey('edit');
                 $action->setParentKey('video-moderate');
                 $action->setLabel($lang->text('base', 'edit'));
                 $action->setId('btn-video-edit');
                 $action->addAttribute('rel', $videoId);
     
                 $context->addAction($action);
     
                 $action = new BASE_ContextAction();
                 $action->setKey('delete');
                 $action->setParentKey('video-moderate');
                 $action->setLabel($lang->text('base', 'delete'));
                 $action->setId('video-delete');
                 $action->addAttribute('rel', $videoId);
     
                 $context->addAction($action);
     	
     	$this->assign('canEdit', true);
             }
     
             if ( $modPermissions )
             {
                 if ( $is_featured )
                 {
                     $action = new BASE_ContextAction();
                     $action->setKey('unmark-featured');
                     $action->setParentKey('video-moderate');
                     $action->setLabel($lang->text('video', 'remove_from_featured'));
                     $action->setId('video-mark-featured');
                     $action->addAttribute('rel', 'remove_from_featured');
                     $action->addAttribute('video-id', $videoId);
     
                     $context->addAction($action);
     		$this->assign('isFeature', true);
                 }
                 else
                 {
                     $action = new BASE_ContextAction();
                     $action->setKey('mark-featured');
                     $action->setParentKey('video-moderate');
                     $action->setLabel($lang->text('video', 'mark_featured'));
                     $action->setId('video-mark-featured');
                     $action->addAttribute('rel', 'mark_featured');
                     $action->addAttribute('video-id', $videoId);
     
                     $context->addAction($action);
     		$this->assign('isFeature', false);
                 }
     	$this->assign('canMakeFeature', true);
             }
     
             $this->addComponent('contextAction', $context);
             $avatar = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($contentOwner), true, true, true, false);
             $this->assign('avatar', $avatar[$contentOwner]);
     */
 }
Ejemplo n.º 11
0
/**
 * Smarty date modifier.
 *
 * @author Kambalin Sergey <*****@*****.**>
 * @package ow.ow_smarty.plugin
 * @since 1.0
 */
function smarty_modifier_autolink($string)
{
    return UTIL_HtmlTag::autoLink($string);
}
Ejemplo n.º 12
0
 public function addQuestion()
 {
     if (!OW::getRequest()->isAjax()) {
         throw new Redirect404Exception();
     }
     if (!OW::getUser()->isAuthenticated()) {
         echo json_encode(false);
         exit;
     }
     if (empty($_POST['question'])) {
         echo json_encode(false);
         exit;
     }
     $question = empty($_POST['question']) ? '' : strip_tags($_POST['question']);
     $question = UTIL_HtmlTag::autoLink($question);
     $answers = empty($_POST['answers']) ? array() : array_filter($_POST['answers'], 'trim');
     $allowAddOprions = !empty($_POST['allowAddOprions']);
     $userId = OW::getUser()->getId();
     $questionDto = $this->service->addQuestion($userId, $question, array('allowAddOprions' => $allowAddOprions));
     foreach ($answers as $ans) {
         $this->service->addOption($questionDto->id, $userId, $ans);
     }
     $event = new OW_Event('feed.action', array('entityType' => QUESTIONS_BOL_Service::ENTITY_TYPE, 'entityId' => $questionDto->id, 'pluginKey' => 'questions', 'userId' => $userId, 'visibility' => 15));
     OW::getEventManager()->trigger($event);
     $activityList = QUESTIONS_BOL_FeedService::getInstance()->findMainActivity(time(), array($questionDto->id), array(0, 6));
     $cmp = new QUESTIONS_CMP_FeedItem($questionDto, reset($activityList[$questionDto->id]), $activityList[$questionDto->id]);
     $html = $cmp->render();
     $script = OW::getDocument()->getOnloadScript();
     echo json_encode(array('markup' => array('html' => $html, 'script' => $script, 'position' => 'prepend')));
     exit;
 }
Ejemplo n.º 13
0
 public function view($params)
 {
     $event = $this->getEventForParams($params);
     $cmpId = UTIL_HtmlTag::generateAutoId('cmp');
     $this->assign('contId', $cmpId);
     $language = OW::getLanguage();
     if (!OW::getUser()->isAuthorized('eventx', 'view_event') && $event->getUserId() != OW::getUser()->getId()) {
         $this->assign('authErrorText', OW::getLanguage()->text('eventx', 'event_view_permission_error_message'));
         return;
     }
     // guest gan't view private events
     if ((int) $event->getWhoCanView() === EVENTX_BOL_EventService::CAN_VIEW_INVITATION_ONLY && !OW::getUser()->isAuthenticated()) {
         $this->redirect(OW::getRouter()->urlForRoute('eventx.private_event', array('eventId' => $event->getId())));
     }
     $eventInvite = $this->eventService->findEventInvite($event->getId(), OW::getUser()->getId());
     $eventUser = $this->eventService->findEventUser($event->getId(), OW::getUser()->getId());
     // check if user can view event
     if ((int) $event->getWhoCanView() === EVENTX_BOL_EventService::CAN_VIEW_INVITATION_ONLY && $eventUser === null && $eventInvite === null && !OW::getUser()->isAuthorized('eventx')) {
         $this->redirect(OW::getRouter()->urlForRoute('eventx.private_event', array('eventId' => $event->getId())));
     }
     $modPermissions = OW::getUser()->isAuthorized('eventx');
     $ownerMode = $event->getUserId() == OW::getUser()->getId();
     $whoCanDeleteEvent = explode(",", OW::getConfig()->getValue('eventx', 'eventDelete'));
     $toolbar = array();
     if (OW::getUser()->isAuthenticated()) {
         array_push($toolbar, array('href' => 'javascript://', 'id' => 'btn-eventx-flag', 'label' => OW::getLanguage()->text('base', 'flag')));
     }
     if ($ownerMode || $modPermissions) {
         array_push($toolbar, array('href' => OW::getRouter()->urlForRoute('eventx.edit', array('eventId' => $event->getId())), 'label' => OW::getLanguage()->text('eventx', 'edit_button_label')));
     }
     if ($modPermissions) {
         if ($event->status == 'approved') {
             array_push($toolbar, array('href' => 'javascript://', 'id' => 'eventx-set-approval-staus', 'rel' => 'disapprove', 'label' => $language->text('base', 'disapprove')));
         } else {
             array_push($toolbar, array('href' => 'javascript://', 'id' => 'eventx-set-approval-staus', 'rel' => 'approve', 'label' => $language->text('base', 'approve')));
         }
     }
     $canDelete = FALSE;
     if ($ownerMode && in_array(3, $whoCanDeleteEvent)) {
         $canDelete = TRUE;
     }
     if (OW::getUser()->isAuthorized('eventx') && in_array(2, $whoCanDeleteEvent)) {
         $canDelete = TRUE;
     }
     if (OW::getUser()->isAdmin() && in_array(1, $whoCanDeleteEvent)) {
         $canDelete = TRUE;
     }
     if ($canDelete) {
         array_push($toolbar, array('href' => 'javascript://', 'id' => 'eventx-delete', 'label' => OW::getLanguage()->text('eventx', 'delete_button_label')));
     }
     $this->assign('toolbar', $toolbar);
     OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'eventx', 'main_menu_item');
     $this->setPageHeading($event->getTitle());
     $this->setPageTitle(OW::getLanguage()->text('eventx', 'event_view_page_heading', array('event_title' => $event->getTitle())));
     $this->setPageHeadingIconClass('ow_ic_calendar');
     OW::getDocument()->setDescription(UTIL_String::truncate(strip_tags($event->getDescription()), 200, '...'));
     $maxInvites = $event->getMaxInvites();
     $currentInvites = $this->eventService->findEventUsersCount($event->getId(), EVENTX_BOL_EventService::USER_STATUS_YES);
     $isFullyBooked = $currentInvites >= $maxInvites && $maxInvites > 0;
     $infoArray = array('id' => $event->getId(), 'image' => $event->getImage() ? $this->eventService->generateImageUrl($event->getImage(), false) : null, 'date' => $this->eventService->formatSimpleDate($event->getStartTimeStamp(), $event->getStartTimeDisable()), 'endDate' => $event->getEndTimeStamp() === null || !$event->getEndDateFlag() ? null : $this->eventService->formatSimpleDate($event->getEndTimeDisable() ? strtotime("-1 day", $event->getEndTimeStamp()) : $event->getEndTimeStamp(), $event->getEndTimeDisable()), 'location' => $event->getLocation(), 'desc' => UTIL_HtmlTag::autoLink($event->getDescription()), 'title' => $event->getTitle(), 'maxInvites' => $maxInvites, 'currentInvites' => $currentInvites, 'availableInvites' => $maxInvites - $currentInvites, 'creatorName' => BOL_UserService::getInstance()->getDisplayName($event->getUserId()), 'creatorLink' => BOL_UserService::getInstance()->getUserUrl($event->getUserId()));
     $this->assign('info', $infoArray);
     // event attend form
     if (OW::getUser()->isAuthenticated() && $event->getEndTimeStamp() > time()) {
         if ($eventUser !== null) {
             $this->assign('currentStatus', OW::getLanguage()->text('eventx', 'user_status_label_' . $eventUser->getStatus()));
         }
         $this->addForm(new AttendForm($event->getId(), $cmpId));
         $onloadJs = "\n                var \$context = \$('#" . $cmpId . "');";
         $onloadJs .= " \$('#event_attend_yes_btn').click(\n                    function(){\n                        \$('input[name=attend_status]', \$context).val(" . EVENTX_BOL_EventService::USER_STATUS_YES . ");\n                    }\n                );\n                \n                \$('#event_attend_maybe_btn').click(\n                    function(){\n                        \$('input[name=attend_status]', \$context).val(" . EVENTX_BOL_EventService::USER_STATUS_MAYBE . ");\n                    }\n                );\n                \$('#event_attend_no_btn').click(\n                    function(){\n                        \$('input[name=attend_status]', \$context).val(" . EVENTX_BOL_EventService::USER_STATUS_NO . ");\n                    }\n                );\n\n                \$('.current_status a', \$context).click(\n                    function(){\n                        \$('.attend_buttons .buttons', \$context).fadeIn(500);\n                    }\n                );\n            ";
         OW::getDocument()->addOnloadScript($onloadJs);
     } else {
         $this->assign('no_attend_form', true);
     }
     if ($event->getEndTimeStamp() > time() && ((int) $event->getUserId() === OW::getUser()->getId() || (int) $event->getWhoCanInvite() === EVENTX_BOL_EventService::CAN_INVITE_PARTICIPANT && $eventUser !== null)) {
         $params = array($event->id);
         $this->assign('inviteLink', true);
         OW::getDocument()->addOnloadScript("\n                var eventFloatBox;\n                \$('#inviteLink', \$('#" . $cmpId . "')).click(\n                    function(){\n                        eventFloatBox = OW.ajaxFloatBox('EVENTX_CMP_InviteUserListSelect', " . json_encode($params) . ", {width:600, height:400, iconClass: 'ow_ic_user', title: '" . OW::getLanguage()->text('eventx', 'friends_invite_button_label') . "'});\n                    }\n                );\n                OW.bind('base.avatar_user_list_select',\n                    function(list){\n                        eventFloatBox.close();\n                        \$.ajax({\n                            type: 'POST',\n                            url: " . json_encode(OW::getRouter()->urlFor('EVENTX_CTRL_Base', 'inviteResponder')) . ",\n                            data: 'eventId=" . json_encode($event->getId()) . "&userIdList='+JSON.stringify(list),\n                            dataType: 'json',\n                            success : function(data){\n                                if( data.messageType == 'error' ){\n                                    OW.error(data.message);\n                                }\n                                else{\n                                    OW.info(data.message);\n                                }\n                            },\n                            error : function( XMLHttpRequest, textStatus, errorThrown ){\n                                OW.error(textStatus);\n                            }\n                        });\n                    }\n                );\n            ");
     }
     $cmntParams = new BASE_CommentsParams('eventx', 'eventx');
     $cmntParams->setEntityId($event->getId());
     $cmntParams->setOwnerId($event->getUserId());
     $this->addComponent('comments', new BASE_CMP_Comments($cmntParams));
     $this->addComponent('userListCmp', new EVENTX_CMP_EventUsers($event->getId()));
     $tagCloud = new BASE_CMP_EntityTagCloud('eventx');
     $tagCloud->setEntityId($event->id);
     $tagCloud->setRouteName('eventx_view_tagged_list');
     $this->addComponent('tagCloud', $tagCloud);
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin("eventx")->getStaticJsUrl() . 'eventx.js');
     OW::getDocument()->addScript("http://maps.google.com/maps/api/js?sensor=false");
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin("eventx")->getStaticJsUrl() . 'jquery.gmap.min.js');
     $objParams = array('ajaxResponder' => $this->ajaxResponder, 'id' => $event->getId(), 'txtDelConfirm' => $language->text('eventx', 'confirm_delete'), 'txtApprove' => $language->text('base', 'approve'), 'txtDisapprove' => $language->text('base', 'disapprove'));
     $script = "\$(document).ready(function(){\n                   var item = new eventxItem( " . json_encode($objParams) . ");\n                 });";
     OW::getDocument()->addOnloadScript($script);
     $js = UTIL_JsGenerator::newInstance()->jQueryEvent('#btn-eventx-flag', 'click', 'OW.flagContent(e.data.entity, e.data.id, e.data.title, e.data.href, "eventx+flags");', array('e'), array('entity' => 'eventx_event', 'id' => $event->getId(), 'title' => $event->getTitle(), 'href' => OW::getRouter()->urlForRoute('eventx.view', array('eventId' => $event->getId()))));
     OW::getDocument()->addOnloadScript($js, 1001);
     $categoryList = $this->eventService->getItemCategories($event->id);
     $i = 0;
     $categoryUrlList = array();
     foreach ($categoryList as $category) {
         $catName = $this->eventService->getCategoryName($category->categoryId);
         $categoryUrlList[$i]['id'] = $category->categoryId;
         $categoryUrlList[$i]['name'] = $catName;
         $categoryUrlList[$i]['url'] = OW::getRouter()->urlForRoute('eventx_category_items', array('category' => $catName));
         $i += 1;
     }
     $this->assign('categoryUrl', $categoryUrlList);
     $this->assign('mapWidth', OW::getConfig()->getValue('eventx', 'mapWidth'));
     $this->assign('mapHeight', OW::getConfig()->getValue('eventx', 'mapHeight'));
 }
Ejemplo n.º 14
0
 /**
  * Video view action
  *
  * @param array $params
  * @throws Redirect404Exception
  */
 public function view(array $params)
 {
     if (!isset($params['id']) || !($id = (int) $params['id'])) {
         throw new Redirect404Exception();
     }
     $clip = $this->clipService->findClipById($id);
     if (!$clip) {
         throw new Redirect404Exception();
     }
     $userId = OW::getUser()->getId();
     $contentOwner = (int) $this->clipService->findClipOwner($id);
     $ownerMode = $contentOwner == $userId;
     // is moderator
     $modPermissions = OW::getUser()->isAuthorized('video');
     if ($clip->status != "approved" && !($modPermissions || $ownerMode)) {
         throw new Redirect403Exception();
     }
     $language = OW_Language::getInstance();
     $description = $clip->description;
     $clip->description = UTIL_HtmlTag::autoLink($clip->description);
     $this->assign('clip', $clip);
     $is_featured = VIDEO_BOL_ClipFeaturedService::getInstance()->isFeatured($clip->id);
     $this->assign('featured', $is_featured);
     $this->assign('moderatorMode', $modPermissions);
     $this->assign('ownerMode', $ownerMode);
     if (!$ownerMode && !OW::getUser()->isAuthorized('video', 'view') && !$modPermissions) {
         $error = BOL_AuthorizationService::getInstance()->getActionStatus('video', 'view');
         throw new AuthorizationException($error['msg']);
     }
     // permissions check
     if (!$ownerMode && !$modPermissions) {
         $privacyParams = array('action' => 'video_view_video', 'ownerId' => $contentOwner, 'viewerId' => $userId);
         $event = new OW_Event('privacy_check_permission', $privacyParams);
         OW::getEventManager()->trigger($event);
     }
     $cmtParams = new BASE_CommentsParams('video', 'video_comments');
     $cmtParams->setEntityId($id);
     $cmtParams->setOwnerId($contentOwner);
     $cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST);
     $cmtParams->setAddComment($clip->status == "approved");
     $videoCmts = new BASE_CMP_Comments($cmtParams);
     $this->addComponent('comments', $videoCmts);
     if ($clip->status == "approved") {
         $videoRates = new BASE_CMP_Rate('video', 'video_rates', $id, $contentOwner);
         $this->addComponent('rate', $videoRates);
     }
     $videoTags = new BASE_CMP_EntityTagCloud('video');
     $videoTags->setEntityId($id);
     $videoTags->setRouteName('view_tagged_list');
     $this->addComponent('tags', $videoTags);
     $username = BOL_UserService::getInstance()->getUserName($clip->userId);
     $this->assign('username', $username);
     $displayName = BOL_UserService::getInstance()->getDisplayName($clip->userId);
     $this->assign('displayName', $displayName);
     OW::getDocument()->addScript($this->pluginJsUrl . 'video.js');
     $objParams = array('ajaxResponder' => $this->ajaxResponder, 'clipId' => $id, 'txtDelConfirm' => OW::getLanguage()->text('video', 'confirm_delete'), 'txtMarkFeatured' => OW::getLanguage()->text('video', 'mark_featured'), 'txtRemoveFromFeatured' => OW::getLanguage()->text('video', 'remove_from_featured'), 'txtApprove' => OW::getLanguage()->text('base', 'approve'), 'txtDisapprove' => OW::getLanguage()->text('base', 'disapprove'));
     $script = "\$(document).ready(function(){\n                var clip = new videoClip( " . json_encode($objParams) . ");\n            }); ";
     OW::getDocument()->addOnloadScript($script);
     $pendingApprovalString = "";
     if ($clip->status != "approved") {
         $pendingApprovalString = '<span class="ow_remark ow_small">(' . OW::getLanguage()->text("base", "pending_approval") . ')</span>';
     }
     OW::getDocument()->setHeading($clip->title . " " . $pendingApprovalString);
     OW::getDocument()->setHeadingIconClass('ow_ic_video');
     $toolbar = array();
     $toolbarEvent = new BASE_CLASS_EventCollector('video.collect_video_toolbar_items', array('clipId' => $clip->id, 'clipDto' => $clip));
     OW::getEventManager()->trigger($toolbarEvent);
     foreach ($toolbarEvent->getData() as $toolbarItem) {
         array_push($toolbar, $toolbarItem);
     }
     if ($clip->status == "approved" && OW::getUser()->isAuthenticated() && !$ownerMode) {
         array_push($toolbar, array('href' => 'javascript://', 'id' => 'btn-video-flag', 'label' => $language->text('base', 'flag')));
     }
     if ($ownerMode || $modPermissions) {
         array_push($toolbar, array('href' => OW::getRouter()->urlForRoute('edit_clip', array('id' => $clip->id)), 'label' => $language->text('base', 'edit')));
         array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-delete', 'label' => $language->text('base', 'delete')));
     }
     if ($modPermissions) {
         if ($is_featured) {
             array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-mark-featured', 'rel' => 'remove_from_featured', 'label' => $language->text('video', 'remove_from_featured')));
         } else {
             array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-mark-featured', 'rel' => 'mark_featured', 'label' => $language->text('video', 'mark_featured')));
         }
         if ($clip->status != 'approved') {
             array_push($toolbar, array('href' => OW::getRouter()->urlFor(__CLASS__, "approve", array("clipId" => $clip->id)), 'label' => $language->text('base', 'approve'), "class" => "ow_green"));
         }
     }
     $this->assign('toolbar', $toolbar);
     $js = UTIL_JsGenerator::newInstance()->jQueryEvent('#btn-video-flag', 'click', 'OW.flagContent(e.data.entity, e.data.id);', array('e'), array('entity' => VIDEO_BOL_ClipService::ENTITY_TYPE, 'id' => $clip->id));
     OW::getDocument()->addOnloadScript($js, 1001);
     OW::getDocument()->setTitle($language->text('video', 'meta_title_video_view', array('title' => $clip->title)));
     $tagsArr = BOL_TagService::getInstance()->findEntityTags($clip->id, 'video');
     $labels = array();
     foreach ($tagsArr as $t) {
         $labels[] = $t->label;
     }
     $tagStr = $tagsArr ? implode(', ', $labels) : '';
     OW::getDocument()->setDescription($language->text('video', 'meta_description_video_view', array('title' => $clip->title, 'tags' => $tagStr)));
     $clipThumbUrl = $this->clipService->getClipThumbUrl($id);
     $this->assign('clipThumbUrl', $clipThumbUrl);
 }
Ejemplo n.º 15
0
 /**
  * Displays mailbox conversation page
  */
 public function conversation($params)
 {
     $userId = OW::getUser()->getId();
     if (!OW::getUser()->isAuthenticated() || $userId === null) {
         throw new AuthenticateException();
         // TODO: Redirect to login page
     }
     $conversation = null;
     $conversationService = MAILBOX_BOL_ConversationService::getInstance();
     $userService = BOL_UserService::getInstance();
     if (empty($params['conversationId'])) {
         throw new AuthenticateException();
     }
     $conversationId = (int) $params['conversationId'];
     $conversation = $conversationService->getConversation($conversationId);
     if ($conversation === null) {
         throw new Redirect404Exception();
     }
     $lastMessages = $conversationService->getLastMessages($conversationId);
     if ($lastMessages === null) {
         throw new Redirect404Exception();
     }
     $conversationService->markRead(array($conversation->id), $userId);
     $language = OW::getLanguage();
     $addMessageForm = new AddMessageForm();
     $this->addForm($addMessageForm);
     if (OW::getRequest()->isPost()) {
         switch ($userId) {
             case $conversation->initiatorId:
                 $blockedByUserId = $conversation->interlocutorId;
                 break;
             case $conversation->interlocutorId:
                 $blockedByUserId = $conversation->initiatorId;
                 break;
         }
         if (BOL_UserService::getInstance()->isBlocked($userId, $blockedByUserId)) {
             OW::getFeedback()->error(OW::getLanguage()->text('base', 'user_block_message'));
         } else {
             if ($addMessageForm->isValid($_POST)) {
                 $res = $addMessageForm->process($conversation, $userId);
                 if (!$res['result'] && !empty($res['error'])) {
                     OW::getFeedback()->warning($res['error']);
                 }
                 $this->redirect();
             } else {
                 OW::getFeedback()->error($language->text('base', 'form_validate_common_error_message'));
             }
         }
     }
     $conversationArray = array();
     $conversationArray["conversationId"] = $conversation->id;
     $conversationArray["subject"] = $conversation->subject;
     if (!empty($_GET['redirectTo']) && $_GET['redirectTo'] === MAILBOX_CTRL_Mailbox::REDIRECT_TO_SENT) {
         $conversationArray["deleteUrl"] = OW::getRouter()->urlFor('MAILBOX_CTRL_Mailbox', 'deleteSent', array("conversationId" => $conversation->id, "page" => 1));
     } else {
         $conversationArray["deleteUrl"] = OW::getRouter()->urlFor('MAILBOX_CTRL_Mailbox', 'deleteInbox', array("conversationId" => $conversation->id, "page" => 1));
     }
     $conversationArray['read'] = $conversationService->isConversationReadByUser($userId, $conversation->initiatorId, $conversation->interlocutorId, $conversation->read);
     $conversationArray['isOpponentLastMessage'] = false;
     switch ($userId) {
         case $conversation->initiatorId:
             $conversationArray['opponentId'] = $conversation->interlocutorId;
             $conversationArray['userId'] = $conversation->initiatorId;
             if ($lastMessages->initiatorMessageId < $lastMessages->interlocutorMessageId) {
                 $conversationArray['isOpponentLastMessage'] = true;
             }
             break;
         case $conversation->interlocutorId:
             $conversationArray['opponentId'] = $conversation->initiatorId;
             $conversationArray['userId'] = $conversation->interlocutorId;
             if ($lastMessages->initiatorMessageId > $lastMessages->interlocutorMessageId) {
                 $conversationArray['isOpponentLastMessage'] = true;
             }
             break;
         default:
             throw new Redirect403Exception();
     }
     $avatarList = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($conversationArray['userId'], $conversationArray['opponentId']));
     $displayNames = $userService->getDisplayNamesForList(array($userId, $conversationArray['opponentId']));
     $conversationArray['opponentDisplayName'] = $displayNames[$conversationArray['opponentId']];
     $conversationArray['userDisplayName'] = $displayNames[$conversationArray['userId']];
     $userNames = $userService->getDisplayNamesForList(array($conversationArray['userId'], $conversationArray['opponentId']));
     $conversationArray['opponentName'] = $userNames[$conversationArray['opponentId']];
     $conversationArray['userName'] = $userNames[$conversationArray['userId']];
     $conversationArray['opponentUrl'] = $userService->getUserUrl($conversationArray['opponentId'], $conversationArray['opponentName']);
     $conversationArray['userUrl'] = $userService->getUserUrl($conversationArray['userId'], $conversationArray['userName']);
     $messages = $conversationService->getConversationMessagesList($conversationId);
     $messageList = array();
     $messageIdList = array();
     $trackConvView = false;
     foreach ($messages as $value) {
         $messageIdList[] = $value->id;
         $message = array();
         $message['id'] = $value->id;
         $message['senderId'] = $value->senderId;
         $message['recipientId'] = $value->recipientId;
         $message['recipientRead'] = $value->recipientRead;
         $message['senderDisplayName'] = $value->senderId == $userId ? $conversationArray['userDisplayName'] : $conversationArray['opponentDisplayName'];
         $message['senderName'] = $value->senderId == $userId ? $conversationArray['userName'] : $conversationArray['opponentName'];
         $message['senderUrl'] = $userService->getUserUrl($value->senderId, $message['senderName']);
         $message['timeStamp'] = UTIL_DateTime::formatDate((int) $value->timeStamp);
         $message['toolbar'] = array();
         $isReadable = false;
         if ($value->senderId == $userId || $message['recipientRead']) {
             $isReadable = true;
         } else {
             if (OW::getUser()->isAuthorized('mailbox', 'read_message')) {
                 // check credits
                 $eventParams = array('pluginKey' => 'mailbox', 'action' => 'read_message');
                 $credits = OW::getEventManager()->call('usercredits.check_balance', $eventParams);
                 if ($credits === false) {
                     $creditsMsg = OW::getEventManager()->call('usercredits.error_message', $eventParams);
                     $message['content'] = '<span class="error">' . $creditsMsg . '</span>';
                 } else {
                     $conversationService->markMessageRead($value->id);
                     $isReadable = true;
                     $trackConvView = true;
                 }
             } else {
                 $message['content'] = '<span class="error">' . $language->text('mailbox', 'read_permission_denied') . '</span>';
             }
         }
         if ($isReadable) {
             $message['content'] = UTIL_HtmlTag::autoLink($value->text);
             //TODO: Insert text formatter
             $event = new OW_Event('mailbox.message_render', array('conversationId' => $conversationId, 'messageId' => $message['id'], 'senderId' => $message['senderId'], 'recipientId' => $message['recipientId']), array('short' => '', 'full' => $message['content']));
             OW::getEventManager()->trigger($event);
             $eventData = $event->getData();
             $message['content'] = $eventData['full'];
         }
         $message['isReadableMessage'] = $isReadable;
         $messageList[] = $message;
     }
     if ($trackConvView) {
         if (isset($credits) && $credits === true) {
             $eventParams = array('pluginKey' => 'mailbox', 'action' => 'read_message', 'extra' => array('layer_check' => true, 'senderId' => $conversationArray['userId'], 'recipientId' => $conversationArray['opponentId']));
             OW::getEventManager()->call('usercredits.track_action', $eventParams);
         }
         // message read event triggered
         $event = new OW_Event('mailbox.message_read', array('conversationId' => $conversationId, 'userId' => $userId));
         OW::getEventManager()->trigger($event);
     }
     $attachments = $conversationService->findAttachmentsByMessageIdList($messageIdList);
     $attachmentList = array();
     foreach ($attachments as $attachment) {
         $ext = UTIL_File::getExtension($attachment->fileName);
         $attachmentPath = $conversationService->getAttachmentFilePath($attachment->id, $attachment->hash, $ext);
         $list = array();
         $list['id'] = $attachment->id;
         $list['messageId'] = $attachment->messageId;
         $list['downloadUrl'] = OW::getStorage()->getFileUrl($attachmentPath);
         $list['fileName'] = $attachment->fileName;
         $list['fileSize'] = $attachment->fileSize;
         $attachmentList[$attachment->messageId][$attachment->id] = $list;
     }
     $this->assign('attachmentList', $attachmentList);
     $this->assign('messageList', $messageList);
     $this->assign('conversation', $conversationArray);
     $this->assign('writeMessage', OW::getUser()->isAuthorized('mailbox', 'send_message'));
     $this->assign('avatars', $avatarList);
     $configs = OW::getConfig()->getValues('mailbox');
     $this->assign('enableAttachments', !empty($configs['enable_attachments']));
     //include js
     $deleteConfirmMessage = $language->text('mailbox', 'delete_confirm_message');
     $onLoadJs = " \$(document).ready(function(){\n\t\t\t\t\t\tvar conversation = new mailboxConversation( " . json_encode(array('responderUrl' => $this->responderUrl, 'deleteConfirmMessage' => $deleteConfirmMessage)) . " );\n\t\t\t\t\t}); ";
     OW::getDocument()->addOnloadScript($onLoadJs);
     OW::getDocument()->addScript($this->jsDirUrl . "mailbox.js");
     OW::getDocument()->setTitle($language->text('mailbox', 'conversation_meta_tilte', array('conversation_title' => $conversation->subject)));
 }
Ejemplo n.º 16
0
 public function generatePhotoList($photos)
 {
     $unique = uniqid(time(), true);
     if ($photos) {
         foreach ($photos as $key => $photo) {
             $entityIdList[] = $photo->id;
             $photos[$key]->title = UTIL_HtmlTag::autoLink($photos[$key]->title);
             $photos[$key]->unique = $unique;
             $photos[$key]->addDatetime = UTIL_DateTime::formatSimpleDate($photos[$key]->addDatetime, true);
         }
     }
     return array('status' => 'success', 'data' => array('photoList' => $photos, 'unique' => $unique));
 }
Ejemplo n.º 17
0
 private function prepareMarkup($photoId, $layout = NULL)
 {
     $markup = array();
     $photo = $this->photoService->findPhotoById($photoId);
     $album = $this->photoAlbumService->findAlbumById($photo->albumId);
     $layoutList = array('page' => BASE_CommentsParams::DISPLAY_TYPE_WITH_LOAD_LIST, 'floatbox' => BASE_CommentsParams::DISPLAY_TYPE_WITH_LOAD_LIST_MINI);
     $userId = OW::getUser()->getId();
     $ownerMode = $album->userId == $userId;
     $modPermissions = OW::getUser()->isAuthorized('photo');
     $photo->addDatetime = UTIL_DateTime::formatDate($photo->addDatetime);
     $photo->description = UTIL_HtmlTag::autoLink($photo->description);
     $dim = !empty($photo->dimension) ? $photo->dimension : FALSE;
     $photo->url = $this->photoService->getPhotoUrlByType($photo->id, PHOTO_BOL_PhotoService::TYPE_MAIN, $photo->hash, $dim);
     if ($photo->hasFullsize) {
         $photo->urlFullscreen = $this->photoService->getPhotoUrlByType($photo->id, PHOTO_BOL_PhotoService::TYPE_FULLSCREEN, $photo->hash, $dim);
     }
     if (!empty($photo->description)) {
         $photo->description = $this->photoService->hashtagToDesc($photo->description);
     }
     $markup['photo'] = $photo;
     $markup['album'] = $album;
     $markup['albumUrl'] = OW::getRouter()->urlForRoute('photo_user_album', array('user' => BOL_UserService::getInstance()->getUserName($album->userId), 'album' => $album->id));
     $markup['photoCount'] = $this->photoAlbumService->countAlbumPhotos($photo->albumId);
     $markup['photoIndex'] = $this->photoService->getPhotoIndex($photo->albumId, $photo->id);
     $avatar = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($album->userId), TRUE, TRUE, TRUE, FALSE);
     $markup['avatar'] = $avatar[$album->userId];
     $cmtParams = new BASE_CommentsParams('photo', 'photo_comments');
     $cmtParams->setEntityId($photo->id);
     $cmtParams->setOwnerId($album->userId);
     $cmtParams->setWrapInBox(FALSE);
     $cmtParams->setDisplayType(array_key_exists($layout, $layoutList) ? $layoutList[$layout] : BASE_CommentsParams::DISPLAY_TYPE_WITH_LOAD_LIST_MINI);
     $cmtParams->setInitialCommentsCount(6);
     $cmtParams->setAddComment($photo->status == PHOTO_BOL_PhotoDao::STATUS_APPROVED);
     $customId = uniqid('photoComment');
     $cmtParams->setCustomId($customId);
     $markup['customId'] = $customId;
     $comment = new BASE_CMP_Comments($cmtParams);
     $markup['comment'] = $comment->render();
     $action = new BASE_ContextAction();
     $action->setKey('photo-moderate');
     $context = new BASE_CMP_ContextAction();
     $context->addAction($action);
     $contextEvent = new BASE_CLASS_EventCollector('photo.collect_photo_context_actions', array('photoId' => $photo->id, 'photoDto' => $photo));
     OW::getEventManager()->trigger($contextEvent);
     foreach ($contextEvent->getData() as $contextAction) {
         $action = new BASE_ContextAction();
         $action->setKey(empty($contextAction['key']) ? uniqid() : $contextAction['key']);
         $action->setParentKey('photo-moderate');
         $action->setLabel($contextAction['label']);
         if (!empty($contextAction['id'])) {
             $action->setId($contextAction['id']);
         }
         if (!empty($contextAction['order'])) {
             $action->setOrder($contextAction['order']);
         }
         if (!empty($contextAction['class'])) {
             $action->setClass($contextAction['class']);
         }
         if (!empty($contextAction['url'])) {
             $action->setUrl($contextAction['url']);
         }
         $attributes = empty($contextAction['attributes']) ? array() : $contextAction['attributes'];
         foreach ($attributes as $key => $value) {
             $action->addAttribute($key, $value);
         }
         $context->addAction($action);
     }
     $lang = OW::getLanguage();
     if ($userId && !$ownerMode && $photo->status == PHOTO_BOL_PhotoDao::STATUS_APPROVED) {
         $action = new BASE_ContextAction();
         $action->setKey('flag');
         $action->setParentKey('photo-moderate');
         $action->setLabel($lang->text('base', 'flag'));
         $action->setId('btn-photo-flag');
         $action->addAttribute('rel', $photoId);
         $action->addAttribute('url', OW::getRouter()->urlForRoute('view_photo', array('id' => $photo->id)));
         $context->addAction($action);
     }
     if ($ownerMode || $modPermissions) {
         $action = new BASE_ContextAction();
         $action->setKey('edit');
         $action->setParentKey('photo-moderate');
         $action->setLabel($lang->text('base', 'edit'));
         $action->setId('btn-photo-edit');
         $action->addAttribute('rel', $photoId);
         $context->addAction($action);
         $action = new BASE_ContextAction();
         $action->setKey('delete');
         $action->setParentKey('photo-moderate');
         $action->setLabel($lang->text('base', 'delete'));
         $action->setId('photo-delete');
         $action->addAttribute('rel', $photoId);
         $context->addAction($action);
     }
     if ($modPermissions) {
         if (PHOTO_BOL_PhotoFeaturedService::getInstance()->isFeatured($photo->id)) {
             $action = new BASE_ContextAction();
             $action->setKey('unmark-featured');
             $action->setParentKey('photo-moderate');
             $action->setLabel($lang->text('photo', 'remove_from_featured'));
             $action->setId('photo-mark-featured');
             $action->addAttribute('rel', 'remove_from_featured');
             $action->addAttribute('photo-id', $photoId);
             $context->addAction($action);
         } elseif ($photo->status == PHOTO_BOL_PhotoDao::STATUS_APPROVED) {
             $action = new BASE_ContextAction();
             $action->setKey('mark-featured');
             $action->setParentKey('photo-moderate');
             $action->setLabel($lang->text('photo', 'mark_featured'));
             $action->setId('photo-mark-featured');
             $action->addAttribute('rel', 'mark_featured');
             $action->addAttribute('photo-id', $photoId);
             $context->addAction($action);
         }
         if ($photo->status != PHOTO_BOL_PhotoDao::STATUS_APPROVED) {
             $action = new BASE_ContextAction();
             $action->setKey('mark-approved');
             $action->setParentKey('photo-moderate');
             $action->setLabel($lang->text('photo', 'approve_photo'));
             $action->setUrl(OW::getRouter()->urlForRoute('photo.approve', array('id' => $photoId)));
             //                $action->setId('photo-approve');
             //                $action->addAttribute('url', OW::getRouter()->urlForRoute('photo.approve', array('id' => $photoId)));
             $context->addAction($action);
         }
     }
     $markup['contextAction'] = $context->render();
     $eventParams = array('url' => OW::getRouter()->urlForRoute('view_photo', array('id' => $photo->id)), 'image' => $photo->url, 'title' => $photo->description, 'entityType' => 'photo', 'entityId' => $photo->id);
     $event = new BASE_CLASS_EventCollector('socialsharing.get_sharing_buttons', $eventParams);
     OW::getEventManager()->trigger($event);
     $markup['share'] = @implode("\n", $event->getData());
     $document = OW::getDocument();
     $onloadScript = $document->getOnloadScript();
     if (!empty($onloadScript)) {
         $markup['onloadScript'] = $onloadScript;
     }
     $scriptFiles = $document->getScripts();
     if (!empty($scriptFiles)) {
         $markup['scriptFiles'] = $scriptFiles;
     }
     $css = $document->getStyleDeclarations();
     if (!empty($css)) {
         $markup['css'] = $css;
     }
     $cssFiles = $document->getStyleSheets();
     if (!empty($cssFiles)) {
         $markup['cssFiles'] = $cssFiles;
     }
     $meta = $document->getMeta();
     if (!empty($meta)) {
         $markup['meta'] = $meta;
     }
     return $markup;
 }
Ejemplo n.º 18
0
 public function view(array $params)
 {
     if (!isset($params['id']) || !($photoId = (int) $params['id'])) {
         throw new Redirect404Exception();
     }
     $lang = OW::getLanguage();
     $photo = $this->photoService->findPhotoById($photoId);
     if (!$photo) {
         throw new Redirect404Exception();
     }
     $album = $this->photoAlbumService->findAlbumById($photo->albumId);
     $this->assign('album', $album);
     $ownerName = BOL_UserService::getInstance()->getUserName($album->userId);
     $albumUrl = OW::getRouter()->urlForRoute('photo_user_album', array('album' => $album->id, 'user' => $ownerName));
     $this->assign('albumUrl', $albumUrl);
     // is owner
     $contentOwner = $this->photoService->findPhotoOwner($photo->id);
     $userId = OW::getUser()->getId();
     $ownerMode = $contentOwner == $userId;
     $this->assign('ownerMode', $ownerMode);
     // is moderator
     $modPermissions = OW::getUser()->isAuthorized('photo');
     $this->assign('moderatorMode', $modPermissions);
     $this->assign('url', $this->photoService->getPhotoUrl($photo->id, false, $photo->hash));
     if (!$ownerMode && !$modPermissions && !OW::getUser()->isAuthorized('photo', 'view')) {
         $status = BOL_AuthorizationService::getInstance()->getActionStatus('photo', 'view');
         $this->assign('authError', $status['msg']);
         return;
     }
     // permissions check
     if (!$ownerMode && !$modPermissions) {
         $privacyParams = array('action' => 'photo_view_album', 'ownerId' => $contentOwner, 'viewerId' => $userId);
         $event = new OW_Event('privacy_check_permission', $privacyParams);
         OW::getEventManager()->trigger($event);
     }
     $photo->description = UTIL_HtmlTag::autoLink($photo->description);
     $this->assign('photo', $photo);
     $fullsizeUrl = (int) OW::getConfig()->getValue('photo', 'store_fullsize') && $photo->hasFullsize ? $this->photoService->getPhotoFullsizeUrl($photo->id, $photo->hash) : null;
     $this->assign('fullsizeUrl', $fullsizeUrl);
     $this->assign('nextPhoto', $this->photoService->getNextPhotoId($photo->albumId, $photo->id));
     $this->assign('previousPhoto', $this->photoService->getPreviousPhotoId($photo->albumId, $photo->id));
     $photoCount = $this->photoAlbumService->countAlbumPhotos($photo->albumId);
     $this->assign('photoCount', $photoCount);
     $photoIndex = $this->photoService->getPhotoIndex($photo->albumId, $photo->id);
     $this->assign('photoIndex', $photoIndex);
     $avatar = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($contentOwner), true, true, true, false);
     $this->assign('avatar', $avatar[$contentOwner]);
     $cmtParams = new BASE_CommentsParams('photo', 'photo_comments');
     $cmtParams->setEntityId($photo->id);
     $cmtParams->setOwnerId($contentOwner);
     $cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST);
     $photoCmts = new BASE_MCMP_Comments($cmtParams);
     $this->addComponent('comments', $photoCmts);
     OW::getDocument()->setHeading($album->name);
     $description = strip_tags($photo->description);
     $description = mb_strlen($description) ? $description : $photo->id;
     OW::getDocument()->setTitle($lang->text('photo', 'meta_title_photo_view', array('title' => $description)));
 }
Ejemplo n.º 19
0
 /**
  * View event controller
  * 
  * @param array $params
  */
 public function view($params)
 {
     $event = $this->getEventForParams($params);
     $cmpId = UTIL_HtmlTag::generateAutoId('cmp');
     $this->assign('contId', $cmpId);
     if (!OW::getUser()->isAuthorized('event', 'view_event') && $event->getUserId() != OW::getUser()->getId()) {
         $status = BOL_AuthorizationService::getInstance()->getActionStatus('event', 'view_event');
         throw new AuthorizationException($status['msg']);
     }
     if ($event->status != 1 && !OW::getUser()->isAuthorized('event') && $event->getUserId() != OW::getUser()->getId()) {
         throw new Redirect403Exception();
     }
     // guest gan't view private events
     if ((int) $event->getWhoCanView() === EVENT_BOL_EventService::CAN_VIEW_INVITATION_ONLY && !OW::getUser()->isAuthenticated()) {
         $this->redirect(OW::getRouter()->urlForRoute('event.private_event', array('eventId' => $event->getId())));
     }
     $eventInvite = $this->eventService->findEventInvite($event->getId(), OW::getUser()->getId());
     $eventUser = $this->eventService->findEventUser($event->getId(), OW::getUser()->getId());
     // check if user can view event
     if ((int) $event->getWhoCanView() === EVENT_BOL_EventService::CAN_VIEW_INVITATION_ONLY && $eventUser === null && $eventInvite === null && !OW::getUser()->isAuthorized('event')) {
         $this->redirect(OW::getRouter()->urlForRoute('event.private_event', array('eventId' => $event->getId())));
     }
     $buttons = array();
     $toolbar = array();
     if (OW::getUser()->isAuthorized('event') || OW::getUser()->getId() == $event->getUserId()) {
         $buttons = array('edit' => array('url' => OW::getRouter()->urlForRoute('event.edit', array('eventId' => $event->getId())), 'label' => OW::getLanguage()->text('event', 'edit_button_label')), 'delete' => array('url' => OW::getRouter()->urlForRoute('event.delete', array('eventId' => $event->getId())), 'label' => OW::getLanguage()->text('event', 'delete_button_label'), 'confirmMessage' => OW::getLanguage()->text('event', 'delete_confirm_message')));
     }
     $this->assign('editArray', $buttons);
     OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'event', 'main_menu_item');
     $moderationStatus = '';
     if ($event->status == 2) {
         $moderationStatus = " <span class='ow_remark ow_small'>(" . OW::getLanguage()->text('event', 'moderation_status_pending_approval') . ")</span>";
     }
     $this->setPageHeading($event->getTitle() . $moderationStatus);
     $this->setPageTitle(OW::getLanguage()->text('event', 'event_view_page_heading', array('event_title' => $event->getTitle())));
     $this->setPageHeadingIconClass('ow_ic_calendar');
     OW::getDocument()->setDescription(UTIL_String::truncate(strip_tags($event->getDescription()), 200, '...'));
     $infoArray = array('id' => $event->getId(), 'image' => $event->getImage() ? $this->eventService->generateImageUrl($event->getImage(), false) : null, 'date' => UTIL_DateTime::formatSimpleDate($event->getStartTimeStamp(), $event->getStartTimeDisable()), 'endDate' => $event->getEndTimeStamp() === null || !$event->getEndDateFlag() ? null : UTIL_DateTime::formatSimpleDate($event->getEndTimeDisable() ? strtotime("-1 day", $event->getEndTimeStamp()) : $event->getEndTimeStamp(), $event->getEndTimeDisable()), 'location' => $event->getLocation(), 'desc' => UTIL_HtmlTag::autoLink($event->getDescription()), 'title' => $event->getTitle(), 'creatorName' => BOL_UserService::getInstance()->getDisplayName($event->getUserId()), 'creatorLink' => BOL_UserService::getInstance()->getUserUrl($event->getUserId()), 'moderationStatus' => $event->status);
     $this->assign('info', $infoArray);
     // event attend form
     if (OW::getUser()->isAuthenticated() && $event->getEndTimeStamp() > time()) {
         if ($eventUser !== null) {
             $this->assign('currentStatus', OW::getLanguage()->text('event', 'user_status_label_' . $eventUser->getStatus()));
         }
         $this->addForm(new AttendForm($event->getId(), $cmpId));
         $onloadJs = "\n                var \$context = \$('#" . $cmpId . "');\n                \$('#event_attend_yes_btn').click(\n                    function(){\n                        \$('input[name=attend_status]', \$context).val(" . EVENT_BOL_EventService::USER_STATUS_YES . ");\n                    }\n                );\n                \$('#event_attend_maybe_btn').click(\n                    function(){\n                        \$('input[name=attend_status]', \$context).val(" . EVENT_BOL_EventService::USER_STATUS_MAYBE . ");\n                    }\n                );\n                \$('#event_attend_no_btn').click(\n                    function(){\n                        \$('input[name=attend_status]', \$context).val(" . EVENT_BOL_EventService::USER_STATUS_NO . ");\n                    }\n                );\n\n                \$('.current_status a', \$context).click(\n                    function(){\n                        \$('.attend_buttons .buttons', \$context).fadeIn(500);\n                    }\n                );\n            ";
         OW::getDocument()->addOnloadScript($onloadJs);
     } else {
         $this->assign('no_attend_form', true);
     }
     if ($event->status == EVENT_BOL_EventService::MODERATION_STATUS_ACTIVE && ($event->getEndTimeStamp() > time() && ((int) $event->getUserId() === OW::getUser()->getId() || (int) $event->getWhoCanInvite() === EVENT_BOL_EventService::CAN_INVITE_PARTICIPANT && $eventUser !== null))) {
         $params = array($event->id);
         $this->assign('inviteLink', true);
         OW::getDocument()->addOnloadScript("\n                var eventFloatBox;\n                \$('#inviteLink', \$('#" . $cmpId . "')).click(\n                    function(){\n                        eventFloatBox = OW.ajaxFloatBox('EVENT_CMP_InviteUserListSelect', " . json_encode($params) . ", {width:600, iconClass: 'ow_ic_user', title: " . json_encode(OW::getLanguage()->text('event', 'friends_invite_button_label')) . "});\n                    }\n                );\n                OW.bind('base.avatar_user_list_select',\n                    function(list){\n                        eventFloatBox.close();\n                        \$.ajax({\n                            type: 'POST',\n                            url: " . json_encode(OW::getRouter()->urlFor('EVENT_CTRL_Base', 'inviteResponder')) . ",\n                            data: 'eventId=" . json_encode($event->getId()) . "&userIdList='+JSON.stringify(list),\n                            dataType: 'json',\n                            success : function(data){\n                                if( data.messageType == 'error' ){\n                                    OW.error(data.message);\n                                }\n                                else{\n                                    OW.info(data.message);\n                                }\n                            },\n                            error : function( XMLHttpRequest, textStatus, errorThrown ){\n                                OW.error(textStatus);\n                            }\n                        });\n                    }\n                );\n            ");
     }
     if ($event->status == EVENT_BOL_EventService::MODERATION_STATUS_ACTIVE) {
         $cmntParams = new BASE_CommentsParams('event', 'event');
         $cmntParams->setEntityId($event->getId());
         $cmntParams->setOwnerId($event->getUserId());
         $this->addComponent('comments', new BASE_CMP_Comments($cmntParams));
     }
     $this->addComponent('userListCmp', new EVENT_CMP_EventUsers($event->getId()));
     $event = new BASE_CLASS_EventCollector(EVENT_BOL_EventService::EVENT_COLLECT_TOOLBAR, array("event" => $event));
     OW::getEventManager()->trigger($event);
     $this->assign("toolbar", $event->getData());
 }
Ejemplo n.º 20
0
 /**
  * Class constructor
  *
  * @param string $listType
  * @param int $count
  * @param string $tag
  */
 public function __construct(array $params)
 {
     parent::__construct();
     $photoId = $params['photoId'];
     $config = OW::getConfig();
     $lang = OW::getLanguage();
     $this->photoService = PHOTO_BOL_PhotoService::getInstance();
     $this->photoAlbumService = PHOTO_BOL_PhotoAlbumService::getInstance();
     $photo = $this->photoService->findPhotoById($photoId);
     $album = $this->photoAlbumService->findAlbumById($photo->albumId);
     $this->assign('album', $album);
     // is owner
     $contentOwner = $this->photoService->findPhotoOwner($photo->id);
     $userId = OW::getUser()->getId();
     $ownerMode = $contentOwner == $userId;
     $this->assign('ownerMode', $ownerMode);
     // is moderator
     $modPermissions = OW::getUser()->isAuthorized('photo');
     $this->assign('moderatorMode', $modPermissions);
     $canView = true;
     if (!$ownerMode && !$modPermissions && !OW::getUser()->isAuthorized('photo', 'view')) {
         $canView = false;
     }
     $this->assign('canView', $canView);
     $cmtParams = new BASE_CommentsParams('photo', 'photo_comments');
     $cmtParams->setEntityId($photo->id);
     $cmtParams->setOwnerId($contentOwner);
     $cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST);
     $photoCmts = new BASE_CMP_Comments($cmtParams);
     $this->addComponent('comments', $photoCmts);
     $photoRates = new BASE_CMP_Rate('photo', 'photo_rates', $photo->id, $contentOwner);
     $this->addComponent('rate', $photoRates);
     $photoTags = new BASE_CMP_EntityTagCloud('photo');
     $photoTags->setEntityId($photo->id);
     $photoTags->setRouteName('view_tagged_photo_list');
     $this->addComponent('tags', $photoTags);
     $description = $photo->description;
     $photo->description = UTIL_HtmlTag::autoLink($photo->description);
     $this->assign('photo', $photo);
     $this->assign('url', $this->photoService->getPhotoUrl($photo->id, false, $photo->hash));
     $this->assign('ownerName', BOL_UserService::getInstance()->getUserName($album->userId));
     $is_featured = PHOTO_BOL_PhotoFeaturedService::getInstance()->isFeatured($photo->id);
     if ((int) $config->getValue('photo', 'store_fullsize') && $photo->hasFullsize) {
         $this->assign('fullsizeUrl', $this->photoService->getPhotoFullsizeUrl($photo->id, $photo->hash));
     } else {
         $this->assign('fullsizeUrl', null);
     }
     $action = new BASE_ContextAction();
     $action->setKey('photo-moderate');
     $context = new BASE_CMP_ContextAction();
     $context->addAction($action);
     $contextEvent = new BASE_CLASS_EventCollector('photo.collect_photo_context_actions', array('photoId' => $photoId, 'photoDto' => $photo));
     OW::getEventManager()->trigger($contextEvent);
     foreach ($contextEvent->getData() as $contextAction) {
         $action = new BASE_ContextAction();
         $action->setKey(empty($contextAction['key']) ? uniqid() : $contextAction['key']);
         $action->setParentKey('photo-moderate');
         $action->setLabel($contextAction['label']);
         if (!empty($contextAction['id'])) {
             $action->setId($contextAction['id']);
         }
         if (!empty($contextAction['order'])) {
             $action->setOrder($contextAction['order']);
         }
         if (!empty($contextAction['class'])) {
             $action->setClass($contextAction['class']);
         }
         if (!empty($contextAction['url'])) {
             $action->setUrl($contextAction['url']);
         }
         $attributes = empty($contextAction['attributes']) ? array() : $contextAction['attributes'];
         foreach ($attributes as $key => $value) {
             $action->addAttribute($key, $value);
         }
         $context->addAction($action);
     }
     if ($userId && !$ownerMode) {
         $action = new BASE_ContextAction();
         $action->setKey('flag');
         $action->setParentKey('photo-moderate');
         $action->setLabel($lang->text('base', 'flag'));
         $action->setId('btn-photo-flag');
         $action->addAttribute('rel', $photoId);
         $action->addAttribute('url', OW::getRouter()->urlForRoute('view_photo', array('id' => $photo->id)));
         $context->addAction($action);
     }
     if ($ownerMode || $modPermissions) {
         $action = new BASE_ContextAction();
         $action->setKey('edit');
         $action->setParentKey('photo-moderate');
         $action->setLabel($lang->text('base', 'edit'));
         $action->setId('btn-photo-edit');
         $action->addAttribute('rel', $photoId);
         $context->addAction($action);
         $action = new BASE_ContextAction();
         $action->setKey('delete');
         $action->setParentKey('photo-moderate');
         $action->setLabel($lang->text('base', 'delete'));
         $action->setId('photo-delete');
         $action->addAttribute('rel', $photoId);
         $context->addAction($action);
     }
     if ($modPermissions) {
         if ($is_featured) {
             $action = new BASE_ContextAction();
             $action->setKey('unmark-featured');
             $action->setParentKey('photo-moderate');
             $action->setLabel($lang->text('photo', 'remove_from_featured'));
             $action->setId('photo-mark-featured');
             $action->addAttribute('rel', 'remove_from_featured');
             $action->addAttribute('photo-id', $photoId);
             $context->addAction($action);
         } else {
             $action = new BASE_ContextAction();
             $action->setKey('mark-featured');
             $action->setParentKey('photo-moderate');
             $action->setLabel($lang->text('photo', 'mark_featured'));
             $action->setId('photo-mark-featured');
             $action->addAttribute('rel', 'mark_featured');
             $action->addAttribute('photo-id', $photoId);
             $context->addAction($action);
         }
     }
     $this->addComponent('contextAction', $context);
     $nextPhoto = $this->photoService->getNextPhoto($photo->albumId, $photo->id);
     $this->assign('nextPhoto', $nextPhoto);
     $previousPhoto = $this->photoService->getPreviousPhoto($photo->albumId, $photo->id);
     $this->assign('previousPhoto', $previousPhoto);
     $photoCount = $this->photoAlbumService->countAlbumPhotos($photo->albumId);
     $this->assign('photoCount', $photoCount);
     $photoIndex = $this->photoService->getPhotoIndex($photo->albumId, $photo->id);
     $this->assign('photoIndex', $photoIndex);
     $avatar = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($contentOwner), true, true, true, false);
     $this->assign('avatar', $avatar[$contentOwner]);
 }
Ejemplo n.º 21
0
 public function getQuestionValueForUserList(BOL_Question $question, $value)
 {
     $stringValue = "";
     switch ($question->presentation) {
         case BOL_QuestionService::QUESTION_PRESENTATION_CHECKBOX:
             if ((int) $value === 1) {
                 $stringValue = OW::getLanguage()->text('base', 'yes');
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_DATE:
             $format = OW::getConfig()->getValue('base', 'date_field_format');
             $value = 0;
             switch ($question->type) {
                 case BOL_QuestionService::QUESTION_VALUE_TYPE_DATETIME:
                     $date = UTIL_DateTime::parseDate($value, UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
                     if (isset($date)) {
                         $stringValue = mktime(0, 0, 0, $date['month'], $date['day'], $date['year']);
                     }
                     break;
                 case BOL_QuestionService::QUESTION_VALUE_TYPE_SELECT:
                     $stringValue = (int) $value;
                     break;
             }
             if ($format === 'dmy') {
                 $stringValue = date("d/m/Y", $value);
             } else {
                 $stringValue = date("m/d/Y", $value);
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_BIRTHDATE:
             $date = UTIL_DateTime::parseDate($value, UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             $stringValue = UTIL_DateTime::formatBirthdate($date['year'], $date['month'], $date['day']);
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_AGE:
             $date = UTIL_DateTime::parseDate($alue, UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT);
             $stringValue = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']) . " " . $language->text('base', 'questions_age_year_old');
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_RANGE:
             $range = explode('-', $value);
             $stringValue = $language->text('base', 'form_element_from') . " " . $range[0] . " " . $language->text('base', 'form_element_to') . " " . $range[1];
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_SELECT:
         case BOL_QuestionService::QUESTION_PRESENTATION_RADIO:
         case BOL_QuestionService::QUESTION_PRESENTATION_MULTICHECKBOX:
             $multicheckboxValue = (int) $value;
             $parentName = $question->name;
             if (!empty($question->parent)) {
                 $parent = BOL_QuestionService::getInstance()->findQuestionByName($question->parent);
                 if (!empty($parent)) {
                     $parentName = $parent->name;
                 }
             }
             $questionValues = BOL_QuestionService::getInstance()->findQuestionValues($parentName);
             foreach ($questionValues as $val) {
                 /* @var $val BOL_QuestionValue */
                 if ((int) $val->value & $multicheckboxValue) {
                     $stringValue .= BOL_QuestionService::getInstance()->getQuestionValueLang($val->questionName, $val->value) . ', ';
                 }
             }
             if (!empty($stringValue)) {
                 $stringValue = mb_substr($stringValue, 0, -2);
             }
             break;
         case BOL_QuestionService::QUESTION_PRESENTATION_URL:
         case BOL_QuestionService::QUESTION_PRESENTATION_TEXT:
         case BOL_QuestionService::QUESTION_PRESENTATION_TEXTAREA:
             if (!is_string($value)) {
                 break;
             }
             $value = trim($value);
             if (strlen($value) > 0) {
                 $stringValue = UTIL_HtmlTag::autoLink(nl2br($value));
             }
             break;
     }
     return $stringValue;
 }
Ejemplo n.º 22
0
 /**
  * Vwls view_video action
  *
  * @param array $params
  */
 public function viewVideo(array $params)
 {
     if (!isset($params['id']) || !($id = (int) $params['id'])) {
         throw new Redirect404Exception();
         return;
     }
     $clip = $this->clipService->findClipById($id);
     if (!$clip) {
         throw new Redirect404Exception();
     }
     $contentOwner = (int) $this->clipService->findClipOwner($id);
     $language = OW_Language::getInstance();
     $description = $clip->description;
     $clip->description = UTIL_HtmlTag::autoLink($clip->description);
     $this->assign('clip', $clip);
     //        $is_featured = VWLS_BOL_ClipFeaturedService::getInstance()->isFeatured($clip->id);
     //        $this->assign('featured', $is_featured);
     // is moderator
     $modPermissions = OW::getUser()->isAuthorized('vwls');
     $this->assign('moderatorMode', $modPermissions);
     $userId = OW::getUser()->getId();
     $ownerMode = $contentOwner == $userId;
     $this->assign('ownerMode', $ownerMode);
     if (!$ownerMode && !OW::getUser()->isAuthorized('vwls', 'view') && !$modPermissions) {
         $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
         return;
     }
     //        $this->assign('auth_msg', null);
     // permissions check
     if (!$ownerMode && !$modPermissions) {
         $privacyParams = array('action' => 'vwls_view_vwls', 'ownerId' => $contentOwner, 'viewerId' => $userId);
         $event = new OW_Event('privacy_check_permission', $privacyParams);
         OW::getEventManager()->trigger($event);
     }
     $cmtParams = new BASE_CommentsParams('vwls', 'vwls_comments');
     $cmtParams->setEntityId($id);
     $cmtParams->setOwnerId($contentOwner);
     $cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST);
     $vwlsCmts = new BASE_CMP_Comments($cmtParams);
     $this->addComponent('comments', $vwlsCmts);
     $vwlsRates = new BASE_CMP_Rate('vwls', 'vwls_rates', $id, $contentOwner);
     $this->addComponent('rate', $vwlsRates);
     $vwlsTags = new BASE_CMP_EntityTagCloud('vwls');
     $vwlsTags->setEntityId($id);
     $vwlsTags->setRouteName('vwview_tagged_list_ls');
     $this->addComponent('tags', $vwlsTags);
     $username = BOL_UserService::getInstance()->getUserName($clip->userId);
     $this->assign('username', $username);
     $displayName = BOL_UserService::getInstance()->getDisplayName($clip->userId);
     $this->assign('displayName', $displayName);
     OW::getDocument()->addScript($this->pluginJsUrl . 'vwls.js');
     $objParams = array('ajaxResponder' => $this->ajaxResponder, 'clipId' => $id, 'txtDelConfirm' => OW::getLanguage()->text('vwls', 'confirm_delete'), 'txtMarkFeatured' => OW::getLanguage()->text('vwls', 'mark_featured'), 'txtRemoveFromFeatured' => OW::getLanguage()->text('vwls', 'remove_from_featured'), 'txtApprove' => OW::getLanguage()->text('base', 'approve'), 'txtDisapprove' => OW::getLanguage()->text('base', 'disapprove'));
     $script = "\$(document).ready(function(){\n                var clip = new vwlsClip( " . json_encode($objParams) . ");\n            }); ";
     OW::getDocument()->addOnloadScript($script);
     OW::getDocument()->setHeading($clip->title);
     OW::getDocument()->setHeadingIconClass('ow_ic_vwls');
     $toolbar = array();
     array_push($toolbar, array('href' => 'javascript://', 'id' => 'btn-vwls-flag', 'label' => $language->text('base', 'flag')));
     if ($ownerMode || $modPermissions) {
         array_push($toolbar, array('href' => OW::getRouter()->urlForRoute('vwedit_clip_ls', array('id' => $clip->id)), 'label' => $language->text('base', 'edit')));
         array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-delete', 'label' => $language->text('base', 'delete')));
     }
     /**
             if ( $modPermissions )
             {
                 if ( $is_featured )
                 {
                     array_push($toolbar, array(
                         'href' => 'javascript://',
                         'id' => 'clip-mark-featured',
                         'rel' => 'remove_from_featured',
                         'label' => $language->text('vwls', 'remove_from_featured')
                     ));
                 }
                 else
                 {
                     array_push($toolbar, array(
                         'href' => 'javascript://',
                         'id' => 'clip-mark-featured',
                         'rel' => 'mark_featured',
                         'label' => $language->text('vwls', 'mark_featured')
                     ));
                 }
                 
                 if ( $clip->status == 'approved' )
                 {
                     array_push($toolbar, array(
                         'href' => 'javascript://',
                         'id' => 'clip-set-approval-staus',
                         'rel' => 'disapprove',
                         'label' => $language->text('base', 'disapprove')
                     ));
                 }
                 else
                 {
                     array_push($toolbar, array(
                         'href' => 'javascript://',
                         'id' => 'clip-set-approval-staus',
                         'rel' => 'approve',
                         'label' => $language->text('base', 'approve')
                     ));
                 }
     
             }
     */
     $this->assign('toolbar', $toolbar);
     $js = UTIL_JsGenerator::newInstance()->jQueryEvent('#btn-vwls-flag', 'click', 'document.flag(e.data.entity, e.data.id, e.data.title, e.data.href, "vwls+flags");', array('e'), array('entity' => 'vwls_clip', 'id' => $clip->id, 'title' => $clip->title, 'href' => OW::getRouter()->urlForRoute('vwview_clip_ls', array('id' => $clip->id))));
     OW::getDocument()->addOnloadScript($js, 1001);
     OW::getDocument()->setTitle($language->text('vwls', 'meta_title_vwls_view', array('title' => $clip->title)));
     $tagsArr = BOL_TagService::getInstance()->findEntityTags($clip->id, 'vwls');
     foreach ($tagsArr as $t) {
         $labels[] = $t->label;
     }
     $tagStr = $tagsArr ? implode(', ', $labels) : '';
     OW::getDocument()->setDescription($language->text('vwls', 'meta_description_vwls_view', array('title' => $clip->title, 'tags' => $tagStr)));
 }
Ejemplo n.º 23
0
 public function entityAdd(OW_Event $e)
 {
     $params = $e->getParams();
     $data = $e->getData();
     if ($params['entityType'] != 'base_profile_wall') {
         return;
     }
     $comment = BOL_CommentService::getInstance()->findComment($params['commentId']);
     $attachment = empty($comment->attachment) ? null : json_decode($comment->attachment, true);
     if (empty($attachment)) {
         $data['attachment'] = null;
     } else {
         $data['attachment'] = array('oembed' => $attachment, 'attachId' => empty($attachment['genId']) ? null : $attachment['genId'], 'url' => empty($attachment['url']) ? null : $attachment['url']);
     }
     $data['content'] = '[ph:attachment]';
     $data['string'] = strip_tags($comment->getMessage());
     $data['string'] = UTIL_HtmlTag::autoLink($data['string']);
     $data['context'] = array('label' => BOL_UserService::getInstance()->getDisplayName($params['entityId']), 'url' => BOL_UserService::getInstance()->getUserUrl($params['entityId']));
     $data['params']['feedType'] = 'user';
     $data['params']['feedId'] = $params['entityId'];
     $data['params']['entityType'] = 'user-comment';
     $data['params']['entityId'] = $params['commentId'];
     $data['view'] = array('iconClass' => 'ow_ic_comment');
     $data['features'] = array();
     $e->setData($data);
 }
Ejemplo n.º 24
0
 /**
  * Controller's default action
  *
  * @param array $params
  * @throws AuthorizationException
  * @throws Redirect404Exception
  */
 public function index(array $params)
 {
     if (!isset($params['topicId']) || ($topicDto = $this->forumService->findTopicById($params['topicId'])) === null) {
         throw new Redirect404Exception();
     }
     if ($topicDto != FORUM_BOL_ForumService::STATUS_APPROVED) {
         //throw new Redirect404Exception();
     }
     $forumGroup = $this->forumService->findGroupById($topicDto->groupId);
     $forumSection = $this->forumService->findSectionById($forumGroup->sectionId);
     $isHidden = $forumSection->isHidden;
     $userId = OW::getUser()->getId();
     $isOwner = $topicDto->userId == $userId ? true : false;
     $postReplyPermissionErrorText = null;
     if ($isHidden) {
         $event = new OW_Event('forum.can_view', array('entity' => $forumSection->entity, 'entityId' => $forumGroup->entityId), true);
         OW::getEventManager()->trigger($event);
         $canView = $event->getData();
         $isModerator = OW::getUser()->isAuthorized($forumSection->entity);
         $params = array('entity' => $forumSection->entity, 'entityId' => $forumGroup->entityId, 'action' => 'edit_topic');
         $event = new OW_Event('forum.check_permissions', $params);
         OW::getEventManager()->trigger($event);
         $canEdit = $event->getData();
         $params = array('entity' => $forumSection->entity, 'entityId' => $forumGroup->entityId, 'action' => 'add_topic');
         $event = new OW_Event('forum.check_permissions', $params);
         OW::getEventManager()->trigger($event);
         $canPost = $event->getData();
         $postReplyPermissionErrorText = OW::getLanguage()->text($forumSection->entity, 'post_reply_permission_error');
         $canMoveToHidden = BOL_AuthorizationService::getInstance()->isActionAuthorized($forumSection->entity, 'move_topic_to_hidden') && $isModerator;
         //$eventParams = array('pluginKey' => $forumSection->entity, 'action' => 'add_post');
         //TODO Zaph:create action that will check if user allowed to delete post separately from topic
     } else {
         $isModerator = OW::getUser()->isAuthorized('forum');
         $canView = OW::getUser()->isAuthorized('forum', 'view');
         $canEdit = $isOwner || $isModerator;
         $canPost = OW::getUser()->isAuthorized('forum', 'edit');
         $canMoveToHidden = BOL_AuthorizationService::getInstance()->isActionAuthorized('forum', 'move_topic_to_hidden') && $isModerator;
         //$eventParams = array('pluginKey' => 'forum', 'action' => 'add_post');
     }
     $canLock = $canSticky = $isModerator;
     if (!$canView && !$isModerator) {
         $status = BOL_AuthorizationService::getInstance()->getActionStatus('forum', 'view');
         throw new AuthorizationException($status['msg']);
     }
     if ($forumGroup->isPrivate) {
         if (!$userId) {
             throw new AuthorizationException();
         } else {
             if (!$isModerator) {
                 if (!$this->forumService->isPrivateGroupAvailable($userId, json_decode($forumGroup->roles))) {
                     throw new AuthorizationException();
                 }
             }
         }
     }
     $page = !empty($_GET['page']) && (int) $_GET['page'] ? abs((int) $_GET['page']) : 1;
     //update topic's view count
     $topicDto->viewCount += 1;
     $this->forumService->saveOrUpdateTopic($topicDto);
     //update user read info
     $this->forumService->setTopicRead($topicDto->id, $userId);
     $topicInfo = $this->forumService->getTopicInfo($topicDto->id);
     $postList = $this->forumService->getTopicPostList($topicDto->id, $page);
     OW::getEventManager()->trigger(new OW_Event('forum.topic_post_list', array('list' => $postList)));
     $this->assign('isHidden', $isHidden);
     // adds forum caption if any
     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);
         }
         $eParams = array('entity' => $forumSection->entity, 'entityId' => $forumGroup->entityId, 'action' => 'edit_topic');
         $event = new OW_Event('forum.check_permissions', $eParams);
         OW::getEventManager()->trigger($event);
         if ($event->getData()) {
             $canLock = $canSticky = true;
         }
     }
     $this->assign('postReplyPermissionErrorText', $postReplyPermissionErrorText);
     $this->assign('isHidden', $isHidden);
     $this->assign('isOwner', $isOwner);
     $this->assign('canPost', $canPost);
     $this->assign('canLock', $canLock);
     $this->assign('canSticky', $canSticky);
     $this->assign('canSubscribe', OW::getUser()->isAuthorized('forum', 'subscribe'));
     $this->assign('isSubscribed', $userId && FORUM_BOL_SubscriptionService::getInstance()->isUserSubscribed($userId, $topicDto->id));
     if (!$postList) {
         throw new Redirect404Exception();
     }
     $toolbars = array();
     $lang = OW::getLanguage();
     $langQuote = $lang->text('forum', 'quote');
     $langFlag = $lang->text('base', 'flag');
     $langEdit = $lang->text('forum', 'edit');
     $langDelete = $lang->text('forum', 'delete');
     $iteration = 0;
     $userIds = array();
     $postIds = array();
     $flagItems = array();
     $firstTopicPost = $this->forumService->findTopicFirstPost($topicDto->id);
     foreach ($postList as &$post) {
         $post['text'] = UTIL_HtmlTag::autoLink($post['text']);
         $post['permalink'] = $this->forumService->getPostUrl($post['topicId'], $post['id'], true, $page);
         $post['number'] = ($page - 1) * $this->forumService->getPostPerPageConfig() + $iteration + 1;
         if ($iteration == 0) {
             $firstPostText = substr(htmlspecialchars(strip_tags($post['text'])), 0, 154);
         }
         // get list of users
         if (!in_array($post['userId'], $userIds)) {
             $userIds[$post['userId']] = $post['userId'];
         }
         $toolbar = array();
         array_push($toolbar, array('class' => 'post_permalink', 'href' => $post['permalink'], 'label' => '#' . $post['number']));
         if ($userId) {
             if (!$topicDto->locked && ($canEdit || $canPost)) {
                 array_push($toolbar, array('id' => $post['id'], 'class' => 'quote_post', 'href' => 'javascript://', 'label' => $langQuote));
             }
             if ($userId != (int) $post['userId']) {
                 $lagItemKey = 'flag_' . $post['id'];
                 $flagItems[$lagItemKey] = array('id' => $post['id'], 'title' => $post['text'], 'href' => $this->forumService->getPostUrl($post['topicId'], $post['id']));
                 array_push($toolbar, array('label' => $langFlag, 'href' => 'javascript://', 'id' => $lagItemKey, 'class' => 'post_flag_item'));
             }
         }
         if ($isModerator || $userId == (int) $post['userId'] && !$topicDto->locked) {
             $href = $iteration == 0 && $page == 1 ? OW::getRouter()->urlForRoute('edit-topic', array('id' => $post['topicId'])) : OW::getRouter()->urlForRoute('edit-post', array('id' => $post['id']));
             array_push($toolbar, array('id' => $post['id'], 'href' => $href, 'label' => $langEdit));
             if (!($iteration == 0 && $page == 1)) {
                 array_push($toolbar, array('id' => $post['id'], 'class' => 'delete_post', 'href' => 'javascript://', 'label' => $langDelete));
             }
             if ($iteration === 0 && !$isOwner && $isModerator && $topicInfo['status'] == FORUM_BOL_ForumService::STATUS_APPROVAL) {
                 $toolbar[] = array('id' => $topicInfo['id'], 'href' => OW::getRouter()->urlForRoute('forum_approve_topic', array('id' => $topicInfo['id'])), 'label' => OW::getLanguage()->text('forum', 'approve_topic'));
             }
         }
         $toolbars[$post['id']] = $toolbar;
         if (count($post['edited']) && !in_array($post['edited']['userId'], $userIds)) {
             $userIds[$post['edited']['userId']] = $post['edited']['userId'];
         }
         $iteration++;
         array_push($postIds, $post['id']);
     }
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'jquery-fieldselection.js');
     $js = UTIL_JsGenerator::newInstance()->newVariable('flagItems', $flagItems)->jQueryEvent('.post_flag_item a', 'click', 'var inf = flagItems[this.id];
             if (inf.id == ' . $firstTopicPost->id . ' ){
                 OW.flagContent("' . FORUM_BOL_ForumService::FEED_ENTITY_TYPE . '", ' . $firstTopicPost->topicId . ');
             }
             else{
                 OW.flagContent("' . FORUM_BOL_ForumService::FEED_POST_ENTITY_TYPE . '", inf.id);
             }');
     OW::getDocument()->addOnloadScript($js, 1001);
     $this->assign('toolbars', $toolbars);
     $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars($userIds);
     $this->assign('avatars', $avatars);
     $enableAttachments = OW::getConfig()->getValue('forum', 'enable_attachments');
     $this->assign('enableAttachments', $enableAttachments);
     $uid = uniqid();
     $addPostForm = $this->generateAddPostForm($topicDto->id, $uid);
     $this->addForm($addPostForm);
     $addPostInputId = $addPostForm->getElement('text')->getId();
     if ($enableAttachments) {
         $attachments = FORUM_BOL_PostAttachmentService::getInstance()->findAttachmentsByPostIdList($postIds);
         $this->assign('attachments', $attachments);
         $attachmentCmp = new BASE_CLASS_FileAttachment('forum', $uid);
         $this->addComponent('attachmentsCmp', $attachmentCmp);
     }
     $plugin = OW::getPluginManager()->getPlugin('forum');
     $indexUrl = OW::getRouter()->urlForRoute('forum-default');
     $groupUrl = OW::getRouter()->urlForRoute('group-default', array('groupId' => $topicDto->groupId));
     $deletePostUrl = OW::getRouter()->urlForRoute('delete-post', array('topicId' => $topicDto->id, 'postId' => 'postId'));
     $stickyTopicUrl = OW::getRouter()->urlForRoute('sticky-topic', array('topicId' => $topicDto->id, 'page' => $page));
     $lockTopicUrl = OW::getRouter()->urlForRoute('lock-topic', array('topicId' => $topicDto->id, 'page' => $page));
     $deleteTopicUrl = OW::getRouter()->urlForRoute('delete-topic', array('topicId' => $topicDto->id));
     $getPostUrl = OW::getRouter()->urlForRoute('get-post', array('postId' => 'postId'));
     $moveTopicUrl = OW::getRouter()->urlForRoute('move-topic');
     $subscribeTopicUrl = OW::getRouter()->urlForRoute('subscribe-topic', array('id' => $topicDto->id));
     $unsubscribeTopicUrl = OW::getRouter()->urlForRoute('unsubscribe-topic', array('id' => $topicDto->id));
     $topicInfoJs = json_encode(array('sticky' => $topicDto->sticky, 'locked' => $topicDto->locked, 'ishidden' => $isHidden && !$canMoveToHidden));
     $onloadJs = "\n\t\t\tForumTopic.deletePostUrl = '{$deletePostUrl}';\n\t\t\tForumTopic.stickyTopicUrl = '{$stickyTopicUrl}';\n\t\t\tForumTopic.lockTopicUrl = '{$lockTopicUrl}';\n\t\t\tForumTopic.subscribeTopicUrl = '{$subscribeTopicUrl}';\n\t\t\tForumTopic.unsubscribeTopicUrl = '{$unsubscribeTopicUrl}';\n\t\t\tForumTopic.deleteTopicUrl = '{$deleteTopicUrl}';\n\t\t\tForumTopic.getPostUrl = '{$getPostUrl}';\n\t\t\tForumTopic.add_post_input_id = '{$addPostInputId}';\n\t\t\tForumTopic.construct({$topicInfoJs});\n\t\t\t";
     OW::getDocument()->addOnloadScript($onloadJs);
     OW::getDocument()->addScript($plugin->getStaticJsUrl() . "forum.js");
     // add language keys for javascript
     $lang->addKeyForJs('forum', 'sticky_topic_confirm');
     $lang->addKeyForJs('forum', 'unsticky_topic_confirm');
     $lang->addKeyForJs('forum', 'lock_topic_confirm');
     $lang->addKeyForJs('forum', 'unlock_topic_confirm');
     $lang->addKeyForJs('forum', 'delete_topic_confirm');
     $lang->addKeyForJs('forum', 'delete_post_confirm');
     $lang->addKeyForJs('forum', 'edit_topic_title');
     $lang->addKeyForJs('forum', 'edit_post_title');
     $lang->addKeyForJs('forum', 'move_topic_title');
     $lang->addKeyForJs('forum', 'confirm_delete_attachment');
     $lang->addKeyForJs('forum', 'forum_quote');
     $lang->addKeyForJs('forum', 'forum_quote_from');
     // first topic's post
     $postDto = $firstTopicPost;
     //posts count on page
     $count = $this->forumService->getPostPerPageConfig();
     $postCount = $this->forumService->findTopicPostCount($topicDto->id);
     $pageCount = ceil($postCount / $count);
     $groupSelect = $this->forumService->getGroupSelectList($topicDto->groupId, $canMoveToHidden, $userId);
     $moveTopicForm = $this->generateMoveTopicForm($moveTopicUrl, $groupSelect, $topicDto);
     $this->addForm($moveTopicForm);
     $Paging = new BASE_CMP_Paging($page, $pageCount, $count);
     $this->assign('paging', $Paging->render());
     if ($isHidden) {
         OW::getNavigation()->deactivateMenuItems(OW_Navigation::MAIN);
         OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, $forumSection->entity, $eventData['key']);
         OW::getDocument()->setHeading(OW::getLanguage()->text($forumSection->entity, 'topic_page_heading', array('topic' => $topicInfo['title'], 'group' => $topicInfo['groupName'], 'content' => '')));
         $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);
     } else {
         $bcItems = array(array('href' => $indexUrl, 'label' => $lang->text('forum', 'forum_index')), array('href' => OW::getRouter()->urlForRoute('section-default', array('sectionId' => $topicInfo['sectionId'])), 'label' => $topicInfo['sectionName']), array('href' => $groupUrl, 'label' => $topicInfo['groupName']));
         $breadCrumbCmp = new BASE_CMP_Breadcrumb($bcItems, $lang->text('forum', 'topic_location'));
         $this->addComponent('breadcrumb', $breadCrumbCmp);
         OW::getDocument()->setHeading(OW::getLanguage()->text('forum', 'topic_page_heading', array('topic' => $topicInfo['title'], 'content' => $topicInfo['status'] == FORUM_BOL_ForumService::STATUS_APPROVED ? '' : OW::getLanguage()->text('forum', 'pending_approval'))));
     }
     OW::getDocument()->setHeadingIconClass('ow_ic_script');
     $this->assign('indexUrl', $indexUrl);
     $this->assign('groupUrl', $groupUrl);
     $this->assign('topicInfo', $topicInfo);
     $this->assign('postList', $postList);
     $this->assign('page', $page);
     $this->assign('userId', $userId);
     $this->assign('isModerator', $isModerator);
     $this->assign('canEdit', $canEdit);
     $this->assign('canMoveToHidden', $canMoveToHidden);
     OW::getDocument()->setTitle($topicInfo['title']);
     OW::getDocument()->setDescription($firstPostText);
     $this->addComponent('search', new FORUM_CMP_ForumSearch(array('scope' => 'topic', 'topicId' => $topicDto->id)));
     $tb = array();
     $toolbarEvent = new BASE_CLASS_EventCollector('forum.collect_topic_toolbar_items', array('topicId' => $topicDto->id, 'topicDto' => $topicDto));
     OW::getEventManager()->trigger($toolbarEvent);
     foreach ($toolbarEvent->getData() as $toolbarItem) {
         array_push($tb, $toolbarItem);
     }
     $this->assign('tb', $tb);
 }
Ejemplo n.º 25
0
 public function statusUpdate()
 {
     if (empty($_POST['status']) && empty($_POST['attachment'])) {
         echo json_encode(false);
         exit;
     }
     if (!OW::getUser()->isAuthenticated()) {
         echo json_encode(false);
         exit;
     }
     $oembed = null;
     $attachId = null;
     $status = empty($_POST['status']) ? '' : strip_tags($_POST['status']);
     $content = array();
     if (!empty($_POST['attachment'])) {
         $content = json_decode($_POST['attachment'], true);
         if (!empty($content)) {
             if ($content['type'] == 'photo' && !empty($content['genId'])) {
                 $content['url'] = $content['href'] = OW::getEventManager()->call('base.attachment_save_image', array('genId' => $content['genId']));
                 $attachId = $content['genId'];
             }
             if ($content['type'] == 'video') {
                 $content['html'] = BOL_TextFormatService::getInstance()->validateVideoCode($content['html']);
             }
         }
     }
     $status = UTIL_HtmlTag::autoLink($status);
     $out = NEWSFEED_BOL_Service::getInstance()->addStatus(OW::getUser()->getId(), $_POST['feedType'], $_POST['feedId'], $_POST['visibility'], $status, array("content" => $content, "attachmentId" => $attachId));
     echo json_encode($out);
     exit;
 }
Ejemplo n.º 26
0
function renderQuestion($userId, $questionName, $label = false)
{
    global $QuestionService;
    global $language;
    global $getConfig;
    global $QUESTION_PRESENTATION_SELECT;
    global $QUESTION_PRESENTATION_RADIO;
    global $QUESTION_PRESENTATION_MULTICHECKBOX;
    global $QUESTION_PRESENTATION_URL;
    global $QUESTION_PRESENTATION_TEXT;
    global $QUESTION_PRESENTATION_TEXTAREA;
    global $QUESTION_PRESENTATION_DATE;
    global $QUESTION_VALUE_TYPE_DATETIME;
    global $QUESTION_VALUE_TYPE_SELECT;
    global $QUESTION_PRESENTATION_BIRTHDATE;
    global $QUESTION_PRESENTATION_AGE;
    global $QUESTION_PRESENTATION_RANGE;
    global $MYSQL_DATETIME_DATE_FORMAT;
    $questionData = $QuestionService->getQuestionData(array($userId), array($questionName));
    if (!isset($questionData[$userId][$questionName])) {
        return null;
    }
    $question = $QuestionService->findQuestionByName($questionName);
    switch ($question->presentation) {
        case $QUESTION_PRESENTATION_DATE:
            $format = $getConfig->getValue('base', 'date_field_format');
            $value = 0;
            switch ($question->type) {
                case $QUESTION_VALUE_TYPE_DATETIME:
                    $date = UTIL_DateTime::parseDate($questionData[$userId][$question->name], $MYSQL_DATETIME_DATE_FORMAT);
                    $value = $date;
                    break;
                case $QUESTION_VALUE_TYPE_SELECT:
                    $value = (int) $questionData[$userId][$question->name];
                    break;
            }
            if ($format === 'dmy') {
                $questionData[$userId][$question->name] = date("d/m/Y", $value);
            } else {
                $questionData[$userId][$question->name] = date("m/d/Y", $value);
            }
            break;
        case $QUESTION_PRESENTATION_BIRTHDATE:
            $date = UTIL_DateTime::parseDate($questionData[$userId][$question->name], $MYSQL_DATETIME_DATE_FORMAT);
            $questionData[$userId][$question->name] = UTIL_DateTime::formatBirthdate($date['year'], $date['month'], $date['day']);
            break;
        case $QUESTION_PRESENTATION_AGE:
            $date = UTIL_DateTime::parseDate($questionData[$userId][$question->name], $MYSQL_DATETIME_DATE_FORMAT);
            $questionData[$userId][$question->name] = date("Y/m/d", strtotime($date['year'] . "/" . $date['month'] . "/" . $date['day']));
            break;
        case $QUESTION_PRESENTATION_RANGE:
            $range = explode('-', $questionData[$userId][$question->name]);
            $questionData[$userId][$question->name] = $language->text('base', 'form_element_from') . " " . $range[0] . " " . $language->text('base', 'form_element_to') . " " . $range[1];
            break;
        case $QUESTION_PRESENTATION_SELECT:
        case $QUESTION_PRESENTATION_RADIO:
        case $QUESTION_PRESENTATION_MULTICHECKBOX:
            $value = "";
            $multicheckboxValue = (int) $questionData[$userId][$question->name];
            $questionValues = $QuestionService->findQuestionValues($question->name);
            foreach ($questionValues as $val) {
                /* @var $val BOL_QuestionValue */
                if ((int) $val->value & $multicheckboxValue) {
                    if ($label == false) {
                        if (strlen($value) > 0) {
                            $value .= ',';
                        }
                        $value .= $val->value;
                        //$language->text('base', 'questions_question_' . $question->name . '_value_' . ($val->value));
                    } else {
                        if (strlen($value) > 0) {
                            $value .= ',';
                            // $value .= '@@';
                        }
                        // $QuestionService = $QuestionService;
                        $value .= $QuestionService->getQuestionValueLang($question->name, $val->value);
                        //$language->text('base', 'questions_question_' . $question->name . '_value_' . ($val->value));
                    }
                }
            }
            if (strlen($value) > 0) {
                $questionData[$userId][$question->name] = $value;
            }
            break;
        case $QUESTION_PRESENTATION_URL:
        case $QUESTION_PRESENTATION_TEXT:
        case $QUESTION_PRESENTATION_TEXTAREA:
            // googlemap_location shortcut
            if ($question->name == "googlemap_location" && !empty($questionData[$userId][$question->name]) && is_array($questionData[$userId][$question->name])) {
                $mapData = $questionData[$userId][$question->name];
                $value = trim($mapData["address"]);
            } else {
                $value = trim($questionData[$userId][$question->name]);
            }
            if (strlen($value) > 0) {
                $questionData[$userId][$question->name] = UTIL_HtmlTag::autoLink(nl2br($value));
            }
            break;
        default:
            $questionData[$userId][$question->name] = null;
    }
    return $questionData[$userId][$question->name];
}
Ejemplo n.º 27
0
 public function statusUpdate()
 {
     if (empty($_POST['status']) && empty($_POST['attachment'])) {
         echo json_encode(array("error" => OW::getLanguage()->text('base', 'form_validate_common_error_message')));
         exit;
     }
     if (!OW::getUser()->isAuthenticated()) {
         echo json_encode(false);
         exit;
     }
     $oembed = null;
     $attachId = null;
     $status = empty($_POST['status']) ? '' : strip_tags($_POST['status']);
     $content = array();
     if (!empty($_POST['attachment'])) {
         $content = json_decode($_POST['attachment'], true);
         if (!empty($content)) {
             if ($content['type'] == 'photo' && !empty($content['uid'])) {
                 $attachmentData = OW::getEventManager()->call('base.attachment_save_image', array("pluginKey" => "newsfeed", 'uid' => $content['uid']));
                 $content['url'] = $content['href'] = $attachmentData["url"];
                 $attachId = $content['uid'];
             }
             if ($content['type'] == 'video') {
                 $content['html'] = BOL_TextFormatService::getInstance()->validateVideoCode($content['html']);
             }
         }
     }
     $userId = OW::getUser()->getId();
     $event = new OW_Event("feed.before_content_add", array("feedType" => $_POST['feedType'], "feedId" => $_POST['feedId'], "visibility" => $_POST['visibility'], "userId" => $userId, "status" => $status, "type" => empty($content["type"]) ? "text" : $content["type"], "data" => $content));
     OW::getEventManager()->trigger($event);
     $data = $event->getData();
     if (!empty($data)) {
         if (!empty($attachId)) {
             BOL_AttachmentService::getInstance()->deleteAttachmentByBundle("newsfeed", $attachId);
         }
         $item = empty($data["entityType"]) || empty($data["entityId"]) ? null : array("entityType" => $data["entityType"], "entityId" => $data["entityId"]);
         echo json_encode(array("item" => $item, "message" => empty($data["message"]) ? null : $data["message"], "error" => empty($data["error"]) ? null : $data["error"]));
         exit;
     }
     $status = UTIL_HtmlTag::autoLink($status);
     $out = NEWSFEED_BOL_Service::getInstance()->addStatus(OW::getUser()->getId(), $_POST['feedType'], $_POST['feedId'], $_POST['visibility'], $status, array("content" => $content, "attachmentId" => $attachId));
     echo json_encode(array("item" => $out));
     exit;
 }