Example #1
0
	/**
	 * Accessor:
	 * Returns a field in specified format
	 *
	 * @param  FieldTable  $field
	 * @param  UserTable   $user
	 * @param  string      $output               'html', 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist', 'htmledit'
	 * @param  string      $reason               'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'search' for searches
	 * @param  int         $list_compare_types   IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search
	 * @return mixed
	 */
	public function getField( &$field, &$user, $output, $reason, $list_compare_types )
	{
		$return			=	null;

		if ( $field->get( 'type' ) == 'comments' ) {
			$comments	=	new Comments( 'field', $user, (int) $field->params->get( 'field_comments_direction', 0 ) );

			$comments->set( 'type', 'field' );
			$comments->set( 'item', (int) $field->get( 'fieldid' ) );
			$comments->set( 'parent', (int) $user->get( 'id' ) );

			CBActivity::loadStreamDefaults( $comments, $field->params, 'field_comments_' );

			$return		=	$comments->stream( false );
		} else {
			$activity	=	new Activity( 'field', $user, (int) $field->params->get( 'field_activity_direction', 0 ) );

			$activity->set( 'type', 'field' );
			$activity->set( 'subtype', 'status' );
			$activity->set( 'item', (int) $field->get( 'fieldid' ) );
			$activity->set( 'parent', (int) $user->get( 'id' ) );

			CBActivity::loadStreamDefaults( $activity, $field->params, 'field_activity_' );

			$return		=	$activity->stream( false );
		}

		if ( ! ( ( $output == 'html' ) && ( $reason == 'profile' ) ) ) {
			return null;
		}

		return $this->formatFieldValueLayout( $this->_formatFieldOutput( $field->get( 'name' ), $return, $output, false ), $reason, $field, $user );
	}
Example #2
0
	/**
	 * @param ActivityTable   $row
	 * @param Activity        $stream
	 * @param int             $output 0: Normal, 1: Raw, 2: Inline, 3: Load, 4: Save
	 * @param UserTable       $user
	 * @param UserTable       $viewer
	 * @param cbPluginHandler $plugin
	 * @return null|string
	 */
	static public function showAttachments( $row, $stream, $output, $user, $viewer, $plugin )
	{
		global $_PLUGINS;

		if ( ! $stream->get( 'links', 1 ) ) {
			return null;
		}

		$links					=	$row->attachments();

		$_PLUGINS->trigger( 'activity_onDisplayActivityAttachments', array( &$row, &$links, $stream, $output ) );

		if ( ! $links ) {
			return null;
		}

		$cbModerator			=	CBActivity::isModerator( (int) $viewer->get( 'id' ) );

		$isStatus				=	( ( $row->get( 'type' ) == 'status' ) || ( $row->get( 'subtype' ) == 'status' ) );
		$rowOwner				=	( $viewer->get( 'id' ) == $row->get( 'user_id' ) );

		$count					=	count( $links );

		$return					=	'<div class="streamItemScroll">'
								.		'<div class="streamItemScrollLeft' . ( $count > 1 ? null : ' hidden' ) . '">'
								.			'<table>'
								.				'<tr>'
								.					'<td>'
								.						'<span class="streamItemScrollLeftIcon fa fa-chevron-left"></span>'
								.					'</td>'
								.				'</tr>'
								.			'</table>'
								.		'</div>';

		foreach ( $links as $i => $link ) {
			$hasMedia			=	( ( $link['type'] == 'custom' ) || ( ( $link['type'] != 'url' ) && $link['media']['url'] ) || ( ( $link['type'] == 'url' ) && $link['media']['url'] && $link['thumbnail'] ) );

			$return				.=		'<div class="activityContainerAttachment streamItemScrollContent ' . ( $link['type'] == 'url' ? 'streamMedia media' : 'streamPanel panel' ) . ( $i != 0 ? ' hidden' : null ) . '">';

			if ( $hasMedia ) {
				$return			.=			'<div class="activityContainerAttachmentMedia ' . ( $link['type'] == 'url' ? 'streamMediaLeft media-left' : 'streamPanelBody panel-body' ) . ' text-center">';

				switch ( $link['type'] ) {
					case 'custom':
						$return	.=				$link['media']['custom'];
						break;
					case 'video':
						$return	.=				'<video width="640" height="360" style="width: 100%; height: 100%;" src="' . htmlspecialchars( $link['media']['url'] ) . '" type="' . htmlspecialchars( $link['media']['mimetype'] ) . '" class="streamItemVideo" preload="none" controls></video>';
						break;
					case 'audio':
						$return	.=				'<audio width="640" style="width: 100%;" src="' . htmlspecialchars( $link['media']['url'] ) . '" type="' . htmlspecialchars( $link['media']['mimetype'] ) . '" class="streamItemAudio" preload="none" controls></audio>';
						break;
					case 'image':
						$return	.=				'<a href="' . htmlspecialchars( $link['url'] ) . '" rel="nofollow" target="_blank">'
								.					'<img src="' . htmlspecialchars( $link['media']['url'] ) . '" class="img-responsive streamItemImage" />'
								.				'</a>';
						break;
					case 'url':
					default:
						$return	.=				'<a href="' . htmlspecialchars( $link['url'] ) . '" rel="nofollow" target="_blank">'
								.					'<img src="' . htmlspecialchars( $link['media']['url'] ) . '" class="img-responsive streamItemImage" />'
								.				'</a>';
						break;
				}

				$return			.=			'</div>';
			}

			if ( $link['title'] || $link['description'] || ( ( ! $link['internal'] ) && ( ( ! $link['title'] ) || $link['text'] ) ) || ( $count > 1 ) ) {
				$hypertext		=	( $link['text'] ? CBTxt::T( $link['text'] ) : $link['url'] );

				$return			.=			'<div class="streamPanelFooter streamItemDisplay activityContainerAttachmentInfo panel-footer' . ( $link['type'] == 'url' ? ' streamMediaBody media-body' : null ) . '">'
								.				'<div class="cbMoreLess">'
								.					'<div class="cbMoreLessContent">'
								.						( $link['title'] ? '<div><strong><a href="' . htmlspecialchars( $link['url'] ) . '" rel="nofollow" target="_blank">' . ( $isStatus ? htmlspecialchars( CBTxt::T( $link['title'] ) ) : CBTxt::T( $link['title'] ) ) . '</a></strong></div>' : null )
								.						( $isStatus ? htmlspecialchars( CBTxt::T( $link['description'] ) ) : CBTxt::T( $link['description'] ) )
								.					'</div>'
								.					'<div class="activityContainerAttachmentUrl small">'
								.						( ( ! $link['internal'] ) && ( ( ! $link['title'] ) || $link['text'] ) ? '<a href="' . htmlspecialchars( $link['url'] ) . '" rel="nofollow" target="_blank">' . ( $isStatus ? htmlspecialchars( $hypertext ) : $hypertext ) . '</a>' : null )
								.						( $count > 1 ? '<div class="activityContainerAttachmentCount text-muted">' . ( $i + 1 ) . ' - ' . $count . '</div>' : null )
								.					'</div>'
								.					'<div class="cbMoreLessOpen fade-edge hidden">'
								.						'<a href="javascript: void(0);" class="cbMoreLessButton">' . CBTxt::T( 'See More' ) . '</a>'
								.					'</div>'
								.				'</div>'
								.			'</div>';
			}

			if ( $isStatus && ( $cbModerator || $rowOwner ) ) {
				$return			.=			'<div class="streamPanelFooter streamItemEdit activityContainerAttachmentInfo panel-footer' . ( $link['type'] == 'url' ? ' streamMediaBody media-body' : null ) . ' hidden">'
								.				'<input type="text" id="' . $stream->id() . '_links_title_edit_' . (int) $row->get( 'id' ) . '_' . ( $i + 1 ) . '" name="links[' . $i . '][title]" value="' . htmlspecialchars( $link['title'] ) . '" class="streamInput streamInputLinkTitle form-control" placeholder="' . htmlspecialchars( CBTxt::T( 'Title' ) ) . '" />'
								.				'<textarea id="' . $stream->id() . '_links_description_edit_' . (int) $row->get( 'id' ) . '_' . ( $i + 1 ) . '" name="links[' . $i . '][description]" rows="1" class="streamInput streamInputAutosize streamInputLinkDescription form-control" placeholder="' . htmlspecialchars( CBTxt::T( 'Description' ) ) . '">' . htmlspecialchars( $link['description'] ) . '</textarea>';

				if ( $link['type'] == 'url' ) {
					$return		.=				'<div class="streamInput">'
								.					'<label class="checkbox-inline">'
								.						'<input type="checkbox" id="' . $stream->id() . '_links_thumbnail_edit_' . (int) $row->get( 'id' ) . '_' . ( $i + 1 ) . '" name="links[' . $i . '][thumbnail]" value="0"' . ( ! $link['thumbnail'] ? ' checked="checked"' : null ) . '> ' . CBTxt::T( 'Do not display thumbnail' )
								.					'</label>'
								.				'</div>';
				}

				$return			.=			'</div>';
			}

			$return				.=		'</div>';
		}

		$return					.=		'<div class="streamItemScrollRight' . ( $count > 1 ? null : ' hidden' ) . '">'
								.			'<table>'
								.				'<tr>'
								.					'<td>'
								.						'<span class="streamItemScrollRightIcon fa fa-chevron-right"></span>'
								.					'</td>'
								.				'</tr>'
								.			'</table>'
								.		'</div>'
								.	'</div>';

		return $return;
	}
	/**
	 * Hides activity
	 *
	 * @param int       $id
	 * @param Activity  $stream
	 * @param UserTable $user
	 * @param UserTable $viewer
	 * @param bool      $silent
	 */
	private function hideActivity( $id, $stream, $user, $viewer, $silent = false )
	{
		$item		=	new ActivityTable();

		$item->load( (int) $id );

		if ( ( ! $item->get( 'id' ) ) || ( ! $viewer->get( 'id' ) ) || ( $viewer->get( 'id' ) == $item->get( 'user_id' ) ) ) {
			header( 'HTTP/1.0 404 Not Found' );
			exit();
		}

		$row		=	new HiddenTable();

		$row->load( array( 'user_id' => (int) $viewer->get( 'id' ), 'type' => 'activity', 'item' => (int) $item->get( 'id' ) ) );

		if ( $row->get( 'id' ) ) {
			header( 'HTTP/1.0 200 OK' );
			exit();
		}

		$row->set( 'user_id', (int) $viewer->get( 'id' ) );
		$row->set( 'type', 'activity' );
		$row->set( 'item', (int) $item->get( 'id' ) );

		if ( ! $row->check() ) {
			header( 'HTTP/1.0 401 Unauthorized' );
			exit();
		}

		if ( ! $row->store() ) {
			header( 'HTTP/1.0 500 Internal Server Error' );
			exit();
		}

		if ( ! $silent ) {
			$unhide		=	'<a href="' . $stream->endpoint( 'unhide', array( 'id' => (int) $item->get( 'id' ) ) ) . '" class="activityContainerUnhide streamItemAction streamItemNoticeRevert">' . CBTxt::T( 'Unhide' ) . '</a>';

			echo CBTxt::T( 'ACTIVITY_HIDDEN_UNHIDE', 'This activity has been hidden. [unhide]', array( '[unhide]' => $unhide ) );
		}

		header( 'HTTP/1.0 200 OK' );
		exit();
	}