public function __construct($userId, $idList) { parent::__construct(); if (!empty($userId) && !empty($idList)) { $this->user = BOL_UserService::getInstance()->findUserById($userId); $userService = BOL_UserService::getInstance(); $avatars = BOL_AvatarService::getInstance()->getAvatarsUrlList($idList, 2); $sexValue = array(); $list = array(); foreach (BOL_QuestionValueDao::getInstance()->findQuestionValues('sex') as $sexDto) { $sexValue[$sexDto->value] = BOL_QuestionService::getInstance()->getQuestionValueLang('sex', $sexDto->value); } $userData = BOL_QuestionService::getInstance()->getQuestionData($idList, array('sex', 'birthdate', 'googlemap_location')); foreach ($idList as $userId) { $list[$userId]['userUrl'] = $userService->getUserUrl($userId); $list[$userId]['displayName'] = $userService->getDisplayName($userId); $list[$userId]['avatarUrl'] = $avatars[$userId]; $list[$userId]['activity'] = UTIL_DateTime::formatDate(BOL_UserService::getInstance()->findUserById($userId)->getActivityStamp()); if (!empty($userData[$userId]['birthdate'])) { $date = UTIL_DateTime::parseDate($userData[$userId]['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT); $list[$userId]['age'] = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']); } if (!empty($userData[$userId]['sex'])) { $list[$userId]['sex'] = $sexValue[$userData[$userId]['sex']]; } if (!empty($userData[$userId]['googlemap_location'])) { $list[$userId]['googlemap_location'] = $userData[$userId]['googlemap_location']['address']; } } $this->assign('userName', BOL_UserService::getInstance()->getDisplayName($this->user->id)); $this->assign('list', $list); } else { $this->setVisible(FALSE); } }
/** * @return Constructor. */ public function __construct($groupId) { parent::__construct(); $service = GROUPS_BOL_Service::getInstance(); $groupDto = $service->findGroupById($groupId); $group = array('title' => htmlspecialchars($groupDto->title), 'description' => $groupDto->description, 'time' => $groupDto->timeStamp, 'imgUrl' => empty($groupDto->imageHash) ? false : $service->getGroupImageUrl($groupDto), 'url' => OW::getRouter()->urlForRoute('groups-view', array('groupId' => $groupDto->id)), "id" => $groupDto->id); $imageUrl = empty($groupDto->imageHash) ? '' : $service->getGroupImageUrl($groupDto); OW::getDocument()->addMetaInfo('image', $imageUrl, 'itemprop'); OW::getDocument()->addMetaInfo('og:image', $imageUrl, 'property'); $createDate = UTIL_DateTime::formatDate($groupDto->timeStamp); $adminName = BOL_UserService::getInstance()->getDisplayName($groupDto->userId); $adminUrl = BOL_UserService::getInstance()->getUserUrl($groupDto->userId); $js = UTIL_JsGenerator::newInstance()->jQueryEvent('#groups_toolbar_flag', 'click', UTIL_JsGenerator::composeJsString('OW.flagContent({$entity}, {$id}, {$title}, {$href}, "groups+flags", {$ownerId});', array('entity' => GROUPS_BOL_Service::WIDGET_PANEL_NAME, 'id' => $groupDto->id, 'title' => $group['title'], 'href' => $group['url'], 'ownerId' => $groupDto->userId))); OW::getDocument()->addOnloadScript($js, 1001); $toolbar = array(array('label' => OW::getLanguage()->text('groups', 'widget_brief_info_create_date', array('date' => $createDate))), array('label' => OW::getLanguage()->text('groups', 'widget_brief_info_admin', array('name' => $adminName, 'url' => $adminUrl)))); if ($service->isCurrentUserCanEdit($groupDto)) { $toolbar[] = array('label' => OW::getLanguage()->text('groups', 'edit_btn_label'), 'href' => OW::getRouter()->urlForRoute('groups-edit', array('groupId' => $groupId))); } if (OW::getUser()->isAuthenticated() && OW::getUser()->getId() != $groupDto->userId) { $toolbar[] = array('label' => OW::getLanguage()->text('base', 'flag'), 'href' => 'javascript://', 'id' => 'groups_toolbar_flag'); } $event = new BASE_CLASS_EventCollector('groups.on_toolbar_collect', array('groupId' => $groupId)); OW::getEventManager()->trigger($event); foreach ($event->getData() as $item) { $toolbar[] = $item; } $this->assign('toolbar', $toolbar); $this->assign('group', $group); }
public function getList($params) { $data = OW::getEventManager()->call("guests.get_guests_list", array("userId" => OW::getUser()->getId())); if (empty($data)) { $this->assign("list", array()); return; } $idList = array(); $viewedMap = array(); $timeMap = array(); foreach ($data as $item) { $idList[] = $item["userId"]; $viewedMap[$item["userId"]] = $item["viewed"]; $timeMap[$item["userId"]] = UTIL_DateTime::formatDate($item["timeStamp"]); } OW::getEventManager()->call("guests.mark_guests_viewed", array("userId" => OW::getUser()->getId(), "guestIds" => $idList)); $bookmarkList = OW::getEventManager()->call("bookmarks.get_mark_list", array("userId" => OW::getUser()->getId(), "idList" => $idList)); $bookmarkList = empty($bookmarkList) ? array() : $bookmarkList; $avatarList = BOL_AvatarService::getInstance()->getDataForUserAvatars($idList, true, false); $onlineMap = BOL_UserService::getInstance()->findOnlineStatusForUserList($idList); foreach ($avatarList as $userId => $user) { $color = array('r' => '100', 'g' => '100', 'b' => '100'); if (!empty($user['labelColor'])) { $_color = explode(', ', trim($user['labelColor'], 'rgba()')); $color = array('r' => $_color[0], 'g' => $_color[1], 'b' => $_color[2]); } $list[] = array("userId" => $userId, "displayName" => $user["title"], "avatarUrl" => $user["src"], "label" => $user["label"], "labelColor" => $color, "viewed" => $viewedMap[$userId], "online" => $onlineMap[$userId], "bookmarked" => !empty($bookmarkList[$userId]), "time" => $timeMap[$userId]); } $this->assign("list", $list); }
public function __construct(BASE_CLASS_WidgetParameter $params) { parent::__construct(); $service = LinkService::getInstance(); $userId = $params->additionalParamList['entityId']; if ($userId != OW::getUser()->getId() && !OW::getUser()->isAuthorized('links', 'view')) { $this->setVisible(false); return; } /* Check privacy permissions */ $eventParams = array('action' => LinkService::PRIVACY_ACTION_VIEW_LINKS, 'ownerId' => $userId, 'viewerId' => OW::getUser()->getId()); try { OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams); } catch (RedirectException $ex) { $this->setVisible(false); return; } /* */ if ($service->countUserLinks($userId) == 0 && !$params->customizeMode) { $this->setVisible(false); return; } $this->assign('displayname', BOL_UserService::getInstance()->getDisplayName($userId)); $this->assign('username', BOL_UserService::getInstance()->getUsername($userId)); $list = array(); $count = $params->customParamList['count']; $userLinkList = $service->findUserLinkList($userId, 0, $count); $idList = array(); foreach ($userLinkList as $item) { /* Check privacy permissions */ if ($item->userId != OW::getUser()->getId() && !OW::getUser()->isAuthorized('links')) { $eventParams = array('action' => LinkService::PRIVACY_ACTION_VIEW_LINKS, 'ownerId' => $item->userId, 'viewerId' => OW::getUser()->getId()); try { OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams); } catch (RedirectException $ex) { continue; } } /* */ $list[] = $item; $idList[] = $item->id; } $commentInfo = array(); if (!empty($idList)) { $commentInfo = BOL_CommentService::getInstance()->findCommentCountForEntityList('link', $idList); $tb = array(); foreach ($list as $key => $item) { if (mb_strlen($item->getDescription()) > 100) { $item->setDescription(UTIL_String::truncate($item->getDescription(), 100, '...')); } $list[$key]->setDescription(strip_tags($item->getDescription())); $tb[$item->getId()] = array(array('label' => '<span class="ow_txt_value">' . $commentInfo[$item->getId()] . '</span> ' . OW::getLanguage()->text('links', 'comments'), 'href' => OW::getRouter()->urlForRoute('link', array('id' => $item->getId()))), array('label' => UTIL_DateTime::formatDate($item->getTimestamp()), 'class' => 'ow_ic_date')); } $this->assign('tb', $tb); } $this->assign('list', $list); $this->setSettingValue(self::SETTING_TOOLBAR, array(array('label' => OW::getLanguage()->text('base', 'view_all'), 'href' => OW::getRouter()->urlForRoute('links-user', array('user' => BOL_UserService::getInstance()->getUserName($userId)))))); }
/** * @param $userId * @param $page * @param $limit * @return array */ public function findGuestsForUser($userId, $page, $limit) { if (!$userId) { return array(); } $guests = $this->guestDao->findUserGuests($userId, $page, $limit); foreach ($guests as &$g) { $g->visitTimestamp = UTIL_DateTime::formatDate($g->visitTimestamp, false); } return $guests; }
public function render() { $rss = array_slice($this->rss, 0, $this->count); $this->assign('rss', $rss); $toolbars = array(); if (!$this->titleOnly) { foreach ($rss as $key => $item) { $toolbars[$key] = array(array('label' => UTIL_DateTime::formatDate($item['time']))); } } $this->assign('toolbars', $toolbars); return parent::render(); }
public function __construct(BASE_CLASS_WidgetParameter $params) { parent::__construct(); $service = PostService::getInstance(); $count = $params->customParamList['count']; $previewLength = $params->customParamList['previewLength']; $list = $service->findList(0, $count); if ((empty($list) || false && !OW::getUser()->isAuthorized('blogs', 'add') && !OW::getUser()->isAuthorized('blogs', 'view')) && !$params->customizeMode) { $this->setVisible(false); return; } $posts = array(); $userService = BOL_UserService::getInstance(); $postIdList = array(); foreach ($list as $dto) { /* @var $dto Post */ if (mb_strlen($dto->getTitle()) > 50) { $dto->setTitle(UTIL_String::splitWord(UTIL_String::truncate($dto->getTitle(), 50, '...'))); } $text = $service->processPostText($dto->getPost()); $posts[] = array('dto' => $dto, 'text' => UTIL_String::splitWord(UTIL_String::truncate($text, $previewLength)), 'truncated' => mb_strlen($text) > $previewLength, 'url' => OW::getRouter()->urlForRoute('user-post', array('id' => $dto->getId()))); $idList[] = $dto->getAuthorId(); $postIdList[] = $dto->id; } $commentInfo = array(); if (!empty($idList)) { $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars($idList, true, false); $this->assign('avatars', $avatars); $urls = BOL_UserService::getInstance()->getUserUrlsForList($idList); $commentInfo = BOL_CommentService::getInstance()->findCommentCountForEntityList('blog-post', $postIdList); $toolbars = array(); foreach ($list as $dto) { $toolbars[$dto->getId()] = array(array('class' => 'ow_icon_control ow_ic_user', 'href' => isset($urls[$dto->getAuthorId()]) ? $urls[$dto->getAuthorId()] : '#', 'label' => isset($avatars[$dto->getAuthorId()]['title']) ? $avatars[$dto->getAuthorId()]['title'] : ''), array('class' => 'ow_remark ow_ipc_date', 'label' => UTIL_DateTime::formatDate($dto->getTimestamp()))); } $this->assign('tbars', $toolbars); } $this->assign('commentInfo', $commentInfo); $this->assign('list', $posts); if ($service->countPosts() > 0) { $toolbar = array(); if (OW::getUser()->isAuthorized('blogs', 'add')) { $toolbar[] = array('label' => OW::getLanguage()->text('blogs', 'add_new'), 'href' => OW::getRouter()->urlForRoute('post-save-new')); } if (OW::getUser()->isAuthorized('blogs', 'view')) { $toolbar[] = array('label' => OW::getLanguage()->text('blogs', 'go_to_blog'), 'href' => Ow::getRouter()->urlForRoute('blogs')); } if (!empty($toolbar)) { $this->setSettingValue(self::SETTING_TOOLBAR, $toolbar); } } }
public function __construct(BASE_CLASS_WidgetParameter $params) { parent::__construct(); $service = LinkService::getInstance(); $count = $params->customParamList['count']; $list = $service->findList(0, $count); if ((empty($list) || false && !OW::getUser()->isAuthorized('links', 'add') && !OW::getUser()->isAuthorized('links', 'view')) && !$params->customizeMode) { $this->setVisible(false); return; } $links = array(); $toolbars = array(); $userService = BOL_UserService::getInstance(); $authorIdList = array(); foreach ($list as $dto) { $dto->setUrl(strip_tags($dto->getUrl())); $dto->setTitle(strip_tags($dto->getTitle())); $dto->setDescription(strip_tags($dto->getDescription())); $links[] = array('dto' => $dto); $idList[] = $dto->id; $authorIdList[] = $dto->getUserId(); } $commentInfo = array(); $this->assign('avatars', null); if (!empty($idList)) { $commentInfo = BOL_CommentService::getInstance()->findCommentCountForEntityList('link', $idList); $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars($authorIdList, true, false); $this->assign('avatars', $avatars); $urls = BOL_UserService::getInstance()->getUserUrlsForList($authorIdList); } $tbars = array(); foreach ($list as $dto) { $tbars[$dto->getId()] = array(array('class' => 'ow_icon_control ow_ic_user', 'href' => !empty($urls[$dto->getUserId()]) ? $urls[$dto->getUserId()] : '#', 'label' => !empty($avatars[$dto->getUserId()]['title']) ? $avatars[$dto->getUserId()]['title'] : ''), array('class' => 'ow_remark ow_ipc_date', 'label' => UTIL_DateTime::formatDate($dto->getTimestamp()))); } $this->assign('tbars', $tbars); $this->assign('commentInfo', $commentInfo); $this->assign('list', $links); if ($service->countAll()) { $toolbar = array(); if (OW::getUser()->isAuthorized('links', 'add')) { $toolbar[] = array('label' => OW::getLanguage()->text('links', 'add_new'), 'href' => OW::getRouter()->urlForRoute('link-save-new')); } if (OW::getUser()->isAuthorized('links', 'view')) { $toolbar[] = array('label' => OW::getLanguage()->text('links', 'go_to_links'), 'href' => Ow::getRouter()->urlForRoute('links')); } if (!empty($toolbar)) { $this->setSettingValue(self::SETTING_TOOLBAR, $toolbar); } } }
public function findLastMessages($userId, $rosterId, $lastMessageTimestamp, $count = 10, $omit_last_message = 0) { $result_msg_list = array(); $msg_list = $this->messageDao->findLastMessages($userId, $rosterId, $lastMessageTimestamp, $count); foreach ($msg_list as $id => $msg) { if ($omit_last_message == 1 && $id == count($msg_list) - 1) { continue; } else { //$msg->setMessage(UTIL_HtmlTag::autoLink($msg->getMessage())); $msg->setRead(UTIL_DateTime::formatDate($msg->getTimestamp())); $msg->setTimestamp($msg->getTimestamp() * 1000); $result_msg_list[$id] = $msg; } } return $result_msg_list; }
public function onBeforeRender() { parent::onBeforeRender(); $tplList = array(); foreach ($this->response['feed']['entry'] as $item) { $vid = $item['media$group']['yt$videoid']['$t']; $uploaded = strtotime($item['media$group']['yt$uploaded']['$t']); $duration = $item['media$group']['yt$duration']['seconds']; $description = UTIL_String::truncate(strip_tags($item['media$group']['media$description']['$t']), 130, ' ...'); $title = UTIL_String::truncate(strip_tags($item['media$group']['media$title']['$t']), 65, ' ...'); $thumb = $item['media$group']['media$thumbnail'][0]['url']; $image = $item['media$group']['media$thumbnail'][1]['url']; $oembed = array('thumbnail_url' => $image, 'type' => 'video', 'title' => $title, 'description' => $description, 'html' => '<iframe class="attp-yt-iframe" width="300" height="230" src="http://www.youtube.com/embed/' . $vid . '?autoplay=1" frameborder="0" allowfullscreen></iframe>'); $tplList[] = array('title' => $title, 'description' => $description, 'thumb' => $thumb, 'video' => $vid, 'duration' => round($duration / 60), 'uploaded' => $uploaded, 'date' => UTIL_DateTime::formatDate($uploaded), 'oembed' => json_encode($oembed)); } $this->assign('list', $tplList); }
public function status() { $this->addComponent('menu', $this->getMenu()); $this->getComponent('menu')->getElement('status')->setActive(true); $config = OW::getConfig(); $statusCongigs = $config->getValues('watchdog'); if ($statusCongigs[WATCHDOG_BOL_WatchdogService::COUNT_SPAM_ATTEMPT] <= 0) { $statusCongigs[WATCHDOG_BOL_WatchdogService::COUNT_SPAM_ATTEMPT] = OW::getLanguage()->text('watchdog', 'count_spam_attempt_none'); } if ($statusCongigs[WATCHDOG_BOL_WatchdogService::TIME_UPDATE_DATABASE] > 0) { $statusCongigs[WATCHDOG_BOL_WatchdogService::TIME_UPDATE_DATABASE] = UTIL_DateTime::formatDate($statusCongigs[WATCHDOG_BOL_WatchdogService::TIME_UPDATE_DATABASE]); } else { $statusCongigs[WATCHDOG_BOL_WatchdogService::TIME_UPDATE_DATABASE] = OW::getLanguage()->text('watchdog', 'database_not_updated'); } $this->assign('configs', $statusCongigs); $this->assign('logo', OW::getPluginManager()->getPlugin('watchdog')->getStaticUrl() . 'images/Watchdog_logo.png'); OW::getDocument()->addStyleSheet(OW::getPluginManager()->getPlugin('watchdog')->getStaticCssUrl() . 'watchdog.css'); }
public function findUserVideos($userId, $start, $offset) { $clipDao = VIDEO_BOL_ClipDao::getInstance(); $example = new OW_Example(); $example->andFieldEqual('status', 'approved'); $example->andFieldEqual('userId', $userId); $example->setOrder('`addDatetime` DESC'); $example->setLimitClause($start, $offset); $list = $clipDao->findListByExample($example); $out = array(); foreach ($list as $video) { $id = $video->id; $videoThumb = VIDEO_BOL_ClipService::getInstance()->getClipThumbUrl($id); $out[$id] = array('id' => $id, 'embed' => $video->code, 'title' => UTIL_String::truncate($video->title, 65, ' ...'), 'description' => UTIL_String::truncate($video->description, 130, ' ...'), 'thumb' => $videoThumb == 'undefined' ? null : $videoThumb, 'date' => UTIL_DateTime::formatDate($video->addDatetime), 'permalink' => OW::getRouter()->urlForRoute('view_clip', array('id' => $id))); $out[$id]['oembed'] = json_encode(array('type' => 'video', 'thumbnail_url' => $out[$id]['thumb'], 'html' => $out[$id]['embed'], 'title' => $out[$id]['title'], 'description' => $out[$id]['description'])); } return $out; }
private function getGroupInfo() { static $groupInfo = array(); if (!empty($groupInfo)) { return $groupInfo; } $groupInfo['id'] = $this->group->id; $groupInfo['hasImage'] = !empty($this->group->imageHash); $groupInfo['image'] = $this->groupService->getGroupImageUrl($this->group); $groupInfo['title'] = htmlspecialchars($this->group->title); $groupInfo['description'] = $this->group->description; $groupInfo['url'] = $this->groupService->getGroupUrl($this->group); $groupInfo['time'] = UTIL_DateTime::formatDate($this->group->timeStamp); $groupInfo['admin'] = array(); $groupInfo['admin']['name'] = BOL_UserService::getInstance()->getDisplayName($this->group->userId); $groupInfo['admin']['url'] = BOL_UserService::getInstance()->getUserUrl($this->group->userId); return $groupInfo; }
/** * Smarty date modifier. * * @author Sardar Madumarov <*****@*****.**> * @package ow.ow_smarty.plugin * @since 1.0 */ function smarty_modifier_date($timeStamp, $dateOnly = false) { return UTIL_DateTime::formatDate($timeStamp, $dateOnly); }
private function displayGroupList($list, $paging, $menu = null) { $templatePath = OW::getPluginManager()->getPlugin('groups')->getCtrlViewDir() . 'groups_list.html'; $this->setTemplate($templatePath); $out = array(); foreach ($list as $item) { /* @var $item GROUPS_BOL_Group */ $userCount = GROUPS_BOL_Service::getInstance()->findUserListCount($item->id); $title = strip_tags($item->title); $toolbar = array(array('label' => OW::getLanguage()->text('groups', 'listing_users_label', array('count' => $userCount)))); $out[] = array('id' => $item->id, 'url' => OW::getRouter()->urlForRoute('groups-view', array('groupId' => $item->id)), 'title' => $title, 'imageTitle' => $title, 'content' => strip_tags($item->description), 'time' => UTIL_DateTime::formatDate($item->timeStamp), 'imageSrc' => GROUPS_BOL_Service::getInstance()->getGroupImageUrl($item), 'users' => $userCount, 'toolbar' => $toolbar); } $this->addComponent('paging', $paging); if (!empty($menu)) { $this->addComponent('menu', $menu); } else { $this->assign('menu', ''); } $this->assign('canCreate', $this->service->isCurrentUserCanCreate()); $this->assign('list', $out); }
public function approve($params) { $ownerId = empty($params["userId"]) ? null : $params["userId"]; $this->setPageTitle(OW::getLanguage()->text("base", "moderation_tools")); $this->setPageHeading(OW::getLanguage()->text("base", "moderation_tools")); if (empty($ownerId)) { $this->onlyModerators(); $menu = $this->getMenu(); if ($menu === null) { $this->redirect(OW::getRouter()->urlForRoute("base.moderation_tools")); } $menu->deactivateElements(); $menuItem = $menu->getElement("approve"); if ($menuItem) { $menuItem->setActive(true); } $this->addComponent("menu", $menu); } else { if ($ownerId != OW::getUser()->getId()) { throw new Redirect403Exception(); } $this->setPageHeading(OW::getLanguage()->text("moderation", "console_pending_approval")); } $groups = MODERATION_BOL_Service::getInstance()->getContentGroupsWithCount($ownerId); if (!empty($params["group"]) && empty($groups[$params["group"]])) { if ($ownerId) { return $this->noItems(); } $this->redirect(OW::getRouter()->urlForRoute("moderation.approve_index")); } $currentGroup = empty($params["group"]) ? reset($groups) : $groups[$params["group"]]; if (empty($currentGroup)) { if ($ownerId) { return $this->noItems(); } $this->redirect(OW::getRouter()->urlForRoute("base.moderation_tools")); } $contentMenu = new BASE_CMP_VerticalMenu(); $sideMenuOrder = 1; foreach ($groups as $groupKey => $group) { $item = new BASE_VerticalMenuItem(); $item->setKey($groupKey); $item->setUrl($group["url"]); $item->setNumber($group["count"]); $item->setLabel($group["label"]); $item->setActive($currentGroup["name"] == $group["name"]); $item->setOrder($sideMenuOrder++); $contentMenu->addElement($item); } $this->addComponent("contentMenu", $contentMenu); // Paging $page = isset($_GET['page']) && intval($_GET['page']) > 0 ? $_GET['page'] : 1; $perPage = self::ITEMS_PER_PAGE; $limit = array(($page - 1) * $perPage, $perPage); $this->addComponent("paging", new BASE_CMP_Paging($page, ceil($currentGroup["count"] / $perPage), 5)); // List $entityRecords = MODERATION_BOL_Service::getInstance()->findEntityListByTypes($currentGroup["entityTypes"], $limit, $ownerId); $entityList = array(); $userIds = array(); foreach ($entityRecords as $record) { $entityList[$record->entityType] = empty($entityList[$record->entityType]) ? array() : $entityList[$record->entityType]; $entityList[$record->entityType][] = $record->entityId; } $contentData = array(); foreach ($entityList as $entityType => $entityIds) { $infoList = BOL_ContentService::getInstance()->getContentList($entityType, $entityIds); foreach ($infoList as $entityId => $info) { $userIds[] = $info["userId"]; $contentData[$entityType . ':' . $entityId] = $info; } } $avatarData = BOL_AvatarService::getInstance()->getDataForUserAvatars($userIds); $tplRecords = array(); foreach ($entityRecords as $record) { $recordData = $record->getData(); $content = $contentData[$record->entityType . ":" . $record->entityId]; $contentPresenter = new BASE_CMP_ContentPresenter($content); $label = empty($content["label"]) ? $content["typeInfo"]["entityLabel"] : $content["label"]; $string = null; if (!isset($recordData["string"])) { $string = OW::getLanguage()->text("moderation", "list_string_" . $recordData["reason"], array("content" => strtolower($label))); } else { if (is_string($recordData["string"])) { $string = $recordData["string"]; } else { list($langPrefix, $langKey) = explode("+", $recordData["string"]["key"]); $langVars = empty($recordData["string"]["vars"]) ? array() : $recordData["string"]["vars"]; $string = OW::getLanguage()->text($langPrefix, $langKey, $langVars); } } $tplRecords[] = array("content" => $contentPresenter->render(), "avatar" => $avatarData[$content["userId"]], "string" => $string, "contentLabel" => strtolower($label), "entityType" => $record->entityType, "entityId" => $record->entityId, "reason" => $recordData["reason"], "time" => UTIL_DateTime::formatDate($record->timeStamp)); } $uniqId = uniqid("m-"); $this->assign("uniqId", $uniqId); $this->assign("items", $tplRecords); $this->assign("group", $currentGroup); $this->assign("actions", array("delete" => true, "approve" => empty($ownerId))); $this->assign("responderUrl", OW::getRouter()->urlFor(__CLASS__, "responder", array("group" => $currentGroup["name"], "userId" => $ownerId))); OW::getLanguage()->addKeyForJs("base", "are_you_sure"); OW::getLanguage()->addKeyForJs("base", "moderation_delete_confirmation"); OW::getLanguage()->addKeyForJs("base", "moderation_delete_multiple_confirmation"); OW::getLanguage()->addKeyForJs("base", "moderation_no_items_warning"); $options = array("groupLabel" => strtolower($currentGroup["label"])); $js = UTIL_JsGenerator::newInstance(); $js->callFunction("MODERATION_ApproveInit", array($uniqId, $options)); OW::getDocument()->addOnloadScript($js); }
protected function processList($commentList) { $arrayToAssign = array(); /* @var $value BOL_Comment */ foreach ($commentList as $value) { $this->userIdList[] = $value->getUserId(); $this->commentIdList[] = $value->getId(); } $userAvatarArrayList = empty($this->staticData['avatars']) ? $this->avatarService->getDataForUserAvatars($this->userIdList) : $this->staticData['avatars']; /* @var $value BOL_Comment */ foreach ($commentList as $value) { $cmItemArray = array('displayName' => $userAvatarArrayList[$value->getUserId()]['title'], 'avatarUrl' => $userAvatarArrayList[$value->getUserId()]['src'], 'profileUrl' => $userAvatarArrayList[$value->getUserId()]['url'], 'content' => $value->getMessage(), 'date' => UTIL_DateTime::formatDate($value->getCreateStamp()), 'userId' => $value->getUserId(), 'commentId' => $value->getId(), 'avatar' => $userAvatarArrayList[$value->getUserId()]); $contentAdd = ''; if ($value->getAttachment() !== null) { $tempCmp = new BASE_CMP_OembedAttachment((array) json_decode($value->getAttachment()), $this->isOwnerAuthorized); $contentAdd .= '<div class="ow_attachment ow_small" id="att' . $value->getId() . '">' . $tempCmp->render() . '</div>'; } $cmItemArray['content_add'] = $contentAdd; $event = new BASE_CLASS_EventProcessCommentItem('base.comment_item_process', $value, $cmItemArray); OW::getEventManager()->trigger($event); $arrayToAssign[] = $event->getDataArr(); } return $arrayToAssign; }
private function displayGroupList($list, $paging, $menu = null) { $templatePath = OW::getPluginManager()->getPlugin('groups')->getCtrlViewDir() . 'groups_list.html'; $this->setTemplate($templatePath); $out = array(); foreach ($list as $item) { /* @var $item GROUPS_BOL_Group */ $userCount = GROUPS_BOL_Service::getInstance()->findUserListCount($item->id); $title = strip_tags($item->title); $toolbar = array(array('label' => OW::getLanguage()->text('groups', 'listing_users_label', array('count' => $userCount)))); $out[] = array('id' => $item->id, 'url' => OW::getRouter()->urlForRoute('groups-view', array('groupId' => $item->id)), 'title' => $title, 'imageTitle' => $title, 'content' => UTIL_String::truncate(strip_tags($item->description), 300, '...'), 'time' => UTIL_DateTime::formatDate($item->timeStamp), 'imageSrc' => GROUPS_BOL_Service::getInstance()->getGroupImageUrl($item), 'users' => $userCount, 'toolbar' => $toolbar); } $this->addComponent('paging', $paging); if (!empty($menu)) { $this->addComponent('menu', $menu); } else { $this->assign('menu', ''); } $this->assign("showCreate", true); if (!$this->service->isCurrentUserCanCreate()) { $authStatus = BOL_AuthorizationService::getInstance()->getActionStatus('groups', 'create'); if ($authStatus['status'] == BOL_AuthorizationService::STATUS_PROMOTED) { $this->assign("authMsg", json_encode($authStatus["msg"])); } else { $this->assign("showCreate", false); } } $this->assign('list', $out); }
public function getFields($userIdList) { $lang = OW::getLanguage(); $fields = array(); $qs = array(); $qBdate = BOL_QuestionService::getInstance()->findQuestionByName('birthdate', 'sex'); if ($qBdate->onView) { $qs[] = 'birthdate'; } $qSex = BOL_QuestionService::getInstance()->findQuestionByName('sex'); if ($qSex->onView) { $qs[] = 'sex'; } $questionList = BOL_QuestionService::getInstance()->getQuestionData($userIdList, $qs); $sm = new Smarty(); foreach ($questionList as $uid => $question) { $fields[$uid] = array(); $age = ''; if (!empty($question['birthdate'])) { $date = UTIL_DateTime::parseDate($question['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT); $age = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']); } $sexValue = ''; if (!empty($question['sex'])) { $sex = $question['sex']; for ($i = 0; $i < 31; $i++) { $val = pow(2, $i); if ((int) $sex & $val) { $sexValue .= BOL_QuestionService::getInstance()->getQuestionValueLang('sex', $val) . ', '; } } if (!empty($sexValue)) { $sexValue = substr($sexValue, 0, -2); } } if (!empty($sexValue) && !empty($age)) { $fields[$uid][] = array('label' => '', 'value' => $sexValue . ' ' . $age); } $rate = BASE_CTRL_Rate::displayRate(array('avg_rate' => $this->fields[$uid]['score']), $sm); $fields[$uid][] = array('label' => '', 'value' => $rate); $fields[$uid][] = array('label' => '', 'value' => UTIL_DateTime::formatDate($this->fields[$uid]['timeStamp'])); } return $fields; }
public function onInfoRender(OW_Event $event) { $params = $event->getParams(); $entityType = $params["entityType"]; $entityId = $params["entityId"]; switch ($params["key"]) { case "base-gender-age": $questionData = BOL_QuestionService::getInstance()->getQuestionData(array($entityId), array("birthdate")); $ageStr = ""; if (!empty($questionData[$entityId]['birthdate'])) { $date = UTIL_DateTime::parseDate($questionData[$entityId]['birthdate'], UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT); $age = UTIL_DateTime::getAge($date['year'], $date['month'], $date['day']); $ageStr = $age . " " . OW::getLanguage()->text('base', 'questions_age_year_old'); } $sex = $this->renderQuestion($entityId, "sex"); $event->setData($sex . " " . $ageStr); break; case "base-about": $settings = BOL_ComponentEntityService::getInstance()->findSettingList("profile-BASE_CMP_AboutMeWidget", $entityId, array('content')); $content = empty($settings['content']) ? null : UTIL_String::truncate($settings['content'], 100, '...'); $event->setData('<span class="ow_remark ow_small">' . $content . '</span>'); break; case "base-activity": // Check privacy permissions $eventParams = array('action' => 'base_view_my_presence_on_site', 'ownerId' => $entityId, 'viewerId' => OW::getUser()->getId()); try { OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams); } catch (RedirectException $e) { break; } $isOnline = BOL_UserService::getInstance()->findOnlineUserById($entityId); if ($isOnline) { $event->setData(OW::getLanguage()->text("base", "activity_online")); } else { $user = BOL_UserService::getInstance()->findUserById($entityId); $activity = UTIL_DateTime::formatDate($user->activityStamp); $event->setData(OW::getLanguage()->text("hint", "info-activity", array("activity" => $activity))); } break; case "base-question": if (!empty($params["question"])) { $renderedQuestion = $this->renderQuestion($entityId, $params["question"]); if ($params["line"] == HINT_BOL_Service::INFO_LINE2) { $renderedQuestion = '<span class="ow_remark">' . $renderedQuestion . '</span>'; } $event->setData($renderedQuestion); } break; } }
public function getTplData($cycle = null) { $action = $this->action; $data = $this->getActionData($action); $permalink = empty($data['permalink']) ? NEWSFEED_BOL_Service::getInstance()->getActionPermalink($action->getId(), $this->sharedData['feedType'], $this->sharedData['feedId']) : $data['permalink']; $this->itemPermalink = $permalink; $userId = (int) $data['action']['userId']; $content = null; if (is_array($data["content"]) && !empty($data["content"]["format"])) { $vars = empty($data["content"]["vars"]) ? array() : $data["content"]["vars"]; $content = $this->renderFormat($data["content"]["format"], $vars); } $respond = empty($data["respond"]) ? array() : $data["respond"]; $creatorsInfo = $this->getActionUsersInfo($data); $desktopUrl = $permalink; if (strpos($permalink, OW_URL_HOME) === 0) { $permalinkUri = str_replace(OW_URL_HOME, "", $permalink); $desktopUrl = OW::getRequest()->buildUrlQueryString(OW::getRouter()->urlForRoute("base.desktop_version"), array("back-uri" => urlencode($permalinkUri))); } $item = array('id' => $action->getId(), 'view' => $data['view'], 'toolbar' => $data['toolbar'], 'string' => $this->getLocalizedText($data['string']), 'line' => $this->getLocalizedText($data['line']), 'content' => $content, 'context' => $data['context'], 'entityType' => $data['action']['entityType'], 'entityId' => $data['action']['entityId'], 'createTime' => UTIL_DateTime::formatDate($data['action']['createTime']), 'updateTime' => $action->getUpdateTime(), 'respond' => $respond, "responded" => !empty($respond), "user" => reset($creatorsInfo), 'users' => $creatorsInfo, 'permalink' => $permalink, 'cycle' => $cycle, "disabled" => !empty($data["disabled"]) && $data["disabled"], "desktopUrl" => $desktopUrl); $item['autoId'] = $this->autoId; $item['features'] = $this->getFeatures($data); $item['contextActionMenu'] = $this->getContextMenu($data); return $item; }
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; }
public function index() { if (!OW::getUser()->isAuthorized('links', 'view')) { $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html'); return; } $this->assign('addNew_isAuthorized', OW::getUser()->isAuthenticated() && OW::getUser()->isAuthorized('links', 'add')); switch (OW::getConfig()->getValue('links', 'result_mode')) { case LinkService::RESULT_MODE_SUM: $this->assign('mode', 'sum'); break; case LinkService::RESULT_MODE_DETAILED: $this->assign('mode', 'detailed'); break; } $this->setPageHeading(OW::getLanguage()->text('links', 'list_page_heading')); $this->setPageHeadingIconClass('ow_ic_link'); $plugin = OW::getPluginManager()->getPlugin('links'); OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, $plugin->getKey(), 'main_menu_item'); if (false === strstr($_SERVER['REQUEST_URI'], 'browse-by-tag')) { $isBrowseByTagCase = false; } else { $this->assign('tag', empty($_GET['tag']) ? '' : strip_tags($_GET['tag'])); $isBrowseByTagCase = true; } $this->assign('isBrowseByTagCase', $isBrowseByTagCase); $tagCloud = new BASE_CMP_EntityTagCloud('link', OW::getRouter()->urlForRoute('links-by-tag')); if ($isBrowseByTagCase) { $tagCloud->setTemplate(OW::getPluginManager()->getPlugin('base')->getCmpViewDir() . 'big_tag_cloud.html'); } $this->addComponent('tagCloud', $tagCloud); $tagSearch = new BASE_CMP_TagSearch(OW::getRouter()->urlForRoute('links-by-tag')); $this->addComponent('tagSearch', $tagSearch); //~~ $menu = new BASE_CMP_ContentMenu($this->getMenuItems()); $this->assign('menu', $menu->render()); $service = LinkService::getInstance(); $rpp = (int) OW::getConfig()->getValue('links', 'results_per_page'); $page = !empty($_GET['page']) && (int) $_GET['page'] ? (int) $_GET['page'] : 1; $first = ($page - 1) * $rpp; $count = $rpp; $list = array(); $itemsCount = 0; list($list, $itemsCount) = $this->getData($first, $count); $descLength = 120; //$this->assign('descLength', $descLength); $titleLength = 50; $this->assign('titleLength', $titleLength); $voteService = BOL_VoteService::getInstance(); $idList = array(); $links = array(); $voteTotall = array(); $authorIdList = array(); $commentTotall = array(); foreach ($list as $item) { $link = $item['dto']; $link->setUrl(strip_tags($link->getUrl())); $link->setTitle(strip_tags($link->getTitle())); $description = BASE_CMP_TextFormatter::fromBBtoHtml($link->getDescription()); $description = strip_tags($description); if (strlen($description) > $descLength) { $description = UTIL_String::truncate($description, $descLength, '...'); $description .= ' <a href="' . OW::getRouter()->urlForRoute('link', array('id' => $link->getId())) . '" class="ow_lbutton">' . OW::getLanguage()->text('base', 'more') . '</a>'; } $link->setDescription($description); $links[$link->getId()] = array('dto' => $link); $idList[] = $link->getId(); $authorIdList[] = $link->getUserId(); } $ulist = BOL_UserService::getInstance()->getUserNamesForList($authorIdList); $nlist = BOL_UserService::getInstance()->getDisplayNamesForList($authorIdList); $this->assign('usernameList', $ulist); $this->assign('nameList', $nlist); if (!empty($idList)) { $commentTotall = BOL_CommentService::getInstance()->findCommentCountForEntityList('link', $idList); $voteTotall = $voteService->findTotalVotesResultForList($idList, 'link'); $tagsInfo = BOL_TagService::getInstance()->findTagListByEntityIdList('link', $idList); $this->assign('tagsInfo', $tagsInfo); $toolbars = array(); foreach ($list as $item) { $dto = $item['dto']; $toolbars[$dto->id] = array(); $userId = $dto->userId; $toolbars[$dto->id][] = array('class' => ' ow_icon_control ow_ic_user', 'label' => !empty($nlist[$userId]) ? $nlist[$userId] : OW::getLanguage()->text('base', 'deleted_user'), 'href' => !empty($ulist[$userId]) ? BOL_UserService::getInstance()->getUserUrlForUsername($ulist[$userId]) : '#'); $toolbars[$dto->id][] = array('href' => OW::getRouter()->urlForRoute('link', array('id' => $dto->id)), 'label' => UTIL_DateTime::formatDate($dto->timestamp)); if ($commentTotall[$dto->id]) { $toolbars[$dto->id][] = array('href' => OW::getRouter()->urlForRoute('link', array('id' => $dto->id)) . "#comments", 'label' => '<span class="ow_txt_value">' . $commentTotall[$dto->id] . '</span> ' . OW::getLanguage()->text('links', 'toolbar_comments')); } if (empty($tagsInfo[$dto->id])) { continue; } $value = OW::getLanguage()->text('links', 'tags') . ' '; $c = 0; foreach ($tagsInfo[$dto->id] as $tag) { if ($c == 3) { break; } $value .= '<a href="' . OW::getRouter()->urlForRoute('links-by-tag') . "?tag={$tag}" . "\">{$tag}</a>, "; $c++; } $value = mb_substr($value, 0, mb_strlen($value) - 2); $toolbars[$dto->id][] = array('label' => $value); } if (OW::getUser()->isAuthenticated()) { $userVotes = $voteService->findUserVoteForList($idList, 'link', OW::getUser()->getId()); $this->assign('userVotes', $userVotes); } $this->assign('tb', $toolbars); } foreach ($voteTotall as $val) { $links[$val['id']]['isVoted'] = true; $links[$val['id']]['voteTotal'] = $val['sum']; $links[$val['id']]['up'] = $val['up']; $links[$val['id']]['down'] = $val['down']; } $this->assign('commentTotall', $commentTotall); $this->assign('list', $links); $this->assign('url_new_link', OW::getRouter()->urlForRoute('link-save-new')); $paging = new BASE_CMP_Paging($page, ceil($itemsCount / $rpp), 5); $this->assign('paging', $paging->render()); $this->assign('isAuthenticated', OW::getUser()->isAuthenticated()); }
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); }
/** * @param MAILBOX_BOL_Message $message * @return array */ public function getMessageDataForApi($message) { $defaultAvatarUrl = BOL_AvatarService::getInstance()->getDefaultAvatarUrl(); $item = array(); $item['convId'] = (int) $message->conversationId; $item['mode'] = $this->getConversationMode((int) $message->conversationId); $item['id'] = (int) $message->id; $item['date'] = date('Y-m-d', (int) $message->timeStamp); $item['dateLabel'] = UTIL_DateTime::formatDate((int) $message->timeStamp, true); $item['timeStamp'] = (int) $message->timeStamp; $militaryTime = (bool) OW::getConfig()->getValue('base', 'military_time'); $item['timeLabel'] = $militaryTime ? strftime("%H:%M", (int) $message->timeStamp) : strftime("%I:%M%p", (int) $message->timeStamp); $item['recipientId'] = (int) $message->recipientId; $item['senderId'] = (int) $message->senderId; $profileDisplayname = BOL_UserService::getInstance()->getDisplayName((int) $message->senderId); $profileDisplayname = empty($profileDisplayname) ? BOL_UserService::getInstance()->getUserName((int) $message->senderId) : $profileDisplayname; $item['displayName'] = $profileDisplayname; $avatarUrl = BOL_AvatarService::getInstance()->getAvatarUrl((int) $message->senderId); $profileAvatarUrl = empty($avatarUrl) ? $defaultAvatarUrl : $avatarUrl; $item['senderAvatarUrl'] = $profileAvatarUrl; $avatarUrl = BOL_AvatarService::getInstance()->getAvatarUrl((int) $message->recipientId); $profileAvatarUrl = empty($avatarUrl) ? $defaultAvatarUrl : $avatarUrl; $item['recipientAvatarUrl'] = $profileAvatarUrl; $item['isAuthor'] = (bool) ((int) $message->senderId == OW::getUser()->getId()); $item['recipientRead'] = (int) $message->recipientRead; $item['isSystem'] = (int) $message->isSystem; $item['attachments'] = array(); $conversation = $this->getConversation($message->conversationId); if ((int) $conversation->initiatorId == OW::getUser()->getId()) { $item['conversationViewed'] = (bool) ((int) $conversation->viewed & MAILBOX_BOL_ConversationDao::VIEW_INITIATOR); } if ((int) $conversation->interlocutorId == OW::getUser()->getId()) { $item['conversationViewed'] = (bool) ((int) $conversation->viewed & MAILBOX_BOL_ConversationDao::VIEW_INTERLOCUTOR); } if ($item['mode'] == 'mail') { $actionName = 'read_message'; } if ($item['mode'] == 'chat') { $actionName = 'read_chat_message'; } $status = BOL_AuthorizationService::getInstance()->getActionStatus('mailbox', $actionName); $readMessageAuthorized = true; if ((int) $message->senderId != OW::getUser()->getId() && !$message->wasAuthorized) { if ($status['status'] == BOL_AuthorizationService::STATUS_AVAILABLE) { if ($status['authorizedBy'] == 'usercredits') { $action = USERCREDITS_BOL_CreditsService::getInstance()->findAction('mailbox', $actionName); $actionPrice = USERCREDITS_BOL_CreditsService::getInstance()->findActionPriceForUser($action->id, OW::getUser()->getId()); if ($actionPrice->amount == 0 || $actionPrice->disabled) { $readMessageAuthorized = true; $this->markMessageAuthorizedToRead($message->id); } else { $readMessageAuthorized = false; $item['isSystem'] = 1; $text = array('text' => OW::getLanguage()->text('mailbox', 'api_read_the_message'), 'eventName' => 'authorizationPromoted', 'status' => 'available'); } } else { $readMessageAuthorized = true; $this->markMessageAuthorizedToRead($message->id); } } else { if ($status['status'] == BOL_AuthorizationService::STATUS_PROMOTED) { $readMessageAuthorized = false; $item['isSystem'] = 1; $text = array('text' => strip_tags($status['msg']), 'eventName' => 'authorizationPromoted', 'status' => 'promoted'); } else { $readMessageAuthorized = false; $text = OW::getLanguage()->text('mailbox', $actionName . '_permission_denied'); } } } $item['readMessageAuthorized'] = $readMessageAuthorized; if ($readMessageAuthorized) { if ($message->isSystem) { $eventParams = json_decode($message->text, true); $eventParams['params']['messageId'] = (int) $message->id; $event = new OW_Event($eventParams['entityType'] . '.' . $eventParams['eventName'], $eventParams['params']); OW::getEventManager()->trigger($event); $data = $event->getData(); if (!empty($data)) { $text = $data; } else { $text = array('eventName' => $eventParams['eventName'], 'text' => OW::getLanguage()->text('mailbox', 'can_not_display_entitytype_message', array('entityType' => $eventParams['entityType']))); } } else { $text = $this->splitLongMessages($message->text); } $attachments = $this->attachmentDao->findAttachmentsByMessageId($message->id); if (!empty($attachments)) { foreach ($attachments as $attachment) { $ext = UTIL_File::getExtension($attachment->fileName); $attachmentPath = $this->getAttachmentFilePath($attachment->id, $attachment->hash, $ext, $attachment->fileName); $attItem = array(); $attItem['id'] = $attachment->id; $attItem['messageId'] = $attachment->messageId; $attItem['downloadUrl'] = OW::getStorage()->getFileUrl($attachmentPath); $attItem['fileName'] = $attachment->fileName; $attItem['fileSize'] = $attachment->fileSize; $attItem['type'] = $this->getAttachmentType($attachment); $item['attachments'][] = $attItem; } } } $item['text'] = $text; return $item; }
/** * Displays mailbox conversation page */ public function conversation($params) { $userId = OW::getUser()->getId(); if (!OW::getUser()->isAuthenticated() || $userId === null) { throw new AuthenticateException(); // TODO: Redirect to login page } $conversation = null; $conversationService = MAILBOX_BOL_ConversationService::getInstance(); $userService = BOL_UserService::getInstance(); if (empty($params['conversationId'])) { throw new AuthenticateException(); } $conversationId = (int) $params['conversationId']; $conversation = $conversationService->getConversation($conversationId); if ($conversation === null) { throw new Redirect404Exception(); } $lastMessages = $conversationService->getLastMessages($conversationId); if ($lastMessages === null) { throw new Redirect404Exception(); } $conversationService->markRead(array($conversation->id), $userId); $language = OW::getLanguage(); $addMessageForm = new AddMessageForm(); $this->addForm($addMessageForm); if (OW::getRequest()->isPost()) { switch ($userId) { case $conversation->initiatorId: $blockedByUserId = $conversation->interlocutorId; break; case $conversation->interlocutorId: $blockedByUserId = $conversation->initiatorId; break; } if (BOL_UserService::getInstance()->isBlocked($userId, $blockedByUserId)) { OW::getFeedback()->error(OW::getLanguage()->text('base', 'user_block_message')); } else { if ($addMessageForm->isValid($_POST)) { $res = $addMessageForm->process($conversation, $userId); if (!$res['result'] && !empty($res['error'])) { OW::getFeedback()->warning($res['error']); } $this->redirect(); } else { OW::getFeedback()->error($language->text('base', 'form_validate_common_error_message')); } } } $conversationArray = array(); $conversationArray["conversationId"] = $conversation->id; $conversationArray["subject"] = $conversation->subject; if (!empty($_GET['redirectTo']) && $_GET['redirectTo'] === MAILBOX_CTRL_Mailbox::REDIRECT_TO_SENT) { $conversationArray["deleteUrl"] = OW::getRouter()->urlFor('MAILBOX_CTRL_Mailbox', 'deleteSent', array("conversationId" => $conversation->id, "page" => 1)); } else { $conversationArray["deleteUrl"] = OW::getRouter()->urlFor('MAILBOX_CTRL_Mailbox', 'deleteInbox', array("conversationId" => $conversation->id, "page" => 1)); } $conversationArray['read'] = $conversationService->isConversationReadByUser($userId, $conversation->initiatorId, $conversation->interlocutorId, $conversation->read); $conversationArray['isOpponentLastMessage'] = false; switch ($userId) { case $conversation->initiatorId: $conversationArray['opponentId'] = $conversation->interlocutorId; $conversationArray['userId'] = $conversation->initiatorId; if ($lastMessages->initiatorMessageId < $lastMessages->interlocutorMessageId) { $conversationArray['isOpponentLastMessage'] = true; } break; case $conversation->interlocutorId: $conversationArray['opponentId'] = $conversation->initiatorId; $conversationArray['userId'] = $conversation->interlocutorId; if ($lastMessages->initiatorMessageId > $lastMessages->interlocutorMessageId) { $conversationArray['isOpponentLastMessage'] = true; } break; default: throw new Redirect403Exception(); } $avatarList = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($conversationArray['userId'], $conversationArray['opponentId'])); $displayNames = $userService->getDisplayNamesForList(array($userId, $conversationArray['opponentId'])); $conversationArray['opponentDisplayName'] = $displayNames[$conversationArray['opponentId']]; $conversationArray['userDisplayName'] = $displayNames[$conversationArray['userId']]; $userNames = $userService->getDisplayNamesForList(array($conversationArray['userId'], $conversationArray['opponentId'])); $conversationArray['opponentName'] = $userNames[$conversationArray['opponentId']]; $conversationArray['userName'] = $userNames[$conversationArray['userId']]; $conversationArray['opponentUrl'] = $userService->getUserUrl($conversationArray['opponentId'], $conversationArray['opponentName']); $conversationArray['userUrl'] = $userService->getUserUrl($conversationArray['userId'], $conversationArray['userName']); $messages = $conversationService->getConversationMessagesList($conversationId); $messageList = array(); $messageIdList = array(); $trackConvView = false; foreach ($messages as $value) { $messageIdList[] = $value->id; $message = array(); $message['id'] = $value->id; $message['senderId'] = $value->senderId; $message['recipientId'] = $value->recipientId; $message['recipientRead'] = $value->recipientRead; $message['senderDisplayName'] = $value->senderId == $userId ? $conversationArray['userDisplayName'] : $conversationArray['opponentDisplayName']; $message['senderName'] = $value->senderId == $userId ? $conversationArray['userName'] : $conversationArray['opponentName']; $message['senderUrl'] = $userService->getUserUrl($value->senderId, $message['senderName']); $message['timeStamp'] = UTIL_DateTime::formatDate((int) $value->timeStamp); $message['toolbar'] = array(); $isReadable = false; if ($value->senderId == $userId || $message['recipientRead']) { $isReadable = true; } else { if (OW::getUser()->isAuthorized('mailbox', 'read_message')) { // check credits $eventParams = array('pluginKey' => 'mailbox', 'action' => 'read_message'); $credits = OW::getEventManager()->call('usercredits.check_balance', $eventParams); if ($credits === false) { $creditsMsg = OW::getEventManager()->call('usercredits.error_message', $eventParams); $message['content'] = '<span class="error">' . $creditsMsg . '</span>'; } else { $conversationService->markMessageRead($value->id); $isReadable = true; $trackConvView = true; } } else { $message['content'] = '<span class="error">' . $language->text('mailbox', 'read_permission_denied') . '</span>'; } } if ($isReadable) { $message['content'] = UTIL_HtmlTag::autoLink($value->text); //TODO: Insert text formatter $event = new OW_Event('mailbox.message_render', array('conversationId' => $conversationId, 'messageId' => $message['id'], 'senderId' => $message['senderId'], 'recipientId' => $message['recipientId']), array('short' => '', 'full' => $message['content'])); OW::getEventManager()->trigger($event); $eventData = $event->getData(); $message['content'] = $eventData['full']; } $message['isReadableMessage'] = $isReadable; $messageList[] = $message; } if ($trackConvView) { if (isset($credits) && $credits === true) { $eventParams = array('pluginKey' => 'mailbox', 'action' => 'read_message', 'extra' => array('layer_check' => true, 'senderId' => $conversationArray['userId'], 'recipientId' => $conversationArray['opponentId'])); OW::getEventManager()->call('usercredits.track_action', $eventParams); } // message read event triggered $event = new OW_Event('mailbox.message_read', array('conversationId' => $conversationId, 'userId' => $userId)); OW::getEventManager()->trigger($event); } $attachments = $conversationService->findAttachmentsByMessageIdList($messageIdList); $attachmentList = array(); foreach ($attachments as $attachment) { $ext = UTIL_File::getExtension($attachment->fileName); $attachmentPath = $conversationService->getAttachmentFilePath($attachment->id, $attachment->hash, $ext); $list = array(); $list['id'] = $attachment->id; $list['messageId'] = $attachment->messageId; $list['downloadUrl'] = OW::getStorage()->getFileUrl($attachmentPath); $list['fileName'] = $attachment->fileName; $list['fileSize'] = $attachment->fileSize; $attachmentList[$attachment->messageId][$attachment->id] = $list; } $this->assign('attachmentList', $attachmentList); $this->assign('messageList', $messageList); $this->assign('conversation', $conversationArray); $this->assign('writeMessage', OW::getUser()->isAuthorized('mailbox', 'send_message')); $this->assign('avatars', $avatarList); $configs = OW::getConfig()->getValues('mailbox'); $this->assign('enableAttachments', !empty($configs['enable_attachments'])); //include js $deleteConfirmMessage = $language->text('mailbox', 'delete_confirm_message'); $onLoadJs = " \$(document).ready(function(){\n\t\t\t\t\t\tvar conversation = new mailboxConversation( " . json_encode(array('responderUrl' => $this->responderUrl, 'deleteConfirmMessage' => $deleteConfirmMessage)) . " );\n\t\t\t\t\t}); "; OW::getDocument()->addOnloadScript($onLoadJs); OW::getDocument()->addScript($this->jsDirUrl . "mailbox.js"); OW::getDocument()->setTitle($language->text('mailbox', 'conversation_meta_tilte', array('conversation_title' => $conversation->subject))); }
public function index($params) { $plugin = OW::getPluginManager()->getPlugin('blogs'); OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'blogs', 'main_menu_item'); if (!OW::getUser()->isAdmin() && !OW::getUser()->isAuthorized('blogs', 'view')) { $status = BOL_AuthorizationService::getInstance()->getActionStatus('blogs', 'view'); throw new AuthorizationException($status['msg']); return; } /* @var $service PostService */ $service = PostService::getInstance(); /* @var $userService BOL_UserService */ $userService = BOL_UserService::getInstance(); /* @var $author BOL_User */ if (!empty($params['user'])) { $author = $userService->findByUsername($params['user']); } else { $author = $userService->findUserById(OW::getUser()->getId()); } if (empty($author)) { throw new Redirect404Exception(); return; } /* Check privacy permissions */ $eventParams = array('action' => 'blogs_view_blog_posts', 'ownerId' => $author->getId(), 'viewerId' => OW::getUser()->getId()); OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams); /* */ $displaySocialSharing = true; try { $eventParams = array('action' => 'blogs_view_blog_posts', 'ownerId' => $author->getId(), 'viewerId' => 0); OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams); } catch (RedirectException $ex) { $displaySocialSharing = false; } if ($displaySocialSharing && !BOL_AuthorizationService::getInstance()->isActionAuthorizedForUser(0, 'blogs', 'view')) { $displaySocialSharing = false; } $this->assign('display_social_sharing', $displaySocialSharing); $displayName = $userService->getDisplayName($author->getId()); $this->assign('author', $author); $this->assign('username', $author->getUsername()); $this->assign('displayname', $displayName); $this->setPageHeading(OW::getLanguage()->text('blogs', 'user_blog_page_heading', array('name' => $author->getUsername()))); $this->setPageHeadingIconClass('ow_ic_write'); $page = !empty($_GET['page']) && intval($_GET['page']) > 0 ? intval($_GET['page']) : 1; $rpp = (int) OW::getConfig()->getValue('blogs', 'results_per_page'); $first = ($page - 1) * $rpp; $count = $rpp; if (!empty($_GET['month'])) { $archive_params = htmlspecialchars($_GET['month']); $arr = explode('-', $archive_params); $month = $arr[0]; $year = $arr[1]; $lb = mktime(null, null, null, $month, 1, $year); $ub = mktime(null, null, null, $month + 1, null, $year); $list = $service->findUserPostListByPeriod($author->getId(), $lb, $ub, $first, $count); $itemsCount = $service->countUserPostByPeriod($author->getId(), $lb, $ub); $l = OW::getLanguage(); $arciveHeaderPart = ', ' . $l->text('base', "month_{$month}") . " {$year} " . $l->text('base', 'archive'); OW::getDocument()->setTitle(OW::getLanguage()->text('blogs', 'user_blog_archive_title', array('month_name' => $l->text('base', "month_{$month}"), 'display_name' => $displayName))); OW::getDocument()->setDescription(OW::getLanguage()->text('blogs', 'user_blog_archive_description', array('year' => $year, 'month_name' => $l->text('base', "month_{$month}"), 'display_name' => $displayName))); } else { $list = $service->findUserPostList($author->getId(), $first, $count); $itemsCount = $service->countUserPost($author->getId()); OW::getDocument()->setTitle(OW::getLanguage()->text('blogs', 'user_blog_title', array('display_name' => $displayName))); OW::getDocument()->setDescription(OW::getLanguage()->text('blogs', 'user_blog_description', array('display_name' => $displayName))); } $this->assign('archiveHeaderPart', !empty($arciveHeaderPart) ? $arciveHeaderPart : ''); $posts = array(); $commentInfo = array(); $idList = array(); foreach ($list as $dto) { $idList[] = $dto->getId(); $dto_post = BASE_CMP_TextFormatter::fromBBtoHtml($dto->getPost()); $dto->setPost($dto_post); $parts = explode('<!--more-->', $dto->getPost()); if (!empty($parts)) { $text = $parts[0]; //$text = UTIL_HtmlTag::sanitize($text); } else { $text = $dto->getPost(); } $posts[] = array('id' => $dto->getId(), 'href' => OW::getRouter()->urlForRoute('user-post', array('id' => $dto->getId())), 'title' => UTIL_String::truncate($dto->getTitle(), 65, '...'), 'text' => $text, 'truncated' => count($parts) > 1 ? true : false); } if (!empty($idList)) { $commentInfo = BOL_CommentService::getInstance()->findCommentCountForEntityList('blog-post', $idList); $this->assign('commentInfo', $commentInfo); $tagsInfo = BOL_TagService::getInstance()->findTagListByEntityIdList('blog-post', $idList); $this->assign('tagsInfo', $tagsInfo); $tb = array(); foreach ($list as $dto) { $tb[$dto->getId()] = array(array('label' => UTIL_DateTime::formatDate($dto->timestamp))); //if ( $commentInfo[$dto->getId()] ) //{ $tb[$dto->getId()][] = array('href' => OW::getRouter()->urlForRoute('post', array('id' => $dto->getId())), 'label' => '<span class="ow_outline">' . $commentInfo[$dto->getId()] . '</span> ' . OW::getLanguage()->text('blogs', 'toolbar_comments')); //} if ($tagsInfo[$dto->getId()]) { $tags =& $tagsInfo[$dto->getId()]; $t = OW::getLanguage()->text('blogs', 'tags'); for ($i = 0; $i < (count($tags) > 3 ? 3 : count($tags)); $i++) { $t .= " <a href=\"" . OW::getRouter()->urlForRoute('blogs.list', array('list' => 'browse-by-tag')) . "?tag={$tags[$i]}\">{$tags[$i]}</a>" . ($i != 2 ? ',' : ''); } $tb[$dto->getId()][] = array('label' => mb_substr($t, 0, mb_strlen($t) - 1)); } } $this->assign('tb', $tb); } $this->assign('list', $posts); $info = array('lastPost' => $service->findUserLastPost($author->getId()), 'author' => $author); $this->assign('info', $info); $paging = new BASE_CMP_Paging($page, ceil($itemsCount / $rpp), 5); $this->assign('paging', $paging->render()); $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); $this->assign('my_drafts_url', OW::getRouter()->urlForRoute('blog-manage-drafts')); if (OW::getUser()->isAuthenticated()) { $isOwner = $params['user'] == OW::getUser()->getUserObject()->getUsername() ? true : false; } else { $isOwner = false; } $this->assign('isOwner', $isOwner); }
/** * Smarty date function. * * @author Sardar Madumarov <*****@*****.**> * @package ow.ow_smarty.plugin * @since 1.0 */ function smarty_function_format_date($params, $smarty) { return UTIL_DateTime::formatDate($params['timestamp']); }
public function searchInTopic($token, $userToken, $topicId, $sortBy = null) { $posts = $this->postDao->searchInTopic($token, $userToken, $topicId, $sortBy); if ($posts) { $topic = $this->findTopicById($topicId); if (!$topic) { return null; } $groupInfo = $this->getGroupInfo($topic->groupId); $forumSection = $this->findSectionById($groupInfo->sectionId); $highlight = mb_strlen($token) != 0; $parentTopic = array(); $parentTopic['userId'] = $topic->userId; $parentTopic['title'] = $highlight ? $this->highlightSearchWords($topic->title, $token) : $topic->title; $parentTopic['topicUrl'] = OW::getRouter()->urlForRoute('topic-default', array('topicId' => $topic->id)); $parentTopic['groupId'] = $topic->groupId; $parentTopic['sectionId'] = $groupInfo->sectionId; $parentTopic['groupName'] = $groupInfo->name; $parentTopic['sectionName'] = $forumSection->name; foreach ($posts as $postDto) { $formatter = new FORUM_CLASS_ForumSearchResultFormatter(); $text = strip_tags($postDto->text); $postInfo = array('postId' => $postDto->id, 'topicId' => $postDto->topicId, 'userId' => $postDto->userId, 'text' => $formatter->formatResult($text, array($token), $highlight), 'createStamp' => UTIL_DateTime::formatDate($postDto->createStamp), 'postUrl' => $this->getPostUrl($postDto->topicId, $postDto->id)); $parentTopic['posts'][$postDto->id] = $postInfo; } return array($parentTopic); } return null; }
/** * @param $goalId * @param $type * @param int $page * @param int $limit * @return array|bool */ public function getDonationList($goalId, $type, $page = 1, $limit = 3) { if (!$goalId) { return false; } switch ($type) { case 'top': $list = $this->donationDao->getGoalTopDonations($goalId, $limit); break; case 'latest': $list = $this->donationDao->getGoalLatestDonations($goalId, $limit); break; case 'all': $list = $this->donationDao->getGoalDonations($goalId, $page, $limit); break; } if (!$list) { return false; } $avatarService = BOL_AvatarService::getInstance(); $userService = BOL_UserService::getInstance(); $defAvatar = array('src' => $avatarService->getDefaultAvatarUrl()); $userIdList = array(); foreach ($list as $donation) { if ($donation->userId && !in_array($donation->userId, $userIdList)) { array_push($userIdList, $donation->userId); } } $avatars = $avatarService->getDataForUserAvatars($userIdList); $displayNames = $userService->getDisplayNamesForList($userIdList); $userNames = $userService->getUserNamesForList($userIdList); $res = array(); foreach ($list as $donation) { $donation->donationStamp = UTIL_DateTime::formatDate($donation->donationStamp, false); $donation->amount = floatval($donation->amount); $res[$donation->id]['dto'] = $donation; if ($donation->userId) { $res[$donation->id]['avatar'] = !empty($avatars[$donation->userId]) ? $avatars[$donation->userId] : $defAvatar; $res[$donation->id]['username'] = !empty($userNames[$donation->userId]) ? $userNames[$donation->userId] : $userService->getUserName($donation->userId); $res[$donation->id]['displayName'] = !empty($displayNames[$donation->userId]) ? $displayNames[$donation->userId] : $userService->getDisplayName($donation->userId); } else { $res[$donation->id]['avatar'] = $defAvatar; $res[$donation->id]['username'] = $donation->username; $res[$donation->id]['displayName'] = $donation->username; } } return $res; }