3 require_once('Photo.php');
4 require_once('view/acl_selectors.php');
6 function photos_init(&$a) {
10 $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1",
17 $a->data['user'] = $r[0];
19 $albums = q("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = %d",
20 intval($a->data['user']['uid'])
24 $a->data['albums'] = $albums;
26 $o .= '<h4><a href="' . $a->get_baseurl() . '/profile/' . $a->data['user']['nickname'] . '">' . $a->data['user']['username'] . '</a></h4>';
27 $o .= '<h4>' . '<a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '">' . t('Photo Albums') . '</a></h4>';
30 foreach($albums as $album) {
31 if((! strlen($album['album'])) || ($album['album'] == t('Contact Photos')))
33 $o .= '<li>' . '<a href="photos/' . $a->argv[1] . '/album/' . bin2hex($album['album']) . '" />' . $album['album'] . '</a></li>';
37 $a->page['aside'] .= $o;
46 function photos_post(&$a) {
50 notice( t('Permission denied.') . EOL );
56 $r = q("SELECT * FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
57 WHERE `user`.`uid` = %d AND `self` = 1 LIMIT 1",
58 intval($_SESSION['uid'])
61 $contact_record = $r[0];
64 if(($a->argc > 2) && ($a->argv[1] == 'album')) {
65 $album = hex2bin($a->argv[2]);
67 if($album == t('Profile Photos') || $album == t('Contact Photos')) {
68 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
72 $r = q("SELECT count(*) FROM `photo` WHERE `album` = '%s' AND `uid` = %d",
74 intval($_SESSION['uid'])
77 notice( t('Album not found.') . EOL);
78 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
82 $newalbum = notags(trim($_POST['albumname']));
83 if($newalbum != $album) {
84 q("UPDATE `photo` SET `album` = '%s' WHERE `album` = '%s' AND `uid` = %d",
87 intval($_SESSION['uid'])
89 $newurl = str_replace(bin2hex($album),bin2hex($newalbum),$_SESSION['photo_return']);
90 goaway($a->get_baseurl() . '/' . $newurl);
94 if($_POST['dropalbum'] == t('Delete Album')) {
97 $r = q("SELECT distinct(`resource-id`) as `rid` FROM `photo` WHERE `uid` = %d AND `album` = '%s'",
98 intval($_SESSION['uid']),
103 $res[] = "'" . dbesc($rr['rid']) . "'" ;
107 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
108 return; // NOTREACHED
110 $str_res = implode(',', $res);
112 q("DELETE FROM `photo` WHERE `resource-id` IN ( $str_res ) AND `uid` = %d",
113 intval($_SESSION['uid'])
115 $r = q("SELECT `parent-uri` FROM `item` WHERE `resource-id` IN ( $str_res ) AND `uid` = %d",
116 intval($_SESSION['uid'])
120 q("UPDATE `item` SET `deleted` = 1 WHERE `parent-uri` = '%s' AND `uid` = %d",
121 dbesc($rr['parent-uri']),
122 intval($_SESSION['uid'])
125 $url = $a->get_baseurl();
126 $drop_id = intval($rr['id']);
127 $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
129 // send the notification upstream/downstream as the case may be
132 proc_close(proc_open("\"php_path\" \"include/notifier.php\" \"$url\" \"drop\" \"$drop_id\" & ",
138 goaway($a->get_baseurl() . '/photos/' . $a->data['user']['nickname']);
139 return; // NOTREACHED
142 if(($a->argc > 1) && (x($_POST,'delete')) && ($_POST['delete'] == t('Delete Photo'))) {
143 $r = q("SELECT `id` FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' LIMIT 1",
144 intval($_SESSION['uid']),
148 q("DELETE FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'",
149 intval($_SESSION['uid']),
150 dbesc($r[0]['resource-id'])
152 $i = q("SELECT * FROM `item` WHERE `resource-id` = '%s' AND `uid` = %d LIMIT 1",
153 dbesc($r[0]['resource-id']),
154 intval($_SESSION['uid'])
157 q("UPDATE `item` SET `deleted` = 1 WHERE `parent-uri` = '%s' AND `uid` = %d",
159 intval($_SESSION['uid'])
162 $url = $a->get_baseurl();
163 $drop_id = intval($i[0]['id']);
164 $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
166 // send the notification upstream/downstream as the case may be
169 proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"$url\" \"drop\" \"$drop_id\" & ",
174 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
175 return; // NOTREACHED
180 if(($a->argc > 1) && (x($_POST,'desc') !== false)) {
181 $desc = notags(trim($_POST['desc']));
182 $tags = notags(trim($_POST['tags']));
183 $item_id = intval($_POST['item_id']);
184 $resource_id = $a->argv[1];
186 $p = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d ORDER BY `scale` DESC",
188 intval($_SESSION['uid'])
191 $r = q("UPDATE `photo` SET `desc` = '%s' WHERE `resource-id` = '%s' AND `uid` = %d",
194 intval($_SESSION['uid'])
200 $basename = basename($filename);
202 // Create item container
204 $body = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']'
205 . '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.jpg' . '[/img]'
210 $item_hash = random_string();
212 $uri = "urn:X-dfrn:" . $a->get_hostname() . ':' . $_SESSION['uid'] . ':' . $item_hash;
214 $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
218 } while($dups == true);
221 $r = q("INSERT INTO `item` (`uid`, `type`, `resource-id`, `contact-id`,
222 `owner-name`,`owner-link`,`owner-avatar`, `created`,
223 `edited`, `uri`, `parent-uri`, `title`, `body`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`)
224 VALUES( %d, '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
225 intval($_SESSION['uid']),
227 dbesc($p[0]['resource-id']),
228 intval($contact_record['id']),
229 dbesc($contact_record['name']),
230 dbesc($contact_record['url']),
231 dbesc($contact_record['thumb']),
238 dbesc($p[0]['allow_cid']),
239 dbesc($p[0]['allow_gid']),
240 dbesc($p[0]['deny_cid']),
241 dbesc($p[0]['deny_gid'])
246 $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
250 $item_id = $r[0]['id'];
251 q("UPDATE `item` SET `parent` = %d, `last-child` = 1 WHERE `id` = %d LIMIT 1",
258 $r = q("UPDATE `item` SET `tag` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
261 intval($_SESSION['uid'])
264 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
265 return; // NOTREACHED
271 if(! x($_FILES,'userfile'))
274 if($_POST['partitionCount'])
277 $java_upload = false;
279 $album = notags(trim($_POST['album']));
280 $newalbum = notags(trim($_POST['newalbum']));
282 if(! strlen($album)) {
283 if(strlen($newalbum))
286 $album = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y');
289 $r = q("SELECT * FROM `photo` WHERE `album` = '%s' AND `uid` = %d",
291 intval($_SESSION['uid'])
293 if((! count($r)) || ($album == t('Profile Photos')))
298 $str_group_allow = '';
299 $group_allow = $_POST['group_allow'];
300 if(is_array($group_allow)) {
301 array_walk($group_allow,'sanitise_acl');
302 $str_group_allow = implode('',$group_allow);
305 $str_contact_allow = '';
306 $contact_allow = $_POST['contact_allow'];
307 if(is_array($contact_allow)) {
308 array_walk($contact_allow,'sanitise_acl');
309 $str_contact_allow = implode('',$contact_allow);
312 $str_group_deny = '';
313 $group_deny = $_POST['group_deny'];
314 if(is_array($group_deny)) {
315 array_walk($group_deny,'sanitise_acl');
316 $str_group_deny = implode('',$group_deny);
319 $str_contact_deny = '';
320 $contact_deny = $_POST['contact_deny'];
321 if(is_array($contact_deny)) {
322 array_walk($contact_deny,'sanitise_acl');
323 $str_contact_deny = implode('',$contact_deny);
327 $src = $_FILES['userfile']['tmp_name'];
328 $filename = basename($_FILES['userfile']['name']);
329 $filesize = intval($_FILES['userfile']['size']);
331 $imagedata = @file_get_contents($src);
332 $ph = new Photo($imagedata);
334 if(! ($image = $ph->getImage())) {
335 notice( t('Unable to process image.') . EOL );
342 $width = $ph->getWidth();
343 $height = $ph->getHeight();
347 $photo_hash = hash('md5',uniqid(mt_rand(),true));
349 $r = $ph->store($_SESSION['uid'], 0, $photo_hash, $filename, $album, 0 , 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
352 notice( t('Image upload failed.') . EOL );
356 if($width > 640 || $height > 640) {
357 $ph->scaleImage(640);
358 $ph->store($_SESSION['uid'], 0, $photo_hash, $filename, $album, 1, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
362 if($width > 320 || $height > 320) {
363 $ph->scaleImage(320);
364 $ph->store($_SESSION['uid'], 0, $photo_hash, $filename, $album, 2, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
368 $basename = basename($filename);
370 // Create item container
372 $body = '[url=' . $a->get_baseurl() . '/photos/' . $contact_record['nickname'] . '/image/' . $photo_hash . ']'
373 . '[img]' . $a->get_baseurl() . "/photo/{$photo_hash}-{$smallest}.jpg" . '[/img]'
378 $item_hash = random_string();
380 $uri = "urn:X-dfrn:" . $a->get_hostname() . ':' . $_SESSION['uid'] . ':' . $item_hash;
382 $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
386 } while($dups == true);
389 $r = q("INSERT INTO `item` (`uid`, `type`, `resource-id`, `contact-id`,`owner-name`,`owner-link`,`owner-avatar`, `created`,
390 `edited`, `uri`, `parent-uri`, `title`, `body`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `visible`)
391 VALUES( %d, '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d )",
392 intval($_SESSION['uid']),
395 intval($contact_record['id']),
396 dbesc($contact_record['name']),
397 dbesc($contact_record['url']),
398 dbesc($contact_record['thumb']),
405 dbesc($str_contact_allow),
406 dbesc($str_group_allow),
407 dbesc($str_contact_deny),
408 dbesc($str_group_deny),
413 $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
417 q("UPDATE `item` SET `parent` = %d, `last-child` = 1 WHERE `id` = %d LIMIT 1",
425 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
426 return; // NOTREACHED
430 return; // NOTREACHED
436 function photos_content(&$a) {
440 // photos/name/upload
441 // photos/name/album/xxxxx
442 // photos/name/album/xxxxx/edit
443 // photos/name/image/xxxxx
444 // photos/name/image/xxxxx/edit
447 if(! x($a->data,'user')) {
448 notice( t('No photos selected') . EOL );
452 $_SESSION['photo_return'] = $a->cmd;
459 $datatype = $a->argv[2];
460 $datum = $a->argv[3];
462 elseif(($a->argc > 2) && ($a->argv[2] == 'upload'))
463 $datatype = 'upload';
465 $datatype = 'summary';
473 // Setup permissions structures
476 $owner_uid = $a->data['user']['uid'];
479 $contact_id = $_SESSION['visitor_id'];
480 $groups = init_groups_visitor($contact_id);
483 // default permissions - anonymous user
485 $sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '' ";
487 // Profile owner - everything is visible
489 if(local_user() && ($_SESSION['uid'] == $owner_uid)) {
492 elseif(remote_user()) {
493 // authenticated visitor - here lie dragons
494 $gs = '<<>>'; // should be impossible to match
496 foreach($groups as $g)
497 $gs .= '|<' . intval($g) . '>';
499 $sql_extra = sprintf(
500 " AND ( `allow_cid` = '' OR `allow_cid` REGEXP '<%d>' )
501 AND ( `deny_cid` = '' OR NOT `deny_cid` REGEXP '<%d>' )
502 AND ( `allow_gid` = '' OR `allow_gid` REGEXP '%s' )
503 AND ( `deny_gid` = '' OR NOT `deny_gid` REGEXP '%s') ",
505 intval($_SESSION['visitor_id']),
506 intval($_SESSION['visitor_id']),
517 if($datatype == 'upload') {
518 if( ! (local_user() && ($_SESSION['uid'] == $a->data['user']['uid']))) {
519 notice( t('Permission denied.'));
522 $albumselect = '<select id="photos-upload-album-select" name="album" size="4">';
524 $albumselect .= '<option value="" selected="selected" > </option>';
525 if(count($a->data['albums'])) {
526 foreach($a->data['albums'] as $album) {
527 if(($album['album'] == '') || ($album['album'] == t('Contact Photos')))
529 $albumselect .= '<option value="' . $album['album'] . '">' . $album['album'] . '</option>';
532 $albumselect .= '</select>';
533 $tpl = file_get_contents('view/photos_upload.tpl');
534 $o .= replace_macros($tpl,array(
535 '$pagename' => t('Upload Photos'),
536 '$sessid' => session_id(),
537 '$newalbum' => t('New album name: '),
538 '$existalbumtext' => t('or existing album name: '),
539 '$filestext' => t('Select files to upload: '),
540 '$albumselect' => $albumselect,
541 '$permissions' => t('Permissions'),
542 '$aclselect' => populate_acl($a->user),
543 '$archive' => $a->get_baseurl() . '/jumploader_z.jar',
544 '$nojava' => t('Use the following controls only if the Java uploader (above) fails to launch.'),
545 '$uploadurl' => $a->get_baseurl() . '/photos',
546 '$submit' => t('Submit')
553 if($datatype == 'album') {
555 $album = hex2bin($datum);
557 $r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` = '%s'
558 $sql_extra GROUP BY `resource-id`",
559 intval($a->data['user']['uid']),
563 $a->set_pager_total(count($r));
566 $r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` = '%s'
567 $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d",
568 intval($a->data['user']['uid']),
570 intval($a->pager['start']),
571 intval($a->pager['itemspage'])
574 $o .= '<h3>' . $album . '</h3>';
577 if(($album != t('Profile Photos')) && ($album != t('Contact Photos'))) {
578 if(local_user() && ($_SESSION['uid'] == $a->data['user']['uid'])) {
579 $edit_tpl = file_get_contents('view/album_edit.tpl');
580 $o .= replace_macros($edit_tpl,array(
581 '$nametext' => t('New album name: '),
583 '$hexalbum' => bin2hex($album),
584 '$submit' => t('Submit'),
585 '$dropsubmit' => t('Delete Album')
591 if(($album != t('Profile Photos')) && ($album != t('Contact Photos'))) {
592 if(local_user() && ($_SESSION['uid'] == $a->data['user']['uid'])) {
593 $o .= '<div id="album-edit-link"><a href="'. $a->get_baseurl() . '/photos/'
594 . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '/edit' . '">'
595 . t('Edit Album') . '</a></div>';
599 $tpl = file_get_contents('view/photo_album.tpl');
602 $o .= replace_macros($tpl,array(
604 '$photolink' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'],
605 '$phototitle' => t('View Photo'),
606 '$imgsrc' => $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['scale'] . '.jpg',
607 '$imgalt' => $rr['filename']
611 $o .= '<div id="photo-album-end"></div>';
617 if($datatype == 'image') {
619 require_once('security.php');
620 require_once('bbcode.php');
622 // fetch image, item containing image, then comments
624 $ph = q("SELECT * FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'
625 $sql_extra ORDER BY `scale` ASC ",
626 intval($a->data['user']['uid']),
631 notice( t('Photo not available') . EOL );
636 $hires = $lores = $ph[0];
638 if($ph[1]['scale'] == 2) {
639 // original is 640 or less, we can display it directly
640 $hires = $lores = $ph[0];
649 $o .= '<h3>' . '<a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($ph[0]['album']) . '">' . $ph[0]['album'] . '</a></h3>';
651 if(local_user() && ($ph[0]['uid'] == $_SESSION['uid'])) {
652 $o .= '<div id="photo-edit-link-wrap" ><a id="photo-edit-link" href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $datum . '/edit' . '">' . t('Edit photo') . '</a></div>';
656 $o .= '<a href="' . $a->get_baseurl() . '/photo/'
657 . $hires['resource-id'] . '-' . $hires['scale'] . '.jpg" title="'
658 . t('View Full Size') . '" ><img src="' . $a->get_baseurl() . '/photo/'
659 . $lores['resource-id'] . '-' . $lores['scale'] . '.jpg' . '" /></a>';
662 // Do we have an item for this photo?
664 $i1 = q("SELECT * FROM `item` WHERE `resource-id` = '%s' $sql_extra LIMIT 1",
669 $r = q("SELECT COUNT(*) AS `total`
670 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
671 WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0
672 AND NOT `item`.`type` IN ( 'remote', 'net-comment')
673 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
675 dbesc($i1[0]['uri']),
681 $a->set_pager_total($r[0]['total']);
684 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
685 `contact`.`name`, `contact`.`photo`, `contact`.`url`,
686 `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
687 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
688 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
689 WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0
690 AND NOT `item`.`type` IN ( 'remote', 'net-comment')
691 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
693 ORDER BY `parent` DESC, `id` ASC LIMIT %d ,%d ",
694 dbesc($i1[0]['uri']),
695 dbesc($i1[0]['uri']),
696 intval($a->pager['start']),
697 intval($a->pager['itemspage'])
702 $o .= '<div id="photo-caption" >' . $ph[0]['desc'] . '</div>';
704 if(count($i1) && strlen($i1[0]['tag'])) {
705 // parse tags and add links
706 $o .= '<div id="in-this-photo-text">' . t('In this photo: ') . '</div>';
707 $o .= '<div id="in-this-photo">' . $i1[0]['tag'] . '</div>';
711 $edit_tpl = file_get_contents('view/photo_edit.tpl');
712 $o .= replace_macros($edit_tpl, array(
713 '$id' => $ph[0]['id'],
714 '$resource_id' => $ph[0]['resource-id'],
715 '$capt_label' => t('Caption'),
716 '$caption' => $ph[0]['desc'],
717 '$tag_label' => t('Tags'),
718 '$tags' => $i1[0]['tag'],
719 '$item_id' => ((count($i1)) ? $i1[0]['id'] : 0),
720 '$submit' => t('Submit'),
721 '$delete' => t('Delete Photo')
727 // pull out how many people like the photo
729 $cmnt_tpl = file_get_contents('view/comment_item.tpl');
730 $tpl = file_get_contents('view/photo_item.tpl');
731 $return_url = $a->cmd;
733 if(can_write_wall($a,$a->data['user']['uid'])) {
734 if($i1[0]['last-child']) {
735 $o .= replace_macros($cmnt_tpl,array(
736 '$return_path' => $return_url,
737 '$type' => 'wall-comment',
738 '$id' => $i1[0]['id'],
739 '$parent' => $i1[0]['id'],
740 '$profile_uid' => $a->data['user']['uid'],
749 foreach($r as $item) {
753 $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
755 if(can_write_wall($a,$a->data['user']['uid'])) {
756 if($item['last-child']) {
757 $comment = replace_macros($cmnt_tpl,array(
758 '$return_path' => $return_url,
759 '$type' => 'wall-comment',
760 '$id' => $item['item_id'],
761 '$parent' => $item['parent'],
762 '$profile_uid' => $a->data['user']['uid'],
768 $profile_url = $item['url'];
771 if(local_user() && ($item['contact-uid'] == $_SESSION['uid']) && (strlen($item['dfrn-id'])) && (! $item['self'] ))
772 $profile_url = $redirect_url;
775 $profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']);
776 $profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb']);
777 $profile_link = $profile_url;
781 if(($item['contact-id'] == $_SESSION['visitor_id']) || ($item['uid'] == $_SESSION['uid']))
782 $drop = replace_macros(file_get_contents('view/wall_item_drop.tpl'), array('$id' => $item['id']));
785 $o .= replace_macros($template,array(
786 '$id' => $item['item_id'],
787 '$profile_url' => $profile_link,
788 '$name' => $profile_name,
789 '$thumb' => $profile_avatar,
790 '$title' => $item['title'],
791 '$body' => bbcode($item['body']),
792 '$ago' => relative_date($item['created']),
793 '$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''),
795 '$comment' => $comment
805 // Default - show recent photos with upload link (if applicable)
807 $r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s'
808 $sql_extra GROUP BY `resource-id`",
809 intval($a->data['user']['uid']),
810 dbesc( t('Contact Photos'))
813 $a->set_pager_total(count($r));
816 $r = q("SELECT `resource-id`, `album`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s'
817 $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d",
818 intval($a->data['user']['uid']),
819 dbesc( t('Contact Photos')),
820 intval($a->pager['start']),
821 intval($a->pager['itemspage'])
824 $o .= '<h3>' . t('Recent Photos') . '</h3>';
826 if( local_user() && ($_SESSION['uid'] == $a->data['user']['uid'])) {
827 $o .= '<div id="photo-top-links"><a id="photo-top-upload-link" href="'. $a->get_baseurl() . '/photos/'
828 . $a->data['user']['nickname'] . '/upload' . '">' . t('Upload New Photos') . '</a></div>';
831 $tpl = file_get_contents('view/photo_top.tpl');
834 $o .= replace_macros($tpl,array(
836 '$photolink' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname']
837 . '/image/' . $rr['resource-id'],
838 '$phototitle' => t('View Photo'),
839 '$imgsrc' => $a->get_baseurl() . '/photo/'
840 . $rr['resource-id'] . '-' . $rr['scale'] . '.jpg',
841 '$albumlink' => $a->get_baseurl . '/photos/'
842 . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']),
843 '$albumname' => $rr['album'],
844 '$albumalt' => t('View Album'),
845 '$imgalt' => $rr['filename']
849 $o .= '<div id="photo-top-end"></div>';