2 require_once('include/Photo.php');
3 require_once('include/items.php');
4 require_once('include/acl_selectors.php');
5 require_once('include/bbcode.php');
6 require_once('include/security.php');
9 function photos_init(&$a) {
12 if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
19 $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
26 $a->data['user'] = $r[0];
28 $sql_extra = permissions_sql($a->data['user']['uid']);
30 $albums = q("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = %d $sql_extra ",
31 intval($a->data['user']['uid'])
35 $a->data['albums'] = $albums;
37 $o .= '<div class="vcard">';
38 $o .= '<div class="fn">' . $a->data['user']['username'] . '</div>';
39 $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'] . '.jpg') . '" alt="' . $a->data['user']['username'] . '" /></div>';
42 $albums_visible = ((intval($a->data['user']['hidewall']) && (! local_user()) && (! remote_user())) ? false : true);
45 $o .= '<div id="side-bar-photos-albums" class="widget">';
46 $o .= '<h3>' . '<a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '">' . t('Photo Albums') . '</a></h3>';
49 foreach($albums as $album) {
51 // don't show contact photos. We once translated this name, but then you could still access it under
52 // a different language setting. Now we store the name in English and check in English (and translated for legacy albums).
54 if((! strlen($album['album'])) || ($album['album'] === 'Contact Photos') || ($album['album'] === t('Contact Photos')))
56 $o .= '<li>' . '<a href="photos/' . $a->argv[1] . '/album/' . bin2hex($album['album']) . '" >' . $album['album'] . '</a></li>';
60 if(local_user() && $a->data['user']['uid'] == local_user()) {
61 $o .= '<div id="photo-albums-upload-link"><a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload" >' .t('Upload New Photos') . '</a></div>';
67 if(! x($a->page,'aside'))
68 $a->page['aside'] = '';
69 $a->page['aside'] .= $o;
72 $a->page['htmlhead'] .= "<script> var ispublic = '" . t('everybody') . "';" ;
74 $a->page['htmlhead'] .= <<< EOT
76 $(document).ready(function() {
78 $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
80 $('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {
81 selstr = $(this).text();
82 $('#jot-perms-icon').removeClass('unlock').addClass('lock');
83 $('#jot-public').hide();
86 $('#jot-perms-icon').removeClass('lock').addClass('unlock');
87 $('#jot-public').show();
103 function photos_post(&$a) {
105 logger('mod-photos: photos_post: begin' , LOGGER_DEBUG);
108 logger('mod_photos: REQUEST ' . print_r($_REQUEST,true), LOGGER_DATA);
109 logger('mod_photos: FILES ' . print_r($_FILES,true), LOGGER_DATA);
111 $phototypes = Photo::supportedTypes();
116 $page_owner_uid = $a->data['user']['uid'];
117 $community_page = (($a->data['user']['page-flags'] == PAGE_COMMUNITY) ? true : false);
119 if((local_user()) && (local_user() == $page_owner_uid))
122 if($community_page && remote_user()) {
123 $r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
124 intval(remote_user()),
125 intval($page_owner_uid)
129 $visitor = remote_user();
135 notice( t('Permission denied.') . EOL );
139 $r = q("SELECT `contact`.*, `user`.`nickname` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
140 WHERE `user`.`uid` = %d AND `self` = 1 LIMIT 1",
141 intval($page_owner_uid)
145 notice( t('Contact information unavailable') . EOL);
146 logger('photos_post: unable to locate contact record for page owner. uid=' . $page_owner_uid);
150 $owner_record = $r[0];
153 if(($a->argc > 3) && ($a->argv[2] === 'album')) {
154 $album = hex2bin($a->argv[3]);
156 if($album === t('Profile Photos') || $album === 'Contact Photos' || $album === t('Contact Photos')) {
157 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
158 return; // NOTREACHED
161 $r = q("SELECT count(*) FROM `photo` WHERE `album` = '%s' AND `uid` = %d",
163 intval($page_owner_uid)
166 notice( t('Album not found.') . EOL);
167 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
168 return; // NOTREACHED
171 $newalbum = notags(trim($_POST['albumname']));
172 if($newalbum != $album) {
173 q("UPDATE `photo` SET `album` = '%s' WHERE `album` = '%s' AND `uid` = %d",
176 intval($page_owner_uid)
178 $newurl = str_replace(bin2hex($album),bin2hex($newalbum),$_SESSION['photo_return']);
179 goaway($a->get_baseurl() . '/' . $newurl);
180 return; // NOTREACHED
184 if($_POST['dropalbum'] == t('Delete Album')) {
188 // get the list of photos we are about to delete
191 $r = q("SELECT distinct(`resource-id`) as `rid` FROM `photo` WHERE `contact-id` = %d AND `uid` = %d AND `album` = '%s'",
193 intval($page_owner_uid),
198 $r = q("SELECT distinct(`resource-id`) as `rid` FROM `photo` WHERE `uid` = %d AND `album` = '%s'",
199 intval(local_user()),
205 $res[] = "'" . dbesc($rr['rid']) . "'" ;
209 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
210 return; // NOTREACHED
213 $str_res = implode(',', $res);
215 // remove the associated photos
217 q("DELETE FROM `photo` WHERE `resource-id` IN ( $str_res ) AND `uid` = %d",
218 intval($page_owner_uid)
221 // find and delete the corresponding item with all the comments and likes/dislikes
223 $r = q("SELECT `parent-uri` FROM `item` WHERE `resource-id` IN ( $str_res ) AND `uid` = %d",
224 intval($page_owner_uid)
228 q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
229 dbesc(datetime_convert()),
230 dbesc($rr['parent-uri']),
231 intval($page_owner_uid)
234 $drop_id = intval($rr['id']);
236 // send the notification upstream/downstream as the case may be
239 proc_run('php',"include/notifier.php","drop","$drop_id");
243 goaway($a->get_baseurl() . '/photos/' . $a->data['user']['nickname']);
244 return; // NOTREACHED
247 if(($a->argc > 2) && (x($_POST,'delete')) && ($_POST['delete'] == t('Delete Photo'))) {
249 // same as above but remove single photo
252 $r = q("SELECT `id`, `resource-id` FROM `photo` WHERE `contact-id` = %d AND `uid` = %d AND `resource-id` = '%s' LIMIT 1",
254 intval($page_owner_uid),
259 $r = q("SELECT `id`, `resource-id` FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' LIMIT 1",
260 intval(local_user()),
265 q("DELETE FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'",
266 intval($page_owner_uid),
267 dbesc($r[0]['resource-id'])
269 $i = q("SELECT * FROM `item` WHERE `resource-id` = '%s' AND `uid` = %d LIMIT 1",
270 dbesc($r[0]['resource-id']),
271 intval($page_owner_uid)
274 q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
275 dbesc(datetime_convert()),
276 dbesc(datetime_convert()),
278 intval($page_owner_uid)
281 $url = $a->get_baseurl();
282 $drop_id = intval($i[0]['id']);
285 proc_run('php',"include/notifier.php","drop","$drop_id");
289 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
290 return; // NOTREACHED
293 if(($a->argc > 2) && ((x($_POST,'desc') !== false) || (x($_POST,'newtag') !== false)) || (x($_POST,'albname') !== false)) {
296 $desc = ((x($_POST,'desc')) ? notags(trim($_POST['desc'])) : '');
297 $rawtags = ((x($_POST,'newtag')) ? notags(trim($_POST['newtag'])) : '');
298 $item_id = ((x($_POST,'item_id')) ? intval($_POST['item_id']) : 0);
299 $albname = ((x($_POST,'albname')) ? notags(trim($_POST['albname'])) : '');
300 $str_group_allow = perms2str($_POST['group_allow']);
301 $str_contact_allow = perms2str($_POST['contact_allow']);
302 $str_group_deny = perms2str($_POST['group_deny']);
303 $str_contact_deny = perms2str($_POST['contact_deny']);
305 $resource_id = $a->argv[2];
307 if(! strlen($albname))
308 $albname = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y');
311 if((x($_POST,'rotate') !== false) &&
312 ( (intval($_POST['rotate']) == 1) || (intval($_POST['rotate']) == 2) )) {
315 $r = q("select * from photo where `resource-id` = '%s' and uid = %d and scale = 0 limit 1",
317 intval($page_owner_uid)
320 $ph = new Photo($r[0]['data'], $r[0]['type']);
321 if($ph->is_valid()) {
322 $rotate_deg = ( (intval($_POST['rotate']) == 1) ? 270 : 90 );
323 $ph->rotate($rotate_deg);
325 $width = $ph->getWidth();
326 $height = $ph->getHeight();
328 $x = q("update photo set data = '%s', height = %d, width = %d where `resource-id` = '%s' and uid = %d and scale = 0 limit 1",
329 dbesc($ph->imageString()),
333 intval($page_owner_uid)
336 if($width > 640 || $height > 640) {
337 $ph->scaleImage(640);
338 $width = $ph->getWidth();
339 $height = $ph->getHeight();
341 $x = q("update photo set data = '%s', height = %d, width = %d where `resource-id` = '%s' and uid = %d and scale = 1 limit 1",
342 dbesc($ph->imageString()),
346 intval($page_owner_uid)
350 if($width > 320 || $height > 320) {
351 $ph->scaleImage(320);
352 $width = $ph->getWidth();
353 $height = $ph->getHeight();
355 $x = q("update photo set data = '%s', height = %d, width = %d where `resource-id` = '%s' and uid = %d and scale = 2 limit 1",
356 dbesc($ph->imageString()),
360 intval($page_owner_uid)
367 $p = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d ORDER BY `scale` DESC",
369 intval($page_owner_uid)
372 $ext = $phototypes[$p[0]['type']];
373 $r = q("UPDATE `photo` SET `desc` = '%s', `album` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' WHERE `resource-id` = '%s' AND `uid` = %d",
376 dbesc($str_contact_allow),
377 dbesc($str_group_allow),
378 dbesc($str_contact_deny),
379 dbesc($str_group_deny),
381 intval($page_owner_uid)
385 /* Don't make the item visible if the only change was the album name */
388 if($p[0]['desc'] !== $desc || strlen($rawtags))
393 // Create item container
396 $uri = item_new_uri($a->get_hostname(),$page_owner_uid);
400 $arr['uid'] = $page_owner_uid;
402 $arr['parent-uri'] = $uri;
403 $arr['type'] = 'photo';
405 $arr['resource-id'] = $p[0]['resource-id'];
406 $arr['contact-id'] = $owner_record['id'];
407 $arr['owner-name'] = $owner_record['name'];
408 $arr['owner-link'] = $owner_record['url'];
409 $arr['owner-avatar'] = $owner_record['thumb'];
410 $arr['author-name'] = $owner_record['name'];
411 $arr['author-link'] = $owner_record['url'];
412 $arr['author-avatar'] = $owner_record['thumb'];
413 $arr['title'] = $title;
414 $arr['allow_cid'] = $p[0]['allow_cid'];
415 $arr['allow_gid'] = $p[0]['allow_gid'];
416 $arr['deny_cid'] = $p[0]['deny_cid'];
417 $arr['deny_gid'] = $p[0]['deny_gid'];
418 $arr['last-child'] = 1;
419 $arr['visible'] = $visibility;
422 $arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']'
423 . '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.'. $ext . '[/img]'
426 $item_id = item_store($arr);
431 $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
433 intval($page_owner_uid)
437 $old_tag = $r[0]['tag'];
438 $old_inform = $r[0]['inform'];
441 if(strlen($rawtags)) {
446 // if the new tag doesn't have a namespace specifier (@foo or #foo) give it a hashtag
448 $x = substr($rawtags,0,1);
449 if($x !== '@' && $x !== '#')
450 $rawtags = '#' . $rawtags;
453 $tags = get_tags($rawtags);
456 foreach($tags as $tag) {
459 if(strpos($tag,'@') === 0) {
460 $name = substr($tag,1);
461 if((strpos($name,'@')) || (strpos($name,'http://'))) {
463 $links = @lrdd($name);
465 foreach($links as $link) {
466 if($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page')
467 $profile = $link['@attributes']['href'];
468 if($link['@attributes']['rel'] === 'salmon') {
469 $salmon = '$url:' . str_replace(',','%sc',$link['@attributes']['href']);
476 $taginfo[] = array($newname,$profile,$salmon);
482 if(strrpos($newname,'+'))
483 $tagcid = intval(substr($newname,strrpos($newname,'+') + 1));
486 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
491 elseif(strstr($name,'_') || strstr($name,' ')) {
492 $newname = str_replace('_',' ',$name);
493 $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
495 intval($page_owner_uid)
499 $r = q("SELECT * FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1",
502 intval($page_owner_uid)
506 $newname = $r[0]['name'];
507 $profile = $r[0]['url'];
508 $notify = 'cid:' . $r[0]['id'];
515 if(substr($notify,0,4) === 'cid:')
516 $taginfo[] = array($newname,$profile,$notify,$r[0],'@[url=' . str_replace(',','%2c',$profile) . ']' . $newname . '[/url]');
518 $taginfo[] = array($newname,$profile,$notify,null,$str_tags .= '@[url=' . $profile . ']' . $newname . '[/url]');
519 if(strlen($str_tags))
521 $profile = str_replace(',','%2c',$profile);
522 $str_tags .= '@[url=' . $profile . ']' . $newname . '[/url]';
529 if(strlen($newtag) && strlen($str_tags))
531 $newtag .= $str_tags;
533 $newinform = $old_inform;
534 if(strlen($newinform) && strlen($inform))
536 $newinform .= $inform;
538 $r = q("UPDATE `item` SET `tag` = '%s', `inform` = '%s', `edited` = '%s', `changed` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
541 dbesc(datetime_convert()),
542 dbesc(datetime_convert()),
544 intval($page_owner_uid)
548 foreach($p as $scales) {
549 if(intval($scales['scale']) == 2) {
553 if(intval($scales['scale']) == 4) {
559 if(count($taginfo)) {
560 foreach($taginfo as $tagged) {
562 $uri = item_new_uri($a->get_hostname(),$page_owner_uid);
566 $arr['uid'] = $page_owner_uid;
568 $arr['parent-uri'] = $uri;
569 $arr['type'] = 'activity';
571 $arr['contact-id'] = $owner_record['id'];
572 $arr['owner-name'] = $owner_record['name'];
573 $arr['owner-link'] = $owner_record['url'];
574 $arr['owner-avatar'] = $owner_record['thumb'];
575 $arr['author-name'] = $owner_record['name'];
576 $arr['author-link'] = $owner_record['url'];
577 $arr['author-avatar'] = $owner_record['thumb'];
579 $arr['allow_cid'] = $p[0]['allow_cid'];
580 $arr['allow_gid'] = $p[0]['allow_gid'];
581 $arr['deny_cid'] = $p[0]['deny_cid'];
582 $arr['deny_gid'] = $p[0]['deny_gid'];
583 $arr['last-child'] = 1;
585 $arr['verb'] = ACTIVITY_TAG;
586 $arr['object-type'] = ACTIVITY_OBJ_PERSON;
587 $arr['target-type'] = ACTIVITY_OBJ_PHOTO;
588 $arr['tag'] = $tagged[4];
589 $arr['inform'] = $tagged[2];
591 $arr['body'] = '[url=' . $tagged[1] . ']' . $tagged[0] . '[/url]' . ' ' . t('was tagged in a') . ' ' . '[url=' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . t('photo') . '[/url]' . ' ' . t('by') . ' ' . '[url=' . $owner_record['url'] . ']' . $owner_record['name'] . '[/url]' ;
592 $arr['body'] .= "\n\n" . '[url=' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . '[img]' . $a->get_baseurl() . "/photo/" . $p[0]['resource-id'] . '-' . $best . '.' . $ext . '[/img][/url]' . "\n" ;
594 $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $tagged[0] . '</title><id>' . $tagged[1] . '/' . $tagged[0] . '</id>';
595 $arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $tagged[1] . '" />' . "\n");
597 $arr['object'] .= xmlify('<link rel="photo" type="'.$p[0]['type'].'" href="' . $tagged[3]['photo'] . '" />' . "\n");
598 $arr['object'] .= '</link></object>' . "\n";
600 $arr['target'] = '<target><type>' . ACTIVITY_OBJ_PHOTO . '</type><title>' . $p[0]['desc'] . '</title><id>'
601 . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . '</id>';
602 $arr['target'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . '" />' . "\n" . '<link rel="preview" type="'.$p[0]['type'].'" href="' . $a->get_baseurl() . "/photo/" . $p[0]['resource-id'] . '-' . $best . '.' . $ext . '" />') . '</link></target>';
604 $item_id = item_store($arr);
606 q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1",
607 dbesc($a->get_baseurl() . '/display/' . $owner_record['nickname'] . '/' . $item_id),
608 intval($page_owner_uid),
612 proc_run('php',"include/notifier.php","tag","$item_id");
619 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
620 return; // NOTREACHED
625 * default post action - upload a photo
628 call_hooks('photo_post_init', $_POST);
631 * Determine the album to use
634 $album = notags(trim($_REQUEST['album']));
635 $newalbum = notags(trim($_REQUEST['newalbum']));
637 logger('mod/photos.php: photos_post(): album= ' . $album . ' newalbum= ' . $newalbum , LOGGER_DEBUG);
639 if(! strlen($album)) {
640 if(strlen($newalbum))
643 $album = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y');
648 * We create a wall item for every photo, but we don't want to
649 * overwhelm the data stream with a hundred newly uploaded photos.
650 * So we will make the first photo uploaded to this album in the last several hours
651 * visible by default, the rest will become visible over time when and if
652 * they acquire comments, likes, dislikes, and/or tags
656 $r = q("SELECT * FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `created` > UTC_TIMESTAMP() - INTERVAL 3 HOUR ",
658 intval($page_owner_uid)
660 if((! count($r)) || ($album == t('Profile Photos')))
665 if(intval($_REQUEST['not_visible']) || $_REQUEST['not_visible'] === 'true')
668 $str_group_allow = perms2str(((is_array($_REQUEST['group_allow'])) ? $_REQUEST['group_allow'] : explode(',',$_REQUEST['group_allow'])));
669 $str_contact_allow = perms2str(((is_array($_REQUEST['contact_allow'])) ? $_REQUEST['contact_allow'] : explode(',',$_REQUEST['contact_allow'])));
670 $str_group_deny = perms2str(((is_array($_REQUEST['group_deny'])) ? $_REQUEST['group_deny'] : explode(',',$_REQUEST['group_deny'])));
671 $str_contact_deny = perms2str(((is_array($_REQUEST['contact_deny'])) ? $_REQUEST['contact_deny'] : explode(',',$_REQUEST['contact_deny'])));
673 $ret = array('src' => '', 'filename' => '', 'filesize' => 0, 'type' => '');
675 call_hooks('photo_post_file',$ret);
677 if(x($ret,'src') && x($ret,'filesize')) {
679 $filename = $ret['filename'];
680 $filesize = $ret['filesize'];
681 $type = $ret['type'];
684 $src = $_FILES['userfile']['tmp_name'];
685 $filename = basename($_FILES['userfile']['name']);
686 $filesize = intval($_FILES['userfile']['size']);
687 $type = $_FILES['userfile']['type'];
689 if ($type=="") $type=guess_image_type($filename);
691 logger('photos: upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes', LOGGER_DEBUG);
693 $maximagesize = get_config('system','maximagesize');
695 if(($maximagesize) && ($filesize > $maximagesize)) {
696 notice( t('Image exceeds size limit of ') . $maximagesize . EOL);
699 call_hooks('photo_post_end',$foo);
704 notice( t('Image file is empty.') . EOL);
707 call_hooks('photo_post_end',$foo);
711 logger('mod/photos.php: photos_post(): loading the contents of ' . $src , LOGGER_DEBUG);
713 $imagedata = @file_get_contents($src);
717 $r = q("select sum(octet_length(data)) as total from photo where uid = %d and scale = 0 and album != 'Contact Photos' ",
718 intval($a->data['user']['uid'])
721 $limit = service_class_fetch($a->data['user']['uid'],'photo_upload_limit');
723 if(($limit !== false) && (($r[0]['total'] + strlen($imagedata)) > $limit)) {
724 notice( upgrade_message() . EOL );
727 call_hooks('photo_post_end',$foo);
732 $ph = new Photo($imagedata, $type);
734 if(! $ph->is_valid()) {
735 logger('mod/photos.php: photos_post(): unable to process image' , LOGGER_DEBUG);
736 notice( t('Unable to process image.') . EOL );
739 call_hooks('photo_post_end',$foo);
746 $max_length = get_config('system','max_image_length');
748 $max_length = MAX_IMAGE_LENGTH;
750 $ph->scaleImage($max_length);
752 $width = $ph->getWidth();
753 $height = $ph->getHeight();
757 $photo_hash = photo_new_resource();
759 $r = $ph->store($page_owner_uid, $visitor, $photo_hash, $filename, $album, 0 , 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
762 logger('mod/photos.php: photos_post(): image store failed' , LOGGER_DEBUG);
763 notice( t('Image upload failed.') . EOL );
767 if($width > 640 || $height > 640) {
768 $ph->scaleImage(640);
769 $ph->store($page_owner_uid, $visitor, $photo_hash, $filename, $album, 1, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
773 if($width > 320 || $height > 320) {
774 $ph->scaleImage(320);
775 $ph->store($page_owner_uid, $visitor, $photo_hash, $filename, $album, 2, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
779 $basename = basename($filename);
780 $uri = item_new_uri($a->get_hostname(), $page_owner_uid);
782 // Create item container
786 $arr['uid'] = $page_owner_uid;
788 $arr['parent-uri'] = $uri;
789 $arr['type'] = 'photo';
791 $arr['resource-id'] = $photo_hash;
792 $arr['contact-id'] = $owner_record['id'];
793 $arr['owner-name'] = $owner_record['name'];
794 $arr['owner-link'] = $owner_record['url'];
795 $arr['owner-avatar'] = $owner_record['thumb'];
796 $arr['author-name'] = $owner_record['name'];
797 $arr['author-link'] = $owner_record['url'];
798 $arr['author-avatar'] = $owner_record['thumb'];
800 $arr['allow_cid'] = $str_contact_allow;
801 $arr['allow_gid'] = $str_group_allow;
802 $arr['deny_cid'] = $str_contact_deny;
803 $arr['deny_gid'] = $str_group_deny;
804 $arr['last-child'] = 1;
805 $arr['visible'] = $visible;
808 $arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo_hash . ']'
809 . '[img]' . $a->get_baseurl() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/img]'
812 $item_id = item_store($arr);
815 q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1",
816 dbesc($a->get_baseurl() . '/display/' . $owner_record['nickname'] . '/' . $item_id),
817 intval($page_owner_uid),
823 proc_run('php', "include/notifier.php", 'wall-new', $item_id);
825 call_hooks('photo_post_end',intval($item_id));
827 // addon uploaders should call "killme()" [e.g. exit] within the photo_post_end hook
828 // if they do not wish to be redirected
830 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
836 function photos_content(&$a) {
840 // photos/name/upload
841 // photos/name/upload/xxxxx (xxxxx is album name)
842 // photos/name/album/xxxxx
843 // photos/name/album/xxxxx/edit
844 // photos/name/image/xxxxx
845 // photos/name/image/xxxxx/edit
848 if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
849 notice( t('Public access denied.') . EOL);
854 require_once('include/bbcode.php');
855 require_once('include/security.php');
856 require_once('include/conversation.php');
858 if(! x($a->data,'user')) {
859 notice( t('No photos selected') . EOL );
863 $phototypes = Photo::supportedTypes();
865 $_SESSION['photo_return'] = $a->cmd;
872 $datatype = $a->argv[2];
873 $datum = $a->argv[3];
875 elseif(($a->argc > 2) && ($a->argv[2] === 'upload'))
876 $datatype = 'upload';
878 $datatype = 'summary';
886 // Setup permissions structures
892 $remote_contact = false;
894 $owner_uid = $a->data['user']['uid'];
896 $community_page = (($a->data['user']['page-flags'] == PAGE_COMMUNITY) ? true : false);
898 if((local_user()) && (local_user() == $owner_uid))
901 if($community_page && remote_user()) {
902 $r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
903 intval(remote_user()),
909 $remote_contact = true;
910 $visitor = remote_user();
915 // perhaps they're visiting - but not a community page, so they wouldn't have write access
917 if(remote_user() && (! $visitor)) {
918 $contact_id = $_SESSION['visitor_id'];
919 $groups = init_groups_visitor($contact_id);
920 $r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
921 intval(remote_user()),
926 $remote_contact = true;
930 if(! $remote_contact) {
932 $contact_id = $_SESSION['cid'];
933 $contact = $a->contact;
937 if($a->data['user']['hidewall'] && (local_user() != $owner_uid) && (! $remote_contact)) {
938 notice( t('Access to this item is restricted.') . EOL);
942 $sql_extra = permissions_sql($owner_uid,$remote_contact,$groups);
947 $_is_owner = (local_user() && (local_user() == $owner_uid));
948 $o .= profile_tabs($a,$_is_owner, $a->data['user']['nickname']);
955 if($datatype === 'upload') {
957 notice( t('Permission denied.'));
962 $selname = (($datum) ? hex2bin($datum) : '');
965 $albumselect = '<select id="photos-upload-album-select" name="album" size="4">';
968 $albumselect .= '<option value="" ' . ((! $selname) ? ' selected="selected" ' : '') . '> </option>';
969 if(count($a->data['albums'])) {
970 foreach($a->data['albums'] as $album) {
971 if(($album['album'] === '') || ($album['album'] === 'Contact Photos') || ($album['album'] === t('Contact Photos')))
973 $selected = (($selname === $album['album']) ? ' selected="selected" ' : '');
974 $albumselect .= '<option value="' . $album['album'] . '"' . $selected . '>' . $album['album'] . '</option>';
978 $celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false);
980 $albumselect .= '</select>';
984 $ret = array('post_url' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'],
985 'addon_text' => $uploader,
986 'default_upload' => true);
989 call_hooks('photo_upload_form',$ret);
991 $default_upload = '<input id="photos-upload-choose" type="file" name="userfile" /> <div class="photos-upload-submit-wrapper" >
992 <input type="submit" name="submit" value="' . t('Submit') . '" id="photos-upload-submit" /> </div>';
995 $r = q("select sum(octet_length(data)) as total from photo where uid = %d and scale = 0 and album != 'Contact Photos' ",
996 intval($a->data['user']['uid'])
1000 $limit = service_class_fetch($a->data['user']['uid'],'photo_upload_limit');
1001 if($limit !== false) {
1002 $usage_message = sprintf( t("You have used %1$.2f Mbytes of %2$.2f Mbytes photo storage."), $r[0]['total'] / 1024000, $limit / 1024000 );
1005 $usage_message = sprintf( t('You have used %1$.2f Mbytes of photo storage.'), $r[0]['total'] / 1024000 );
1009 $tpl = get_markup_template('photos_upload.tpl');
1010 $o .= replace_macros($tpl,array(
1011 '$pagename' => t('Upload Photos'),
1012 '$sessid' => session_id(),
1013 '$usage' => $usage_message,
1014 '$nickname' => $a->data['user']['nickname'],
1015 '$newalbum' => t('New album name: '),
1016 '$existalbumtext' => t('or existing album name: '),
1017 '$nosharetext' => t('Do not show a status post for this upload'),
1018 '$albumselect' => template_escape($albumselect),
1019 '$permissions' => t('Permissions'),
1020 '$aclselect' => (($visitor) ? '' : template_escape(populate_acl($a->user, $celeb))),
1021 '$uploader' => $ret['addon_text'],
1022 '$default' => (($ret['default_upload']) ? $default_upload : ''),
1023 '$uploadurl' => $ret['post_url']
1030 if($datatype === 'album') {
1032 $album = hex2bin($datum);
1034 $r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` = '%s'
1035 AND `scale` <= 4 $sql_extra GROUP BY `resource-id`",
1040 $a->set_pager_total(count($r));
1041 $a->set_pager_itemspage(20);
1044 $r = q("SELECT `resource-id`, `id`, `filename`, type, max(`scale`) AS `scale`, `desc` FROM `photo` WHERE `uid` = %d AND `album` = '%s'
1045 AND `scale` <= 4 $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d",
1048 intval($a->pager['start']),
1049 intval($a->pager['itemspage'])
1052 $o .= '<h3>' . $album . '</h3>';
1054 if($cmd === 'edit') {
1055 if(($album !== t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) {
1057 $edit_tpl = get_markup_template('album_edit.tpl');
1058 $o .= replace_macros($edit_tpl,array(
1059 '$nametext' => t('New album name: '),
1060 '$nickname' => $a->data['user']['nickname'],
1061 '$album' => template_escape($album),
1062 '$hexalbum' => bin2hex($album),
1063 '$submit' => t('Submit'),
1064 '$dropsubmit' => t('Delete Album')
1070 if(($album !== t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) {
1072 $o .= '<div id="album-edit-link"><a href="'. $a->get_baseurl() . '/photos/'
1073 . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '/edit' . '">'
1074 . t('Edit Album') . '</a></div>';
1080 $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>';
1083 $tpl = get_markup_template('photo_album.tpl');
1085 $twist = 'rotright';
1086 foreach($r as $rr) {
1087 if($twist == 'rotright')
1090 $twist = 'rotright';
1092 $ext = $phototypes[$rr['type']];
1094 $o .= replace_macros($tpl,array(
1096 '$twist' => ' ' . $twist . rand(2,4),
1097 '$photolink' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'],
1098 '$phototitle' => t('View Photo'),
1099 '$imgsrc' => $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['scale'] . '.' .$ext,
1100 '$imgalt' => template_escape($rr['filename']),
1101 '$desc'=> template_escape($rr['desc'])
1105 $o .= '<div id="photo-album-end"></div>';
1113 if($datatype === 'image') {
1118 // fetch image, item containing image, then comments
1120 $ph = q("SELECT * FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'
1121 $sql_extra ORDER BY `scale` ASC ",
1127 $ph = q("SELECT `id` FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'
1133 notice( t('Permission denied. Access to this item may be restricted.'));
1135 notice( t('Photo not available') . EOL );
1142 $prvnxt = q("SELECT `resource-id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `scale` = 0
1143 $sql_extra ORDER BY `created` DESC ",
1144 dbesc($ph[0]['album']),
1148 if(count($prvnxt)) {
1149 for($z = 0; $z < count($prvnxt); $z++) {
1150 if($prvnxt[$z]['resource-id'] == $ph[0]['resource-id']) {
1154 $prv = count($prvnxt) - 1;
1155 if($nxt >= count($prvnxt))
1160 $edit_suffix = ((($cmd === 'edit') && ($can_post)) ? '/edit' : '');
1161 $prevlink = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . $edit_suffix;
1162 $nextlink = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . $edit_suffix;
1167 $hires = $lores = $ph[0];
1168 if(count($ph) > 1) {
1169 if($ph[1]['scale'] == 2) {
1170 // original is 640 or less, we can display it directly
1171 $hires = $lores = $ph[0];
1179 $album_link = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($ph[0]['album']);
1183 if($can_post && ($ph[0]['uid'] == $owner_uid)) {
1185 'edit' => array($a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $datum . (($cmd === 'edit') ? '' : '/edit'), (($cmd === 'edit') ? t('View photo') : t('Edit photo'))),
1186 'profile'=>array($a->get_baseurl() . '/profile_photo/use/'.$ph[0]['resource-id'], t('Use as profile photo')),
1190 $lock = ( ( ($ph[0]['uid'] == local_user()) && (strlen($ph[0]['allow_cid']) || strlen($ph[0]['allow_gid'])
1191 || strlen($ph[0]['deny_cid']) || strlen($ph[0]['deny_gid'])) )
1192 ? t('Private Message')
1198 if(! $cmd !== 'edit') {
1199 $a->page['htmlhead'] .= '<script>
1200 $(document).keydown(function(event) {' . "\n";
1203 $a->page['htmlhead'] .= 'if(event.ctrlKey && event.keyCode == 37) { event.preventDefault(); window.location.href = \'' . $prevlink . '\'; }' . "\n";
1205 $a->page['htmlhead'] .= 'if(event.ctrlKey && event.keyCode == 39) { event.preventDefault(); window.location.href = \'' . $nextlink . '\'; }' . "\n";
1206 $a->page['htmlhead'] .= '});</script>';
1210 $prevlink = array($prevlink, '<div class="icon prev"></div>') ;
1213 'href' => $a->get_baseurl() . '/photo/' . $hires['resource-id'] . '-' . $hires['scale'] . '.' . $phototypes[$hires['type']],
1214 'title'=> t('View Full Size'),
1215 'src' => $a->get_baseurl() . '/photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?f=&_u=' . datetime_convert('','','','ymdhis')
1219 $nextlink = array($nextlink, '<div class="icon next"></div>');
1222 // Do we have an item for this photo?
1224 $linked_items = q("SELECT * FROM `item` WHERE `resource-id` = '%s' $sql_extra LIMIT 1",
1227 if(count($linked_items)) {
1228 $link_item = $linked_items[0];
1229 $r = q("SELECT COUNT(*) AS `total`
1230 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
1231 WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0 and `item`.`moderated` = 0
1232 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
1233 AND `item`.`uid` = %d
1235 dbesc($link_item['uri']),
1236 dbesc($link_item['uri']),
1237 intval($link_item['uid'])
1242 $a->set_pager_total($r[0]['total']);
1245 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
1246 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`,
1247 `contact`.`rel`, `contact`.`thumb`, `contact`.`self`,
1248 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
1249 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
1250 WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0 and `item`.`moderated` = 0
1251 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
1252 AND `item`.`uid` = %d
1254 ORDER BY `parent` DESC, `id` ASC LIMIT %d ,%d ",
1255 dbesc($link_item['uri']),
1256 dbesc($link_item['uri']),
1257 intval($link_item['uid']),
1258 intval($a->pager['start']),
1259 intval($a->pager['itemspage'])
1263 if((local_user()) && (local_user() == $link_item['uid'])) {
1264 q("UPDATE `item` SET `unseen` = 0 WHERE `parent` = %d and `uid` = %d",
1265 intval($link_item['parent']),
1266 intval(local_user())
1273 if(count($linked_items) && strlen($link_item['tag'])) {
1274 $arr = explode(',',$link_item['tag']);
1275 // parse tags and add links
1277 foreach($arr as $t) {
1278 if(strlen($tag_str))
1280 $tag_str .= bbcode($t);
1282 $tags = array(t('Tags: '), $tag_str);
1283 if($cmd === 'edit') {
1284 $tags[] = $a->get_baseurl() . '/tagrm/' . $link_item['id'];
1285 $tags[] = t('[Remove any tag]');
1291 if(($cmd === 'edit') && ($can_post)) {
1292 $edit_tpl = get_markup_template('photo_edit.tpl');
1293 $edit = replace_macros($edit_tpl, array(
1294 '$id' => $ph[0]['id'],
1295 '$rotatecw' => t('Rotate CW (right)'),
1296 '$rotateccw' => t('Rotate CCW (left)'),
1297 '$album' => template_escape($ph[0]['album']),
1298 '$newalbum' => t('New album name'),
1299 '$nickname' => $a->data['user']['nickname'],
1300 '$resource_id' => $ph[0]['resource-id'],
1301 '$capt_label' => t('Caption'),
1302 '$caption' => template_escape($ph[0]['desc']),
1303 '$tag_label' => t('Add a Tag'),
1304 '$tags' => $link_item['tag'],
1305 '$permissions' => t('Permissions'),
1306 '$aclselect' => template_escape(populate_acl($ph[0])),
1307 '$help_tags' => t('Example: @bob, @Barbara_Jensen, @jim@example.com, #California, #camping'),
1308 '$item_id' => ((count($linked_items)) ? $link_item['id'] : 0),
1309 '$submit' => t('Submit'),
1310 '$delete' => t('Delete Photo')
1314 if(count($linked_items)) {
1316 $cmnt_tpl = get_markup_template('comment_item.tpl');
1317 $tpl = get_markup_template('photo_item.tpl');
1318 $return_url = $a->cmd;
1320 $like_tpl = get_markup_template('like_noshare.tpl');
1324 if($can_post || can_write_wall($a,$owner_uid)) {
1325 $likebuttons = replace_macros($like_tpl,array(
1326 '$id' => $link_item['id'],
1327 '$likethis' => t("I like this \x28toggle\x29"),
1328 '$nolike' => t("I don't like this \x28toggle\x29"),
1329 '$share' => t('Share'),
1330 '$wait' => t('Please wait')
1336 if($can_post || can_write_wall($a,$owner_uid)) {
1337 if($link_item['last-child']) {
1338 $comments .= replace_macros($cmnt_tpl,array(
1339 '$return_path' => '',
1340 '$jsreload' => $return_url,
1341 '$type' => 'wall-comment',
1342 '$id' => $link_item['id'],
1343 '$parent' => $link_item['id'],
1344 '$profile_uid' => $owner_uid,
1345 '$mylink' => $contact['url'],
1346 '$mytitle' => t('This is you'),
1347 '$myphoto' => $contact['thumb'],
1348 '$comment' => t('Comment'),
1349 '$submit' => t('Submit'),
1350 '$preview' => t('Preview'),
1366 foreach($r as $item) {
1367 like_puller($a,$item,$alike,'like');
1368 like_puller($a,$item,$dlike,'dislike');
1371 $like = ((isset($alike[$link_item['id']])) ? format_like($alike[$link_item['id']],$alike[$link_item['id'] . '-l'],'like',$link_item['id']) : '');
1372 $dislike = ((isset($dlike[$link_item['id']])) ? format_like($dlike[$link_item['id']],$dlike[$link_item['id'] . '-l'],'dislike',$link_item['id']) : '');
1376 if($can_post || can_write_wall($a,$owner_uid)) {
1377 if($link_item['last-child']) {
1378 $comments .= replace_macros($cmnt_tpl,array(
1379 '$return_path' => '',
1380 '$jsreload' => $return_url,
1381 '$type' => 'wall-comment',
1382 '$id' => $link_item['id'],
1383 '$parent' => $link_item['id'],
1384 '$profile_uid' => $owner_uid,
1385 '$mylink' => $contact['url'],
1386 '$mytitle' => t('This is you'),
1387 '$myphoto' => $contact['thumb'],
1388 '$comment' => t('Comment'),
1389 '$submit' => t('Submit'),
1396 foreach($r as $item) {
1401 if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE))) && ($item['id'] != $item['parent']))
1404 $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
1406 if($can_post || can_write_wall($a,$owner_uid)) {
1408 if($item['last-child']) {
1409 $comments .= replace_macros($cmnt_tpl,array(
1410 '$return_path' => '',
1411 '$jsreload' => $return_url,
1412 '$type' => 'wall-comment',
1413 '$id' => $item['item_id'],
1414 '$parent' => $item['parent'],
1415 '$profile_uid' => $owner_uid,
1416 '$mylink' => $contact['url'],
1417 '$mytitle' => t('This is you'),
1418 '$myphoto' => $contact['thumb'],
1419 '$comment' => t('Comment'),
1420 '$submit' => t('Submit'),
1427 if(local_user() && ($item['contact-uid'] == local_user())
1428 && ($item['network'] == 'dfrn') && (! $item['self'] )) {
1429 $profile_url = $redirect_url;
1430 $sparkle = ' sparkle';
1433 $profile_url = $item['url'];
1437 $diff_author = (($item['url'] !== $item['author-link']) ? true : false);
1439 $profile_name = (((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']);
1440 $profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $item['thumb']);
1442 $profile_link = $profile_url;
1446 if(($item['contact-id'] == remote_user()) || ($item['uid'] == local_user()))
1447 $drop = replace_macros(get_markup_template('photo_drop.tpl'), array('$id' => $item['id'], '$delete' => t('Delete')));
1450 $comments .= replace_macros($template,array(
1451 '$id' => $item['item_id'],
1452 '$profile_url' => $profile_link,
1453 '$name' => template_escape($profile_name),
1454 '$thumb' => $profile_avatar,
1455 '$sparkle' => $sparkle,
1456 '$title' => template_escape($item['title']),
1457 '$body' => template_escape(bbcode($item['body'])),
1458 '$ago' => relative_date($item['created']),
1459 '$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''),
1461 '$comment' => $comment
1466 $paginate = paginate($a);
1469 $photo_tpl = get_markup_template('photo_view.tpl');
1470 $o .= replace_macros($photo_tpl, array(
1471 '$id' => $ph[0]['id'],
1472 '$album' => array($album_link,template_escape($ph[0]['album'])),
1476 '$prevlink' => $prevlink,
1477 '$nextlink' => $nextlink,
1478 '$desc' => $ph[0]['desc'],
1479 '$tags' => template_escape($tags),
1481 '$likebuttons' => $likebuttons,
1482 '$like' => template_escape($like),
1483 '$dislike' => template_escape($dislike),
1484 '$comments' => $comments,
1485 '$paginate' => $paginate,
1491 // Default - show recent photos with upload link (if applicable)
1494 $r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
1495 $sql_extra GROUP BY `resource-id`",
1496 intval($a->data['user']['uid']),
1497 dbesc('Contact Photos'),
1498 dbesc( t('Contact Photos'))
1501 $a->set_pager_total(count($r));
1502 $a->set_pager_itemspage(20);
1505 $r = q("SELECT `resource-id`, `id`, `filename`, type, `album`, max(`scale`) AS `scale` FROM `photo`
1506 WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
1507 $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d",
1508 intval($a->data['user']['uid']),
1509 dbesc('Contact Photos'),
1510 dbesc( t('Contact Photos')),
1511 intval($a->pager['start']),
1512 intval($a->pager['itemspage'])
1519 $twist = 'rotright';
1520 foreach($r as $rr) {
1521 if($twist == 'rotright')
1524 $twist = 'rotright';
1525 $ext = $phototypes[$rr['type']];
1529 'twist' => ' ' . $twist . rand(2,4),
1530 'link' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'],
1531 'title' => t('View Photo'),
1532 'src' => $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.' . $ext,
1533 'alt' => template_escape($rr['filename']),
1535 'link' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']),
1536 'name' => template_escape($rr['album']),
1537 'alt' => t('View Album'),
1544 $tpl = get_markup_template('photos_recent.tpl');
1545 $o .= replace_macros($tpl,array(
1546 '$title' => t('Recent Photos'),
1547 '$can_post' => $can_post,
1548 '$upload' => array(t('Upload New Photos'), $a->get_baseurl().'/photos/'.$a->data['user']['nickname'].'/upload'),
1549 '$photos' => $photos,