I have been able to get CB Activity to log and display new image uploads. However, the only problem is, it is logging and displaying it twice. Any quick fix to make it display only once? Instead of detecting an image or file, I made the message "an image or file," and there is no thumbnail. This is the code from plugin.cbactivity.php:
public function onAfterUserProfileDisplay( $user ) {
global $_CB_framework, $_CB_database;
$myId = $_CB_framework->myId();
if ( $myId ) {
$userId = $user->get( 'id' );
if ( class_exists( 'pbProfileBookEntry' ) ) {
$pbComment = stripslashes( cbGetParam( $_POST, 'profilebookpostercomments' ) );
$pbGuest = $this->params->get( 'activity_pb_guest_create', 1 );
$pbWall = $this->params->get( 'activity_pb_wall_create', 1 );
$pbBlog = $this->params->get( 'activity_pb_blog_create', 1 );
if ( $pbComment && ( $pbGuest || $pbWall || $pbBlog ) ) {
$query = 'SELECT ' . $_CB_database->NameQuote( 'id' )
. "\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plug_profilebook' )
. "\n WHERE " . $_CB_database->NameQuote( 'postercomment' ) . " = " . $_CB_database->Quote( $pbComment )
. "\n AND " . $_CB_database->NameQuote( 'posterid' ) . " = " . (int) $myId
. "\n ORDER BY " . $_CB_database->NameQuote( 'date' ) . " DESC";
$_CB_database->setQuery( $query );
$pbEntry = $_CB_database->loadResult();
if ( $pbEntry ) {
if ( $pbGuest && ( cbGetParam( $_POST, 'profilebookformactiong' ) == 'new' ) ) {
$activity = new cbactivityActivity( $_CB_database );
$activity->set( 'user_id', (int) $myId );
$activity->set( 'user', (int) $userId );
$activity->set( 'type', 'profilebook' );
$activity->set( 'subtype', 'guest' );
$activity->set( 'item', (int) $pbEntry );
$activity->set( 'title', 'posted a guestbook entry to [user_linked]' );
$activity->set( 'icon', 'book' );
$activity->set( 'date', $_CB_framework->getUTCDate() );
$activity->store();
} elseif ( $pbWall && ( cbGetParam( $_POST, 'profilebookformactionw' ) == 'new' ) ) {
$activity = new cbactivityActivity( $_CB_database );
$activity->set( 'user_id', (int) $myId );
$activity->set( 'type', 'profilebook' );
$activity->set( 'subtype', 'wall' );
$activity->set( 'item', (int) $pbEntry );
$activity->set( 'icon', 'comment' );
$activity->set( 'date', $_CB_framework->getUTCDate() );
if ( $myId != $userId ) {
$activity->set( 'user', (int) $userId );
$activity->set( 'title', CBTxt::T( 'POSTED_WALL_ENTRY_TO' ) );
} else {
$activity->set( 'title', CBTxt::T( 'POSTED_WALL_ENTRY' ) );
}
$activity->store();
} elseif ( $pbBlog && ( cbGetParam( $_POST, 'profilebookformactionb' ) == 'new' ) ) {
$activity = new cbactivityActivity( $_CB_database );
$activity->set( 'user_id', (int) $myId );
$activity->set( 'type', 'profilebook' );
$activity->set( 'subtype', 'blog' );
$activity->set( 'item', (int) $pbEntry );
$activity->set( 'title', CBTxt::T( 'POSTED_BLOG_ENTRY' ) );
$activity->set( 'icon', 'font' );
$activity->set( 'date', $_CB_framework->getUTCDate() );
$activity->store();
}
}
}
}
// if ( class_exists( 'getProfileGalleryTab' ) ) {
// $pgTitle = stripslashes( cbGetParam( $_POST, 'profilegallerypgitemtitle' ) );
if ( $this->params->get( 'activity_pg_create', 1 ) ) {
// if ( $pgTitle && $this->params->get( 'activity_pg_create', 1 ) ) {
/* $query = 'SELECT *'
. "\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plug_profilegallery' )
. "\n WHERE " . $_CB_database->NameQuote( 'pgitemtitle' ) . " = " . $_CB_database->Quote( $pgTitle )
. "\n AND " . $_CB_database->NameQuote( 'userid' ) . " = " . (int) $myId
. "\n ORDER BY " . $_CB_database->NameQuote( 'pgitemdate' ) . " DESC";
$_CB_database->setQuery( $query );
$pgEntry = null;
$_CB_database->loadObject( $pgEntry );
if ( $pgEntry ) {
if ( in_array( $pgEntry->pgitemtype, array( 'jpg', 'jpeg', 'gif', 'png', 'bmp' ) ) ) {
$isImage = true;
} else {
$isImage = false;
}
*/
$activity = new cbactivityActivity( $_CB_database );
$activity->set( 'user_id', (int) $myId );
$activity->set( 'type', 'profilegallery1' );
$activity->set( 'item', (int) $pgEntry->id );
$activity->set( 'date', $_CB_framework->getUTCDate() );
// if ( $isImage ) {
$activity->set( 'subtype', 'image1' );
$activity->set( 'title', CBTxt::T( 'UPLOADED_GALLERY_IMAGE_OR_FILE' ) );
$activity->set( 'icon', 'picture' );
/* } else {
$activity->set( 'subtype', 'file' );
$activity->set( 'title', CBTxt::T( 'UPLOADED_GALLERY_FILE' ) );
$activity->set( 'icon', 'download-alt' );
}
*/
$activity->store();
}
}
}
// }
// }
Warmly,
Joseph