/** * Constructor. * * @param array<count,label> $tagList * */ public function __construct(array $tagList = null, $url = null) { parent::__construct(); $this->tagList = $tagList; $this->url = $url; $this->service = BOL_TagService::getInstance(); }
/** * Adds video clip * * @return boolean */ public function process() { $values = $this->getValues(); $clipService = VIDEO_BOL_ClipService::getInstance(); $clip = new VIDEO_BOL_Clip(); $clip->title = htmlspecialchars($values['title']); $description = UTIL_HtmlTag::stripJs($values['description']); $description = UTIL_HtmlTag::stripTags($description, array('frame', 'style'), array(), true); $description = nl2br($description, true); $clip->description = $description; $clip->userId = OW::getUser()->getId(); $clip->code = '<iframe src="' . (OW::getRouter()->getBaseUrl() . 'spvideo/proxy/Allmyvideos/pending/') . $values['token'] . '" width="540" height="315" frameborder="0"></iframe>'; $privacy = OW::getEventManager()->call('plugin.privacy.get_privacy', array('ownerId' => $clip->userId, 'action' => 'video_view_video')); $clip->provider = 'allmyvideos'; $clip->addDatetime = time(); $clip->status = 'approved'; $clip->privacy = mb_strlen($privacy) ? $privacy : 'everybody'; $eventParams = array('pluginKey' => 'video', 'action' => 'add_video'); if (OW::getEventManager()->call('usercredits.check_balance', $eventParams) === true) { OW::getEventManager()->call('usercredits.track_action', $eventParams); } if ($clipService->addClip($clip)) { SPVIDEOLITE_PRO_ALLMYVIDEOS_CLASS_Processing::processTemporaryUpload($values['token'], $values['filename']); BOL_TagService::getInstance()->updateEntityTags($clip->id, 'video', $values['tags']); return array('result' => true, 'id' => $clip->id); } return false; }
/** * Constructor. * * @param string $entityType * @param string $url * @param integer $tagsCount */ public function __construct($entityType, $url, $tagsCount = null) { parent::__construct(); $this->service = BOL_TagService::getInstance(); $this->entityType = trim($entityType); $this->url = trim($url); $this->tagsCount = $tagsCount; }
/** * Constructor. * * @param string $entityType * @param string $url * @param integer $tagsCount */ public function __construct($entityType, $url = null, $tagsCount = null) { parent::__construct(); $this->service = BOL_TagService::getInstance(); $this->entityType = trim($entityType); $this->url = trim($url); $this->tagsCount = $tagsCount; $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCmpViewDir() . 'tag_cloud.html'); }
public function delete(Link $dto) { BOL_CommentService::getInstance()->deleteEntityComments('link', $dto->getId()); BOL_TagService::getInstance()->deleteEntityTags($dto->getId(), 'link'); BOL_VoteService::getInstance()->deleteEntityItemVotes($dto->getId(), 'link'); BOL_FlagService::getInstance()->deleteByTypeAndEntityId('link', $dto->getId()); OW::getCacheManager()->clean(array(LinkDao::CACHE_TAG_LINK_COUNT)); OW::getEventManager()->trigger(new OW_Event('feed.delete_item', array('entityType' => 'link', 'entityId' => $dto->getId()))); $this->dao->delete($dto); }
/** * Class constructor */ public function __construct($photoId) { parent::__construct('photo-edit-form'); $this->setAjax(true); $this->setAction(OW::getRouter()->urlFor('PHOTO_CTRL_Photo', 'ajaxUpdatePhoto')); $language = OW::getLanguage(); $photo = PHOTO_BOL_PhotoService::getInstance()->findPhotoById($photoId); $album = PHOTO_BOL_PhotoAlbumService::getInstance()->findAlbumById($photo->albumId); $userId = OW::getUser()->getId(); // photo id field $photoIdField = new HiddenField('id'); $photoIdField->setRequired(true); $this->addElement($photoIdField); // photo album Field $albumField = new SuggestField('album'); $responderUrl = OW::getRouter()->urlFor('PHOTO_CTRL_Upload', 'suggestAlbum', array('userId' => $userId)); $albumField->setResponderUrl($responderUrl); if ($album) { $albumField->setValue($album->name); } $albumField->setRequired(true); $albumField->setLabel($language->text('photo', 'album')); $this->addElement($albumField); // description Field $descField = new WysiwygTextarea('description', null, false); $descField->setId("photo-desc-area"); $this->addElement($descField->setLabel($language->text('photo', 'description'))); $tags = array(); $entityTags = BOL_TagService::getInstance()->findEntityTags($photo->id, 'photo'); if ($entityTags) { $tags = array(); foreach ($entityTags as $entityTag) { $tags[] = $entityTag->label; } $tagsField = new TagsInputField('tags'); $tagsField->setValue($tags); } else { $tagsField = new TagsInputField('tags'); } $this->addElement($tagsField->setLabel($language->text('photo', 'tags'))); $submit = new Submit('edit'); $submit->setValue($language->text('photo', 'btn_edit')); $this->addElement($submit); }
public function onUpdateInfo(OW_Event $event) { $params = $event->getParams(); $data = $event->getData(); if ($params["entityType"] != self::ENTITY_TYPE) { return; } foreach ($data as $entityId => $info) { $statusActive = $info["status"] == BOL_ContentService::STATUS_ACTIVE; $status = $statusActive ? "approved" : "approval"; // Set tags status BOL_TagService::getInstance()->setEntityStatus(VIDEO_BOL_ClipService::TAGS_ENTITY_TYPE, $entityId, $statusActive); // Set rates status BOL_RateService::getInstance()->setEntityStatus(VIDEO_BOL_ClipService::RATES_ENTITY_TYPE, $entityId, $statusActive); $entityDto = $this->service->findClipById($entityId); $entityDto->status = $status; $this->service->saveClip($entityDto); } }
/** * Class constructor */ public function __construct($clipId) { parent::__construct('videoEditForm'); $this->setAjax(true); $this->setAction(OW::getRouter()->urlFor('GVIDEOVIEWER_CTRL_Index', 'ajaxUpdateVideo')); $language = OW::getLanguage(); // clip id field $clipIdField = new HiddenField('id'); $clipIdField->setRequired(true); $this->addElement($clipIdField); // title Field $titleField = new TextField('title'); $titleField->addValidator(new StringValidator(1, 128)); $titleField->setRequired(true); $this->addElement($titleField->setLabel($language->text('video', 'title'))); // description Field $descField = new WysiwygTextarea('description'); $descField->setId("video-desc-area"); $this->addElement($descField->setLabel($language->text('video', 'description'))); $code = new Textarea('code'); $code->setRequired(true); $this->addElement($code->setLabel($language->text('video', 'code'))); $entityTags = BOL_TagService::getInstance()->findEntityTags($clipId, 'video'); if ($entityTags) { $tags = array(); foreach ($entityTags as $entityTag) { $tags[] = $entityTag->label; } $tagsField = new TagsInputField('tags'); $tagsField->setValue($tags); } else { $tagsField = new TagsInputField('tags'); } $this->addElement($tagsField->setLabel($language->text('video', 'tags'))); $submit = new Submit('edit'); $submit->setValue($language->text('video', 'btn_edit')); $this->addElement($submit); }
public function onUpdateEntityItemsStatus(OW_Event $event) { $params = $event->getParams(); if (empty($params['entityType']) || empty($params['entityIds']) || !isset($params['status']) || !is_array($params['entityIds'])) { return; } $status = empty($params['status']) ? 0 : 1; foreach ($params['entityIds'] as $entityId) { BOL_CommentService::getInstance()->setEntityStatus($params['entityType'], $entityId, $status); BOL_TagService::getInstance()->updateEntityItemStatus($params['entityType'], $entityId, $status); BOL_RateService::getInstance()->updateEntityStatus($params['entityType'], $entityId, $status); BOL_VoteService::getInstance()->updateEntityItemStatus($params['entityType'], $entityId, $status); } }
public function moveTemporaryPhoto($tmpId, $albumId, $desc, $tag = NULL, $angle = 0, $uploadKey = null, $status = null) { $tmp = $this->photoTemporaryDao->findById($tmpId); $album = PHOTO_BOL_PhotoAlbumService::getInstance()->findAlbumById($albumId); if (!$tmp || !$album) { return FALSE; } $previewTmp = $this->photoTemporaryDao->getTemporaryPhotoPath($tmp->id, 1); $mainTmp = $this->photoTemporaryDao->getTemporaryPhotoPath($tmp->id, 2); $originalTmp = $this->photoTemporaryDao->getTemporaryPhotoPath($tmp->id, 3); $smallTmp = $this->photoTemporaryDao->getTemporaryPhotoPath($tmp->id, 4); $fullscreenTmp = $this->photoTemporaryDao->getTemporaryPhotoPath($tmp->id, 5); $privacy = OW::getEventManager()->call('plugin.privacy.get_privacy', array('ownerId' => $album->userId, 'action' => 'photo_view_album')); $photoService = PHOTO_BOL_PhotoService::getInstance(); $photo = new PHOTO_BOL_Photo(); $photo->description = htmlspecialchars(trim($desc)); $photo->albumId = $albumId; $photo->addDatetime = time(); $photo->status = empty($status) ? "approved" : $status; $photo->hasFullsize = (int) $tmp->hasFullsize; $photo->privacy = !empty($privacy) ? $privacy : 'everybody'; $photo->hash = uniqid(); $photo->uploadKey = empty($uploadKey) ? $photoService->getPhotoUploadKey($albumId) : $uploadKey; PHOTO_BOL_PhotoDao::getInstance()->save($photo); try { $storage = OW::getStorage(); $dimension = array(); if ((int) $angle !== 0) { $tmpImage = $tmp->hasFullsize ? (bool) OW::getConfig()->getValue('photo', 'store_fullsize') ? $originalTmp : $fullscreenTmp : $mainTmp; $smallImg = new UTIL_Image($tmpImage); $smallImg->resizeImage(PHOTO_BOL_PhotoService::DIM_SMALL_WIDTH, PHOTO_BOL_PhotoService::DIM_SMALL_HEIGHT, TRUE)->rotate($angle)->saveImage($smallTmp); $storage->copyFile($smallTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_SMALL)); $dimension[PHOTO_BOL_PhotoService::TYPE_SMALL] = array($smallImg->getWidth(), $smallImg->getHeight()); $smallImg->destroy(); $previewImage = new UTIL_Image($tmpImage); $previewImage->resizeImage(PHOTO_BOL_PhotoService::DIM_PREVIEW_WIDTH, PHOTO_BOL_PhotoService::DIM_PREVIEW_HEIGHT)->rotate($angle)->saveImage($previewTmp); $storage->copyFile($previewTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_PREVIEW)); $dimension[PHOTO_BOL_PhotoService::TYPE_PREVIEW] = array($previewImage->getWidth(), $previewImage->getHeight()); $previewImage->destroy(); $main = new UTIL_Image($tmpImage); $main->resizeImage(PHOTO_BOL_PhotoService::DIM_MAIN_WIDTH, PHOTO_BOL_PhotoService::DIM_MAIN_HEIGHT)->rotate($angle)->saveImage($mainTmp); $storage->copyFile($mainTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_MAIN)); $dimension[PHOTO_BOL_PhotoService::TYPE_MAIN] = array($main->getWidth(), $main->getHeight()); $main->destroy(); $originalImage = new UTIL_Image($tmpImage); $originalImage->resizeImage(PHOTO_BOL_PhotoService::DIM_ORIGINAL_WIDTH, PHOTO_BOL_PhotoService::DIM_ORIGINAL_HEIGHT)->rotate($angle)->saveImage($originalTmp); $storage->copyFile($originalTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_ORIGINAL)); $dimension[PHOTO_BOL_PhotoService::TYPE_ORIGINAL] = array($originalImage->getWidth(), $originalImage->getHeight()); $originalImage->destroy(); if ($tmp->hasFullsize && (bool) OW::getConfig()->getValue('photo', 'store_fullsize')) { $fullscreen = new UTIL_Image($tmpImage); $fullscreen->resizeImage(PHOTO_BOL_PhotoService::DIM_FULLSCREEN_WIDTH, PHOTO_BOL_PhotoService::DIM_FULLSCREEN_HEIGHT)->rotate($angle)->saveImage($fullscreenTmp); $storage->copyFile($fullscreenTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_FULLSCREEN)); $dimension[PHOTO_BOL_PhotoService::TYPE_FULLSCREEN] = array($fullscreen->getWidth(), $fullscreen->getHeight()); $fullscreen->destroy(); } } else { $storage->copyFile($smallTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_SMALL)); list($width, $height) = getimagesize($smallTmp); $dimension[PHOTO_BOL_PhotoService::TYPE_SMALL] = array($width, $height); $storage->copyFile($previewTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_PREVIEW)); list($width, $height) = getimagesize($previewTmp); $dimension[PHOTO_BOL_PhotoService::TYPE_PREVIEW] = array($width, $height); $storage->copyFile($mainTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_MAIN)); list($width, $height) = getimagesize($mainTmp); $dimension[PHOTO_BOL_PhotoService::TYPE_MAIN] = array($width, $height); $storage->copyFile($originalTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_ORIGINAL)); list($width, $height) = getimagesize($originalTmp); $dimension[PHOTO_BOL_PhotoService::TYPE_ORIGINAL] = array($width, $height); if ($tmp->hasFullsize && (bool) OW::getConfig()->getValue('photo', 'store_fullsize')) { $storage->copyFile($fullscreenTmp, $photoService->getPhotoPath($photo->id, $photo->hash, PHOTO_BOL_PhotoService::TYPE_FULLSCREEN)); list($width, $height) = getimagesize($fullscreenTmp); $dimension[PHOTO_BOL_PhotoService::TYPE_FULLSCREEN] = array($width, $height); } } $photo->setDimension(json_encode($dimension)); PHOTO_BOL_PhotoDao::getInstance()->save($photo); if (mb_strlen($desc)) { BOL_TagService::getInstance()->updateEntityTags($photo->id, 'photo', $photoService->descToHashtag($desc)); } if (mb_strlen($tag)) { BOL_TagService::getInstance()->updateEntityTags($photo->id, 'photo', explode(',', $tag)); } OW::getEventManager()->trigger(new OW_Event('photo.onMoveTemporaryPhoto', array('tmpId' => $tmpId, 'albumId' => $albumId, 'photoId' => $photo->id))); } catch (Exception $e) { $photo = NULL; } return $photo; }
/** * Updates video clip * * @return boolean */ public function process() { $values = $this->getValues(); $clipService = VIDEO_BOL_ClipService::getInstance(); if ($values['id']) { $clip = $clipService->findClipById($values['id']); if ($clip) { $clip->title = htmlspecialchars($values['title']); $description = UTIL_HtmlTag::stripJs($values['description']); $description = UTIL_HtmlTag::stripTags($description, array('frame', 'style'), array(), true); $clip->description = $description; if ($clip->code != $values['code']) { $prov = new VideoProviders($values['code']); $clip->provider = $prov->detectProvider(); $thumbUrl = $prov->getProviderThumbUrl($clip->provider); if ($thumbUrl != VideoProviders::PROVIDER_UNDEFINED) { $clip->thumbUrl = $thumbUrl; } $clip->thumbCheckStamp = time(); } $clip->code = UTIL_HtmlTag::stripJs($values['code']); if ($clipService->updateClip($clip)) { BOL_TagService::getInstance()->updateEntityTags($clip->id, 'video', $values['tags']); return array('result' => true, 'id' => $clip->id); } } } else { return array('result' => false, 'id' => null); } return false; }
/** * Updates vwvc clip * * @return boolean */ public function process() { $values = $this->getValues(); $clipService = VWVC_BOL_ClipService::getInstance(); $language = OW::getLanguage(); if ($values['id']) { $clip = $clipService->findClipById($values['id']); if ($clip) { $clip->title = htmlspecialchars($values['room_name']); $clip->description = htmlspecialchars($values['description']); $clip->welcome = htmlspecialchars($values['welcome']); $cam = $values['resolution']; $camArr = explode("x", $cam); $clip->camWidth = $camArr[0]; $clip->camHeight = $camArr[1]; $clip->camFPS = $values['camera_fps']; $clip->micRate = $values['microphone_rate']; $clip->soundQuality = $values['soundQuality']; $clip->camBandwidth = $values['bandwidth']; $clip->background_url = $values['background_url']; $clip->layoutCode = htmlspecialchars($values['layout_code']); $permission = $values['fill_window'] . "|"; $permission .= $values['show_camera_settings'] . "|"; $permission .= $values['advanced_camera_settings'] . "|"; $permission .= $values['configure_source'] . "|"; $permission .= $values['disable_video'] . "|"; $permission .= $values['disable_sound'] . "|"; $permission .= $values['panel_rooms'] . "|"; $permission .= $values['panel_users'] . "|"; $permission .= $values['panel_files'] . "|"; $permission .= $values['file_upload'] . "|"; $permission .= $values['file_delete'] . "|"; $permission .= $values['tutorial'] . "|"; $permission .= $values['auto_view_cameras'] . "|"; $permission .= $values['show_timer'] . "|"; $permission .= $values['write_text'] . "|"; $permission .= $values['regular_watch'] . "|"; $permission .= $values['new_watch'] . "|"; $permission .= $values['private_textchat'] . "|"; $permission .= $values['administrator'] . "|"; $permission .= $values['verbose_level'] . "|"; $clip->permission = $permission; $clip->floodProtection = $values['flood_protection']; $clip->filterRegex = $values['filter_regex']; $clip->filterReplace = $values['filter_replace']; $clip->user_list = $values['user_list']; $clip->moderator_list = $values['moderator_list']; $clip->modifDatetime = time(); $description = UTIL_HtmlTag::stripJs($values['description']); $description = UTIL_HtmlTag::stripTags($description, array('frame', 'style'), array(), true); $clip->description = $description; if ($clipService->updateClip($clip)) { BOL_TagService::getInstance()->updateEntityTags($clip->id, 'vwvc', TagsField::getTags($values['tags'])); return array('result' => true, 'id' => $clip->id); } } } else { return array('result' => false, 'id' => $clip->id); } return false; }
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 }
public function cleanupPluginContent() { BOL_CommentService::getInstance()->deleteEntityTypeComments('ivideo-comments'); BOL_RateService::getInstance()->deleteEntityTypeRates('ivideo-rates'); BOL_TagService::getInstance()->deleteEntityTypeTags('ivideo-video'); BOL_FlagService::getInstance()->deleteByType('ivideo_video'); }
/** * Deletes photo * * @param int $id * @return int */ public function deletePhoto($id) { /** @var $photo PHOTO_BOL_Photo */ if (!$id || !($photo = $this->photoDao->findById($id))) { return false; } $event = new OW_Event(PHOTO_CLASS_EventHandler::EVENT_BEFORE_PHOTO_DELETE, array('id' => $id)); OW::getEventManager()->trigger($event); if ($this->photoDao->deleteById($id)) { BOL_CommentService::getInstance()->deleteEntityComments('photo_comments', $id); BOL_RateService::getInstance()->deleteEntityRates($id, 'photo_rates'); BOL_TagService::getInstance()->deleteEntityTags($id, 'photo'); // remove files $this->photoDao->removePhotoFile($id, $photo->hash, 'main'); $this->photoDao->removePhotoFile($id, $photo->hash, 'preview'); $this->photoDao->removePhotoFile($id, $photo->hash, 'original'); $this->photoFeaturedDao->markUnfeatured($id); BOL_FlagService::getInstance()->deleteByTypeAndEntityId('photo', $id); OW::getEventManager()->trigger(new OW_Event('feed.delete_item', array('entityType' => 'photo_comments', 'entityId' => $id))); $this->cleanListCache(); $event = new OW_Event(PHOTO_CLASS_EventHandler::EVENT_ON_PHOTO_DELETE, array('id' => $id)); OW::getEventManager()->trigger($event); return true; } return false; }
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); }
public function onUpdateInfo(OW_Event $event) { $params = $event->getParams(); $data = $event->getData(); if ($params["entityType"] != self::ENTITY_TYPE) { return; } foreach ($data as $postId => $info) { $status = $info["status"] == BOL_ContentService::STATUS_APPROVAL ? PostService::POST_STATUS_APPROVAL : PostService::POST_STATUS_PUBLISHED; $entityDto = $this->service->findById($postId); $entityDto->isDraft = $status; $this->service->save($entityDto); // Set tags status $tagActive = $info["status"] == BOL_ContentService::STATUS_APPROVAL ? false : true; BOL_TagService::getInstance()->setEntityStatus(self::ENTITY_TYPE, $postId, $tagActive); } }
public function cleanupPluginContent() { BOL_CommentService::getInstance()->deleteEntityTypeComments('vwvr_comments'); BOL_RateService::getInstance()->deleteEntityTypeRates('vwvr_rates'); BOL_TagService::getInstance()->deleteEntityTypeTags('vwvr'); BOL_FlagService::getInstance()->deleteByType('vwvr_clip'); }
/** * Adds video clip * * @return boolean */ public function process() { $values = $this->getValues(); $clipService = VIDEO_BOL_ClipService::getInstance(); $clip = new VIDEO_BOL_Clip(); $clip->title = htmlspecialchars($values['title']); $description = UTIL_HtmlTag::stripJs($values['description']); $description = UTIL_HtmlTag::stripTags($description, array('frame', 'style'), array(), true); $clip->description = $description; $clip->userId = OW::getUser()->getId(); $clip->code = UTIL_HtmlTag::stripJs($values['code']); $prov = new VideoProviders($clip->code); $privacy = OW::getEventManager()->call('plugin.privacy.get_privacy', array('ownerId' => $clip->userId, 'action' => 'video_view_video')); $clip->provider = $prov->detectProvider(); $clip->addDatetime = time(); $clip->status = 'approved'; $clip->privacy = mb_strlen($privacy) ? $privacy : 'everybody'; $thumbUrl = $prov->getProviderThumbUrl($clip->provider); if ($thumbUrl != VideoProviders::PROVIDER_UNDEFINED) { $clip->thumbUrl = $thumbUrl; } $clip->thumbCheckStamp = time(); $eventParams = array('pluginKey' => 'video', 'action' => 'add_video'); if (OW::getEventManager()->call('usercredits.check_balance', $eventParams) === true) { OW::getEventManager()->call('usercredits.track_action', $eventParams); } if ($clipService->addClip($clip)) { BOL_TagService::getInstance()->updateEntityTags($clip->id, 'video', $values['tags']); // Newsfeed $event = new OW_Event('feed.action', array('pluginKey' => 'video', 'entityType' => 'video_comments', 'entityId' => $clip->id, 'userId' => $clip->userId)); OW::getEventManager()->trigger($event); return array('result' => true, 'id' => $clip->id); } return false; }
* ============================================================================= * Copyright (c) 2012 by Aron. All rights reserved. * ============================================================================= * Redistribution and use in source and binary forms, with or without modification, are not permitted provided. * Pass on to others in any form are not permitted provided. * Sale are not permitted provided. * Sale this product are not permitted provided. * Gift this product are not permitted provided. * This plugin should be bought from the developer by paying money to PayPal account: biuro@grafnet.pl * Legal purchase is possible only on the web page URL: http://www.oxwall.org/store * Modyfing of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Modifying source code, all information like:copyright must remain. * Official website only: http://oxwall.a6.pl * Full license available at: http://oxwall.a6.pl * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***/ //---widgates: BOL_FlagService::getInstance()->deleteByType('startpage'); BOL_TagService::getInstance()->deleteEntityTypeTags('startpage');
private function getData($first, $count) { $service = LinkService::getInstance(); $list = array(); $itemCount = 0; $case = $this->getCase(); switch ($case) { case 'most-discussed': $commentService = BOL_CommentService::getInstance(); $info = array(); $info = $commentService->findMostCommentedEntityList('link', $first, $count); $idList = array(); foreach ($info as $item) { $idList[] = $item['id']; } if (empty($idList)) { break; } $dtoList = $service->findListByIdList($idList); foreach ($dtoList as $dto) { $list[] = array('dto' => $dto, 'commentCount' => $info[$dto->id]['commentCount']); } function sortMostCommented($e, $e2) { return $e['commentCount'] < $e2['commentCount']; } usort($list, 'sortMostCommented'); $itemsCount = $commentService->findCommentedEntityCount('link'); OW::getDocument()->setTitle(OW::getLanguage()->text('links', 'most_discussed_title')); OW::getDocument()->setDescription(OW::getLanguage()->text('links', 'most_discussed_description')); break; case 'top-rated': $info = array(); $info = BOL_VoteService::getInstance()->findMostVotedEntityList('link', $first, $count); $idList = array(); foreach ($info as $item) { $idList[] = $item['id']; } if (empty($idList)) { break; } $dtoList = $service->findListByIdList($idList); foreach ($dtoList as $dto) { $list[] = array('dto' => $dto, 'sum' => $info[$dto->id]['sum']); } function sortTopRated($e, $e2) { return $e['sum'] < $e2['sum']; } usort($list, 'sortTopRated'); $itemCount = BOL_VoteService::getInstance()->findMostVotedEntityCount('link'); OW::getDocument()->setTitle(OW::getLanguage()->text('links', 'top_rated_title')); OW::getDocument()->setDescription(OW::getLanguage()->text('links', 'top_rated_description')); break; case 'browse-by-tag': if (empty($_GET['tag'])) { $mostPopularTagsArray = BOL_TagService::getInstance()->findMostPopularTags('link', 20); $mostPopularTags = ""; foreach ($mostPopularTagsArray as $tag) { $mostPopularTags .= $tag['label'] . ", "; } OW::getDocument()->setTitle(OW::getLanguage()->text('links', 'browse_by_tag_title')); OW::getDocument()->setDescription(OW::getLanguage()->text('links', 'browse_by_tag_description', array('tags' => $mostPopularTags))); break; } $info = BOL_TagService::getInstance()->findEntityListByTag('link', UTIL_HtmlTag::stripTags($_GET['tag']), $first, $count); $itemCount = BOL_TagService::getInstance()->findEntityCountByTag('link', UTIL_HtmlTag::stripTags($_GET['tag'])); foreach ($info as $item) { $idList[] = $item; } if (empty($idList)) { break; } $dtoList = $service->findListByIdList($idList); foreach ($dtoList as $dto) { $dto->setUrl(strip_tags($dto->getUrl())); $dto->setTitle(strip_tags($dto->getTitle())); $dto->setDescription(BASE_CMP_TextFormatter::fromBBtoHtml($dto->getDescription())); $list[] = array('dto' => $dto); } OW::getDocument()->setTitle(OW::getLanguage()->text('links', 'browse_by_tag_item_title', array('tag' => htmlspecialchars(UTIL_HtmlTag::stripTags($_GET['tag']))))); OW::getDocument()->setDescription(OW::getLanguage()->text('links', 'browse_by_tag_item_description', array('tag' => htmlspecialchars(UTIL_HtmlTag::stripTags($_GET['tag']))))); break; case false !== strstr($_SERVER['REQUEST_URI'], 'latest'): default: $dtoList = $service->findList($first, $count); $itemCount = $service->countLinks(); foreach ($dtoList as $dto) { $list[] = array('dto' => $dto); } OW::getDocument()->setTitle(OW::getLanguage()->text('links', 'latest_title')); OW::getDocument()->setDescription(OW::getLanguage()->text('links', 'latest_description')); break; } return array($list, $itemCount); }
public function moveTemporaryPhoto($tmpId, $albumId, $desc, $tag) { $photoService = PHOTO_BOL_PhotoService::getInstance(); /** @var $tmp PHOTO_BOL_PhotoTemporary */ $tmp = $this->photoTemporaryDao->findById($tmpId); if (!$tmp) { return false; } $album = PHOTO_BOL_PhotoAlbumService::getInstance()->findAlbumById($albumId); $privacy = OW::getEventManager()->call('plugin.privacy.get_privacy', array('ownerId' => $album->userId, 'action' => 'photo_view_album')); $photo = new PHOTO_BOL_Photo(); $photo->description = htmlspecialchars($desc); $photo->albumId = $albumId; $photo->addDatetime = time(); $photo->status = 'approved'; $photo->hasFullsize = $tmp->hasFullsize; $photo->privacy = mb_strlen($privacy) ? $privacy : 'everybody'; $photo->hash = uniqid(); $photo->uploadKey = $photoService->getPhotoUploadKey($albumId); if ($photoService->addPhoto($photo)) { $storage = OW::getStorage(); $main = $photoService->getPhotoPath($photo->id, $photo->hash); $mainTmp = $this->photoTemporaryDao->getTemporaryPhotoPath($tmp->id, 2); $storage->copyFile($mainTmp, $main); @unlink($mainTmp); $preview = $photoService->getPhotoPath($photo->id, $photo->hash, 'preview'); $previewTmp = $this->photoTemporaryDao->getTemporaryPhotoPath($tmp->id, 1); $storage->copyFile($previewTmp, $preview); @unlink($previewTmp); if ($photo->hasFullsize) { $original = $photoService->getPhotoPath($photo->id, $photo->hash, 'original'); $originalTmp = $this->photoTemporaryDao->getTemporaryPhotoPath($tmp->id, 3); $storage->copyFile($originalTmp, $original); @unlink($originalTmp); } $this->photoTemporaryDao->deleteById($tmp->id); if (mb_strlen($tag)) { BOL_TagService::getInstance()->updateEntityTags($photo->id, 'photo', explode(',', $tag)); } return $photo; } return false; }
<?php /** * This software is intended for use with Oxwall Free Community Software http://www.oxwall.org/ and is * licensed under The BSD license. * --- * Copyright (c) 2011, Oxwall Foundation * All rights reserved. * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the * following conditions are met: * * - Redistributions of source code must retain the above copyright notice, this list of conditions and * the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and * the following disclaimer in the documentation and/or other materials provided with the distribution. * * - Neither the name of the Oxwall Foundation nor the names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ BOL_FlagService::getInstance()->deleteByType('link'); BOL_TagService::getInstance()->deleteEntityTypeTags('link');
public function deletePost($postId) { BOL_CommentService::getInstance()->deleteEntityComments('blog-post', $postId); BOL_RateService::getInstance()->deleteEntityRates($postId, 'blog-post'); BOL_TagService::getInstance()->deleteEntityTags($postId, 'blog-post'); BOL_FlagService::getInstance()->deleteByTypeAndEntityId(BLOGS_CLASS_ContentProvider::ENTITY_TYPE, $postId); OW::getCacheManager()->clean(array(PostDao::CACHE_TAG_POST_COUNT)); OW::getEventManager()->trigger(new OW_Event('feed.delete_item', array('entityType' => 'blog-post', 'entityId' => $postId))); $this->dao->deleteById($postId); }
public function process($ctrl) { OW::getCacheManager()->clean(array(PostDao::CACHE_TAG_POST_COUNT)); $service = PostService::getInstance(); /* @var $postDao PostService */ $data = $this->getValues(); $data['title'] = UTIL_HtmlTag::stripJs($data['title']); $postIsNotPublished = $this->post->getStatus() == 2; $text = UTIL_HtmlTag::sanitize($data['post']); /* @var $post Post */ $this->post->setTitle($data['title']); $this->post->setPost($text); $this->post->setIsDraft($_POST['command'] == 'draft'); $isCreate = empty($this->post->id); if ($isCreate) { $this->post->setTimestamp(time()); //Required to make #698 and #822 work together if ($_POST['command'] == 'draft') { $this->post->setIsDraft(2); } BOL_AuthorizationService::getInstance()->trackAction('blogs', 'add_blog'); } else { //If post is not new and saved as draft, remove their item from newsfeed if ($_POST['command'] == 'draft') { OW::getEventManager()->trigger(new OW_Event('feed.delete_item', array('entityType' => 'blog-post', 'entityId' => $this->post->id))); } else { if ($postIsNotPublished) { // Update timestamp if post was published for the first time $this->post->setTimestamp(time()); } } } $service->save($this->post); $tags = array(); if (intval($this->post->getId()) > 0) { $tags = $data['tf']; foreach ($tags as $id => $tag) { $tags[$id] = UTIL_HtmlTag::stripTags($tag); } } $tagService = BOL_TagService::getInstance(); $tagService->updateEntityTags($this->post->getId(), 'blog-post', $tags); if ($this->post->isDraft()) { $tagService->setEntityStatus('blog-post', $this->post->getId(), false); if ($isCreate) { OW::getFeedback()->info(OW::getLanguage()->text('blogs', 'create_draft_success_msg')); } else { OW::getFeedback()->info(OW::getLanguage()->text('blogs', 'edit_draft_success_msg')); } } else { $tagService->setEntityStatus('blog-post', $this->post->getId(), true); //Newsfeed $event = new OW_Event('feed.action', array('pluginKey' => 'blogs', 'entityType' => 'blog-post', 'entityId' => $this->post->getId(), 'userId' => $this->post->getAuthorId())); OW::getEventManager()->trigger($event); if ($isCreate) { OW::getFeedback()->info(OW::getLanguage()->text('blogs', 'create_success_msg')); OW::getEventManager()->trigger(new OW_Event(PostService::EVENT_AFTER_ADD, array('postId' => $this->post->getId()))); } else { OW::getFeedback()->info(OW::getLanguage()->text('blogs', 'edit_success_msg')); OW::getEventManager()->trigger(new OW_Event(PostService::EVENT_AFTER_EDIT, array('postId' => $this->post->getId()))); } $ctrl->redirect(OW::getRouter()->urlForRoute('post', array('id' => $this->post->getId()))); } }
public function deleteExpiredClip() { $config = OW::getConfig(); $availability = $config->getValue('vwls', 'availability'); if ($availability != 0) { // get all clips $example = new OW_Example(); $example->andFieldEqual('status', 'approved'); $example->andFieldEqual('privacy', 'everybody'); $example->setOrder('`addDatetime` DESC'); $clips = $this->findListByExample($example); // if modifDatetime > $avTime, delete clip $avTime = $availability * 86400; // second $expTime = time() - $avTime; foreach ($clips as $clip) { if ($clip->modifDatetime < $expTime) { $id = $clip->id; $this->deleteById($id); BOL_CommentService::getInstance()->deleteEntityComments('vwls_comments', $id); BOL_RateService::getInstance()->deleteEntityRates($id, 'vwls_rates'); BOL_TagService::getInstance()->deleteEntityTags($id, 'vwls'); BOL_FlagService::getInstance()->deleteByTypeAndEntityId('vwls_clip', $id); OW::getEventManager()->trigger(new OW_Event('feed.delete_item', array('entityType' => 'vwls_comments', 'entityId' => $id))); } } } }
/** * Updates vwls clip * * @return boolean */ public function process() { $values = $this->getValues(); $clipService = VWLS_BOL_ClipService::getInstance(); $language = OW::getLanguage(); if ($values['id']) { $clip = $clipService->findClipById($values['id']); if ($clip) { $clip->title = htmlspecialchars($values['room_name']); $clip->roomLimit = $values['room_limit']; $clip->user_list = $values['user_list']; $clip->moderator_list = $values['moderator_list']; $clip->welcome = htmlspecialchars($values['welcome']); $cam = $values['resolution']; $camArr = explode("x", $cam); $clip->camWidth = $camArr[0]; $clip->camHeight = $camArr[1]; $clip->camFPS = $values['camera_fps']; $clip->micRate = $values['microphone_rate']; $clip->soundQuality = $values['soundQuality']; $clip->camBandwidth = $values['bandwidth']; $clip->floodProtection = $values['flood_protection']; $clip->labelColor = $values['label_color']; $clip->layoutCode = $values['layout_code']; $clip->welcome2 = htmlspecialchars($values['welcome2']); $clip->offlineMessage = htmlspecialchars($values['offline_message']); $clip->floodProtection2 = $values['flood_protection2']; $clip->layoutCode2 = htmlspecialchars($values['layout_code2']); $clip->filterRegex = $values['filter_regex']; $clip->filterReplace = $values['filter_replace']; $permission = $values['show_camera_settings'] . "|"; $permission .= $values['advanced_camera_settings'] . "|"; $permission .= $values['configure_source'] . "|"; $permission .= $values['only_video'] . "|"; $permission .= $values['no_video'] . "|"; $permission .= $values['no_embeds'] . "|"; $permission .= $values['show_timer'] . "|"; $permission .= $values['write_text'] . "|"; $permission .= $values['private_textchat'] . "|"; $permission .= $values['fill_window'] . "|"; $permission .= $values['write_text2'] . "|"; $permission .= $values['enable_video'] . "|"; $permission .= $values['enable_chat'] . "|"; $permission .= $values['enable_users'] . "|"; $permission .= $values['fill_window2'] . "|"; $permission .= $values['verbose_level'] . "|"; $clip->permission = $permission; $clip->online = "no"; $clip->onlineCount = 0; $clip->onlineUser = "******"; $clip->onlineUsers = "0"; $description = UTIL_HtmlTag::stripJs($values['description']); $description = UTIL_HtmlTag::stripTags($description, array('frame', 'style'), array(), true); $clip->description = $description; $clip->modifDatetime = time(); if ($clipService->updateClip($clip)) { BOL_TagService::getInstance()->updateEntityTags($clip->id, 'vwls', TagsField::getTags($values['tags'])); return array('result' => true, 'id' => $clip->id); } } } else { return array('result' => false, 'id' => $clip->id); } return false; }
public function ajaxUpdatePhoto() { if (!OW::getRequest()->isAjax()) { exit; } $photoId = $_POST['photoId']; if ($this->photoService->findPhotoOwner($photoId) != OW::getUser()->getId() && !OW::getUser()->isAuthorized('photo', 'upload')) { exit(json_encode(array('result' => FALSE, 'msg' => OW::getLanguage()->text('photo', 'auth_edit_permissions')))); } $form = new PHOTO_CLASS_EditForm($photoId); if ($form->isValid($_POST)) { $values = $form->getValues(); $userId = OW::getUser()->getId(); $photo = $this->photoService->findPhotoById($values['photoId']); $album = $this->photoAlbumService->findAlbumById($photo->albumId); $isNewAlbum = FALSE; if (($albumName = htmlspecialchars(trim($values['album-name']))) != $album->name) { if (($album = $this->photoAlbumService->findAlbumByName($albumName, $userId)) === NULL) { $album = new PHOTO_BOL_PhotoAlbum(); $album->name = $albumName; $album->userId = $userId; $album->entityId = $userId; $album->entityType = 'user'; $album->createDatetime = time(); $album->description = !empty($values['description']) ? htmlspecialchars(trim($values['description'])) : ''; $this->photoAlbumService->addAlbum($album); $isNewAlbum = TRUE; } } if ($photo->albumId != $album->id) { OW::getEventManager()->trigger(new OW_Event(PHOTO_CLASS_EventHandler::EVENT_BEFORE_PHOTO_MOVE, array('fromAlbum' => $photo->albumId, 'toAlbum' => $album->id, 'photoIdList' => array($photo->id)))); if ($this->photoService->movePhotosToAlbum(array($photo->id), $album->id, $isNewAlbum)) { OW::getEventManager()->trigger(new OW_Event(PHOTO_CLASS_EventHandler::EVENT_AFTER_PHOTO_MOVE, array('fromAlbum' => $photo->albumId, 'toAlbum' => $album->id, 'photoIdList' => array($photo->id)))); } } $photo->albumId = $album->id; $photo->description = htmlspecialchars(trim($values['photo-desc'])); if ($this->photoService->updatePhoto($photo)) { BOL_EntityTagDao::getInstance()->deleteItemsForEntityItem($photo->id, 'photo'); BOL_TagService::getInstance()->updateEntityTags($photo->id, 'photo', $this->photoService->descToHashtag($photo->description)); PHOTO_BOL_SearchService::getInstance()->deleteSearchItem(PHOTO_BOL_SearchService::ENTITY_TYPE_PHOTO, $photo->id); PHOTO_BOL_SearchService::getInstance()->addSearchIndex(PHOTO_BOL_SearchService::ENTITY_TYPE_PHOTO, $photo->id, $photo->description); $newPhoto = $this->photoService->findPhotoById($photo->id); exit(json_encode(array('result' => true, 'id' => $photo->id, 'description' => $photo->description, 'albumName' => $album->name, 'albumUrl' => OW::getRouter()->urlForRoute('photo_user_album', array('user' => OW::getUser()->getUserObject()->getUsername(), 'album' => $album->id)), 'msg' => OW::getLanguage()->text('photo', 'photo_updated'), 'msgApproval' => OW::getLanguage()->text('photo', 'photo_uploaded_pending_approval'), 'photo' => get_object_vars($newPhoto)))); } } else { $result = array('result' => FALSE); $errors = array_filter($form->getErrors(), 'count'); if (!empty($errors[key($errors)][0])) { $result['msg'] = $errors[key($errors)][0]; } exit(json_encode($result)); } }
public function delete(Post $dto) { BOL_CommentService::getInstance()->deleteEntityComments('blog-post', $dto->getId()); BOL_RateService::getInstance()->deleteEntityRates($dto->getId(), 'blog-post'); BOL_TagService::getInstance()->deleteEntityTags($dto->getId(), 'blog-post'); BOL_FlagService::getInstance()->deleteByTypeAndEntityId('blog_post', $dto->getId()); OW::getCacheManager()->clean(array(PostDao::CACHE_TAG_POST_COUNT)); OW::getEventManager()->trigger(new OW_Event('feed.delete_item', array('entityType' => 'blog-post', 'entityId' => $dto->getId()))); $this->dao->delete($dto); }
public function addClip($clipInfo) { $clip = new VIDEO_BOL_Clip(); $clip->title = htmlspecialchars($clipInfo["title"]); $description = UTIL_HtmlTag::stripJs($clipInfo["desc"]); $description = UTIL_HtmlTag::stripTags($description, array('frame', 'style'), array(), true); $description = nl2br($description, true); $clip->description = $description; $clip->userId = OW::getUser()->getId(); $clip->thumbUrl = preg_replace("#(http://|https://)#i", "//", $clipInfo["thumbnail"]); $clip->code = UTIL_HtmlTag::stripJs($clipInfo["code"]); $prov = new VideoProviders($clip->code); $privacy = OW::getEventManager()->call('plugin.privacy.get_privacy', array('ownerId' => $clip->userId, 'action' => 'video_view_video')); $clip->provider = $prov->detectProvider(); $clip->addDatetime = time(); $clip->status = 'approved'; $clip->privacy = mb_strlen($privacy) ? $privacy : 'everybody'; $eventParams = array('pluginKey' => 'video', 'action' => 'add_video'); if (OW::getEventManager()->call('usercredits.check_balance', $eventParams) === true) { OW::getEventManager()->call('usercredits.track_action', $eventParams); } if ($this->clipService->addClip($clip)) { if (isset($clipInfo['tags'])) { BOL_TagService::getInstance()->updateEntityTags($clip->id, 'video', explode(',', $clipInfo['tags'])); } // Newsfeed $event = new OW_Event('feed.action', array('pluginKey' => 'video', 'entityType' => 'video_comments', 'entityId' => $clip->id, 'userId' => $clip->userId)); OW::getEventManager()->trigger($event); return $clip->id; } return false; }