Updated : User photos link according to usercontent.class.php

Updated : How photo tagging is set on view_item
Updated : User videos and contacts link according to usercontent.class.php
Updated : startup.php
Registered : Filters to user object count. These are template specific registered filters
This commit is contained in:
Fawaz 2013-01-05 09:35:43 +00:00
parent 18aa78000d
commit 5dbbb246c2
16 changed files with 1080 additions and 178 deletions

View file

@ -196,8 +196,8 @@ class CBPhotos {
$Cbucket->links['photo_upload'] = array('photo_upload.php', 'photo_upload');
$Cbucket->links['manage_favorite_photos'] = array('manage_photos.php?mode=favorite', 'manage_photos.php?mode=favorite');
$Cbucket->links['manage_orphan_photos'] = array('manage_photos.php?mode=orphan', 'manage_photos.php?mode=orphan');
$Cbucket->links['user_photos'] = array('user_photos.php?mode=uploaded&user=', 'user_photos.php?mode=uploaded&user=');
$Cbucket->links['user_fav_photos'] = array('user_photos.php?mode=favorite&user=', 'user_photos.php?mode=favorite&user=');
$Cbucket->links['user_photos'] = array('user_content.php?object_group=content&object=photos&user=', 'user_content.php?object_group=content&object=photos&user=');
$Cbucket->links['user_fav_photos'] = array('user_content.php?object_group=content&object=photos&content_type=favorite&user=', 'user_content.php?object_group=content&object=photos&content_type=favorite&user=');
// Setting Home Tab
add_menu_item('navigation', lang('Photos'), cblink(array("name"=>"photos")), "photos","icon-picture icon-white");

View file

@ -0,0 +1,792 @@
<?php
class user_content {
private $GROUPS; // Holds complete list of groups
private $_current_user; // details of user of which content is being loaded
private $filtered_content; // List of content after being filtered
private $object_details = array(); // details of object being loaded
var $object_group; // Content group
var $object; // content object or content
var $get_callback; // Callback functio
var $display_callback; // Unused variable
var $section = false; // Is section or not
var $is_private = false; // is private or not
var $content_type = null; // content type
var $permissions = null; // permissions for object
var $access = null; // access for object
/**
* Checks if object is section or not. If $section is boolean, we'll
* use $object to if section is enabled. If string provided, we'll
* that string to check section
* @return string
*/
function _check_is_section() {
return ( $this->section ? ( is_bool( $this->section ) ? ':is_section' : ':is_section|'.$this->section ) : '' );
}
/**
* Check if object itself is content or not. For better explaination
* consider following example:
* $object_group is connections
* --> $object is subscribers, this object itself is content,
* whereas
* $object_group is content
* --> $object is videos
* --> $content_type is uploaded, now this is content
* @return string
*/
function _check_is_content() {
return ( $this->content_type ? '' : ':is_content' );
}
/**
* Checks if content is public or private.
* Note: Right now private means only user, user's friends
* are not included.
*
* @return string
*/
function _check_is_private() {
return ( $this->is_private ? ':is_private' : ':is_public' );
}
/**
* Get the list of all groups
* @return array
*/
function ___groups() {
return $this->GROUPS;
}
/**
* Set the list of all groups
* @param array $groups
* @return array
*/
function ___set_groups( $groups ) {
return $this->GROUPS = $groups;
}
/**
* Get details of user whose content is being
* viewed
* @return array
*/
function __get_current_user() {
return $this->_current_user;
}
/**
* Alias of aabove method
* @return array
*/
function get_current_user() {
return $this->__get_current_user();
}
/**
* Set details of user whose content is being
* @param array $user
* @return array
*/
function __set_current_user( $user ) {
return $this->_current_user = $user;
}
/**
* Gets filtered content array
* @return array
*/
function __get_filtered_content() {
return $this->filtered_content;
}
/**
* Sets filtered content
* @param array $content
* @return array
*/
function __set_filtered_content( $content ) {
return $this->filtered_content = $content;
}
/**
* Gets object details
* @return array
*/
function __get_object_details() {
return $this->object_details;
}
/**
* Sets object details which conists of following:
* --> $object
* --> result of _check_is_section()
* --> result of _check_is_private()
* --> result of _check_is_content()
* @param array $details
* @return array
*/
function __set_object_details($details) {
return $this->object_details = $details;
}
/**
* Resets variables back to default values
*/
function __reset_variables() {
$this->object_group = '';
$this->object = '';
$this->section = false;
$this->is_private = false;
$this->content_type = null;
$this->permissions = null;
}
/**
* Adds a new content in array
* @return array
*/
function _add_new_content() {
$groups = $this->___groups();
if (
!$this->object_group || !$this->object ||
!$this->get_callback ||!function_exists( $this->get_callback )
) { return false; }
if ( $this->content_type && !is_string( $this->content_type ) ) {
return false;
}
$complete_id = $this->object.$this->_check_is_section().$this->_check_is_content();
if ( !$this->content_type ) {
$complete_id .= $this->_check_is_private();
}
if ( !$groups[ $this->object_group ] ) {
$groups[ $this->object_group ] = array();
}
if ( !$groups[ $this->object_group ][ $complete_id ] ) {
$groups[ $this->object_group ][ $complete_id ] = array();
}
if ( $this->content_type && !$groups[ $this->object_group ][ $complete_id ][ $this->content_type.$this->_check_is_private() ] ) {
$groups[ $this->object_group ][ $complete_id ][ $this->content_type.$this->_check_is_private() ] = array();
}
$array = array(
'group' => $this->object_group,
'object' => $this->object,
'get' => $this->get_callback,
'display' => $this->display_callback,
'permissions' => $this->permissions
);
if ( !$this->content_type ) {
$groups[ $this->object_group ][ $complete_id ] = $array;
$details = array( $this->object, $this->_check_is_section(), $this->_check_is_content(), $this->_check_is_private() );
} else {
$array['content_type'] = $this->content_type;
$groups[ $this->object_group ][ $complete_id ][ $this->content_type.$this->_check_is_private() ] = $array;
$details = array( $this->object, $this->_check_is_section(), $this->_check_is_content() );
}
$odetails = $this->__get_object_details();
$odetails[$this->object_group ][ $this->object ]['object'] = $details;
if ( $this->content_type ) {
$odetails[$this->object_group ][ $this->object ][ $this->content_type ] = array( $this->content_type, $this->_check_is_private() );
}
$this->__set_object_details( $odetails );
$this->__reset_variables();
return $this->___set_groups( $groups );
}
/**
* Alias function for above
*/
function add_new_content() {
return $this->_add_new_content();
}
/**
* Extract important details of object from key
* @param string $key
* @return array
*/
function __extract_key_details( $key ) {
return array_map("trim", explode(":", $key) );
}
/**
* Confirms if section is enabled or not
* @param array $content
* @param array $key_details
* @return boolean
*/
function _confirm_section_enabled( $content, $key_details ) {
if ( $section = array_find( 'is_section', $key_details ) ) {
if ( strpos( $section, "|" ) !== false ) {
$section_key = end( explode("|", $section) );
} else {
$section_key = $key_details[0];
}
if ( !isSectionEnabled( $section_key ) ) {
return true;
}
return false;
}
}
/**
* Confirms if content is private
* @param array $content
* @param string $key
* @return string|boolean
*/
function _confirm_private( $content, $key ) {
$user = $this->get_current_user();
if ( strpos( $key, ':is_private' ) !== false && ( !userid() || userid() != $user['userid'] ) ) {
return ( $content['content_type'] ? $key : true );
}
}
/**
* Confirms if permissions is allowed or not
* @param array $content
* @param string $key
* @return string|boolean
*/
function _confirm_permissions ( $content, $key ) {
$user = $this->get_current_user();
$permissions = explode(",",$content['permissions']);
$permissions = array_map( "trim", $permissions );
foreach ( $permissions as $per ) {
if ( $user[ $per ] == 'no' && userid() != $user['userid'] ) {
return ( $content['content_type'] ? $key : true );
}
}
}
/**
* This function filters the content array
* using it's details
*
* @global object $userquery
* @param string $group
* @param string $return
* @return array
*/
function __filter_user_object_content( $_group = null, $return = false ) {
if( $this->__get_filtered_content() ) {
return $this->__get_filtered_content();
}
$groups = $this->___groups();
$group = $_group ? $_group : get('object_group');
if (!$this->__get_current_user()) {
global $userquery;
$user = $userquery->get_user_details( get('user'), false, true );
$user = $this->__set_current_user( $user );
} else {
$user = $this->__get_current_user();
}
if ( !$user ) {
return false;
}
if ( !$group || !$groups[ $group ] ) {
$group = key( $groups );
}
if ( $groups[ $group ] ) {
foreach( $groups[$group] as $key => $value ) {
$info = $this->__extract_key_details( $key );
$section_disbaled = false;
$is_private = false;
$no_permission = false;
$section_disbaled = $this->_confirm_section_enabled( $value, $info );
if ( array_find( 'is_content', $info ) ) {
$is_private = $this->_confirm_private( $value, $key );
$no_permission = $this->_confirm_permissions( $value, $key );
} else {
foreach ( $value as $type => $content ) {
$content_pri = $this->_confirm_private( $content, $type );
$content_per = $this->_confirm_permissions( $content, $type );
if ( $content_pri && $content_per ) {
$remove_content[] = $content_pri;
$remove_content[] = $content_per;
} else if ( $content_pri ) {
$remove_content[] = $content_pri;
} else if ( $content_per ) {
$remove_content[] = $content_per;
}
}
}
if ( $section_disbaled || $is_private || $no_permission ) {
continue;
}
if ( isset( $remove_content ) ) {
foreach( $remove_content as $rc ) {
if ( $groups[ $group ][ $key ][ $rc ] ) {
unset ( $groups[ $group ][ $key ][ $rc ] );
}
}
$value = $groups[ $group ][ $key ];
}
unset( $remove_content );
if ( $value ) {
$filtered_content[ $key ] = $value;
}
}
$this->active_group = $group;
return ( $return ) ? $filtered_content : $this->__set_filtered_content( $filtered_content );
}
}
/**
* Function build index key for current object being
* viewed
* @return string
*/
function _build_index_object_content( $build = 'object' ) {
$object_group = mysql_clean( get('object_group') );
$object = mysql_clean( get('object') );
$odetails = $this->__get_object_details();
if ( !$object_group || !$odetails[ $object_group ] ) {
$object_group = key( $odetails );
}
if ( !$object || !$odetails[ $object_group ][ $object ] ) {
$object = key( $odetails[ $object_group ] );
}
if ( $object_group && $object ) {
if ( $odetails[$object_group][$object] ) {
return ( $odetails[$object_group][$object][ $build ] ? implode("", $odetails[$object_group][$object][ $build ] ) : false );
}
}
return false;
}
/**
* Function outputs a list of objects
* @return string
*/
function _display_objects_list() {
$content = $this->__filter_user_object_content();
$index = $this->_build_index_object_content();
$user = $this->__get_current_user();
$output = '';
if ( $content ) {
$keys = array_keys( $content );
foreach ( $keys as $key ) {
$active = '';
if ( $index == $key ) {
$active = ' active';
}
$k = $this->__extract_key_details( $key );
$name = apply_filters( $k[0], 'object_name' );
$name = apply_filters( $name, $k[0].'_name_filter' );
$output .= '<li class="user-objects-list user-object-'.$k[0].$active.'"><a href="'.make_user_content_link( $user['username'], $this->active_group, $k[0] ).'">'.$name.'</a></li>';
}
return $output;
}
}
/**
* Function outputs a list of objects other the active
*/
function _display_other_objects_list() {
$groups = $this->___groups();
$active_group = $group = get('object_group');;
$user = $this->__get_current_user();
if ( !$active_group || !$groups[ $active_group ] ) {
$active_group = key( $groups );
}
if ( $groups ) {
// Remove the active group from $groups array
unset( $groups[ $active_group ] );
$total_groups = count( $groups ); $group_count = 0;
foreach ( $groups as $group => $group_content ) {
$group_content = $this->__filter_user_object_content( $group, true );
if ( $group_content ) {
$keys = array_keys( $group_content );
if ( $group_count > 0 && $group_count < $total_groups ) {
$output .= '<li class="user-other-objects-divider divider"></li>';
}
foreach ( $keys as $key ) {
$k = $this->__extract_key_details( $key );
$name = apply_filters( $k[0], 'object_name' );
$name = apply_filters( $name, $k[0].'_other_name_filter' );
$output .= '<li class="other-objects-list other-object-'.$k[0].'"><a href="'.make_user_content_link( $user['username'], $group, $k[0] ).'">'.$name.'</a></li>';
}
$group_count++;
}
}
return $output;
}
return false;
}
/**
* Function outputs a list of content type if
* object itself is not content and it has content type
* @return boolean|string
*/
function _display_content_type_list() {
$content = $this->__filter_user_object_content();
$index = $this->_build_index_object_content();
$user = $this->__get_current_user();
if ( $content[ $index ] ) {
if ( strpos( $index, ':is_content') !== false ) {
return false;
}
$content_type = mysql_clean( get('content_type') );
if ( !$content_type ) {
$content_type = key( ( $content[$index] ) );
}
$content_type = $this->_build_index_object_content( $content_type );
if ( !$content_type ) {
$content_type = key( $content[ $index ] );
}
$output = '';
foreach ( $content[ $index ] as $type => $object_content ) {
$active = '';
if ( $type == $content_type ) {
$active = ' active';
}
$name = apply_filters( $object_content['content_type'], 'content_type_name' );
$name = apply_filters( $name, $object_content['object'].'_'.$type.'_name_filter' );
$output .= '<li class="user-object-content-type user-object-content-'.$object_content['content_type'].' user-object-'.$object_content['object'].'-'.$object_content['content_type'].$active.'"><a href="'. make_user_content_link( $user['username'], $this->active_group, $object_content['object'], $object_content['content_type'] ).'">'.$name.'</a></li>';
}
return $output;
}
return false;
}
/**
* Function outputs the object content
* @return string
*/
function _display_object_content() {
$content = $this->__filter_user_object_content();
$index = $this->_build_index_object_content();
if ( $content[ $index ] ) {
$output = '';
if ( isset( $content[ $index ]['get'] ) ) {
$output .= $this->__do_content_callback( $content[ $index ], $index );
} else {
$content_type = get('content_type');
if ( !$content_type ) {
$content_type = key( $content[ $index ] );
}
$content_type = $this->_build_index_object_content( $content_type );
if ( !$content_type ) {
$content_type = key( $content[ $index ] );
}
if ( $content[ $index ][ $content_type ]['get'] ) {
$output .= $this->__do_content_callback( $content[ $index ][ $content_type ], $index );
}
}
return $output;
}
return false;
}
/**
* Function calls the callback of current object and
* outputs the result.
* @param array $content
* @param string $key
* @return string
*/
function __do_content_callback( $content, $key ) {
$class = 'user-'.$content['object'].' user-content-container';
if ( $content['content_type'] ) {
$class .= ' user-'.$content['object'].'-'.$content['content_type'];
}
$id = 'user-'.$content['object'];
if ( $content['content_type'] ) {
$id .= '-'.$content['content_type'];
}
$attrs = array( 'class' => $class, 'id' => $id, 'data-object-group' => $content['group'], 'data-object' => $content['object'] );
if ( $content['content_type'] ) {
$attrs['data-content-type'] = $content['content_type'];
}
foreach ( $attrs as $attribute => $value ) {
$attributes .= $attribute.' = "'.$value.'" ';
}
$output = '<div '.$attributes.'> ';
$output .= $content['get']( $content, $key );
$output .= '</div>';
return $output;
}
}
/**
* Adding alias functions
*/
function display_objects_list() {
global $usercontent;
return $usercontent->_display_objects_list();
}
function display_content_type_list() {
global $usercontent;
return $usercontent->_display_content_type_list();
}
function display_object_content() {
global $usercontent;
return $usercontent->_display_object_content();
}
function display_other_objects_list() {
global $usercontent;
return $usercontent->_display_other_objects_list();
}
/**
* Adding functions for usercontent
*/
/**
* This makes string readable
* @param string $name
* @return string
*/
function usercontent_make_label( $name ) {
$name = explode( "_", $name );
$name[0] = ucfirst( $name[0] );
$name = implode( " ", $name );
return $name;
}
/**
* Creates link for user content
*
* @param string $user Could be username or userid
* @param string $group
* @param string $object
* @param string $content_type
* @return string
*/
function make_user_content_link( $user = null, $group = null, $object = null, $content_type = null ) {
$link = BASEURL.'/user_content.php?user='.$user;
if ( !is_null( $group) ) {
$link .= "&object_group=$group";
}
if ( !is_null( $object ) ) {
$link .= "&object=$object";
}
if ( !is_null( $content_type ) ) {
$link .= "&content_type=$content_type";
}
return $link;
}
/**
* Following are default callbacks for user content
*/
function cb_get_user_favorite_videos( $content, $key ) {
global $usercontent, $pages, $cbvid;
$udetails = $usercontent->get_current_user();
$page = mysql_clean( get('page') );
$get_limit = create_query_limit($page,config('videos_items_ufav_page'));
$params = array('userid'=>$udetails['userid'],'limit'=>$get_limit);
$videos = $cbvid->action->get_favorites($params);
$params['count_only'] = "yes";
$total_rows = $cbvid->action->get_favorites( $params );
$total_pages = count_pages($total_rows,config('videos_items_ufav_page'));
$params = array();
$params['file'] = 'user_videos.html';
$params['the_title'] = name( $udetails ).' '.lang('favorites');
$params['videos'] = $videos;
$params['total_videos'] = $total_rows;
$params['mode'] = 'favorite';
subtitle(sprintf(lang("title_usr_fav_vids"),name( $udetails )));
return fetch_template_file( $params );
}
function cb_get_user_uploaded_videos ( $content, $key ) {
global $usercontent, $pages;
$udetails = $usercontent->get_current_user();
$page = mysql_clean( get('page') );
$get_limit = create_query_limit($page,config('videos_items_uvid_page'));
$videos = get_videos(array('user'=>$udetails['userid'],'limit'=>$get_limit));
$total_rows = get_videos(array('user'=>$udetails['userid'],'count_only'=>true));
$total_pages = count_pages($total_rows,config('videos_items_uvid_page'));
$pages->paginate($total_pages,$page);
$params['file'] = 'user_videos.html';
$params['the_title'] = name( $udetails )." ".lang('videos');
$params['videos'] = $videos;
$params['total_videos'] = $total_rows;
$params['mode'] = 'uploaded';
subtitle(sprintf(lang("users_videos"),name( $udetails ) ));
return fetch_template_file($params);
}
function cb_get_user_uploaded_photos( $content, $key ) {
global $usercontent, $pages;
$user = $usercontent->get_current_user();
$page = mysql_clean( get('page') );
$limit = create_query_limit($page,config('photo_user_photos'));
$photos = get_photos(array("limit"=>$limit,"user"=>$user['userid']));
$total_rows = get_photos(array("count_only"=>true,"user"=>$user['userid']));
$total_pages = count_pages($total_rows,config('photo_user_photos'));
$pages->paginate( $total_pages, $page );
$params['file'] = 'user_photos.html';
$params['the_title'] = name( $user )." ".lang('photos');
$params['photos'] = $photos;
$params['total_photos'] = $total_rows;
$params['mode'] = 'uploaded';
return fetch_template_file($params);
}
function cb_get_user_favorite_photos() {
global $usercontent, $pages, $cbphoto;
$user = $usercontent->get_current_user();
$page = mysql_clean( get('page') );
$limit = create_query_limit($page,config('photo_user_favorites'));
$photos = $cbphoto->action->get_favorites( array("user"=>$user['userid'],"limit"=>$limit) );
$total_rows = $cbphoto->action->get_favorites( array("user"=>$user['userid'],"limit"=>$limit, "count_only" => true ) );
$total_pages = count_pages( $total_rows,config('photo_user_favorites') );
$pages->paginate( $total_pages, $page );
$params['file'] = 'user_photos.html';
$params['the_title'] = name( $user )." ".lang('favorites');
$params['photos'] = $photos;
$params['total_photos'] = $total_rows;
$params['mode'] = 'favorite';
return fetch_template_file( $params );
}
function cb_get_user_friends() {
global $usercontent, $userquery;
$udetails = $usercontent->get_current_user();
$friends = $userquery->get_contacts( $udetails['userid'], 0, "yes" );
$params['file'] = 'user_contacts.html';
$params['contacts'] = $friends;
$params['no_result'] = lang( name( $udetails ).' has no friends, yet.' );
$params['mode'] = 'friends';
$params['the_title'] = sprintf( lang('users_contacts'), name ( $udetails ) );
$params['heading'] = sprintf( lang('users_contacts'), name ( $udetails ) );
subtitle(sprintf( lang("users_contacts"), name( $udetails )) );
return fetch_template_file( $params );
}
function cb_get_user_subscriptions() {
global $usercontent, $userquery;
$udetails = $usercontent->get_current_user();
$subscriptions = $userquery->get_user_subscriptions( $udetails['userid'], null );
$params['file'] = 'user_contacts.html';
$params['contacts'] = $subscriptions;
$params['no_result'] = lang( name( $udetails ).' has no subscriptions, yet.' );
$params['mode'] = 'subscriptions';
$params['the_title'] = sprintf( lang('user_subscriptions'), name ( $udetails ) );
$params['heading'] = sprintf( lang('user_subscriptions'), name( $udetails ) );
subtitle(sprintf( lang('user_subscriptions'), name( $udetails )));
return fetch_template_file( $params );
}
function cb_get_user_subscribers() {
global $usercontent, $userquery;
$udetails = $usercontent->get_current_user();
$subscribers = $userquery->get_user_subscribers_detail( $udetails['userid'], null );
$params['file'] = 'user_contacts.html';
$params['contacts'] = $subscribers;
$params['no_result'] = lang( name( $udetails ).' has no subscribers, yet.' );
$params['mode'] = 'users_subscribers';
$params['the_title'] = sprintf( lang('users_subscribers'), name ( $udetails ) );
$params['heading'] = sprintf( lang('users_subscribers'), name( $udetails ) );
subtitle(sprintf( lang('users_subscribers'), name( $udetails )));
return fetch_template_file( $params );
}
?>

View file

@ -28,11 +28,11 @@ $cbLinks = array
'search_result' =>array('search_result.php','search_result.php'),
'signup' =>array('signup.php','signup'),
'upload' =>array('upload.php','upload'),
'user_contacts' =>array('user_contacts.php?user=','user_contacts.php?user='),
'user_subscriptions' =>array('user_contacts.php?mode=subscriptions&user=','user_contacts.php?mode=subscriptions&user='),
'user_subscribers' =>array('user_contacts.php?mode=subscribers&user=','user_contacts.php?mode=subscribers&user='),
'user_favorites' =>array('user_videos.php?mode=favorites&user=','user_videos.php?mode=favorites&user='),
'user_videos' =>array('user_videos.php?user=','user_videos.php?user='),
'user_contacts' =>array('user_content.php?object_group=connections&user=','user_content.php?object_group=connections&user='),
'user_subscriptions' =>array('user_content.php?object_group=connections&object=subscriptions&user=','user_content.php?object_group=connections&object=subscriptions&user='),
'user_subscribers' =>array('user_content.php?object_group=connections&object=subscribers&user=','user_content.php?object_group=connections&object=subscribers&user='),
'user_favorites' =>array('user_content.php?object_group=content&object=videos&content_type=favorites&user=','user_content.php?object_group=content&object=videos&content_type=favorites&user='),
'user_videos' =>array('user_content.php?object_group=content&object=videos&content_type=uploaded&user=','user_content.php?object_group=content&object=videos&content_type=uploaded&user='),
'videos' =>array('videos.php','videos/'),
);

View file

@ -1625,15 +1625,12 @@ function get_image_file ( $params ) {
$attrs['width'] = $width;
$attrs['height'] = $height;
if ( USE_PHOTO_TAGGING && THIS_PAGE == 'view_item' ) {
$id = $cbphoto->get_selector_id()."_".$photo['photo_id'];
} else {
if ( $params['id'] ) {
$id = mysql_clean( $params['id'] )."_".$photo['photo_id'];
} else {
$id = $cbphoto->get_selector_id()."_".$photo['photo_id'];
}
$id = "photo_".$photo['photo_id'];
}
$attrs['id'] = $id;
if ( $params['class'] ) {
@ -1644,12 +1641,16 @@ function get_image_file ( $params ) {
$attrs['align'] = mysql_clean( $params['align'] );
}
$title = $params['title'] ? $params['title'] : $photo['title'];
$title = $params['title'] ? $params['title'] : $photo['photo_title'];
$attrs['title'] = mysql_clean ($title );
$alt = $params['alt'] ? $params['alt'] : TITLE.' - '.$photo['title'];
$alt = $params['alt'] ? TITLE.' - '.$params['alt'] : TITLE.' - '.$photo['photo_title'];
$attrs['alt'] = mysql_clean( $alt );
if ( add_tagging_attribute( $photo ) ) {
$attrs['cb-tagger-photo'] = 'yes';
}
$anchor_p = array( "place" => 'photo_thumb', "data" => $photo );
$params['extra'] = ANCHOR( $anchor_p );
@ -1688,4 +1689,26 @@ function get_image_url( $photo, $size='t', $multi = false, $assign = null, $with
$params = array( "details" => $photo, "size" => $size, "multi" => $multi, "assign" => $assign, "with_path" => $with_path, "with_orig" => $with_orig );
return get_image_file( $params );
}
/**
* Makes sure if photo tagging can be
* added or not
*
* @param array $photo
* @return boolean
*/
function add_tagging_attribute( $photo ) {
if ( $photo ) {
// Make sure current photo is being viewed
// and photo tagging is enabled globally
if ( $photo['photo_key'] == mysql_clean(get('item')) && USE_PHOTO_TAGGING === true ) {
// Make sure photo has enabled tagging
if ( $photo['allow_tagging'] == 'yes' ) {
return true;
}
}
}
return false;
}
?>

View file

@ -6,7 +6,7 @@
*/
include(BASEDIR.'/modules/uploader/uploader.php');
include('classes/usercontent.class.php');
/***
* Adding custom thumb sizes
@ -172,4 +172,76 @@ register_filter( 'dashboard_widgets', '_test_function_ordering' );
register_anchor_function( 'init_dashboard_js', 'cb_head' );
setup_myaccount_dashboard();
/**
* User Content Setup
*/
register_filter( 'object_name', 'usercontent_make_label' );
register_filter( 'content_type_name', 'usercontent_make_label' );
register_filter( 'object_name','lang' );
register_filter( 'content_type_name', 'lang' );
$usercontent = new user_content();
$usercontent->object_group = 'content';
$usercontent->object = 'videos';
$usercontent->section = true;
$usercontent->content_type = 'uploaded';
$usercontent->get_callback = 'cb_get_user_uploaded_videos';
$usercontent->permissions = 'show_my_videos';
$usercontent->add_new_content();
$usercontent->object_group = 'content';
$usercontent->object = 'videos';
$usercontent->section = true;
$usercontent->content_type = 'favorite';
$usercontent->get_callback = 'cb_get_user_favorite_videos';
$usercontent->permissions = 'show_my_videos';
$usercontent->add_new_content();
$usercontent->object_group = 'content';
$usercontent->object = 'photos';
$usercontent->section = true;
$usercontent->content_type = 'uploaded';
$usercontent->get_callback = 'cb_get_user_uploaded_photos';
$usercontent->permissions = 'show_my_photos';
$usercontent->add_new_content();
$usercontent->object_group = 'content';
$usercontent->object = 'photos';
$usercontent->section = true;
$usercontent->content_type = 'favorite';
$usercontent->get_callback = 'cb_get_user_favorite_photos';
$usercontent->permissions = 'show_my_photos';
$usercontent->add_new_content();
$usercontent->object_group = 'content';
$usercontent->object = 'photos';
$usercontent->section = true;
$usercontent->content_type = 'tagged_in';
$usercontent->get_callback = 'cb_get_user_favorite_photos';
$usercontent->permissions = 'show_my_photos';
$usercontent->add_new_content();
$usercontent->object_group = 'connections';
$usercontent->object = 'friends';
$usercontent->get_callback = 'cb_get_user_friends';
$usercontent->permissions = 'show_my_friends';
$usercontent->add_new_content();
$usercontent->object_group = 'connections';
$usercontent->object = 'subscriptions';
$usercontent->get_callback = 'cb_get_user_subscriptions';
$usercontent->permissions = 'show_my_subscriptions';
$usercontent->add_new_content();
$usercontent->object_group = 'connections';
$usercontent->object = 'subscribers';
$usercontent->get_callback = 'cb_get_user_subscribers';
$usercontent->permissions = 'show_my_subscribers';
$usercontent->add_new_content();
?>

View file

@ -86,7 +86,7 @@
</div>
{/if}
{$videos=get_videos(['limit'=>15])}
{$videos=get_videos(['limit'=>15,'order'=>'date_added desc'])}
{if $videos}
{$heading='Latest Videos'}
{$more_mode='recent'}

View file

@ -93,6 +93,7 @@
</tbody>
</table>
</form>
{get_template('pagination')}
{/if}
{if !$photos}
<p class="alert alert-large">{lang code='No founds photos'}{if $smarty.get.query},{lang code='matching this keyword'}{/if}.</p>

View file

@ -1,61 +1,12 @@
{lang code='channel' assign='object_type'}
{include file="$style_dir/global_header.html"}
<body class="relative view_channel">
{display_user_custom_background( $u )}
<div class="container view-channel-container">
{include_template_file file="header.html" }
<div id="global-container" class="relative clearfix">
{include file="$style_dir/message.html"}
<div class="view-channel-box user-info-box clearfix">
<a href="{$userquery->profile_link($u)}"><img src="{avatar size='small' details=$u}" width="30" height="30" /> {name($u)}</a>
</div>
<div class="view-channel-box user-pages-navigation-container clearfix">
<div class="user-pages-navigation">
<ul class="user-pages-list">
<li{if $mode == '' || $mode == 'contacts'} class="active"{/if}><a href="{link name='user_contacts'}{$u.username}">{lang code='Contacts'}<span>{count($friends)}</span></a></li>
<li{if $mode == 'subscriptions'} class="active"{/if}><a href="{link name='user_subscriptions'}{$u.username}">{lang code='Subscriptions'}<span>{$u.total_subscriptions}</span></a></li>
<li{if $mode == 'subscribers'} class="active"{/if}><a href="{link name='user_subscribers'}{$u.username}">{lang code='Subscribers'}<span>{$u.subscribers|number_format}</span></a></li>
</ul>
</div>
</div>
<div class="view-channel-box clearfix">
{if $mode == '' || $mode == 'contacts'}
<div class="view-channel-box-header"><h4>{lang code="%s's Contacts"|sprintf:$u.username}</h4></div>
<div class="view-channel-box-content clearfix">
{if $friends}
<div class="view-channel-box-header"><h4>{$the_title}</h4></div>
<div class="view-channel-box-content clearfix">
{if $contacts}
<ul class="user-contacts">
{foreach $friends as $friend}
{if $u.userid!=$friend.userid}
{assign var=user_detail value=$userquery->get_user_details($friend.userid)}
{else}
{assign var=user_detail value=$userquery->get_user_details($friend.contact_userid)}
{/if}
{include_template_file file='blocks/user.html' user=$user_detail display_method='user_contacts'}
{foreach $contacts as $contact}
{include_template_file file='blocks/user.html' user=$contact display_method='user_contacts'}
{/foreach}
</ul>
{else}
<p class="alert alert-large">This user has no contacts</p>
<p class="alert alert-large">{$no_result}</p>
{/if}
</div>
{else}
<div class="view-channel-box-header"><h4>{$heading}</h4></div>
<div class="view-channel-box-content clearfix">
{if $userSubs}
<ul class="user-contacts">
{foreach $userSubs as $sub}
{include_template_file file='blocks/user.html' user=$sub display_method='user_contacts'}
{/foreach}
</ul>
{else}
<p class="alert alert-large">{$no_subs_found}</p>
{/if}
</div>
{/if}
<div class="view-channel-box-footer">
this is footer
</div>
</div>
</div>
</div>
</body>
</html>
</div>

View file

@ -0,0 +1,49 @@
{include file="$style_dir/global_header.html"}
<body class="relative view_channel">
{display_user_custom_background( $u )}
<div class="container view-channel-container">
{include_template_file file="header.html" }
<div id="global-container" class="relative clearfix">
{include file="$style_dir/message.html"}
<div class="view-channel-box user-info-box clearfix" style=" overflow: visible; ">
<a href="{$userquery->profile_link($u)}" class="name-avatar"><img src="{avatar uid=$u.userid}" class="avatar" /> <span class="name">{name($u)}</span></a>
<div class="user-other-objects-container">
<div class="btn-group">
<a class="btn dropdown-toggle btn-primary" data-toggle="dropdown" href="#">
{lang code='Browse'}
<span class="caret"></span>
</a>
<ul class="dropdown-menu pull-right">
{display_other_objects_list()}
</ul>
</div>
</div>
</div>
<div class="view-channel-box user-pages-navigation-container clearfix">
<div class="user-pages-navigation">
<ul class="user-pages-list">
{display_objects_list()}
</ul>
</div>
</div>
{$content_types=display_content_type_list()}
{if $content_types}
<div class="view-channel-box-connector"></div>
<div class="view-channel-box user-pages-navigation-container clearfix">
<div class="user-pages-navigation">
<ul class="user-pages-list">
{$content_types}
</ul>
</div>
</div>
{/if}
<div class="view-channel-box clearfix">
{display_object_content()}
</div>
</div>
</div>
</body>

View file

@ -1,36 +1,7 @@
{lang code='channel' assign='object_type'}
{include file="$style_dir/global_header.html"}
<body class="relative view_channel">
{display_user_custom_background( $u )}
<div class="container view-channel-container">
{include_template_file file="header.html" }
<div id="global-container" class="relative clearfix">
{include file="$style_dir/message.html"}
<div class="view-channel-box user-info-box clearfix">
<a href="{$userquery->profile_link($u)}"><img src="{avatar size='small' details=$u}" width="30" height="30" /> {name($u)}</a>
</div>
<div class="view-channel-box user-pages-navigation-container clearfix">
<div class="user-pages-navigation">
<ul class="user-pages-list">
<li><a href="{link name='user_videos'}{$u.username}">{lang code='Videos'}<span>{$u.total_videos|number_format}</span></a></li>
<li class="active"><a href="{link name='user_photos'}{$u.username}">{lang code='Photos'}<span>{$u.total_photos|number_format}</span></a></li>
<li><a href="{link name='user_collections'}{$u.username}">{lang code='Collections'}<span>{$u.total_collections|number_format}</span></a></li>
</ul>
</div>
</div>
<div class="view-channel-box-connector"></div>
<div class="view-channel-box user-pages-navigation-container clearfix">
<div class="user-pages-navigation">
<ul class="user-pages-list">
<li{if !$mode || $mode == 'uploaded'} class="active"{/if}><a href="{link name='user_photos'}{$u.username}">{lang code='Uploaded'}</a></li>
<li{if $mode == 'favorite'} class="active"{/if}><a href="{link name='user_fav_photos'}{$u.username}">{lang code='Favorite'}</a></li>
</ul>
</div>
</div>
<div class="view-channel-box clearfix">
<div class="view-channel-box-header"><h4>{$the_title}</h4></div>
<div class="view-channel-box-content clearfix">
<div class="view-channel-box-header"><h4>{$the_title}</h4></div>
<div class="view-channel-box-content clearfix">
{if $photos}
{foreach $photos as $photo}
{include_template_file file='blocks/photo.html' photo=$photo}
@ -38,12 +9,7 @@
{else}
<p class="alert alert-large">{lang code='No photos found'}</p>
{/if}
</div>
<div class="view-channel-box-footer">
</div>
<div class="view-channel-box-footer">
{get_template('pagination')}
</div>
</div>
</div>
</div>
</body>
</html>
</div>

View file

@ -1,38 +1,6 @@
{lang code='channel' assign='object_type'}
{include file="$style_dir/global_header.html"}
<body class="relative view_channel">
{display_user_custom_background( $u )}
<div class="container view-channel-container">
{include_template_file file="header.html" }
<div id="global-container" class="relative clearfix">
{include file="$style_dir/message.html"}
<div class="view-channel-box user-info-box clearfix">
<a href="{$userquery->profile_link($u)}"><img src="{avatar size='small' details=$u}" width="30" height="30" /> {name($u)}</a>
</div>
<div class="view-channel-box user-pages-navigation-container clearfix">
<div class="user-pages-navigation">
<ul class="user-pages-list">
<li class="active"><a href="{link name='user_videos'}{$u.username}">{lang code='Videos'}<span>{$u.total_videos|number_format}</span></a></li>
<li><a href="{link name='user_photos'}{$u.username}">{lang code='Photos'}<span>{$u.total_photos|number_format}</span></a></li>
<li><a href="{link name='user_collections'}{$u.username}">{lang code='Collections'}<span>{$u.total_collections|number_format}</span></a></li>
</ul>
</div>
</div>
<div class="view-channel-box-connector"></div>
<div class="view-channel-box user-pages-navigation-container clearfix">
<div class="user-pages-navigation">
<ul class="user-pages-list">
<li{if !$mode || $mode == 'uploaded'} class="active"{/if}><a href="{link name='user_videos'}{$u.username}">{lang code='Uploaded'}</a></li>
<li{if $mode == 'favorite'} class="active"{/if}><a href="{link name='user_favorites'}{$u.username}">{lang code='Favorite'}</a></li>
</ul>
</div>
</div>
<div class="view-channel-box clearfix">
<div class="view-channel-box-header"><h4>{$the_title}</h4></div>
<div class="view-channel-box-content clearfix">
<div class="view-channel-box-header"><h4>{$the_title}</h4></div>
<div class="view-channel-box-content clearfix">
{if $videos}
{foreach $videos as $video}
{include_template_file file='blocks/video.html' video=$video}
@ -40,9 +8,7 @@
{else}
<p class="alert alert-large">{lang code='No videos found'}</p>
{/if}
</div>
</div>
</div>
</div>
</body>
</html>
</div>
<div class="view-channel-box-footer">
{get_template('pagination')}
</div>

View file

@ -136,4 +136,45 @@ function cbv3_photo_tagger_options( $options ) {
register_filter( 'tagger_configurations', 'cbv3_photo_tagger_options' );
function show_total_videos ( $name ) {
global $usercontent;
$user = $usercontent->get_current_user();
$total_videos = number_format( $user['total_videos'] );
return $name." <span>$total_videos</span>";
}
function show_total_photos ( $name ) {
global $usercontent;
$user = $usercontent->get_current_user();
$total_videos = number_format( $user['total_photos'] );
return $name." <span>$total_videos</span>";
}
function show_total_subscribers( $name ) {
global $usercontent;
$user = $usercontent->get_current_user();
return $name." <span>".number_format( $user['subscribers'] )."</span>";
}
function show_total_subscriptions ( $name ) {
global $usercontent;
$user = $usercontent->get_current_user();
return $name." <span>".number_format( $user['total_subscriptions'] )."</span>";
}
function show_total_friends( $name ) {
global $usercontent, $userquery;
$user = $usercontent->get_current_user();
$total_contacts = $userquery->get_contacts( $user['userid'], 0, 'yes', true );
return $name." <span>".number_format( $total_contacts )."</span>";
}
register_filter( 'videos_name_filter', 'show_total_videos' );
register_filter( 'photos_name_filter', 'show_total_photos' );
register_filter('subscribers_name_filter', 'show_total_subscribers');
register_filter('subscriptions_name_filter', 'show_total_subscriptions');
register_filter('friends_name_filter', 'show_total_friends');
?>

View file

@ -929,7 +929,6 @@ a.playlist .playlist-items-thumb.playlist-4-items .item-thumb img {
padding: 14px 18px;
color: #666;
font-size: 18px;
font-weight: lighter;
}
.user-pages-navigation .user-pages-list li a:hover, .user-pages-navigation .user-pages-list li.active a {
@ -1008,3 +1007,9 @@ ul.user-contacts li img {
margin-right: 10px;
}
.name-avatar { position: relative; }
.name-avatar:hover { text-decoration: none; }
.name-avatar .avatar { max-width: 40px; position: absolute; }
.name-avatar .name { margin-left: 48px; line-height: 40px; font-weight: bold; }
.user-other-objects-container { float: right; padding-top: 5px; }

View file

@ -1,5 +1,5 @@
{if $comments}
<p>{lang code='Following are 20 recent video comments within last 7 days'}</p>
<p>{lang code='Following are video comments within last 7 days'}</p>
<ul class="dashboard-lists cbv3-scroller clearfix">
{foreach $comments as $comment}
<li class="dashboard-list-item clearfix">

View file

@ -4,7 +4,7 @@
{literal}
var CBTAGGER;
$( document ).ready( function() {
CBTAGGER = $('#{/literal}{$cbphoto->get_selector_id()}_{$object.photo_id}{literal}').cbtag({/literal}{$tagger_configs}{literal}).data("cbtagger");
CBTAGGER = $('img[cb-tagger-photo=yes]').cbtag({/literal}{$tagger_configs}{literal}).data("cbtagger");
})
{/literal}
</script>

36
upload/user_content.php Normal file
View file

@ -0,0 +1,36 @@
<?php
/*
****************************************************************
| Copyright (c) 2007-2010 Clip-Bucket.com. All rights reserved.
| @ Author : ArslanHassan
| @ Software : ClipBucket , © PHPBucket.com
****************************************************************
*/
require 'includes/config.inc.php';
define( 'THIS_PAGE', 'user_content' );
$pages->page_redir();
$u = $_GET['user'];
$u = $u ? $u : $_GET['userid'];
$u = $u ? $u : $_GET['username'];
$u = $u ? $u : $_GET['uid'];
$u = $u ? $u : $_GET['u'];
$udetails = $userquery->get_user_details( $u, false, true );
if ( $udetails ) {
$usercontent->__set_current_user( $udetails );
assign("u",$udetails);
} else {
e(lang("usr_exist_err"));
$Cbucket->show_page = false;
}
if( $Cbucket->show_page ) {
Template('user_content.html');
} else {
display_it();
}
?>