/** * @param CommentTable $row * @param Comments $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 showEdit( $row, $stream, $output, $user, $viewer, $plugin ) { global $_PLUGINS; $cbModerator = CBActivity::isModerator( (int) $viewer->get( 'id' ) ); $messageLimit = ( $cbModerator ? 0 : (int) $stream->get( 'message_limit', 400 ) ); $rowId = $stream->id() . '_edit_' . (int) $row->get( 'id' ); $editBody = null; $editFooter = null; $_PLUGINS->trigger( 'activity_onDisplayCommentEdit', array( &$row, &$editBody, &$editFooter, $stream, $output ) ); $return = '<div class="streamMediaBody streamItemEdit commentContainerContentEdit media-body text-small hidden">' . '<form action="' . $stream->endpoint( 'save', array( 'id' => (int) $row->get( 'id' ) ) ) . '" method="post" enctype="multipart/form-data" name="' . $rowId . 'Form" id="' . $rowId . 'Form" class="cb_form streamItemForm form">' . '<textarea id="' . $stream->id() . '_message_edit_' . (int) $row->get( 'id' ) . '" name="message" rows="1" class="streamInput streamInputAutosize streamInputMessage form-control" placeholder="' . htmlspecialchars( ( $stream->get( 'type' ) == 'comment' ? CBTxt::T( 'Write a reply...' ) : CBTxt::T( 'Write a comment...' ) ) ) . '"' . ( $messageLimit ? ' data-cbactivity-input-limit="' . (int) $messageLimit . '" maxlength="' . (int) $messageLimit . '"' : null ) . '>' . htmlspecialchars( $row->get( 'message' ) ) . '</textarea>' . $editBody . '<div class="commentContainerFooter">' . '<div class="commentContainerFooterRow clearfix">' . '<div class="commentContainerFooterRowLeft pull-left">' . $editFooter . '</div>' . '<div class="commentContainerFooterRowRight pull-right text-right">' . '<button type="submit" class="commentButton commentButtonEditSave streamItemEditSave btn btn-primary btn-xs">' . CBTxt::T( 'Done Editing' ) . '</button>' . ' <button type="button" class="commentButton commentButtonEditCancel streamItemEditCancel btn btn-default btn-xs">' . CBTxt::T( 'Cancel' ) . '</button>' . '</div>' . '</div>' . '</div>' . '</form>' . '</div>'; return $return; }
/** * @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; }
/** * Deletes activity hide * * @param int $id * @param Activity $stream * @param UserTable $user * @param UserTable $viewer */ private function unhideActivity( $id, $stream, $user, $viewer ) { $row = new HiddenTable(); $row->load( array( 'user_id' => (int) $viewer->get( 'id' ), 'type' => 'activity', 'item' => (int) $id ) ); if ( ( ! $row->get( 'id' ) ) || ( ( $viewer->get( 'id' ) != $row->get( 'user_id' ) ) && ( ! CBActivity::isModerator( (int) $viewer->get( 'id' ) ) ) ) ) { header( 'HTTP/1.0 404 Not Found' ); exit(); } if ( ! $row->canDelete() ) { header( 'HTTP/1.0 401 Unauthorized' ); exit(); } if ( ! $row->delete() ) { header( 'HTTP/1.0 500 Internal Server Error' ); exit(); } header( 'HTTP/1.0 200 OK' ); exit(); }