Added : Comments on channel

Updated : is_collection_cover to work for both photo id and json encoded value
Added : User functions for user profile item
Added : video profile item callbacks
Moved : Photo profile item to callback
Removed : Tagged in photos from user_content
Added : Collections in user_content
Added : Channel comment in user_content
Added : checking if collection cover mature or not
Added : Profile item badge in photo manager
This commit is contained in:
Fawaz 2013-01-10 12:12:14 +00:00
parent b881a6caeb
commit 4b80780cdb
10 changed files with 292 additions and 44 deletions

View file

@ -30,7 +30,7 @@
{if $c.featured == 'yes'}
<li><a href="?mode=mcuf&collection={$c.collection_id}">Unfeature It</a></li>
{else}
<li><a href="?mode=mcf&photo={$c.collection_id}">Make Featured</a></li>
<li><a href="?mode=mcf&collection={$c.collection_id}">Make Featured</a></li>
{/if}
{if $c.active == 'yes'}
@ -41,7 +41,7 @@
<li class="divider"></li>
<li><a href="#" onclick=" cb_confirm('Delete Collection','Are you sure you want to delete this collection ?', function(){
window.location = 'collection_manager.php?delete_collection={$photo.photo_id}'
window.location = 'collection_manager.php?delete_collection={$c.collection_id}'
}); return false;">Delete Collection</a></li>
</ul>
</div>

View file

@ -924,4 +924,16 @@ function cb_get_user_favorite_collections() {
return fetch_template_file( $params );
}
function cb_get_user_channel_comments() {
global $usercontent;
$user = $usercontent->get_current_user();
$params['file'] = 'blocks/view_channel/channel_comments.html';
$params['the_title'] = $params['heading'] = sprintf( lang("Comments on %s's channel"), name($user) );
$params['user'] = $user;
return fetch_template_file ( $params );
}
?>

View file

@ -1081,8 +1081,9 @@ function display_manager_links( $photo, $front_end = false ) {
* }
*
*/
$remove_query_variables = $url['remove_query_variables'];
$link['title'] = $url['title'] ? $url['title'] : $link['title'];
$url = $url['link'] ? $url['link'] : $link['link'];
$url = $url['link'] ? $url['link'] : $link['link'];
}
if ( $_SERVER['QUERY_STRING'] && strpos( $url, '.php') === false && strpos($url,'?') !== false ) {
@ -1090,19 +1091,18 @@ function display_manager_links( $photo, $front_end = false ) {
// append QUERY_STRING before $url
$url = ltrim( $url, '?' ); // removing the ? from start of string
parse_str( $url, $variables ); // changing $url query string to array
parse_str( $_SERVER['QUERY_STRING'], $server_variables );
if ( $variables ) {
$query_string_variables = array_keys( $variables ); // extracting only names of variables
$server_string_variables = array_keys( $server_variables );
if ( $query_string_variables ) {
$query_string_variables = ( array_merge( $query_string_variables, $server_string_variables ) );
$query_string_variables = array_unique( $query_string_variables );
$query_string_variables = array_diff( $query_string_variables, array('omo') );
//pr( $query_string_variables, true );
if ( $remove_query_variables && is_array( $remove_query_variables ) ) {
$query_string_variables = array_merge( $query_string_variables, $remove_query_variables );
$query_string_variables = array_unique( $query_string_variables );
}
$query_string = queryString( null, $query_string_variables );
}
//echo $query_string."<br/>";
$url = $query_string.$url;
}
}
@ -1737,7 +1737,11 @@ function is_collection_cover_mature( $array ) {
function is_collection_cover( $photo ) {
$cover_photo = json_decode( $photo['cover_photo'], true );
if ( $cover_photo ) {
if ( $cover_photo['photo_id'] == $photo['photo_id'] ) {
if ( $cover_photo['photo_id'] ) {
if ( $cover_photo['photo_id'] == $photo['photo_id'] ) {
return true;
}
} else if ( is_numeric( $cover_photo ) and $cover_photo = $photo['photo_id'] ) {
return true;
}
}
@ -1769,6 +1773,32 @@ function get_photo_fields( $extra = null ) {
return $fields;
}
/**
* Checks if photo profile item exists and user is owner
* @global object $cbphoto
* @param int $id
* @return boolean
*/
function checking_profile_item_photo( $id ) {
global $cbphoto;
if ( $cbphoto->photo_exists( $id ) ) {
if ( userid() != $cbphoto->get_photo_owner( $id ) ) {
e( lang('Unable to set photo as profile item') );
return false;
}
return true;
} else {
e( lang('Photo does not exists') );
return false;
}
}
/**
* Show profile item
* @global object $cbphoto
* @param int $id
* @return boolean
*/
function show_profile_item_photo( $id ) {
global $cbphoto;
$photo = $cbphoto->get_photo( $id, true );

View file

@ -662,23 +662,99 @@ function get_basic_user_details($uid)
}
function add_profile_item_type_callback( $type, $callback ) {
/**
* This function sets the user profile item.
*
* @global array $cb_profile_item_callbacks
* @param int $id
* @param string $type
* @param int $uid
* @return boolean
*/
function set_user_profile_item( $id, $type, $uid = null ) {
global $cb_profile_item_callbacks;
if ( !$type or !$callback or !function_exists( $callback ) or isset( $cb_profile_item_callbacks[ $type ] ) ) {
return false;
if ( is_null( $uid ) ) {
$uid = userid();
}
return $cb_profile_item_callbacks[ $type ] = $callback;
if ( $uid ) {
if ( $id or $type ) {
if ( isset( $cb_profile_item_callbacks[ $type ] ) and isset( $cb_profile_item_callbacks[ $type ][0] ) and function_exists( $cb_profile_item_callbacks[ $type ][0] ) ) {
$result = $cb_profile_item_callbacks[ $type ][0] ( $id );
if ( $result ) {
$profile_item['type'] = $type;
$profile_item['id'] = $id;
$jepi = json_encode( $profile_item );
$field = array( 'profile_item' => $jepi );
if ( is_profile_item( $id, $type ) ) {
$update = true;
} else {
$update = db_update( tbl('user_profile'), $field, " userid = '".userid()."' " );
}
if ( $update ) {
e( lang('Profile item has been updated.'), 'm' );
return true;
} else {
e( lang('Unable to update profile item.') );
return false;
}
} else {
return false;
}
}
}
}
e( lang('Invalid action') );
return false;
}
function display_profile_item( $uid = null ) {
/**
* Function adds a new profile item type and it's required callbacks.
* <em>$type</em> should be unique if already exists this will be not add.
*
* <em>$exists</em>, this callback should check if item exists or not. Profile item
* will not update untill this callback returns true. item id is passed to this callback
*
* <em>$display</em>, this callback should get details of item using $id passed to
* callback. Use fetch_template_file to return html template.
*
* @global array $cb_profile_item_callbacks
* @param string $type
* @param string $exists
* @param string $display
* @return boolean|array
*
*/
function add_profile_item_type_callback( $type, $exists, $display ) {
global $cb_profile_item_callbacks;
if ( !$cb_profile_item_callbacks ) {
if (
( !$type or isset( $cb_profile_item_callbacks[ $type ] ) ) or
( !$exists or !function_exists( $exists ) ) or
( !$display or !function_exists( $display ) )
) {
return false;
}
$callbacks[] = $exists;
$callbacks[] = $display;
return $cb_profile_item_callbacks[ $type ] = $callbacks;
}
/**
* Get profile item of provided $uid, if null
* current loggedin userid is used
*
* @param int $uid
* @return array|boolean
*/
function get_profile_item( $uid = null ) {
if ( is_null( $uid ) ) {
$uid = userid();
}
@ -689,13 +765,65 @@ function display_profile_item( $uid = null ) {
$result = db_select( $query );
if ( $result ) {
$result = $result[0];
return json_decode( $result[0]['profile_item'], true );
} else {
return false;
}
}
/**
* Checks if provided id and type is current
* profile item or not
*
* @param int $id
* @param string $type
* @param int $uid
* @return boolean
*/
function is_profile_item( $id, $type, $uid = null ) {
$item = get_profile_item ( $uid );
if ( $item['id'] == $id and $item['type'] == $type ) {
return true;
} else {
return false;
}
}
/**
* Remove profile item of user
*
* @global OBJECT $userquery
* @param int $uid
*/
function remove_profile_item( $uid=null ) {
global $userquery;
$userquery->removeProfileItem( $uid );
}
/**
* Displays the profile item of user
*
* @global array $cb_profile_item_callbacks
* @param int $uid
* @param array $assign
* @return boolean
*/
function display_profile_item( $uid = null, $assign = array() ) {
global $cb_profile_item_callbacks;
if ( !$cb_profile_item_callbacks ) {
return false;
}
$result = get_profile_item( $uid );
if ( $result ) {
$item = json_decode( $result['profile_item'], true );
// Database item is here, time to check if callback exists
if ( isset( $cb_profile_item_callbacks[ $item['type'] ] ) and function_exists( $cb_profile_item_callbacks[ $item['type'] ] ) ) {
return $cb_profile_item_callbacks[ $item['type'] ]( $item['id'] );
if ( isset( $cb_profile_item_callbacks[ $item['type'] ][1] ) and function_exists( $cb_profile_item_callbacks[ $item['type'] ][1] ) ) {
return $cb_profile_item_callbacks[ $item['type'] ][1]( $item['id'], $assign );
}
} else {
return false;

View file

@ -1463,6 +1463,32 @@ function get_video_menu($video)
return $menu;
}
/**
* Checks if video profile item exists and user is owner
* @global object $cbvid
* @param int $id
* @return boolean
*/
function checking_profile_item_video( $id ) {
global $cbvid;
if ( $cbvid->video_exists( $id ) ) {
if ( userid() != $cbvid->get_video_owner( $id, true ) ) {
e( lang('Unable to set video as profile item.') );
return false;
}
return true;
} else {
e( lang('Video does not exists') );
return false;
}
}
/**
* Show profile item
* @global object $cbvid
* @param int $id
* @return boolean
*/
function show_profile_item_video( $id ) {
global $cbvid;
$video = $cbvid->get_video_details( $id );

View file

@ -18,6 +18,12 @@ add_thumb_size('640x360');
add_thumb_size('original');
/**
* Users
*/
$cb_profile_item_callbacks = array();
add_profile_item_type_callback( 'v','checking_profile_item_video', 'show_profile_item_video' );
add_profile_item_type_callback( 'p','checking_profile_item_photo', 'show_profile_item_photo' );
/**
* Register metas
@ -95,8 +101,8 @@ function _manager_set_avatar_link( $photo ) {
function _set_cover_photo_link( $photo ) {
global $cbphoto;
if ( $photo['is_avatar'] == 'no' && userid() == $cbphoto->get_photo_owner( $photo['photo_id'] ) ) {
return '?cover='.$photo['photo_id'].'&cid='.$photo['collection_id'];
if ( $photo['is_avatar'] == 'no' && userid() == $cbphoto->get_photo_owner( $photo['photo_id'] ) && !is_collection_cover( $photo ) ) {
return '?cover='.$photo['photo_id'].'&cid='.$photo['collection_id'].'&from=myaccount';
}
}
@ -110,13 +116,14 @@ function _set_cover_photo_callback() {
global $cbcollection;
$pid = mysql_clean( $_GET['cover'] );
$cid = mysql_clean( $_GET['cid'] );
$myaccount = mysql_clean( get('from') );
if ( !$pid || !$cid ) {
e( lang('Unable to update collection cover photo.') );
return false;
}
if ( $cbcollection->set_cover_photo( $pid, $cid ) ) {
if ( $cbcollection->set_cover_photo( $pid, $cid, $myaccount ) ) {
e( lang('Collection cover photo has been updated.'), 'm' );
} else {
e( lang('Unable to update collection cover photo.') );
@ -131,23 +138,48 @@ function _make_profile_item_link( $photo ) {
return false;
}
global $userquery;
if ( !$userquery->isProfileItem($photo['photo_id'],'p') ) {
$data = array('title' => lang('Make profile item'), 'link' => '?makeProfileItem='.$photo['photo_id'].'&type=p' );
} else {
$data = array('title' => lang('Remove profile item'), 'link' => '?removeProfileItem='.$photo['photo_id'].'&type=p' );
}
/* Need to figure out a automated way to remove duplicate entries, for time time will work*/
$remove_query_variables = array( 'profile_item', 'type', 'profile_remove_item', 'callback_id' );
if ( !is_profile_item( $photo['photo_id'], 'p' ) ) {
$data = array('title' => lang('Make profile item'), 'link' => '?profile_item='.$photo['photo_id'].'&type=p', 'remove_query_variables' => $remove_query_variables );
} else {
$data = array('title' => lang('Remove profile item'), 'link' => '?profile_remove_item='.$photo['photo_id'].'&type=p', 'remove_query_variables' => $remove_query_variables );
}
return $data;
}
/**
* Callback for profile item
*/
function _make_profile_item_callback() {
global $userquery;
$make_item = mysql_clean( get('profile_item') );
$remove_item = mysql_clean( get('profile_remove_item') );
$type = mysql_clean( get('type') );
if ( $make_item && is_numeric( $make_item) && $type ) {
set_user_profile_item( $make_item, $type );
return true;
} else if ( $remove_item && is_numeric( $remove_item ) && $type ) {
remove_profile_item();
return true;
}
e( lang('Invalid action') );
return false;
}
add_photo_manager_link( lang('Exif data'), '_view_exif_data_link', false, true );
add_photo_manager_link( lang('Edit collection'), '_edit_collection_link', false, true );
add_photo_manager_link( lang('Make profile item'), '_make_profile_item_link', false, true );
add_photo_manager_link( lang('Make profile item'), '_make_profile_item_link', '_make_profile_item_callback', true );
add_photo_manager_link( lang('Set as avatar'), '_manager_set_avatar_link', false, true );
add_photo_manager_link( lang('Make collection cover'), '_set_cover_photo_link', '_set_cover_photo_callback', true );
$Cbucket->custom_get_photo_funcs[] = 'get_private_photo_thumb';
$Cbucket->custom_get_photo_funcs[] = 'is_collection_cover_mature';
/**
* Adding orders for photo manager
*/
@ -218,30 +250,44 @@ $usercontent->permissions = 'show_my_photos';
$usercontent->add_new_content();
$usercontent->object_group = 'content';
$usercontent->object = 'photos';
$usercontent->object = 'collections';
$usercontent->section = true;
$usercontent->content_type = 'tagged_in';
$usercontent->get_callback = 'cb_get_user_favorite_photos';
$usercontent->permissions = 'show_my_photos';
$usercontent->content_type = 'created';
$usercontent->get_callback = 'cb_get_user_collections';
$usercontent->permissions = 'show_my_collections';
$usercontent->add_new_content();
$usercontent->object_group = 'content';
$usercontent->object = 'collections';
$usercontent->section = true;
$usercontent->content_type = 'favorite';
$usercontent->get_callback = 'cb_get_user_favorite_collections';
$usercontent->permissions = 'show_my_collections';
$usercontent->add_new_content();
$usercontent->object_group = 'connections';
$usercontent->object = 'friends';
$usercontent->section = 'channels';
$usercontent->get_callback = 'cb_get_user_friends';
$usercontent->permissions = 'show_my_friends';
$usercontent->add_new_content();
$usercontent->object_group = 'connections';
$usercontent->object = 'subscriptions';
$usercontent->section = 'channels';
$usercontent->get_callback = 'cb_get_user_subscriptions';
$usercontent->permissions = 'show_my_subscriptions';
$usercontent->add_new_content();
$usercontent->object_group = 'connections';
$usercontent->object = 'subscribers';
$usercontent->section = 'channels';
$usercontent->get_callback = 'cb_get_user_subscribers';
$usercontent->permissions = 'show_my_subscribers';
$usercontent->add_new_content();
$usercontent->object_group = 'comments';
$usercontent->object = 'comments';
$usercontent->get_callback = 'cb_get_user_channel_comments';
$usercontent->add_new_content();
?>

View file

@ -86,7 +86,7 @@
</ul>
</div>
<div class="object-manager-labels">{if $photo.photo_id == $photo.cover_photo}<span class="label label-info">{lang code='Cover photo'}</span>{/if}{if $photo.featured == 'yes'}<span class="label label-success">{lang code='Featured'}</span>{/if}{if $photo.is_mature == 'yes'}<span class="label label-important" title="{lang code='Login is required to view this photo'}"> {lang code='Mature'}</span>{/if}</div>
<div class="object-manager-labels">{if is_collection_cover( $photo )}<span class="label label-info">{lang code='Cover photo'}</span>{/if}{if is_profile_item($photo.photo_id,'p')}<span class="label label-info">{lang code='Profile Item'}</span>{/if}{if $photo.featured == 'yes'}<span class="label label-success">{lang code='Featured'}</span>{/if}{if $photo.is_mature == 'yes'}<span class="label label-important" title="{lang code='Login is required to view this photo'}"> {lang code='Mature'}</span>{/if}</div>
</td>
</tr>
{/foreach}

View file

@ -347,7 +347,6 @@ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#000000', end
}
.user-profile-photo-item img {
min-height: 100%;
display: block;
margin: auto;
}

View file

@ -752,19 +752,26 @@ a.playlist .playlist-items-thumb.playlist-4-items .item-thumb img {
border-color: #aaa;
}
.view-channel-top-row-items .view-channel-top-row-item-block strong.user-subscribers {
.view-channel-top-row-items .view-channel-top-row-item-block strong.user-subscribers,
.view-channel-top-row-items .view-channel-top-row-item-block strong.user-comments {
display: block;
text-align: center;
background-color: inherit;
background-image: url('../images/icons/rss.png');
/*background-image: url('../images/icons/rss.png');
background-position: -6px 14px;
background-repeat: no-repeat;
background-repeat: no-repeat;*/
height: 100px;
font-size: 42px;
line-height: 100px;
color: #232323;
}
.view-channel-top-row-items .view-channel-top-row-item-block strong.user-comments {
/*background-image: url('../images/icons/comments.png');
background-size: 70%; */
background-position: -5px 20px;
}
.view-channel-top-row-item-block .top-row-content-block img {
max-width: none;
width: 100%;

View file

@ -1,6 +1,6 @@
<div class="user-profile-photo-item collection-box">
{$pd=json_decode($photo.photo_details,true)}
<div class="cbv3-scroller"><img src="{get_image_url($photo,'640')}" onload="$(this).parent().lionbars({ autohide: true }); " /></div>
<div class="cbv3-scroller"><img src="{get_image_url($photo,'l')}" onload="$(this).parent().lionbars({ autohide: true }); " /></div>
<div class="black-gradient absolute bottom manage-collection-item-details">
<h4><a href="{collection_links( $photo )}">{$photo.collection_name}</a></h4>
<div class="pull-left"><a href="{view_photo_link($photo)}">{lang code='View Photo'}</a></div>