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 $drop_id = intval($rr['id']);
126 $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
128 // send the notification upstream/downstream as the case may be
131 proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"drop\" \"$drop_id\" & ",
137 goaway($a->get_baseurl() . '/photos/' . $a->data['user']['nickname']);
138 return; // NOTREACHED
141 if(($a->argc > 1) && (x($_POST,'delete')) && ($_POST['delete'] == t('Delete Photo'))) {
142 $r = q("SELECT `id` FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' LIMIT 1",
143 intval($_SESSION['uid']),
147 q("DELETE FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'",
148 intval($_SESSION['uid']),
149 dbesc($r[0]['resource-id'])
151 $i = q("SELECT * FROM `item` WHERE `resource-id` = '%s' AND `uid` = %d LIMIT 1",
152 dbesc($r[0]['resource-id']),
153 intval($_SESSION['uid'])
156 q("UPDATE `item` SET `deleted` = 1 WHERE `parent-uri` = '%s' AND `uid` = %d",
158 intval($_SESSION['uid'])
161 $url = $a->get_baseurl();
162 $drop_id = intval($i[0]['id']);
163 $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
165 // send the notification upstream/downstream as the case may be
168 proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"drop\" \"$drop_id\" & ",
173 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
174 return; // NOTREACHED
179 if(($a->argc > 1) && (x($_POST,'desc') !== false)) {
180 $desc = notags(trim($_POST['desc']));
181 $tags = notags(trim($_POST['tags']));
182 $item_id = intval($_POST['item_id']);
183 $resource_id = $a->argv[1];
185 $p = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d ORDER BY `scale` DESC",
187 intval($_SESSION['uid'])
190 $r = q("UPDATE `photo` SET `desc` = '%s' WHERE `resource-id` = '%s' AND `uid` = %d",
193 intval($_SESSION['uid'])
199 $basename = basename($filename);
201 // Create item container
203 $body = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']'
204 . '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.jpg' . '[/img]'
209 $item_hash = random_string();
211 $uri = "urn:X-dfrn:" . $a->get_hostname() . ':' . $_SESSION['uid'] . ':' . $item_hash;
213 $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
217 } while($dups == true);
220 $r = q("INSERT INTO `item` (`uid`, `type`, `resource-id`, `contact-id`,
221 `owner-name`,`owner-link`,`owner-avatar`, `created`,
222 `edited`, `uri`, `parent-uri`, `title`, `body`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`)
223 VALUES( %d, '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
224 intval($_SESSION['uid']),
226 dbesc($p[0]['resource-id']),
227 intval($contact_record['id']),
228 dbesc($contact_record['name']),
229 dbesc($contact_record['url']),
230 dbesc($contact_record['thumb']),
237 dbesc($p[0]['allow_cid']),
238 dbesc($p[0]['allow_gid']),
239 dbesc($p[0]['deny_cid']),
240 dbesc($p[0]['deny_gid'])
245 $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
249 $item_id = $r[0]['id'];
250 q("UPDATE `item` SET `parent` = %d, `last-child` = 1 WHERE `id` = %d LIMIT 1",
257 $r = q("UPDATE `item` SET `tag` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
260 intval($_SESSION['uid'])
263 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
264 return; // NOTREACHED
270 if(! x($_FILES,'userfile'))
273 if($_POST['partitionCount'])
276 $java_upload = false;
278 $album = notags(trim($_POST['album']));
279 $newalbum = notags(trim($_POST['newalbum']));
281 if(! strlen($album)) {
282 if(strlen($newalbum))
285 $album = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y');
288 $r = q("SELECT * FROM `photo` WHERE `album` = '%s' AND `uid` = %d",
290 intval($_SESSION['uid'])
292 if((! count($r)) || ($album == t('Profile Photos')))
297 $str_group_allow = '';
298 $group_allow = $_POST['group_allow'];
299 if(is_array($group_allow)) {
300 array_walk($group_allow,'sanitise_acl');
301 $str_group_allow = implode('',$group_allow);
304 $str_contact_allow = '';
305 $contact_allow = $_POST['contact_allow'];
306 if(is_array($contact_allow)) {
307 array_walk($contact_allow,'sanitise_acl');
308 $str_contact_allow = implode('',$contact_allow);
311 $str_group_deny = '';
312 $group_deny = $_POST['group_deny'];
313 if(is_array($group_deny)) {
314 array_walk($group_deny,'sanitise_acl');
315 $str_group_deny = implode('',$group_deny);
318 $str_contact_deny = '';
319 $contact_deny = $_POST['contact_deny'];
320 if(is_array($contact_deny)) {
321 array_walk($contact_deny,'sanitise_acl');
322 $str_contact_deny = implode('',$contact_deny);
326 $src = $_FILES['userfile']['tmp_name'];
327 $filename = basename($_FILES['userfile']['name']);
328 $filesize = intval($_FILES['userfile']['size']);
330 $imagedata = @file_get_contents($src);
331 $ph = new Photo($imagedata);
333 if(! ($image = $ph->getImage())) {
334 notice( t('Unable to process image.') . EOL );
341 $width = $ph->getWidth();
342 $height = $ph->getHeight();
346 $photo_hash = hash('md5',uniqid(mt_rand(),true));
348 $r = $ph->store($_SESSION['uid'], 0, $photo_hash, $filename, $album, 0 , 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
351 notice( t('Image upload failed.') . EOL );
355 if($width > 640 || $height > 640) {
356 $ph->scaleImage(640);
357 $ph->store($_SESSION['uid'], 0, $photo_hash, $filename, $album, 1, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
361 if($width > 320 || $height > 320) {
362 $ph->scaleImage(320);
363 $ph->store($_SESSION['uid'], 0, $photo_hash, $filename, $album, 2, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
367 $basename = basename($filename);
369 // Create item container
371 $body = '[url=' . $a->get_baseurl() . '/photos/' . $contact_record['nickname'] . '/image/' . $photo_hash . ']'
372 . '[img]' . $a->get_baseurl() . "/photo/{$photo_hash}-{$smallest}.jpg" . '[/img]'
377 $item_hash = random_string();
379 $uri = "urn:X-dfrn:" . $a->get_hostname() . ':' . $_SESSION['uid'] . ':' . $item_hash;
381 $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
385 } while($dups == true);
388 $r = q("INSERT INTO `item` (`uid`, `type`, `resource-id`, `contact-id`,`owner-name`,`owner-link`,`owner-avatar`, `created`,
389 `edited`, `uri`, `parent-uri`, `title`, `body`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `visible`)
390 VALUES( %d, '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d )",
391 intval($_SESSION['uid']),
394 intval($contact_record['id']),
395 dbesc($contact_record['name']),
396 dbesc($contact_record['url']),
397 dbesc($contact_record['thumb']),
404 dbesc($str_contact_allow),
405 dbesc($str_group_allow),
406 dbesc($str_contact_deny),
407 dbesc($str_group_deny),
412 $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
416 q("UPDATE `item` SET `parent` = %d, `last-child` = 1 WHERE `id` = %d LIMIT 1",
424 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
425 return; // NOTREACHED
429 return; // NOTREACHED
435 function photos_content(&$a) {
439 // photos/name/upload
440 // photos/name/album/xxxxx
441 // photos/name/album/xxxxx/edit
442 // photos/name/image/xxxxx
443 // photos/name/image/xxxxx/edit
446 if(! x($a->data,'user')) {
447 notice( t('No photos selected') . EOL );
451 $_SESSION['photo_return'] = $a->cmd;
458 $datatype = $a->argv[2];
459 $datum = $a->argv[3];
461 elseif(($a->argc > 2) && ($a->argv[2] == 'upload'))
462 $datatype = 'upload';
464 $datatype = 'summary';
472 // Setup permissions structures
475 $owner_uid = $a->data['user']['uid'];
478 $contact_id = $_SESSION['visitor_id'];
479 $groups = init_groups_visitor($contact_id);
482 // default permissions - anonymous user
484 $sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '' ";
486 // Profile owner - everything is visible
488 if(local_user() && ($_SESSION['uid'] == $owner_uid)) {
491 elseif(remote_user()) {
492 // authenticated visitor - here lie dragons
493 $gs = '<<>>'; // should be impossible to match
495 foreach($groups as $g)
496 $gs .= '|<' . intval($g) . '>';
498 $sql_extra = sprintf(
499 " AND ( `allow_cid` = '' OR `allow_cid` REGEXP '<%d>' )
500 AND ( `deny_cid` = '' OR NOT `deny_cid` REGEXP '<%d>' )
501 AND ( `allow_gid` = '' OR `allow_gid` REGEXP '%s' )
502 AND ( `deny_gid` = '' OR NOT `deny_gid` REGEXP '%s') ",
504 intval($_SESSION['visitor_id']),
505 intval($_SESSION['visitor_id']),
516 if($datatype == 'upload') {
517 if( ! (local_user() && ($_SESSION['uid'] == $a->data['user']['uid']))) {
518 notice( t('Permission denied.'));
521 $albumselect = '<select id="photos-upload-album-select" name="album" size="4">';
523 $albumselect .= '<option value="" selected="selected" > </option>';
524 if(count($a->data['albums'])) {
525 foreach($a->data['albums'] as $album) {
526 if(($album['album'] == '') || ($album['album'] == t('Contact Photos')))
528 $albumselect .= '<option value="' . $album['album'] . '">' . $album['album'] . '</option>';
531 $albumselect .= '</select>';
532 $tpl = file_get_contents('view/photos_upload.tpl');
533 $o .= replace_macros($tpl,array(
534 '$pagename' => t('Upload Photos'),
535 '$sessid' => session_id(),
536 '$newalbum' => t('New album name: '),
537 '$existalbumtext' => t('or existing album name: '),
538 '$filestext' => t('Select files to upload: '),
539 '$albumselect' => $albumselect,
540 '$permissions' => t('Permissions'),
541 '$aclselect' => populate_acl($a->user),
542 '$archive' => $a->get_baseurl() . '/jumploader_z.jar',
543 '$nojava' => t('Use the following controls only if the Java uploader (above) fails to launch.'),
544 '$uploadurl' => $a->get_baseurl() . '/photos',
545 '$submit' => t('Submit')
552 if($datatype == 'album') {
554 $album = hex2bin($datum);
556 $r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` = '%s'
557 $sql_extra GROUP BY `resource-id`",
558 intval($a->data['user']['uid']),
562 $a->set_pager_total(count($r));
565 $r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` = '%s'
566 $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d",
567 intval($a->data['user']['uid']),
569 intval($a->pager['start']),
570 intval($a->pager['itemspage'])
573 $o .= '<h3>' . $album . '</h3>';
576 if(($album != t('Profile Photos')) && ($album != t('Contact Photos'))) {
577 if(local_user() && ($_SESSION['uid'] == $a->data['user']['uid'])) {
578 $edit_tpl = file_get_contents('view/album_edit.tpl');
579 $o .= replace_macros($edit_tpl,array(
580 '$nametext' => t('New album name: '),
582 '$hexalbum' => bin2hex($album),
583 '$submit' => t('Submit'),
584 '$dropsubmit' => t('Delete Album')
590 if(($album != t('Profile Photos')) && ($album != t('Contact Photos'))) {
591 if(local_user() && ($_SESSION['uid'] == $a->data['user']['uid'])) {
592 $o .= '<div id="album-edit-link"><a href="'. $a->get_baseurl() . '/photos/'
593 . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '/edit' . '">'
594 . t('Edit Album') . '</a></div>';
598 $tpl = file_get_contents('view/photo_album.tpl');
601 $o .= replace_macros($tpl,array(
603 '$photolink' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'],
604 '$phototitle' => t('View Photo'),
605 '$imgsrc' => $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['scale'] . '.jpg',
606 '$imgalt' => $rr['filename']
610 $o .= '<div id="photo-album-end"></div>';
616 if($datatype == 'image') {
618 require_once('security.php');
619 require_once('bbcode.php');
621 // fetch image, item containing image, then comments
623 $ph = q("SELECT * FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'
624 $sql_extra ORDER BY `scale` ASC ",
625 intval($a->data['user']['uid']),
630 notice( t('Photo not available') . EOL );
635 $hires = $lores = $ph[0];
637 if($ph[1]['scale'] == 2) {
638 // original is 640 or less, we can display it directly
639 $hires = $lores = $ph[0];
648 $o .= '<h3>' . '<a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($ph[0]['album']) . '">' . $ph[0]['album'] . '</a></h3>';
650 if(local_user() && ($ph[0]['uid'] == $_SESSION['uid'])) {
651 $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>';
655 $o .= '<a href="' . $a->get_baseurl() . '/photo/'
656 . $hires['resource-id'] . '-' . $hires['scale'] . '.jpg" title="'
657 . t('View Full Size') . '" ><img src="' . $a->get_baseurl() . '/photo/'
658 . $lores['resource-id'] . '-' . $lores['scale'] . '.jpg' . '" /></a>';
661 // Do we have an item for this photo?
663 $i1 = q("SELECT * FROM `item` WHERE `resource-id` = '%s' $sql_extra LIMIT 1",
668 $r = q("SELECT COUNT(*) AS `total`
669 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
670 WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0
671 AND NOT `item`.`type` IN ( 'remote', 'net-comment')
672 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
674 dbesc($i1[0]['uri']),
680 $a->set_pager_total($r[0]['total']);
683 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
684 `contact`.`name`, `contact`.`photo`, `contact`.`url`,
685 `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
686 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
687 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
688 WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0
689 AND NOT `item`.`type` IN ( 'remote', 'net-comment')
690 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
692 ORDER BY `parent` DESC, `id` ASC LIMIT %d ,%d ",
693 dbesc($i1[0]['uri']),
694 dbesc($i1[0]['uri']),
695 intval($a->pager['start']),
696 intval($a->pager['itemspage'])
701 $o .= '<div id="photo-caption" >' . $ph[0]['desc'] . '</div>';
703 if(count($i1) && strlen($i1[0]['tag'])) {
704 // parse tags and add links
705 $o .= '<div id="in-this-photo-text">' . t('In this photo: ') . '</div>';
706 $o .= '<div id="in-this-photo">' . $i1[0]['tag'] . '</div>';
710 $edit_tpl = file_get_contents('view/photo_edit.tpl');
711 $o .= replace_macros($edit_tpl, array(
712 '$id' => $ph[0]['id'],
713 '$resource_id' => $ph[0]['resource-id'],
714 '$capt_label' => t('Caption'),
715 '$caption' => $ph[0]['desc'],
716 '$tag_label' => t('Tags'),
717 '$tags' => $i1[0]['tag'],
718 '$item_id' => ((count($i1)) ? $i1[0]['id'] : 0),
719 '$submit' => t('Submit'),
720 '$delete' => t('Delete Photo')
726 // pull out how many people like the photo
728 $cmnt_tpl = file_get_contents('view/comment_item.tpl');
729 $tpl = file_get_contents('view/photo_item.tpl');
730 $return_url = $a->cmd;
732 if(can_write_wall($a,$a->data['user']['uid'])) {
733 if($i1[0]['last-child']) {
734 $o .= replace_macros($cmnt_tpl,array(
735 '$return_path' => $return_url,
736 '$type' => 'wall-comment',
737 '$id' => $i1[0]['id'],
738 '$parent' => $i1[0]['id'],
739 '$profile_uid' => $a->data['user']['uid'],
748 foreach($r as $item) {
752 $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
754 if(can_write_wall($a,$a->data['user']['uid'])) {
755 if($item['last-child']) {
756 $comment = replace_macros($cmnt_tpl,array(
757 '$return_path' => $return_url,
758 '$type' => 'wall-comment',
759 '$id' => $item['item_id'],
760 '$parent' => $item['parent'],
761 '$profile_uid' => $a->data['user']['uid'],
767 $profile_url = $item['url'];
770 if(local_user() && ($item['contact-uid'] == $_SESSION['uid']) && (strlen($item['dfrn-id'])) && (! $item['self'] ))
771 $profile_url = $redirect_url;
774 $profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']);
775 $profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb']);
776 $profile_link = $profile_url;
780 if(($item['contact-id'] == $_SESSION['visitor_id']) || ($item['uid'] == $_SESSION['uid']))
781 $drop = replace_macros(file_get_contents('view/wall_item_drop.tpl'), array('$id' => $item['id']));
784 $o .= replace_macros($template,array(
785 '$id' => $item['item_id'],
786 '$profile_url' => $profile_link,
787 '$name' => $profile_name,
788 '$thumb' => $profile_avatar,
789 '$title' => $item['title'],
790 '$body' => bbcode($item['body']),
791 '$ago' => relative_date($item['created']),
792 '$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''),
794 '$comment' => $comment
804 // Default - show recent photos with upload link (if applicable)
806 $r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s'
807 $sql_extra GROUP BY `resource-id`",
808 intval($a->data['user']['uid']),
809 dbesc( t('Contact Photos'))
812 $a->set_pager_total(count($r));
815 $r = q("SELECT `resource-id`, `album`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s'
816 $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d",
817 intval($a->data['user']['uid']),
818 dbesc( t('Contact Photos')),
819 intval($a->pager['start']),
820 intval($a->pager['itemspage'])
823 $o .= '<h3>' . t('Recent Photos') . '</h3>';
825 if( local_user() && ($_SESSION['uid'] == $a->data['user']['uid'])) {
826 $o .= '<div id="photo-top-links"><a id="photo-top-upload-link" href="'. $a->get_baseurl() . '/photos/'
827 . $a->data['user']['nickname'] . '/upload' . '">' . t('Upload New Photos') . '</a></div>';
830 $tpl = file_get_contents('view/photo_top.tpl');
833 $o .= replace_macros($tpl,array(
835 '$photolink' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname']
836 . '/image/' . $rr['resource-id'],
837 '$phototitle' => t('View Photo'),
838 '$imgsrc' => $a->get_baseurl() . '/photo/'
839 . $rr['resource-id'] . '-' . $rr['scale'] . '.jpg',
840 '$albumlink' => $a->get_baseurl . '/photos/'
841 . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']),
842 '$albumname' => $rr['album'],
843 '$albumalt' => t('View Album'),
844 '$imgalt' => $rr['filename']
848 $o .= '<div id="photo-top-end"></div>';