more progress on the main photos module

This commit is contained in:
friendica 2012-10-24 22:21:35 -07:00
parent 05fd2c758c
commit 939543b26d
4 changed files with 45 additions and 45 deletions

View File

@ -1747,8 +1747,10 @@ if(! function_exists('profile_tabs')){
function profile_tabs($a, $is_owner=False, $nickname=Null){ function profile_tabs($a, $is_owner=False, $nickname=Null){
//echo "<pre>"; var_dump($a->user); killme(); //echo "<pre>"; var_dump($a->user); killme();
$channel = $a->get_channel();
if (is_null($nickname)) if (is_null($nickname))
$nickname = $a->user['nickname']; $nickname = $a->channel['channel_address'];
if(x($_GET,'tab')) if(x($_GET,'tab'))
$tab = notags(trim($_GET['tab'])); $tab = notags(trim($_GET['tab']));
@ -1765,7 +1767,7 @@ if(! function_exists('profile_tabs')){
), ),
array( array(
'label' => t('Profile'), 'label' => t('Profile'),
'url' => $url.'/?tab=profile', 'url' => $url.'?tab=profile',
'sel' => ((isset($tab) && $tab=='profile')?'active':''), 'sel' => ((isset($tab) && $tab=='profile')?'active':''),
'title' => t('Profile Details'), 'title' => t('Profile Details'),
'id' => 'profile-tab', 'id' => 'profile-tab',

View File

@ -23,7 +23,6 @@ function poller_run($argv, $argc){
require_once('library/simplepie/simplepie.inc'); require_once('library/simplepie/simplepie.inc');
require_once('include/items.php'); require_once('include/items.php');
require_once('include/Contact.php'); require_once('include/Contact.php');
require_once('include/email.php');
require_once('include/socgraph.php'); require_once('include/socgraph.php');
require_once('include/pidfile.php'); require_once('include/pidfile.php');

View File

@ -36,14 +36,14 @@ function photos_init(&$a) {
// FIXME // FIXME
$o .= '<div class="vcard">'; $o .= '<div class="vcard">';
$o .= '<div class="fn">' . $a->data['channel']['channel_name'] . '</div>'; $o .= '<div class="fn">' . $a->data['channel']['channel_name'] . '</div>';
$o .= '<div id="profile-photo-wrapper"><img class="photo" style="width: 175px; height: 175px;" src="' . $a->get_cached_avatar_image($a->get_baseurl() . '/photo/profile/' . $a->data['user']['uid']) . '" alt="' . $a->data['user']['username'] . '" /></div>'; $o .= '<div id="profile-photo-wrapper"><img class="photo" style="width: 175px; height: 175px;" src="' . $a->get_cached_avatar_image($a->get_baseurl() . '/photo/profile/' . $a->data['channel']['channel_id']) . '" alt="' . $a->data['user']['username'] . '" /></div>';
$o .= '</div>'; $o .= '</div>';
$albums_visible = ((intval($a->data['user']['hidewall']) && (! local_user()) && (! remote_user())) ? false : true); $albums_visible = ((intval($a->data['user']['hidewall']) && (! local_user()) && (! remote_user())) ? false : true);
if($albums_visible) { if($albums_visible) {
$o .= '<div id="side-bar-photos-albums" class="widget">'; $o .= '<div id="side-bar-photos-albums" class="widget">';
$o .= '<h3>' . '<a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '">' . t('Photo Albums') . '</a></h3>'; $o .= '<h3>' . '<a href="' . $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '">' . t('Photo Albums') . '</a></h3>';
$o .= '<ul>'; $o .= '<ul>';
foreach($albums as $album) { foreach($albums as $album) {
@ -57,8 +57,8 @@ function photos_init(&$a) {
} }
$o .= '</ul>'; $o .= '</ul>';
} }
if(local_user() && $a->data['user']['uid'] == local_user()) { if(local_user() && $a->data['channel']['channel_id'] == local_user()) {
$o .= '<div id="photo-albums-upload-link"><a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload" >' .t('Upload New Photos') . '</a></div>'; $o .= '<div id="photo-albums-upload-link"><a href="' . $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/upload" >' .t('Upload New Photos') . '</a></div>';
} }
$o .= '</div>'; $o .= '</div>';
@ -113,7 +113,7 @@ function photos_post(&$a) {
$can_post = false; $can_post = false;
$visitor = 0; $visitor = 0;
$page_owner_uid = $a->data['user']['uid']; $page_owner_uid = $a->data['channel']['channel_id'];
$community_page = (($a->data['user']['page-flags'] == PAGE_COMMUNITY) ? true : false); $community_page = (($a->data['user']['page-flags'] == PAGE_COMMUNITY) ? true : false);
if((local_user()) && (local_user() == $page_owner_uid)) if((local_user()) && (local_user() == $page_owner_uid))
@ -252,7 +252,7 @@ function photos_post(&$a) {
} }
} }
} }
goaway($a->get_baseurl() . '/photos/' . $a->data['user']['nickname']); goaway($a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address']);
return; // NOTREACHED return; // NOTREACHED
} }
@ -430,7 +430,7 @@ function photos_post(&$a) {
$arr['visible'] = $visibility; $arr['visible'] = $visibility;
$arr['origin'] = 1; $arr['origin'] = 1;
$arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource_id'] . ']' $arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $p[0]['resource_id'] . ']'
. '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource_id'] . '-' . $p[0]['scale'] . '.'. $ext . '[/img]' . '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource_id'] . '-' . $p[0]['scale'] . '.'. $ext . '[/img]'
. '[/url]'; . '[/url]';
@ -743,10 +743,10 @@ function photos_post(&$a) {
$r = q("select sum(octet_length(data)) as total from photo where uid = %d and scale = 0 and album != 'Contact Photos' ", $r = q("select sum(octet_length(data)) as total from photo where uid = %d and scale = 0 and album != 'Contact Photos' ",
intval($a->data['user']['uid']) intval($a->data['channel']['channel_id'])
); );
$limit = service_class_fetch($a->data['user']['uid'],'photo_upload_limit'); $limit = service_class_fetch($a->data['channel']['channel_id'],'photo_upload_limit');
if(($limit !== false) && (($r[0]['total'] + strlen($imagedata)) > $limit)) { if(($limit !== false) && (($r[0]['total'] + strlen($imagedata)) > $limit)) {
notice( upgrade_message() . EOL ); notice( upgrade_message() . EOL );
@ -882,7 +882,7 @@ function photos_content(&$a) {
require_once('include/security.php'); require_once('include/security.php');
require_once('include/conversation.php'); require_once('include/conversation.php');
if(! x($a->data,'user')) { if(! x($a->data,'channel')) {
notice( t('No photos selected') . EOL ); notice( t('No photos selected') . EOL );
return; return;
} }
@ -895,17 +895,17 @@ function photos_content(&$a) {
// Parse arguments // Parse arguments
// //
if($a->argc > 3) { if(argc() > 3) {
$datatype = $a->argv[2]; $datatype = argv(2);
$datum = $a->argv[3]; $datum = argv(3);
} }
elseif(($a->argc > 2) && ($a->argv[2] === 'upload')) elseif((argc() > 2) && (argv(2) === 'upload'))
$datatype = 'upload'; $datatype = 'upload';
else else
$datatype = 'summary'; $datatype = 'summary';
if($a->argc > 4) if(argc() > 4)
$cmd = $a->argv[4]; $cmd = argv(4);
else else
$cmd = 'view'; $cmd = 'view';
@ -919,7 +919,7 @@ function photos_content(&$a) {
$remote_contact = false; $remote_contact = false;
$contact_id = 0; $contact_id = 0;
$owner_uid = $a->data['user']['uid']; $owner_uid = $a->data['channel']['channel_id'];
$community_page = (($a->data['user']['page-flags'] == PAGE_COMMUNITY) ? true : false); $community_page = (($a->data['user']['page-flags'] == PAGE_COMMUNITY) ? true : false);
@ -994,7 +994,7 @@ function photos_content(&$a) {
// tabs // tabs
$_is_owner = (local_user() && (local_user() == $owner_uid)); $_is_owner = (local_user() && (local_user() == $owner_uid));
$o .= profile_tabs($a,$_is_owner, $a->data['user']['nickname']); $o .= profile_tabs($a,$_is_owner, $a->data['channel']['channel_address']);
// //
// dispatch request // dispatch request
@ -1030,7 +1030,7 @@ function photos_content(&$a) {
$uploader = ''; $uploader = '';
$ret = array('post_url' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'], $ret = array('post_url' => $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'],
'addon_text' => $uploader, 'addon_text' => $uploader,
'default_upload' => true); 'default_upload' => true);
@ -1042,11 +1042,11 @@ function photos_content(&$a) {
$r = q("select sum(octet_length(data)) as total from photo where uid = %d and scale = 0 and album != 'Contact Photos' ", $r = q("select sum(octet_length(data)) as total from photo where uid = %d and scale = 0 and album != 'Contact Photos' ",
intval($a->data['user']['uid']) intval($a->data['channel']['channel_id'])
); );
$limit = service_class_fetch($a->data['user']['uid'],'photo_upload_limit'); $limit = service_class_fetch($a->data['channel']['channel_id'],'photo_upload_limit');
if($limit !== false) { if($limit !== false) {
$usage_message = sprintf( t("You have used %1$.2f Mbytes of %2$.2f Mbytes photo storage."), $r[0]['total'] / 1024000, $limit / 1024000 ); $usage_message = sprintf( t("You have used %1$.2f Mbytes of %2$.2f Mbytes photo storage."), $r[0]['total'] / 1024000, $limit / 1024000 );
} }
@ -1060,7 +1060,7 @@ function photos_content(&$a) {
'$pagename' => t('Upload Photos'), '$pagename' => t('Upload Photos'),
'$sessid' => session_id(), '$sessid' => session_id(),
'$usage' => $usage_message, '$usage' => $usage_message,
'$nickname' => $a->data['user']['nickname'], '$nickname' => $a->data['channel']['channel_address'],
'$newalbum' => t('New album name: '), '$newalbum' => t('New album name: '),
'$existalbumtext' => t('or existing album name: '), '$existalbumtext' => t('or existing album name: '),
'$nosharetext' => t('Do not show a status post for this upload'), '$nosharetext' => t('Do not show a status post for this upload'),
@ -1111,7 +1111,7 @@ function photos_content(&$a) {
$edit_tpl = get_markup_template('album_edit.tpl'); $edit_tpl = get_markup_template('album_edit.tpl');
$o .= replace_macros($edit_tpl,array( $o .= replace_macros($edit_tpl,array(
'$nametext' => t('New album name: '), '$nametext' => t('New album name: '),
'$nickname' => $a->data['user']['nickname'], '$nickname' => $a->data['channel']['channel_address'],
'$album' => template_escape($album), '$album' => template_escape($album),
'$hexalbum' => bin2hex($album), '$hexalbum' => bin2hex($album),
'$submit' => t('Submit'), '$submit' => t('Submit'),
@ -1124,20 +1124,20 @@ function photos_content(&$a) {
if(($album !== t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) { if(($album !== t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) {
if($can_post) { if($can_post) {
$o .= '<div id="album-edit-link"><a href="'. $a->get_baseurl() . '/photos/' $o .= '<div id="album-edit-link"><a href="'. $a->get_baseurl() . '/photos/'
. $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '/edit' . '">' . $a->data['channel']['channel_address'] . '/album/' . bin2hex($album) . '/edit' . '">'
. t('Edit Album') . '</a></div>'; . t('Edit Album') . '</a></div>';
} }
} }
} }
if($_GET['order'] === 'posted') if($_GET['order'] === 'posted')
$o .= '<div class="photos-upload-link" ><a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '" >' . t('Show Newest First') . '</a></div>'; $o .= '<div class="photos-upload-link" ><a href="' . $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex($album) . '" >' . t('Show Newest First') . '</a></div>';
else else
$o .= '<div class="photos-upload-link" ><a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '?f=&order=posted" >' . t('Show Oldest First') . '</a></div>'; $o .= '<div class="photos-upload-link" ><a href="' . $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex($album) . '?f=&order=posted" >' . t('Show Oldest First') . '</a></div>';
if($can_post) { if($can_post) {
$o .= '<div class="photos-upload-link" ><a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload/' . bin2hex($album) . '" >' . t('Upload New Photos') . '</a></div>'; $o .= '<div class="photos-upload-link" ><a href="' . $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/upload/' . bin2hex($album) . '" >' . t('Upload New Photos') . '</a></div>';
} }
@ -1155,7 +1155,7 @@ function photos_content(&$a) {
$o .= replace_macros($tpl,array( $o .= replace_macros($tpl,array(
'$id' => $rr['id'], '$id' => $rr['id'],
'$twist' => ' ' . $twist . rand(2,4), '$twist' => ' ' . $twist . rand(2,4),
'$photolink' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource_id'] '$photolink' => $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $rr['resource_id']
. (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''), . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''),
'$phototitle' => t('View Photo'), '$phototitle' => t('View Photo'),
'$imgsrc' => $a->get_baseurl() . '/photo/' . $rr['resource_id'] . '-' . $rr['scale'] . '.' .$ext, '$imgsrc' => $a->get_baseurl() . '/photo/' . $rr['resource_id'] . '-' . $rr['scale'] . '.' .$ext,
@ -1226,8 +1226,8 @@ function photos_content(&$a) {
} }
} }
$edit_suffix = ((($cmd === 'edit') && ($can_post)) ? '/edit' : ''); $edit_suffix = ((($cmd === 'edit') && ($can_post)) ? '/edit' : '');
$prevlink = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource_id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); $prevlink = $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $prvnxt[$prv]['resource_id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
$nextlink = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource_id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); $nextlink = $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $prvnxt[$nxt]['resource_id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
} }
@ -1244,13 +1244,13 @@ function photos_content(&$a) {
} }
} }
$album_link = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($ph[0]['album']); $album_link = $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex($ph[0]['album']);
$tools = Null; $tools = Null;
$lock = Null; $lock = Null;
if($can_post && ($ph[0]['uid'] == $owner_uid)) { if($can_post && ($ph[0]['uid'] == $owner_uid)) {
$tools = array( $tools = array(
'edit' => array($a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $datum . (($cmd === 'edit') ? '' : '/edit'), (($cmd === 'edit') ? t('View photo') : t('Edit photo'))), 'edit' => array($a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $datum . (($cmd === 'edit') ? '' : '/edit'), (($cmd === 'edit') ? t('View photo') : t('Edit photo'))),
'profile'=>array($a->get_baseurl() . '/profile_photo/use/'.$ph[0]['resource_id'], t('Use as profile photo')), 'profile'=>array($a->get_baseurl() . '/profile_photo/use/'.$ph[0]['resource_id'], t('Use as profile photo')),
); );
@ -1364,7 +1364,7 @@ function photos_content(&$a) {
'$rotateccw' => t('Rotate CCW (left)'), '$rotateccw' => t('Rotate CCW (left)'),
'$album' => template_escape($ph[0]['album']), '$album' => template_escape($ph[0]['album']),
'$newalbum' => t('New album name'), '$newalbum' => t('New album name'),
'$nickname' => $a->data['user']['nickname'], '$nickname' => $a->data['channel']['channel_address'],
'$resource_id' => $ph[0]['resource_id'], '$resource_id' => $ph[0]['resource_id'],
'$capt_label' => t('Caption'), '$capt_label' => t('Caption'),
'$caption' => template_escape($ph[0]['desc']), '$caption' => template_escape($ph[0]['desc']),
@ -1554,7 +1554,7 @@ function photos_content(&$a) {
$r = q("SELECT `resource_id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' $r = q("SELECT `resource_id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
$sql_extra GROUP BY `resource_id`", $sql_extra GROUP BY `resource_id`",
intval($a->data['user']['uid']), intval($a->data['channel']['channel_id']),
dbesc('Contact Photos'), dbesc('Contact Photos'),
dbesc( t('Contact Photos')) dbesc( t('Contact Photos'))
); );
@ -1566,7 +1566,7 @@ function photos_content(&$a) {
$r = q("SELECT `resource_id`, `id`, `filename`, type, `album`, max(`scale`) AS `scale` FROM `photo` $r = q("SELECT `resource_id`, `id`, `filename`, type, `album`, max(`scale`) AS `scale` FROM `photo`
WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
$sql_extra GROUP BY `resource_id` ORDER BY `created` DESC LIMIT %d , %d", $sql_extra GROUP BY `resource_id` ORDER BY `created` DESC LIMIT %d , %d",
intval($a->data['user']['uid']), intval($a->data['channel']['channel_id']),
dbesc('Contact Photos'), dbesc('Contact Photos'),
dbesc( t('Contact Photos')), dbesc( t('Contact Photos')),
intval($a->pager['start']), intval($a->pager['start']),
@ -1588,12 +1588,12 @@ function photos_content(&$a) {
$photos[] = array( $photos[] = array(
'id' => $rr['id'], 'id' => $rr['id'],
'twist' => ' ' . $twist . rand(2,4), 'twist' => ' ' . $twist . rand(2,4),
'link' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource_id'], 'link' => $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $rr['resource_id'],
'title' => t('View Photo'), 'title' => t('View Photo'),
'src' => $a->get_baseurl() . '/photo/' . $rr['resource_id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.' . $ext, 'src' => $a->get_baseurl() . '/photo/' . $rr['resource_id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.' . $ext,
'alt' => template_escape($rr['filename']), 'alt' => template_escape($rr['filename']),
'album' => array( 'album' => array(
'link' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']), 'link' => $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex($rr['album']),
'name' => template_escape($rr['album']), 'name' => template_escape($rr['album']),
'alt' => t('View Album'), 'alt' => t('View Album'),
), ),
@ -1606,7 +1606,7 @@ function photos_content(&$a) {
$o .= replace_macros($tpl,array( $o .= replace_macros($tpl,array(
'$title' => t('Recent Photos'), '$title' => t('Recent Photos'),
'$can_post' => $can_post, '$can_post' => $can_post,
'$upload' => array(t('Upload New Photos'), $a->get_baseurl().'/photos/'.$a->data['user']['nickname'].'/upload'), '$upload' => array(t('Upload New Photos'), $a->get_baseurl().'/photos/'.$a->data['channel']['channel_address'].'/upload'),
'$photos' => $photos, '$photos' => $photos,
)); ));

View File

@ -57,7 +57,6 @@ function profile_content(&$a, $update = 0) {
return login(); return login();
} }
$channel = $a->get_channel();
require_once("include/bbcode.php"); require_once("include/bbcode.php");
require_once('include/security.php'); require_once('include/security.php');
@ -127,7 +126,7 @@ function profile_content(&$a, $update = 0) {
if(x($_GET,'tab')) if(x($_GET,'tab'))
$tab = notags(trim($_GET['tab'])); $tab = notags(trim($_GET['tab']));
$o.=profile_tabs($a, $is_owner, $a->profile['nickname']); $o .= profile_tabs($a, $is_owner, $a->profile['channel_address']);
if($tab === 'profile') { if($tab === 'profile') {
@ -152,8 +151,8 @@ function profile_content(&$a, $update = 0) {
'is_owner' => $is_owner, 'is_owner' => $is_owner,
'allow_location' => ((($is_owner || $commvisitor) && $a->profile['allow_location']) ? true : false), 'allow_location' => ((($is_owner || $commvisitor) && $a->profile['allow_location']) ? true : false),
'default_location' => (($is_owner) ? $a->user['default-location'] : ''), 'default_location' => (($is_owner) ? $a->user['default-location'] : ''),
'nickname' => $channel['channel_address'], 'nickname' => $a->profile['channel_address'],
'lockstate' => (((strlen($channel['channel_allow_cid'])) || (strlen($channel['channel_allow_gid'])) || (strlen($channel['channel_deny_cid'])) || (strlen($channel['channel_deny_gid']))) ? 'lock' : 'unlock'), 'lockstate' => (((strlen($a->profile['channel_allow_cid'])) || (strlen($a->profile['channel_allow_gid'])) || (strlen($a->profile['channel_deny_cid'])) || (strlen($a->profile['channel_deny_gid']))) ? 'lock' : 'unlock'),
'acl' => (($is_owner) ? populate_acl($channel, $celeb) : ''), 'acl' => (($is_owner) ? populate_acl($channel, $celeb) : ''),
'bang' => '', 'bang' => '',
'visitor' => (($is_owner || $commvisitor) ? 'block' : 'none'), 'visitor' => (($is_owner || $commvisitor) ? 'block' : 'none'),