Example #1
0
 public function __construct($groupId)
 {
     parent::__construct();
     $cover = GHEADER_BOL_Service::getInstance()->findCoverByGroupId($groupId);
     if (empty($cover)) {
         $this->assign('error', OW::getLanguage()->text('gheader', 'cover_not_found'));
         return;
     }
     $group = GROUPS_BOL_Service::getInstance()->findGroupById($cover->groupId);
     $src = GHEADER_BOL_Service::getInstance()->getCoverUrl($cover);
     $settings = $cover->getSettings();
     $height = $settings['dimensions']['height'];
     $width = $settings['dimensions']['width'];
     $top = 0;
     if ($height < self::MIN_HEIGHT) {
         $top = (self::MIN_HEIGHT - $height) / 2;
     }
     $this->assign('src', $src);
     $this->assign('top', $top);
     $this->assign('dimensions', $settings['dimensions']);
     $userId = OW::getUser()->getId();
     $cmtParams = new BASE_CommentsParams('gheader', GHEADER_CLASS_CommentsBridge::ENTITY_TYPE);
     $cmtParams->setEntityId($cover->id);
     $cmtParams->setAddComment(GHEADER_BOL_Service::getInstance()->isUserCanInteract($userId, $group->id));
     $cmtParams->setOwnerId($group->userId);
     $cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_TOP_FORM_WITH_PAGING);
     $photoCmts = new BASE_CMP_Comments($cmtParams);
     $this->addComponent('comments', $photoCmts);
 }
Example #2
0
 public function __construct($userId)
 {
     parent::__construct();
     $cover = UHEADER_BOL_Service::getInstance()->findCoverByUserId($userId);
     if (empty($cover)) {
         $this->assign('error', OW::getLanguage()->text('uheader', 'cover_not_found'));
         return;
     }
     $src = UHEADER_BOL_Service::getInstance()->getCoverUrl($cover);
     $settings = $cover->getSettings();
     $height = $settings['dimensions']['height'];
     $width = $settings['dimensions']['width'];
     $top = 0;
     if ($height < self::MIN_HEIGHT) {
         $top = (self::MIN_HEIGHT - $height) / 2;
     }
     $avatarsData = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($userId));
     $this->assign('user', $avatarsData[$userId]);
     $this->assign('src', $src);
     $this->assign('top', $top);
     $this->assign('dimensions', $settings['dimensions']);
     $cmtParams = new BASE_CommentsParams('uheader', UHEADER_CLASS_CommentsBridge::ENTITY_TYPE);
     $cmtParams->setWrapInBox(false);
     $cmtParams->setEntityId($cover->id);
     $cmtParams->setOwnerId($userId);
     $cmtParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_TOP_FORM_WITH_PAGING);
     $photoCmts = new BASE_CMP_Comments($cmtParams);
     $this->addComponent('comments', $photoCmts);
 }
Example #3
0
 /**
  * @return Constructor.
  */
 public function __construct(BASE_CLASS_WidgetParameter $paramObj)
 {
     parent::__construct();
     $params = $paramObj->customParamList;
     $commentParams = new BASE_CommentsParams('groups', GROUPS_BOL_Service::ENTITY_TYPE_WAL);
     $groupId = (int) $paramObj->additionalParamList['entityId'];
     $commentParams->setEntityId($groupId);
     if (isset($params['comments_count'])) {
         $commentParams->setCommentCountOnPage($params['comments_count']);
     }
     if (isset($params['display_mode'])) {
         $commentParams->setDisplayType($params['display_mode']);
     }
     $isMember = GROUPS_BOL_Service::getInstance()->findUser($groupId, OW::getUser()->getId()) !== null;
     $commentParams->setAddComment($isMember);
     $this->addComponent('comments', new BASE_CMP_Comments($commentParams));
 }
Example #4
0
 public function __construct(BASE_CommentsParams $params, $id, $formName)
 {
     parent::__construct();
     $language = OW::getLanguage();
     $form = new Form($formName);
     $textArea = new Textarea('commentText');
     $textArea->setHasInvitation(true);
     $textArea->setInvitation($language->text('base', 'comment_form_element_invitation_text'));
     $form->addElement($textArea);
     $hiddenEls = array('entityType' => $params->getEntityType(), 'entityId' => $params->getEntityId(), 'displayType' => $params->getDisplayType(), 'pluginKey' => $params->getPluginKey(), 'ownerId' => $params->getOwnerId(), 'cid' => $id, 'commentCountOnPage' => $params->getCommentCountOnPage(), 'isMobile' => 1);
     foreach ($hiddenEls as $name => $value) {
         $el = new HiddenField($name);
         $el->setValue($value);
         $form->addElement($el);
     }
     $submit = new Submit('comment-submit');
     $submit->setValue($language->text('base', 'comment_add_submit_label'));
     $form->addElement($submit);
     $form->setAjax(true);
     $form->setAction(OW::getRouter()->urlFor('BASE_CTRL_Comments', 'addComment'));
     //        $form->bindJsFunction(Form::BIND_SUBMIT, "function(){ $('#comments-" . $id . " .comments-preloader').show();}");
     //        $form->bindJsFunction(Form::BIND_SUCCESS, "function(){ $('#comments-" . $id . " .comments-preloader').hide();}");
     $this->addForm($form);
     OW::getDocument()->addOnloadScript("window.owCommentCmps['{$id}'].initForm('" . $textArea->getId() . "', '" . $submit->getId() . "');");
     $this->assign('form', true);
     $this->assign('id', $id);
 }
Example #5
0
 /**
  * @return Constructor.
  */
 public function __construct($paramObj)
 {
     parent::__construct();
     // check if comments are empty and user can't add comments
     if ((int) BOL_CommentService::getInstance()->findCommentCount('base_index_wall', 1) === 0) {
         if (!OW::getUser()->isAuthenticated()) {
             $this->setVisible(false);
         }
     }
     $params = $paramObj->customParamList;
     $commentParams = new BASE_CommentsParams('base', 'base_index_wall');
     if (isset($params['comments_count'])) {
         $commentParams->setCommentCountOnPage($params['comments_count']);
     }
     $commentParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_TOP_FORM_WITH_PAGING);
     $commentParams->setWrapInBox(false);
     $this->addComponent('comments', new BASE_CMP_Comments($commentParams));
 }
Example #6
0
 protected function getFeatures($data)
 {
     $configs = $this->sharedData['configs'];
     $feturesData = $this->getFeaturesData($data);
     $featureDefaults = array("uniqId" => uniqid("nf-feature-"), "class" => "", "active" => false, "count" => null, "error" => null, "url" => "javascript://", "hideButton" => false, "innerHtml" => null, "html" => null);
     $features = array();
     $js = UTIL_JsGenerator::newInstance();
     // Likes
     if (!empty($feturesData["system"]["likes"])) {
         $feature = $feturesData["system"]["likes"];
         $features["likes"] = array_merge($featureDefaults, array("uniqId" => uniqid("nf-feature-"), "class" => "owm_newsfeed_control_like", "active" => $feature["liked"], "count" => $feature["count"], "error" => $feature["error"], "url" => "javascript://"));
         $js->newObject("likeFeature", "NEWSFEED_MobileFeatureLikes", array($feature["entityType"], $feature["entityId"], $features["likes"]));
     }
     // Comments
     if (!empty($feturesData["system"]["comments"])) {
         $feature = $feturesData["system"]["comments"];
         $comments = array_merge($featureDefaults, array("uniqId" => uniqid("nf-feature-"), "class" => "owm_newsfeed_control_comment", "active" => false, "count" => $feature["count"], "url" => OW::getRequest()->buildUrlQueryString($this->itemPermalink, array(), "comments")));
         if ($this->displayType == NEWSFEED_MCMP_Feed::DISPLAY_TYPE_PAGE) {
             $comments["hideButton"] = true;
             $commentsParams = new BASE_CommentsParams($feature["authGroup"], $feature["entityType"]);
             $commentsParams->setEntityId($feature["entityId"]);
             $commentsParams->setCommentCountOnPage($configs['comments_count']);
             $commentsParams->setBatchData($feature["comments"]);
             //$commentsParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_PARTIAL_LIST_AND_MINI_IPC);
             $commentsParams->setOwnerId($data['action']['userId']);
             $commentsParams->setWrapInBox(false);
             if (!empty($feature['error'])) {
                 $commentsParams->setErrorMessage($feature['error']);
             }
             if (isset($feature['allow'])) {
                 $commentsParams->setAddComment($feature['allow']);
             }
             $commentCmp = new BASE_MCMP_Comments($commentsParams);
             $comments['html'] = $commentCmp->render();
         }
         $features[] = $comments;
     }
     $jsString = $js->generateJs();
     if (trim($jsString)) {
         OW::getDocument()->addOnloadScript($js);
     }
     foreach ($feturesData["custom"] as $customFeature) {
         $features[] = array_merge($featureDefaults, $customFeature);
     }
     $visibleCount = 0;
     foreach ($features as $f) {
         if (empty($f["hideButton"])) {
             $visibleCount++;
         }
     }
     return array("items" => $features, "buttonsCount" => $visibleCount);
 }
Example #7
0
 public function initForm()
 {
     if ($this->isAuthorized) {
         $countOnPage = isset($this->batchData['countOnPage']) ? $this->batchData['countOnPage'] : $this->params->getCommentCountOnPage();
         $formCmpParams = array($this->params->getEntityType(), $this->params->getEntityId(), $this->params->getDisplayType(), $this->params->getPluginKey(), $this->params->getOwnerId(), in_array($this->params->getDisplayType(), array(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_PARTIAL_LIST, BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_PARTIAL_LIST_AND_MINI_IPC)) ? $countOnPage + 1 : $countOnPage, $this->id, $this->cmpContextId, $this->formName);
         OW::getDocument()->addOnloadScript("window.owCommentCmps['{$this->id}'] = new OwComments('{$this->cmpContextId}', '{$this->formName}', '{$this->id}', " . json_encode($formCmpParams) . ");\n                    \$('.comments_fake_autoclick', \$('#{$this->cmpContextId}')).one('focus', function(){window.owCommentCmps['{$this->id}'].loadForm();});");
         $this->assign('formCmp', true);
         if (!empty($this->staticData['currentUserInfo'])) {
             $userInfoToAssign = $this->staticData['currentUserInfo'];
         } else {
             $currentUserInfo = BOL_AvatarService::getInstance()->getDataForUserAvatars(array(OW::getUser()->getId()));
             $userInfoToAssign = $currentUserInfo[OW::getUser()->getId()];
         }
         $this->assign('currentUserInfo', $userInfoToAssign);
     }
     $this->assign('displayType', $this->params->getDisplayType());
     // add comment list cmp
     $this->addComponent('commentList', new BASE_CMP_CommentsList($this->params, $this->id));
 }
Example #8
0
 protected function init()
 {
     if ($this->commentCount === 0 && $this->params->getDisplayType() !== BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_PARTIAL_LIST_AND_MINI_IPC) {
         $this->assign('noComments', true);
     }
     if ($this->commentCount === 0) {
         $commentList = array();
     } else {
         if ($this->params->getDisplayType() === BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST) {
             $commentList = $this->commentService->findFullCommentList($this->params->getEntityType(), $this->params->getEntityId());
         } else {
             if (in_array($this->params->getDisplayType(), array(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_PARTIAL_LIST, BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_PARTIAL_LIST_AND_MINI_IPC))) {
                 $commentList = empty($this->batchData['commentsList']) ? $this->commentService->findCommentList($this->params->getEntityType(), $this->params->getEntityId(), 1, $this->params->getCommentCountOnPage()) : $this->batchData['commentsList'];
                 $commentList = array_reverse($commentList);
                 if ($this->commentCount > $this->params->getCommentCountOnPage()) {
                     $this->assign('viewAllLink', OW::getLanguage()->text('base', 'comment_view_all', array('count' => $this->commentCount)));
                 }
             } else {
                 $commentList = $this->commentService->findCommentList($this->params->getEntityType(), $this->params->getEntityId(), $this->page, $this->params->getCommentCountOnPage());
             }
         }
     }
     OW::getEventManager()->trigger(new OW_Event('base.comment_list_prepare_data', array('list' => $commentList)));
     OW::getEventManager()->bind('base.comment_item_process', array($this, 'itemHandler'));
     $this->assign('comments', $this->processList($commentList));
     $pages = false;
     if ($this->params->getDisplayType() === BASE_CommentsParams::DISPLAY_TYPE_TOP_FORM_WITH_PAGING) {
         $pagesCount = $this->commentService->findCommentPageCount($this->params->getEntityType(), $this->params->getEntityId(), $this->params->getCommentCountOnPage());
         if ($pagesCount > 1) {
             $pages = $this->getPages($this->page, $pagesCount, 8);
             $this->assign('pages', $pages);
         }
     } else {
         $pagesCount = 0;
     }
     static $dataInit = false;
     if (!$dataInit) {
         $staticDataArray = array('respondUrl' => OW::getRouter()->urlFor('BASE_CTRL_Comments', 'getCommentList'), 'delUrl' => OW::getRouter()->urlFor('BASE_CTRL_Comments', 'deleteComment'), 'delAtchUrl' => OW::getRouter()->urlFor('BASE_CTRL_Comments', 'deleteCommentAtatchment'), 'delConfirmMsg' => OW::getLanguage()->text('base', 'comment_delete_confirm_message'), 'preloaderImgUrl' => OW::getThemeManager()->getCurrentTheme()->getStaticImagesUrl() . 'ajax_preloader_button.gif');
         OW::getDocument()->addOnloadScript("window.owCommentListCmps.staticData=" . json_encode($staticDataArray) . ";");
         $dataInit = true;
     }
     $jsParams = json_encode(array('totalCount' => $this->commentCount, 'contextId' => $this->cmpContextId, 'displayType' => $this->params->getDisplayType(), 'entityType' => $this->params->getEntityType(), 'entityId' => $this->params->getEntityId(), 'pagesCount' => $pagesCount, 'commentIds' => $this->commentIdList, 'pages' => $pages, 'pluginKey' => $this->params->getPluginKey(), 'ownerId' => $this->params->getOwnerId(), 'commentCountOnPage' => $this->params->getCommentCountOnPage(), 'cid' => $this->id, 'actionArray' => $this->actionArr));
     OW::getDocument()->addOnloadScript("window.owCommentListCmps.items['{$this->id}'] = new OwCommentsList({$jsParams});\n            window.owCommentListCmps.items['{$this->id}'].init();");
 }
Example #9
0
 /**
  * Constructor.
  */
 public function __construct(BASE_CLASS_WidgetParameter $paramObj)
 {
     parent::__construct();
     $userId = (int) $paramObj->additionalParamList['entityId'];
     $params = $paramObj->customParamList;
     $commentParams = new BASE_CommentsParams('base', 'base_profile_wall');
     $commentParams->setEntityId($userId);
     if (isset($params['comments_count'])) {
         $commentParams->setCommentCountOnPage($params['comments_count']);
     }
     if (isset($params['display_mode'])) {
         $commentParams->setDisplayType($params['display_mode']);
     }
     $commentParams->setOwnerId($userId);
     $commentParams->setWrapInBox(false);
     $this->addComponent('comments', new BASE_CMP_Comments($commentParams));
 }
Example #10
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]);
 }
Example #11
0
 public function __construct($questionId, $userContext = null, $count = null, $options = null)
 {
     parent::__construct();
     $language = OW::getLanguage();
     $configs = OW::getConfig()->getValues('questions');
     $count = empty($count) ? QUESTIONS_BOL_Service::MORE_DISPLAY_COUNT : $count;
     $uniqId = uniqid('question_');
     $this->assign('uniqId', $uniqId);
     $service = QUESTIONS_BOL_Service::getInstance();
     $userId = OW::getUser()->getId();
     $question = $service->findQuestion($questionId);
     if (empty($question)) {
         $this->assign('noQuestion', true);
         return;
     }
     $settings = $question->getSettings();
     $isPoll = !$settings['allowAddOprions'];
     $optionTotal = $service->findOptionCount($questionId);
     $answerCount = $service->findTotalAnswersCount($questionId);
     $postCount = BOL_CommentService::getInstance()->findCommentCount('question', $questionId);
     $isAutor = $question->userId == $userId;
     if ($optionTotal - $count < 10) {
         $count = $optionTotal;
     }
     $limit = $count ? array(0, $count) : null;
     $answers = new QUESTIONS_CMP_Answers($question, $optionTotal, $limit);
     $answers->setExpandedView();
     $answers->setSettings($options);
     if (isset($options['inPopup']) && $options['inPopup'] === true) {
         $answers->setInPopupMode();
     }
     if (isset($options['loadStatic']) && $options['loadStatic'] === false) {
         $answers->setDoNotLoadStatic();
     }
     $editable = $service->isCurrentUserCanInteract($question);
     $answers->setEditable($editable && $service->isCurrentUserCanAnswer($question));
     if ($userContext !== null) {
         $answers->setUsersContext($userContext);
     }
     $answers->showAddNew();
     $this->addComponent('answers', $answers);
     $followsCount = $service->findFollowsCount($question->id, $userContext, array($question->userId));
     $statusCmp = new QUESTIONS_CMP_QuestionStatus($answers->getUniqId(), $postCount, $answerCount, $followsCount);
     $plugin = OW::getPluginManager()->getPlugin('questions');
     $statusCmp->setTemplate($plugin->getCmpViewDir() . 'question_static_status.html');
     $this->addComponent('questionStatus', $statusCmp);
     $tplQuestion = array('text' => nl2br($question->text));
     $event = new OW_Event(QUESTIONS_BOL_Service::EVENT_ON_QUESTION_RENDER, array("questionId" => $question->id, "questionDto" => $question, "text" => $question->text, "settings" => $settings, "uniqId" => $uniqId), $tplQuestion);
     OW::getEventManager()->trigger($event);
     $this->assign('question', $event->getData());
     $js = UTIL_JsGenerator::newInstance()->newObject('question', 'QUESTIONS_Question', array($uniqId, $question->id));
     if ($configs['allow_comments']) {
         $commentsParams = new BASE_CommentsParams('questions', QUESTIONS_BOL_Service::ENTITY_TYPE);
         $commentsParams->setEntityId($question->id);
         $commentsParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_TOP_FORM_WITH_PAGING);
         $commentsParams->setCommentCountOnPage(5);
         $commentsParams->setOwnerId($question->userId);
         $commentsParams->setAddComment($editable);
         $commentCmp = new BASE_CMP_Comments($commentsParams);
         //$commentTemplate = OW::getPluginManager()->getPlugin('questions')->getCmpViewDir() . 'comments.html';
         //$commentCmp->setTemplate($commentTemplate);
         $this->addComponent('comments', $commentCmp);
         if (!empty($options['focusToPost'])) {
             $js->addScript('question.focusOnPostInput()');
         }
     }
     $jsSelector = 'QUESTIONS_AnswerListCollection.' . $answers->getUniqId();
     $js->addScript('question.setAnswerList(' . $jsSelector . ');');
     if (!empty($options['relation'])) {
         $js->addScript($jsSelector . '.setRelation("' . $options['relation'] . '");');
     }
     $js->equateVarables(array('QUESTIONS_QuestionColletction', $uniqId), 'question');
     OW::getDocument()->addOnloadScript($js);
     $toolbar = array();
     if ($service->isCurrentUserCanInteract($question)) {
         if ($configs['enable_follow']) {
             $this->assign('follow', array('isFollow' => $service->isFollow($userId, $question->id), 'followId' => $answers->getUniqId() . '-follow', 'unfollowId' => $answers->getUniqId() . '-unfollow', 'followClick' => $jsSelector . '.followQuestion()', 'unfollowClick' => $jsSelector . '.unfollowQuestion()'));
             /*$followLabel = $language->text('questions', 'toolbar_follow_btn');
                             $unfollowLabel = $language->text('questions', 'toolbar_unfollow_btn');
             
                             if ( $service->isFollow($userId, $question->id) )
                             {
                                 $toolbar[] = array(
                                     'label' => '<a id="' . $answers->getUniqId() . '-unfollow" href="javascript://" onclick="' .$jsSelector . '.unfollowQuestion()">' . $unfollowLabel . '</a>
                                                 <a id="' . $answers->getUniqId() . '-follow" href="javascript://" style="display: none;" onclick="' .$jsSelector . '.followQuestion()">' . $followLabel . '</a>'
                                 );
                             }
                             else
                             {
                                 $toolbar[] = array(
                                     'label' => '<a id="' . $answers->getUniqId() . '-unfollow" href="javascript://" style="display: none;" onclick="' .$jsSelector . '.unfollowQuestion()">' . $unfollowLabel . '</a>
                                                 <a id="' . $answers->getUniqId() . '-follow" href="javascript://" onclick="' .$jsSelector . '.followQuestion()">' . $followLabel . '</a>'
                                 );
                             }*/
         }
     }
     if ($isPoll) {
         $list = $service->findUserAnswerListByQuestionId($userId, $question->id);
         if (count($list)) {
             $toolbar[] = array('label' => '<a id="' . $answers->getUniqId() . '-unvote" href="javascript://" onclick="' . $jsSelector . '.unvote()">' . $language->text('questions', 'toolbar_unvote_btn') . '</a>');
         }
     }
     if ($service->isCurrentUserCanEdit($question)) {
         $condEmbed = "confirm('" . $language->text('questions', 'delete_question_confirm') . "')";
         $toolbar[] = array('label' => '<a href="javascript://" onclick="if(' . $condEmbed . ') ' . $jsSelector . '.deleteQuestion();">' . $language->text('questions', 'toolbar_delete_btn') . '</a>');
     }
     $userData = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($question->userId));
     $questionInfo = array('avatar' => $userData[$question->userId], 'profileUrl' => $userData[$question->userId]['url'], 'displayName' => $userData[$question->userId]['title'], 'content' => '', 'toolbar' => $toolbar, 'date' => UTIL_DateTime::formatDate($question->timeStamp));
     $this->assign('questionInfo', $questionInfo);
 }
Example #12
0
    public function project(array $params)
    {
        if (empty($params['id'])) {
            throw new Redirect404Exception();
        }
        $projectId = (int) $params['id'];
        $service = OCSFUNDRAISING_BOL_Service::getInstance();
        $project = $service->getGoalById($projectId);
        if (!$project) {
            throw new Redirect404Exception();
        }
        $this->assign('project', $project);
        $image = $project['dto']->image ? $service->generateImageUrl($project['dto']->image, false) : null;
        $this->assign('imageSrc', $image);
        $lang = OW::getLanguage();
        $viewerId = OW::getUser()->getId();
        $isOwner = $viewerId && $project['dto']->ownerId == $viewerId;
        $this->assign('isOwner', $isOwner);
        $avatar = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($project['dto']->ownerId));
        $this->assign('avatar', $avatar[$project['dto']->ownerId]);
        $this->assign('ownerUrl', BOL_UserService::getInstance()->getUserUrl($project['dto']->ownerId));
        $this->assign('categoryUrl', $project['dto']->categoryId ? OW::getRouter()->urlForRoute('ocsfundraising.category', array('id' => $project['dto']->categoryId)) : null);
        $cmntParams = new BASE_CommentsParams('ocsfundraising', 'ocsfundraising_project');
        $cmntParams->setEntityId($project['dto']->id);
        $cmntParams->setOwnerId($project['dto']->ownerId);
        $this->addComponent('comments', new BASE_CMP_Comments($cmntParams));
        // donations
        $userIdList = array();
        $latest = $service->getDonationList($projectId, 'latest', 1, 6);
        if ($latest) {
            foreach ($latest as $d) {
                if ($d['dto']->userId && !in_array($d['dto']->userId, $userIdList)) {
                    array_push($userIdList, $d['dto']->userId);
                }
            }
        }
        $this->assign('latest', $latest);
        $this->assign('currency', BOL_BillingService::getInstance()->getActiveCurrency());
        $script = '$("#btn-edit-project").click(function(){
            document.location.href = ' . json_encode(OW::getRouter()->urlForRoute('ocsfundraising.edit_project', array('id' => $projectId))) . ';
        });

        $("#btn-delete-project").click(function(){
            if ( confirm(' . json_encode($lang->text('ocsfundraising', 'project_delete_confirm')) . ') )
            {
                $.ajax({
                    url: ' . json_encode(OW::getRouter()->urlFor('OCSFUNDRAISING_CTRL_Project', 'ajaxDeleteProject')) . ',
                    type: "POST",
                    data: { projectId: ' . json_encode($projectId) . ' },
                    dataType: "json",
                    success: function(data)
                    {
                        if ( data.result == true ) {
                            if ( data.url )
                                document.location.href = data.url;
                        }
                        else if ( data.error != undefined ) {
                            OW.warning(data.error);
                        }
                    }
                });
            }
        });

        $("#btn-donate").click(function(){
            document.location.href = ' . json_encode(OW::getRouter()->urlForRoute('ocsfundraising.donate', array('goalId' => $projectId))) . '
        });
        ';
        OW::getDocument()->addOnloadScript($script);
        $this->setPageHeading($project['dto']->name);
        $this->setPageTitle($project['dto']->name);
        OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'ocsfundraising', 'projects');
    }
Example #13
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)));
 }
Example #14
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]);
     */
 }
Example #15
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'));
 }
Example #16
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);
 }
Example #17
0
 private function getParamsObject()
 {
     $errorMessage = false;
     $entityType = !isset($_POST['entityType']) ? null : trim($_POST['entityType']);
     $entityId = !isset($_POST['entityId']) ? null : (int) $_POST['entityId'];
     $pluginKey = !isset($_POST['pluginKey']) ? null : trim($_POST['pluginKey']);
     if (!$entityType || !$entityId || !$pluginKey) {
         $errorMessage = OW::getLanguage()->text('base', 'comment_ajax_error');
     }
     $params = new BASE_CommentsParams($pluginKey, $entityType);
     $params->setEntityId($entityId);
     if (isset($_POST['ownerId'])) {
         $params->setOwnerId((int) $_POST['ownerId']);
     }
     if (isset($_POST['commentCountOnPage'])) {
         $params->setCommentCountOnPage((int) $_POST['commentCountOnPage']);
     }
     if (isset($_POST['displayType'])) {
         $params->setDisplayType($_POST['displayType']);
     }
     if (isset($_POST['initialCount'])) {
         $params->setInitialCommentsCount((int) $_POST['initialCount']);
     }
     if (isset($_POST['loadMoreCount'])) {
         $params->setLoadMoreCount((int) $_POST['loadMoreCount']);
     }
     if ($errorMessage) {
         echo json_encode(array('error' => $errorMessage));
         exit;
     }
     return $params;
 }
Example #18
0
 public function index($params)
 {
     /**
      * @var $pl OW_ActionController
      */
     $plugin = OW::getPluginManager()->getPlugin('links');
     OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, $plugin->getKey(), 'main_menu_item');
     if (!OW::getUser()->isAuthorized('links', 'view')) {
         $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
         return;
     }
     $id = $params['id'];
     $service = LinkService::getInstance();
     $userService = BOL_UserService::getInstance();
     $link = $service->findById($id);
     if ($link === null) {
         throw new Redirect404Exception();
     }
     $link->setUrl(strip_tags($link->getUrl()));
     $link->setTitle(strip_tags($link->getTitle()));
     $link->setDescription(BASE_CMP_TextFormatter::fromBBtoHtml($link->getDescription()));
     if (OW::getUser()->isAuthenticated() && $link->getUserId() != OW::getUser()->getId() && !OW::getUser()->isAuthorized('links', 'view')) {
         $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
         return;
     }
     /* Check privacy permissions */
     if ($link->userId != OW::getUser()->getId() && !OW::getUser()->isAuthorized('links')) {
         $eventParams = array('action' => LinkService::PRIVACY_ACTION_VIEW_LINKS, 'ownerId' => $link->userId, 'viewerId' => OW::getUser()->getId());
         OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
     }
     /* */
     $this->setPageHeading(htmlspecialchars($link->getTitle()));
     $this->setPageHeadingIconClass('ow_ic_link');
     OW::getDocument()->setTitle(OW::getLanguage()->text('links', 'link_title', array('link_title' => htmlspecialchars($link->getTitle()), 'link_url' => $link->getUrl())));
     OW::getDocument()->setDescription(OW::getLanguage()->text('links', 'link_description', array('link_title' => htmlspecialchars($link->getTitle()), 'link_description' => htmlspecialchars(strip_tags($link->getDescription())))));
     $this->assign('info', array('dto' => $link, 'link' => mb_ereg_replace('http(s)?:\\/\\/', '', $link->getUrl())));
     $userId = OW::getUser()->getId();
     $user = !empty($userId) && intval($userId) > 0 ? $userService->findUserById($userId) : null;
     $this->assign('user', $user);
     $this->assign('userInfo', array('displayName' => $userService->getDisplayName($link->getUserId()), 'userName' => $userService->getUserName($link->getUserId())));
     $this->assign('isModerator', OW::getUser()->isAuthorized('links'));
     $tb = array();
     $toolbarEvent = new BASE_CLASS_EventCollector('links.collect_link_toolbar_items', array('linkId' => $link->id, 'linkDto' => $link));
     OW::getEventManager()->trigger($toolbarEvent);
     foreach ($toolbarEvent->getData() as $toolbarItem) {
         array_push($tb, $toolbarItem);
     }
     if (OW::getUser()->isAuthenticated() && $link->getUserId() != OW::getUser()->getId()) {
         $js = UTIL_JsGenerator::newInstance()->jQueryEvent('#link_toolbar_flag', 'click', UTIL_JsGenerator::composeJsString('OW.flagContent({$entity}, {$id}, {$title}, {$href}, "links+flags");', array('entity' => 'link', 'id' => $link->getId(), 'title' => htmlspecialchars(json_encode($link->getTitle())), 'href' => OW::getRouter()->urlForRoute('link', array('id' => $link->getId())))));
         OW::getDocument()->addOnloadScript($js, 1001);
         $tb[] = array('label' => OW::getLanguage()->text('base', 'flag'), 'href' => 'javascript://', 'id' => 'link_toolbar_flag');
     }
     if (OW::getUser()->isAuthenticated()) {
         $isModerator = BOL_AuthorizationService::getInstance()->isModerator(OW::getUser()->getId());
         $isGroupAssignedToModerator = BOL_AuthorizationService::getInstance()->isActionAuthorizedForUser(OW::getUser()->getId(), 'links');
         $isOwner = OW::getUser()->getId() == $link->getUserId();
         if ($isOwner || OW::getUser()->isAdmin() || $isModerator && $isGroupAssignedToModerator) {
             $tb[] = array('href' => OW::getRouter()->urlForRoute('link-save-edit', array('id' => $link->getId())), 'label' => OW::getLanguage()->text('links', 'toolbar_edit'));
             $tb[] = array('href' => OW::getRouter()->urlFor('LINKS_CTRL_Save', 'delete', array('id' => $link->getId())), 'click' => "return confirm('" . OW::getLanguage()->text('base', 'are_you_sure') . "')", 'label' => OW::getLanguage()->text('links', 'toolbar_delete'));
         }
     }
     $this->assign('tb', $tb);
     /* Check comments privacy permissions */
     $allow_comments = true;
     if ($link->userId != OW::getUser()->getId() && !OW::getUser()->isAuthorized('links')) {
         $eventParams = array('action' => LinkService::PRIVACY_ACTION_COMMENT_LINKS, 'ownerId' => $link->userId, 'viewerId' => OW::getUser()->getId());
         try {
             OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
         } catch (RedirectException $ex) {
             $allow_comments = false;
         }
     }
     /* */
     $cmpParams = new BASE_CommentsParams('links', 'link');
     $cmpParams->setEntityId($link->getId())->setOwnerId($link->getUserId())->setDisplayType(1)->setAddComment($allow_comments);
     $this->addComponent('comments', new BASE_CMP_Comments($cmpParams));
     $tags = BOL_TagService::getInstance()->findEntityTagsWithPopularity($link->getId(), 'link');
     $tags = $tags !== null ? $tags : array();
     $this->addComponent('tagCloud', new BASE_CMP_TagCloud($tags, OW::getRouter()->urlForRoute('links-by-tag')));
 }
Example #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());
 }
Example #20
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;
 }
Example #21
0
 public function detail($params)
 {
     $document = OW::getDocument();
     $plugin = OW::getPluginManager()->getPlugin('spdownload');
     $document->addStyleSheet($plugin->getStaticCssUrl() . 'file_detail.css');
     $check = $params['fileId'];
     if (!stripos($params['fileId'], "-")) {
         throw new Redirect404Exception();
     }
     $params['fileId'] = substr($params['fileId'], 0, stripos($params['fileId'], "-"));
     $file = SPDOWNLOAD_BOL_FileService::getInstance()->getFileId($params['fileId']);
     if ($file->id . '-' . $file->slug != $check) {
         throw new Redirect404Exception();
     }
     $cmpThumbnails = new SPDOWNLOAD_CMP_Thumbnail($params['fileId']);
     $this->addComponent('cmpThumbnails', $cmpThumbnails);
     $params['authorId'] = $file->authorId;
     $params['quantitySoft'] = 2;
     $cmpRelatedItemUser = new SPDOWNLOAD_CMP_RelatedItemUser($params);
     $this->addComponent('cmpRelatedItemUser', $cmpRelatedItemUser);
     $filevernew = SPDOWNLOAD_BOL_VersionService::getInstance()->getFileVerNew($params['fileId']);
     $limit = 3;
     $fileverold = SPDOWNLOAD_BOL_VersionService::getInstance()->getFileOldVersion($params['fileId'], $filevernew[0]->id, $limit);
     $filevernew[0]->size = $this->splitFilesize($filevernew[0]->size);
     foreach ($fileverold as $key => $value) {
         $value->size = $this->splitFilesize($value->size);
     }
     // rate
     $rateInfo = new BASE_CMP_Rate('spdownload', 'spdownload-software', $file->getId(), $file->authorId);
     $this->addComponent('rate', $rateInfo);
     // comments
     $allow_comments = true;
     if ($file->authorId != OW::getUser()->getId() && !OW::getUser()->isAuthorized('spdownload')) {
         $eventParams = array('action' => 'spdownload_comment_spdownload-posts', 'ownerId' => $file->authorId, 'viewerId' => OW::getUser()->getId());
         try {
             OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
         } catch (RedirectException $ex) {
             $allow_comments = false;
         }
     }
     $cmpParams = new BASE_CommentsParams('spdownload', 'spdownload-post');
     $cmpParams->setEntityId($file->getId())->setOwnerId($file->authorId)->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST)->setAddComment($allow_comments);
     $this->addComponent('comments', new BASE_CMP_Comments($cmpParams));
     $arraylabel = array("filename" => OW::getLanguage()->text('spdownload', 'label_file_name'), "filesize" => OW::getLanguage()->text('spdownload', 'label_file_size'), "filetype" => OW::getLanguage()->text('spdownload', 'label_file_type'), "filedown" => OW::getLanguage()->text('spdownload', 'label_file_download'));
     $url = OW::getPluginManager()->getPlugin('spdownload')->getUserFilesUrl();
     $nameImage = 'icon_large_' . $file->id . '.png';
     $file->icon = $url . $nameImage;
     $CategoryIdList = SPDOWNLOAD_BOL_FileCategoryService::getInstance()->getCategoryId($params['fileId']);
     $arrayCategory = array();
     foreach ($CategoryIdList as $key => $value) {
         $categories = SPDOWNLOAD_BOL_CategoryDao::getInstance()->findById($value->categoryId);
         $arrayCategory[$value->categoryId] = $categories->name;
     }
     $this->assign('arrayCategory', $arrayCategory);
     $this->assign('file', $file);
     $this->assign('var', $file->id);
     $this->assign('filevernew', $filevernew[0]);
     $this->assign('fileverold', $fileverold);
     $this->assign('arraylabel', $arraylabel);
 }
Example #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)));
 }
Example #23
0
 public function index($params)
 {
     $username = !empty($params['user']) ? $params['user'] : '';
     $id = $params['id'];
     $plugin = OW::getPluginManager()->getPlugin('blogs');
     OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'blogs', 'main_menu_item');
     $service = PostService::getInstance();
     $userService = BOL_UserService::getInstance();
     $this->assign('user', OW::getUser()->getId() !== null ? $userService->findUserById(OW::getUser()->getId()) : null);
     $post = $service->findById($id);
     if ($post === null) {
         throw new Redirect404Exception();
     }
     if ($post->isDraft() && $post->authorId != OW::getUser()->getId()) {
         throw new Redirect404Exception();
     }
     $post->post = BASE_CMP_TextFormatter::fromBBtoHtml($post->post);
     $post->setTitle(strip_tags($post->getTitle()));
     if (!OW::getUser()->isAuthorized('blogs', 'view')) {
         $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
         return;
     }
     if (OW::getUser()->isAuthenticated() && OW::getUser()->getId() != $post->getAuthorId() && !OW::getUser()->isAuthorized('blogs', 'view')) {
         $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
         return;
     }
     /* Check privacy permissions */
     if ($post->authorId != OW::getUser()->getId() && !OW::getUser()->isAuthorized('blogs')) {
         $eventParams = array('action' => 'blogs_view_blog_posts', 'ownerId' => $post->authorId, 'viewerId' => OW::getUser()->getId());
         OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
     }
     /* */
     $parts = explode('<!--page-->', $post->getPost());
     $page = !empty($_GET['page']) ? $_GET['page'] : 1;
     $count = count($parts);
     if (strlen($username) > 0) {
         $author = $userService->findByUsername($username);
     } else {
         $author = $userService->findUserById($post->getAuthorId());
         $isAuthorExists = !empty($author);
         if ($isAuthorExists) {
             $username = $author->getUsername();
         }
     }
     $this->assign('isAuthorExists', $isAuthorExists);
     if ($isAuthorExists) {
         $displayName = $userService->getDisplayName($author->getId());
         $this->assign('username', $userService->getUserName($author->getId()));
         $this->assign('displayname', $displayName);
         $url = OW::getRouter()->urlForRoute('user-blog', array('user' => $username));
         $this->setPageHeading(OW::getLanguage()->text('blogs', 'view_page_heading', array('url' => $url, 'name' => $displayName, 'postTitle' => htmlspecialchars($post->getTitle()))));
         $this->setPageHeadingIconClass('ow_ic_write');
         OW::getDocument()->setTitle(OW::getLanguage()->text('blogs', 'blog_post_title', array('post_title' => htmlspecialchars($post->getTitle()), 'display_name' => $displayName)));
         $post_body = UTIL_String::truncate($post->getPost(), 200, '...');
         $postTagsArray = BOL_TagService::getInstance()->findEntityTags($post->getId(), 'blog-post');
         $postTags = "";
         foreach ($postTagsArray as $tag) {
             $postTags .= $tag->label . ", ";
         }
         $postTags = substr($postTags, 0, -2);
         OW::getDocument()->setDescription(OW::getLanguage()->text('blogs', 'blog_post_description', array('post_body' => htmlspecialchars(strip_tags($post_body)), 'tags' => htmlspecialchars($postTags))));
         //OW::getDocument()->setKeywords(OW::getLanguage()->text('nav', 'page_default_keywords').", ".$postTags);
     }
     $info = array('dto' => $post, 'text' => $parts[$page - 1]);
     $this->assign('info', $info);
     if ($isAuthorExists) {
         //blog navigation
         $prev = $service->findAdjacentUserPost($author->getId(), $post->getId(), 'prev');
         $next = $service->findAdjacentUserPost($author->getId(), $post->getId(), 'next');
         if (!empty($prev)) {
             $prevUser = $userService->findUserById($prev->getAuthorId());
         }
         if (!empty($next)) {
             $nextUser = $userService->findUserById($next->getAuthorId());
         }
         $this->assign('adjasentUrl', array('next' => !empty($nextUser) ? OW::getRouter()->urlForRoute('user-post', array('id' => $next->getId(), 'user' => $nextUser->getUsername())) : '', 'prev' => !empty($prevUser) ? OW::getRouter()->urlForRoute('user-post', array('id' => $prev->getId(), 'user' => $prevUser->getUsername())) : '', 'index' => OW::getRouter()->urlForRoute('user-blog', array('user' => $author->getUsername()))));
     } else {
         $this->assign('adjasentUrl', null);
     }
     //~blog navigation
     //toolbar
     $tb = array();
     $toolbarEvent = new BASE_CLASS_EventCollector('blogs.collect_post_toolbar_items', array('postId' => $post->id, 'postDto' => $post));
     OW::getEventManager()->trigger($toolbarEvent);
     foreach ($toolbarEvent->getData() as $toolbarItem) {
         array_push($tb, $toolbarItem);
     }
     if (OW::getUser()->isAuthenticated() && $post->getAuthorId() != OW::getUser()->getId()) {
         $js = UTIL_JsGenerator::newInstance()->jQueryEvent('#blog_post_toolbar_flag', 'click', UTIL_JsGenerator::composeJsString('OW.flagContent({$entity}, {$id}, {$title}, {$href}, "blogs+flags");', array('entity' => 'blog_post', 'id' => $post->getId(), 'title' => htmlspecialchars(json_encode($post->getTitle())), 'href' => OW::getRouter()->urlForRoute('user-post', array('id' => $post->getId())))));
         OW::getDocument()->addOnloadScript($js, 1001);
         $tb[] = array('label' => OW::getLanguage()->text('base', 'flag'), 'href' => 'javascript://', 'id' => 'blog_post_toolbar_flag');
     }
     if (OW::getUser()->isAuthenticated() && (OW::getUser()->getId() == $post->getAuthorId() || BOL_AuthorizationService::getInstance()->isModerator(OW::getUser()->getId()))) {
         $tb[] = array('href' => OW::getRouter()->urlForRoute('post-save-edit', array('id' => $post->getId())), 'label' => OW::getLanguage()->text('blogs', 'toolbar_edit'));
         $tb[] = array('href' => OW::getRouter()->urlFor('BLOGS_CTRL_Save', 'delete', array('id' => $post->getId())), 'click' => "return confirm('" . OW::getLanguage()->text('base', 'are_you_sure') . "');", 'label' => OW::getLanguage()->text('blogs', 'toolbar_delete'));
     }
     $this->assign('tb', $tb);
     //~toolbar
     $paging = new BASE_CMP_Paging($page, $count, $count);
     //<ARCHIVE-NAVIGATOR>
     $this->assign('paging', $paging->render());
     if ($isAuthorExists) {
         $rows = $service->findUserArchiveData($author->getId());
         $archive = array();
         foreach ($rows as $row) {
             if (!array_key_exists($row['y'], $archive)) {
                 $archive[$row['y']] = array();
             }
             $archive[$row['y']][] = $row['m'];
         }
         $this->assign('archive', $archive);
     }
     //</ARCHIVE-NAVIGATOR>
     if ($isAuthorExists) {
         $this->assign('author', $author);
     }
     $this->assign('isModerator', OW::getUser()->isAuthorized('blogs'));
     if ($isAuthorExists) {
         $this->assign('userBlogUrl', OW::getRouter()->urlForRoute('user-blog', array('user' => $author->getUsername())));
     }
     /* Check comments privacy permissions */
     $allow_comments = true;
     if ($post->authorId != OW::getUser()->getId() && !OW::getUser()->isAuthorized('blogs')) {
         $eventParams = array('action' => 'blogs_comment_blog_posts', 'ownerId' => $post->authorId, 'viewerId' => OW::getUser()->getId());
         try {
             OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
         } catch (RedirectException $ex) {
             $allow_comments = false;
         }
     }
     /* */
     // additional components
     $cmpParams = new BASE_CommentsParams('blogs', 'blog-post');
     $cmpParams->setEntityId($post->getId())->setOwnerId($post->getAuthorId())->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST)->setAddComment($allow_comments);
     $this->addComponent('comments', new BASE_CMP_Comments($cmpParams));
     $this->assign('avatarUrl', '');
     $tagCloud = new BASE_CMP_EntityTagCloud('blog-post', OW::getRouter()->urlForRoute('blogs.list', array('list' => 'browse-by-tag')));
     $tagCloud->setEntityId($post->getId());
     $rateInfo = new BASE_CMP_Rate('blogs', 'blog-post', $post->getId(), $post->getAuthorId());
     $this->addComponent('rate', $rateInfo);
     $this->addComponent('tagCloud', $tagCloud);
     //~ additional components
 }
Example #24
0
 public function viewvideo($params)
 {
     if (!isset($params['id']) || !($id = (int) $params['id'])) {
         throw new Redirect404Exception();
         return;
     }
     $id = empty($params['id']) ? 0 : (int) $params['id'];
     $modPermissions = OW::getUser()->isAuthorized('ivideo');
     $contentOwner = (int) IVIDEO_BOL_Service::getInstance()->findVideoOwner($id);
     $userId = OW::getUser()->getId();
     $ownerMode = $contentOwner == $userId;
     if (!$ownerMode && !OW::getUser()->isAuthorized('ivideo', 'view') && !$modPermissions) {
         $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
         return;
     }
     $item = IVIDEO_BOL_VideoDao::getInstance()->findById((int) $id);
     if (!$ownerMode && !$modPermissions) {
         $privacyParams = array('action' => 'ivideo_view_video', 'ownerId' => $contentOwner, 'viewerId' => $userId);
         $event = new OW_Event('privacy_check_permission', $privacyParams);
         OW::getEventManager()->trigger($event);
     }
     $eventParams = array('pluginKey' => 'ivideo', 'action' => 'view_video');
     $credits = OW::getEventManager()->call('usercredits.check_balance', $eventParams);
     if ($credits === false) {
         $this->assign('authMsg', OW::getEventManager()->call('usercredits.error_message', $eventParams));
         return;
     } else {
         $this->assign('authMsg', null);
     }
     $language = OW::getLanguage();
     if (is_null($item)) {
         OW::getFeedback()->error($language->text('ivideo', 'view_invalid_video_error'));
         $this->redirect(OW::getRouter()->urlForRoute('ivideo_view_list', array('type' => 'latest')));
     }
     $this->setPageTitle($item->name);
     $this->setPageHeading($item->name);
     $this->assign('isAdmin', OW::getUser()->isAdmin());
     $this->assign('item', $item);
     $allow_comments = true;
     if ($item->owner != OW::getUser()->getId() && !OW::getUser()->isAuthorized('ivideo')) {
         $eventParams = array('action' => 'add_comment', 'ownerId' => $item->id, 'viewerId' => OW::getUser()->getId());
         try {
             OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
         } catch (RedirectException $ex) {
             $allow_comments = false;
         }
     }
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('ivideo')->getStaticJsUrl() . 'ivideo.js');
     $objParams = array('ajaxResponder' => $this->ajaxResponder, 'id' => $item->id, 'txtDelConfirm' => OW::getLanguage()->text('ivideo', 'confirm_delete'), 'txtMarkFeatured' => OW::getLanguage()->text('ivideo', 'mark_featured'), 'txtRemoveFromFeatured' => OW::getLanguage()->text('ivideo', 'remove_from_featured'), 'txtApprove' => OW::getLanguage()->text('base', 'approve'), 'txtDisapprove' => OW::getLanguage()->text('base', 'disapprove'));
     $script = "\$(document).ready(function(){\n                var clip = new ivideoClip( " . json_encode($objParams) . ");\n            }); ";
     OW::getDocument()->addOnloadScript($script);
     $cmpParams = new BASE_CommentsParams('ivideo', 'ivideo-comments');
     $cmpParams->setEntityId($item->id)->setOwnerId($item->owner)->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST)->setAddComment($allow_comments);
     $this->addComponent('comments', new BASE_CMP_Comments($cmpParams));
     $rateInfo = new BASE_CMP_Rate('ivideo', 'ivideo-rates', $item->id, $item->owner);
     $this->addComponent('rate', $rateInfo);
     $postTagsArray = BOL_TagService::getInstance()->findEntityTags($item->getId(), 'ivideo-video');
     $postTags = "";
     foreach ($postTagsArray as $tag) {
         $postTags .= $tag->label . ", ";
     }
     $postTags = substr($postTags, 0, -2);
     $tagCloud = new BASE_CMP_EntityTagCloud('ivideo-video');
     $tagCloud->setEntityId($item->id);
     $tagCloud->setRouteName('ivideo_view_tagged_list');
     $this->addComponent('tagCloud', $tagCloud);
     $username = BOL_UserService::getInstance()->getUserName($item->owner);
     $this->assign('username', $username);
     $displayName = BOL_UserService::getInstance()->getDisplayName($item->owner);
     $this->assign('displayName', $displayName);
     $ownerMode = $item->owner == OW::getUser()->getId();
     $modPermissions = OW::getUser()->isAuthorized('ivideo');
     $is_featured = IVIDEO_BOL_VideoFeaturedService::getInstance()->isFeatured($item->id);
     $this->assign('featured', $is_featured);
     $categoryList = IVIDEO_BOL_VideoCategoryService::getInstance()->getVideoCategories($item->id);
     $this->assign('categoryList', $categoryList);
     $toolbar = array();
     if (OW::getUser()->isAuthenticated()) {
         array_push($toolbar, array('href' => 'javascript://', 'id' => 'btn-ivideo-flag', 'label' => $language->text('base', 'flag')));
     }
     if ($ownerMode || $modPermissions) {
         array_push($toolbar, array('href' => OW::getRouter()->urlForRoute('ivideo_edit_video', array('id' => $item->getId())), '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('ivideo', 'remove_from_featured')));
         } else {
             array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-mark-featured', 'rel' => 'mark_featured', 'label' => $language->text('ivideo', 'mark_featured')));
         }
         if ($item->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-ivideo-flag', 'click', 'OW.flagContent(e.data.entity, e.data.id, e.data.title, e.data.href, "ivideo+flags");', array('e'), array('entity' => 'ivideo_video', 'id' => $item->getId(), 'title' => $item->name, 'href' => OW::getRouter()->urlForRoute('ivideo_view_video', array('id' => $item->getId()))));
     OW::getDocument()->addOnloadScript($js, 1001);
     $this->assign('getUserFilesUrl', OW::getPluginManager()->getPlugin('ivideo')->getUserFilesUrl());
     $this->assign('videoWidth', OW::getConfig()->getValue('ivideo', 'videoWidth'));
     $this->assign('videoHeight', OW::getConfig()->getValue('ivideo', 'videoHeight'));
     $this->assign('videoType', UTIL_File::getExtension($item->filename));
     $jsURL = OW::getPluginManager()->getPlugin('ivideo')->getStaticJsUrl();
     $this->assign('jsURL', $jsURL);
     OW::getDocument()->addScript($jsURL . 'jquery.media.js');
     OW::getDocument()->addStyleSheet(OW::getPluginManager()->getPlugin('ivideo')->getStaticCssUrl() . 'video-js.css');
     OW::getDocument()->addCustomHeadInfo('<script src="' . $jsURL . 'video.js" type="text/javascript"></script>');
     OW::getDocument()->addCustomHeadInfo('<script type="text/javascript"> _V_.options.flash.swf ="' . $jsURL . 'video-js.swf"</script>');
     OW::getDocument()->addCustomHeadInfo('<script type="text/javascript"> _V_.options.techOrder = ["flash", "html5"]</script>');
 }
Example #25
0
 public function initForm()
 {
     $jsParams = array('entityType' => $this->params->getEntityType(), 'entityId' => $this->params->getEntityId(), 'pluginKey' => $this->params->getPluginKey(), 'contextId' => $this->cmpContextId, 'userAuthorized' => $this->isAuthorized, 'customId' => $this->params->getCustomId());
     if ($this->isAuthorized) {
         OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'jquery.autosize.js');
         $taId = 'cta' . $this->id;
         $attchId = 'attch' . $this->id;
         $attchUid = BOL_CommentService::getInstance()->generateAttachmentUid($this->params->getEntityType(), $this->params->getEntityId());
         $jsParams['ownerId'] = $this->params->getOwnerId();
         $jsParams['cCount'] = isset($this->batchData['countOnPage']) ? $this->batchData['countOnPage'] : $this->params->getCommentCountOnPage();
         $jsParams['initialCount'] = $this->params->getInitialCommentsCount();
         $jsParams['loadMoreCount'] = $this->params->getLoadMoreCount();
         $jsParams['countOnPage'] = $this->params->getCommentCountOnPage();
         $jsParams['uid'] = $this->id;
         $jsParams['addUrl'] = OW::getRouter()->urlFor('BASE_CTRL_Comments', 'addComment');
         $jsParams['displayType'] = $this->params->getDisplayType();
         $jsParams['textAreaId'] = $taId;
         $jsParams['attchId'] = $attchId;
         $jsParams['attchUid'] = $attchUid;
         $jsParams['enableSubmit'] = true;
         $jsParams['mediaAllowed'] = BOL_TextFormatService::getInstance()->isCommentsRichMediaAllowed();
         $jsParams['labels'] = array('emptyCommentMsg' => OW::getLanguage()->text('base', 'empty_comment_error_msg'), 'disabledSubmit' => OW::getLanguage()->text('base', 'submit_disabled_error_msg'), 'attachmentLoading' => OW::getLanguage()->text('base', 'submit_attachment_not_loaded'));
         if (!empty($this->staticData['currentUserInfo'])) {
             $userInfoToAssign = $this->staticData['currentUserInfo'];
         } else {
             $currentUserInfo = BOL_AvatarService::getInstance()->getDataForUserAvatars(array(OW::getUser()->getId()));
             $userInfoToAssign = $currentUserInfo[OW::getUser()->getId()];
         }
         $buttonContId = 'bCcont' . $this->id;
         if (BOL_TextFormatService::getInstance()->isCommentsRichMediaAllowed()) {
             $this->addComponent('attch', new BASE_CLASS_Attachment($this->params->getPluginKey(), $attchUid, $buttonContId));
         }
         $this->assign('buttonContId', $buttonContId);
         $this->assign('currentUserInfo', $userInfoToAssign);
         $this->assign('formCmp', true);
         $this->assign('taId', $taId);
         $this->assign('attchId', $attchId);
     }
     OW::getDocument()->addOnloadScript("new OwComments(" . json_encode($jsParams) . ");");
     $this->assign('displayType', $this->params->getDisplayType());
     // add comment list cmp
     $this->addComponent('commentList', new BASE_CMP_CommentsList($this->params, $this->id));
 }
Example #26
0
 protected function getFeatures($data)
 {
     $configs = $this->sharedData['configs'];
     $featuresData = $this->getFeaturesData($data);
     $out = array('system' => array('comments' => false, 'likes' => false), 'custom' => array());
     $out['custom'] = $featuresData["custom"];
     $systemFeatures = $featuresData["system"];
     if (!empty($systemFeatures["comments"])) {
         $feature = $systemFeatures["comments"];
         $commentsParams = new BASE_CommentsParams($feature["authGroup"], $feature["entityType"]);
         $commentsParams->setEntityId($feature["entityId"]);
         $commentsParams->setInitialCommentsCount($configs['comments_count']);
         $commentsParams->setLoadMoreCount(6);
         $commentsParams->setBatchData($feature["comments"]);
         $commentsParams->setOwnerId($this->action->getUserId());
         $commentsParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_WITH_LOAD_LIST_MINI);
         $commentsParams->setWrapInBox(false);
         $commentsParams->setShowEmptyList(false);
         if (!empty($feature['error'])) {
             $commentsParams->setErrorMessage($feature['error']);
         }
         if (isset($feature['allow'])) {
             $commentsParams->setAddComment($feature['allow']);
         }
         $commentCmp = new BASE_CMP_Comments($commentsParams);
         $out['system']['comments']['cmp'] = $commentCmp->render();
         $out['system']['comments']['count'] = $feature["count"];
         $out['system']['comments']['allow'] = $feature["allow"];
         $out['system']['comments']['expanded'] = $feature["expanded"];
     }
     if (!empty($systemFeatures["likes"])) {
         $feature = $systemFeatures['likes'];
         $out['system']['likes']['count'] = $feature["count"];
         $out['system']['likes']['liked'] = $feature["liked"];
         $out['system']['likes']['allow'] = $feature["allow"];
         $out['system']['likes']['error'] = $feature["error"];
         $likeCmp = new NEWSFEED_CMP_Likes($feature["entityType"], $feature["entityId"], $feature["likes"]);
         $out['system']['likes']['cmp'] = $likeCmp->render();
     }
     return $out;
 }