Example #1
0
 public function picture($albumid, $attachmentid, $pagenumber = 1, $perpage = 10, $commentid = 0, $showignored = false)
 {
     $cleaner = vB::getCleaner();
     $pagenumber = $cleaner->clean($pagenumber, vB_Cleaner::TYPE_UINT);
     $perpage = $cleaner->clean($perpage, vB_Cleaner::TYPE_UINT);
     $albumid = $cleaner->clean($albumid, vB_Cleaner::TYPE_UINT);
     $photoid = $cleaner->clean($attachmentid, vB_Cleaner::TYPE_UINT);
     $mediaFilters = array('nodeid' => $albumid);
     $album = vB_Api::instance('profile')->getAlbum($mediaFilters);
     if ($album === null || isset($album['errors'])) {
         return vB_Library::instance('vb4_functions')->getErrorResponse($album);
     }
     $album = $album[$albumid];
     $picturecomment_commentarea = array('messagestats' => array('total' => 0, 'start' => 1, 'end' => 0, 'perpage' => 10));
     $pictureinfo = array();
     /*
     	            [pictureinfo] => Array
                     (
                         [attachmentid] => 74
                         [albumid] => 2
                         [caption_censored] =>
                         [pictureurl] => http://dev-vb3.internetbrands.com/mobile/vb423/attachment.php?s=13eb2009e65d8e94b851981f629eb094&api=1&attachmentid=74&d=1430433269
                         [caption_html] =>
                         [addtime] => 1430433269
                     )
     
                 [pic_location] => Array
                     (
                         [prev_attachmentid] => 76
                         [prev_text] =>
                         [prev_text_short] =>
                         [next_attachmentid] => 73
                         [next_text] =>
                         [next_text_short] =>
                         [pic_position] => 2
                     )
     */
     $userinfo = vB_Api::instance('user')->fetchUserinfo();
     $currentUserid = $userinfo['userid'];
     $picture_owner = false;
     $bbcodeParserInstance = new vB_Library_BbCode(true, true);
     $prev_attachmentid = NULL;
     $next_attachmentid = NULL;
     $picposition = 0;
     foreach ($album['photo'] as $photo) {
         $picposition++;
         if ($photo['nodeid'] != $photoid) {
             $prev_attachmentid = $photo['nodeid'];
             continue;
         }
         if (!empty($pictureinfo)) {
             $next_attachmentid = $photo['nodeid'];
             break;
         }
         $picture_owner = $photo['userid'] == $currentUserid;
         $pictureUrl = $bbcodeParserInstance->getAttachmentLink($photo);
         $pictureinfo = array('attachmentid' => $photo['nodeid'], 'albumid' => $albumid, 'pictureurl' => $pictureUrl, 'caption_censored' => '', 'caption_html' => '', 'addtime' => $photo['publishdate']);
     }
     $pic_location = array('prev_attachmentid' => $prev_attachmentid, 'prev_text' => '', 'prev_text_short' => '', 'next_attachmentid' => $next_attachmentid, 'next_text' => '', 'next_text_short' => '', 'pic_position' => $picposition);
     // https://admin.vbulletin.com/wiki/VB4_API:album_picture
     return array('response' => array('albuminfo' => array('albumid' => $album['nodeid'], 'title' => $album['title'], 'description' => $album['description']), 'userinfo' => array('userid' => $album['userid'], 'username' => $album['authorname']), 'picturecomment_commentarea ' => $picturecomment_commentarea, 'pictureinfo' => $pictureinfo, 'pic_location' => $pic_location), 'show' => array('picture_owner' => $picture_owner, 'edit_album_option' => 0, 'add_group_link' => 0, 'reportlink' => 1, 'moderation' => 0, 'picturecomment_options' => 0));
 }
Example #2
0
 /**
  * Constructor. Sets up the tag list.
  *
  * @param	bool		Whether to append customer user tags to the tag list
  */
 public function __construct($appendCustomTags = true, $appendSessionHashToImage = false)
 {
     if (!self::$initialized) {
         $response = vB_Api::instanceInternal('bbcode')->initInfo();
         self::$defaultTags = $response['defaultTags'];
         self::$customTags = $response['customTags'];
         self::$defaultOptions = $response['defaultOptions'];
         self::$smilies = $response['smilies'];
         self::$censorship = $response['censorship'];
         self::$sessionUrl = $response['sessionUrl'];
         self::$blankAsciiStrip = $response['blankAsciiStrip'];
         self::$wordWrap = $response['wordWrap'];
         self::$bbUrl = $response['bbUrl'];
         self::$viewAttachedImages = $response['viewAttachedImages'];
         self::$urlNoFollow = $response['urlNoFollow'];
         self::$urlNoFollowWhiteList = $response['urlNoFollowWhiteList'];
         self::$vBHttpHost = $response['vBHttpHost'];
         self::$useFileAvatar = $response['useFileAvatar'];
         self::$sigpicUrl = $response['sigpicUrl'];
         $options = vB::getDatastore()->getValue('options');
         self::$baseurl = preg_replace("#/?core/?\$#", '', $options['bburl']);
         self::$baseurl_core = $options['bburl'];
         self::$frontendurl = $options['frontendurl'];
         self::$initialized = true;
     }
     $this->tag_list = self::$defaultTags;
     if ($appendCustomTags) {
         $this->tag_list = vB_Array::arrayReplaceRecursive($this->tag_list, self::$customTags);
     }
     if (!empty($appendSessionHashToImage)) {
         $session = vB::getCurrentSession();
         if (!empty($session)) {
             $sessionHash = $session->get('dbsessionhash');
             if (!empty($sessionHash)) {
                 // This is going to be part of a URL
                 $this->sessionSuffix = '&s=' . urlencode($sessionHash);
             }
         }
     }
     // Legacy Hook 'bbcode_create' Removed //
 }
Example #3
0
 /**
  * Structuring the result data for output
  *
  * @param  [Array]  $result [Array with the search result]
  * @param  [String] $show   [See constant FILTER_SHOW_*. Only when it has value 'photos' it changes the output structure]
  *
  * @return [array]			[Formatted structure for output]
  */
 private function prepareSearchData($result, $show)
 {
     $bbcodeParserInstance = new vB_Library_BbCode(true, true);
     $activitybits = array();
     $result['results'] = vB_Api::instance('node')->mergeNodeviewsForTopics($result['results']);
     foreach ($result['results'] as $node) {
         $activitybit = array();
         if (empty($node['content'])) {
             $conversation = $node;
         } else {
             $conversation = $node['content'];
         }
         $itemSection = $this->getSection($node);
         if (empty($itemSection)) {
             // This might be some weird node under the special channel or some other node
             // that shouldn't have ended up here. Just skip it.
             continue;
         }
         // Socialgroup not handled in the apps
         // TODO: Need to look into this.
         if ($itemSection == 'socialgroup') {
             continue;
         }
         $activityType = $this->getActivityType($itemSection, $node);
         $activitybit['activity'] = array('posttime' => vbdate('h:i A', $conversation['publishdate']), 'postdate' => vbdate('m-d-Y', $conversation['publishdate']), 'section' => $itemSection, 'type' => $activityType, 'score' => 0.0);
         if ($show == self::FILTER_SHOW_PHOTOS) {
             // TODO: TEST THIS
             $activitybit['attachmentinfo'] = array('attachmentid' => -intval($conversation['nodeid']), 'dateline' => $conversation['publishdate'], 'thumbnail_width' => '', 'thumbnail_height' => '');
             if ($itemSection == 'socialgroup') {
                 $activitybit['groupinfo'] = array('albumid' => $conversation['parentid']);
             } else {
                 $activitybit['albuminfo'] = array('albumid' => $conversation['parentid']);
             }
         } else {
             // Section specific info
             switch ($itemSection) {
                 case 'forum':
                     // @TODO: This is inside the special channel and not here, but at this moment the search api doesn't even return vm's.
                     // Need to set up a filter for those or just a flag of ijf we should include or not.
                     if (!empty($node['setfor'])) {
                         $activitybit['messageinfo'] = array('vmid' => $node['nodeid'], 'preview' => $node['preview']);
                         $activitybit['userinfo2'] = array('userid' => $node['setfor'], 'username' => vB_Library::instance('user')->fetchUserName($node['setfor']));
                     } else {
                         $isPost = false;
                         if ($node['nodeid'] == $node['starter']) {
                             $forumInfo = vB_Library::instance('node')->getNodeBare($node['parentid']);
                             $threadInfo = $node;
                             $forumid = (int) $node['parentid'];
                             $threadid = $postid = (int) $node['nodeid'];
                             $threadPreview = $postPreview = $node['content']['rawtext'];
                         } else {
                             $threadInfo = vB_Library::instance('node')->getNode($node['starter']);
                             $forumInfo = vB_Library::instance('node')->getNodeBare($threadInfo['parentid']);
                             $forumid = (int) $forumInfo['nodeid'];
                             $threadid = (int) $threadInfo['nodeid'];
                             $postid = (int) $node['nodeid'];
                             $threadPreview = $threadInfo['content']['rawtext'];
                             $postPreview = $node['content']['rawtext'];
                             $isPost = true;
                         }
                         $activitybit['foruminfo'] = array('forumid' => $forumid, 'title' => vB_String::unHtmlSpecialChars($forumInfo['title']));
                         $activitybit['threadinfo'] = array('title' => vB_String::unHtmlSpecialChars($threadInfo['title']), 'forumid' => $forumid, 'replycount' => $threadInfo['totalcount'], 'views' => isset($threadInfo['content']['views']) ? $threadInfo['content']['views'] : 0, 'preview' => vB_Library::instance('vb4_functions')->getPreview($threadPreview));
                         if ($node['contenttypeid'] == vB_Types::instance()->getContentTypeID('vBForum_Poll')) {
                             $activitybit['threadinfo']['pollid'] = $node['nodeid'];
                         } else {
                             $activitybit['threadinfo']['threadid'] = $threadid;
                         }
                         if ($isPost) {
                             $activitybit['postinfo'] = array('postid' => $postid, 'threadid' => $threadid, 'preview' => vB_Library::instance('vb4_functions')->getPreview($postPreview));
                         }
                         $activitybit['show'] = array('threadcontent' => true);
                     }
                     break;
                 case 'blog':
                     $topChannels = $this->getTopChannels();
                     $blogComment = false;
                     if ($node['parentid'] == $topChannels['blogs']) {
                         // if it is a blog dont include it
                         break;
                     } elseif ($node['nodeid'] == $node['starter']) {
                         // blog entry
                         $blogentryInfo = $node;
                         $blogInfo = vB_Library::instance('node')->getNodeBare($node['parentid']);
                     } else {
                         // blog comment
                         $blogentryInfo = vB_Library::instance('node')->getNode($node['parentid']);
                         $blogInfo = vB_Library::instance('node')->getNodeBare($blogentryInfo['parentid']);
                         $blogComment = true;
                     }
                     $activitybit['bloginfo'] = array('blogid' => $blogentryInfo['nodeid'], 'title' => vB_String::unHtmlSpecialChars($blogentryInfo['title']), 'blog_title' => vB_String::unHtmlSpecialChars($blogInfo['title']), 'comments_visible' => $blogInfo['textcount'], 'views' => isset($blogentryInfo['content']['views']) ? $blogentryInfo['content']['views'] : 0, 'preview' => vB_Library::instance('vb4_functions')->getPreview($blogentryInfo['content']['rawtext']));
                     if ($blogComment) {
                         $activitybit['blogtextinfo'] = array('blogtextid' => $node['nodeid'], 'preview' => vB_Library::instance('vb4_functions')->getPreview($node['content']['rawtext']));
                     }
                     break;
                 case 'socialgroup':
                     $topChannels = $this->getTopChannels();
                     $discussionInfo = false;
                     $messageinfo = false;
                     if ($node['parentid'] == $topChannels['groups']) {
                         // group
                         $groupInfo = $node;
                     } elseif ($node['nodeid'] == $node['starter']) {
                         // group discussion
                         $discussionInfo = $node;
                         $groupInfo = vB_Library::instance('node')->getNodeBare($node['parentid']);
                     } else {
                         // group message
                         $discussionInfo = vB_Library::instance('node')->getNodeBare($node['parentid']);
                         $groupInfo = vB_Library::instance('node')->getNodeBare($discussionInfo['parentid']);
                         $messageInfo = $node;
                     }
                     $activitybit['groupinfo'] = array('groupid' => $groupInfo['nodeid'], 'name' => $groupInfo['title']);
                     if ($discussionInfo) {
                         $activitybit['discussioninfo'] = array('discussionid' => $discussionInfo['nodeid'], 'title' => $discussionInfo['title'], 'preview' => vB_Library::instance('vb4_functions')->getPreview($discussionInfo['content']['rawtext']), 'visible' => 1);
                     }
                     if ($messageInfo) {
                         $activitybit['messageinfo'] = array('gmid' => $messageInfo['nodeid'], 'preview' => vB_Library::instance('vb4_functions')->getPreview($discussionInfo['content']['rawtext']));
                     }
                     break;
                 case 'album':
                     // Only show albums, not individual photos in albums.
                     // For some reason, the search can return individual photos
                     // added later to the album.
                     if (!($node['nodeid'] == $node['starter'])) {
                         $album = vB_Library::instance('node')->getNodeFullContent($node['starter']);
                         if (empty($album[$node['starter']])) {
                             // This shouldn't happen AFAIK. Maybe if there's data corruption/incomplete cleanup?
                             continue 2;
                         }
                         $album = vB_Api::instance('node')->mergeNodeviewsForTopics($album);
                         $album = $album[$node['starter']];
                     } else {
                         $album = $node;
                     }
                     // There are some serious inconsistencies between getNodeFullContent() and
                     // returned node array from search results...
                     if (!isset($album['photo']) and isset($album['content']['photo'])) {
                         $album['photo'] = $album['content']['photo'];
                     }
                     if (!isset($album['photopreview']) and isset($album['content']['photopreview'])) {
                         $album['photopreview'] = $album['content']['photopreview'];
                     }
                     if (!isset($album['photocount']) and isset($album['content']['photocount'])) {
                         $album['photocount'] = $album['content']['photocount'];
                     }
                     // Use actual thumbnail size if thumbnail is found.
                     // TODO: include this as part of the regular 'photo' array info?
                     $filedataids = array();
                     foreach ($album['photopreview'] as $key => $photo) {
                         $filedataids[$photo['filedataid']] = $photo['filedataid'];
                     }
                     $thumbInfoQuery = vB::getDbAssertor()->getRows('vBForum:filedataresize', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, vB_dB_Query::COLUMNS_KEY => array('filedataid', 'resize_width', 'resize_height'), vB_dB_Query::CONDITIONS_KEY => array('resize_type' => vB_Api_Filedata::SIZE_THUMB, 'filedataid' => $filedataids)));
                     $thumbInfo = array();
                     foreach ($thumbInfoQuery as $row) {
                         $thumbInfo[$row['filedataid']] = $row;
                     }
                     /*
                     	Since this is an "album", let's just ignore any attachments that
                     	the user might've added to the post. Especially since clicking on
                     	an album doesn't show the post, just the photos in the gallery.
                     	vB4 didn't have a "gallery", so it didn't have this issue.
                     */
                     $activitybit['albuminfo'] = array('albumid' => $album['nodeid'], 'title' => $album['title'], 'picturecount' => $album['photocount'], 'views' => isset($album['content']['views']) ? $album['content']['views'] : 0);
                     $activitybit['photocount'] = $album['photocount'];
                     $activitybit['attach'] = array();
                     // Let's just use the photo preview for this view. It never shows more than 3 photos anyways.
                     foreach ($album['photopreview'] as $photo) {
                         $thumburl = $bbcodeParserInstance->getAttachmentLink($photo, vB_Api_Filedata::SIZE_THUMB);
                         $filedataid = $photo['filedataid'];
                         if (isset($thumbInfo[$filedataid])) {
                             $thumbwidth = $thumbInfo[$filedataid]['resize_width'];
                             $thumbheight = $thumbInfo[$filedataid]['resize_height'];
                         } else {
                             $thumbwidth = $photo['width'];
                             $thumbheight = $photo['height'];
                         }
                         $activitybit['attach'][] = array('attachmentid' => -intval($photo['nodeid']), 'thumburl' => $thumburl, 'dateline' => $photo['dateline'], 'thumbnail_width' => $thumbwidth, 'thumbnail_height' => $thumbheight);
                     }
                     break;
                 default:
                     break;
             }
         }
         $userInfo = vB_Library::instance('user')->fetchUserinfo($node['userid'], array('avatar'));
         $activitybit['userinfo'] = array('userid' => $userInfo['userid'], 'username' => $userInfo['username'], 'avatarurl' => vB_Library::instance('vb4_functions')->avatarUrl($userInfo['userid']), 'showavatar' => $userInfo['showavatars']);
         $activitybits[] = $activitybit;
     }
     return $activitybits;
 }