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']);
128 // send the notification upstream/downstream as the case may be
131 proc_close(proc_open("php include/notifier.php \"$url\" \"drop\" \"$drop_id\" ",
137 goaway($a->get_baseurl() . '/photos/' . $a->data['user']['uid']);
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']);
164 // send the notification upstream/downstream as the case may be
167 proc_close(proc_open("php include/notifier.php \"$url\" \"drop\" \"$drop_id\" ",
172 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
173 return; // NOTREACHED
178 if(($a->argc > 1) && (x($_POST,'desc') !== false)) {
179 $desc = notags(trim($_POST['desc']));
180 $tags = notags(trim($_POST['tags']));
181 $item_id = intval($_POST['item_id']);
182 $resource_id = $a->argv[1];
184 $p = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d ORDER BY `scale` DESC",
186 intval($_SESSION['uid'])
189 $r = q("UPDATE `photo` SET `desc` = '%s' WHERE `resource-id` = '%s' AND `uid` = %d",
192 intval($_SESSION['uid'])
198 $basename = basename($filename);
200 // Create item container
202 $body = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']'
203 . '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.jpg' . '[/img]'
208 $item_hash = random_string();
210 $uri = "urn:X-dfrn:" . $a->get_hostname() . ':' . $_SESSION['uid'] . ':' . $item_hash;
212 $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
216 } while($dups == true);
219 $r = q("INSERT INTO `item` (`uid`, `type`, `resource-id`, `contact-id`,
220 `owner-name`,`owner-link`,`owner-avatar`, `created`,
221 `edited`, `uri`, `parent-uri`, `title`, `body`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`)
222 VALUES( %d, '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
223 intval($_SESSION['uid']),
225 dbesc($p[0]['resource-id']),
226 intval($contact_record['id']),
227 dbesc($contact_record['name']),
228 dbesc($contact_record['url']),
229 dbesc($contact_record['thumb']),
236 dbesc($p[0]['allow_cid']),
237 dbesc($p[0]['allow_gid']),
238 dbesc($p[0]['deny_cid']),
239 dbesc($p[0]['deny_gid'])
244 $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
248 $item_id = $r[0]['id'];
249 q("UPDATE `item` SET `parent` = %d, `last-child` = 1 WHERE `id` = %d LIMIT 1",
256 $r = q("UPDATE `item` SET `tag` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
259 intval($_SESSION['uid'])
262 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
263 return; // NOTREACHED
269 if(! x($_FILES,'userfile'))
272 if($_POST['partitionCount'])
275 $java_upload = false;
277 $album = notags(trim($_POST['album']));
278 $newalbum = notags(trim($_POST['newalbum']));
280 if(! strlen($album)) {
281 if(strlen($newalbum))
284 $album = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y');
287 $r = q("SELECT * FROM `photo` WHERE `album` = '%s' AND `uid` = %d",
289 intval($_SESSION['uid'])
291 if((! count($r)) || ($album == t('Profile Photos')))
296 $str_group_allow = '';
297 $group_allow = $_POST['group_allow'];
298 if(is_array($group_allow)) {
299 array_walk($group_allow,'sanitise_acl');
300 $str_group_allow = implode('',$group_allow);
303 $str_contact_allow = '';
304 $contact_allow = $_POST['contact_allow'];
305 if(is_array($contact_allow)) {
306 array_walk($contact_allow,'sanitise_acl');
307 $str_contact_allow = implode('',$contact_allow);
310 $str_group_deny = '';
311 $group_deny = $_POST['group_deny'];
312 if(is_array($group_deny)) {
313 array_walk($group_deny,'sanitise_acl');
314 $str_group_deny = implode('',$group_deny);
317 $str_contact_deny = '';
318 $contact_deny = $_POST['contact_deny'];
319 if(is_array($contact_deny)) {
320 array_walk($contact_deny,'sanitise_acl');
321 $str_contact_deny = implode('',$contact_deny);
325 $src = $_FILES['userfile']['tmp_name'];
326 $filename = basename($_FILES['userfile']['name']);
327 $filesize = intval($_FILES['userfile']['size']);
329 $imagedata = @file_get_contents($src);
330 $ph = new Photo($imagedata);
332 if(! ($image = $ph->getImage())) {
333 notice( t('Unable to process image.') . EOL );
340 $width = $ph->getWidth();
341 $height = $ph->getHeight();
345 $photo_hash = hash('md5',uniqid(mt_rand(),true));
347 $r = $ph->store($_SESSION['uid'], 0, $photo_hash, $filename, $album, 0 , 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
350 notice( t('Image upload failed.') . EOL );
354 if($width > 640 || $height > 640) {
355 $ph->scaleImage(640);
356 $ph->store($_SESSION['uid'], 0, $photo_hash, $filename, $album, 1, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
360 if($width > 320 || $height > 320) {
361 $ph->scaleImage(320);
362 $ph->store($_SESSION['uid'], 0, $photo_hash, $filename, $album, 2, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
366 $basename = basename($filename);
368 // Create item container
370 $body = '[url=' . $a->get_baseurl() . '/photos/' . $contact_record['nickname'] . '/image/' . $photo_hash . ']'
371 . '[img]' . $a->get_baseurl() . "/photo/{$photo_hash}-{$smallest}.jpg" . '[/img]'
376 $item_hash = random_string();
378 $uri = "urn:X-dfrn:" . $a->get_hostname() . ':' . $profile_uid . ':' . $item_hash;
380 $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
384 } while($dups == true);
387 $r = q("INSERT INTO `item` (`uid`, `type`, `resource-id`, `contact-id`,`owner-name`,`owner-link`,`owner-avatar`, `created`,
388 `edited`, `uri`, `parent-uri`, `title`, `body`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `visible`)
389 VALUES( %d, '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d )",
390 intval($_SESSION['uid']),
393 intval($contact_record['id']),
394 dbesc($contact_record['name']),
395 dbesc($contact_record['url']),
396 dbesc($contact_record['thumb']),
403 dbesc($str_contact_allow),
404 dbesc($str_group_allow),
405 dbesc($str_contact_deny),
406 dbesc($str_group_deny),
411 $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
415 q("UPDATE `item` SET `parent` = %d, `last-child` = 1 WHERE `id` = %d LIMIT 1",
423 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
424 return; // NOTREACHED
428 return; // NOTREACHED
434 function photos_content(&$a) {
438 // photos/name/upload
439 // photos/name/album/xxxxx
440 // photos/name/album/xxxxx/edit
441 // photos/name/image/xxxxx
442 // photos/name/image/xxxxx/edit
445 if(! x($a->data,'user')) {
446 notice( t('No photos selected') . EOL );
450 $_SESSION['photo_return'] = $a->cmd;
457 $datatype = $a->argv[2];
458 $datum = $a->argv[3];
460 elseif(($a->argc > 2) && ($a->argv[2] == 'upload'))
461 $datatype = 'upload';
463 $datatype = 'summary';
471 // Setup permissions structures
474 $owner_uid = $a->data['user']['uid'];
477 $contact_id = $_SESSION['visitor_id'];
478 $groups = init_groups_visitor($contact_id);
481 // default permissions - anonymous user
483 $sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '' ";
485 // Profile owner - everything is visible
487 if(local_user() && ($_SESSION['uid'] == $owner_uid)) {
490 elseif(remote_user()) {
491 // authenticated visitor - here lie dragons
492 $gs = '<<>>'; // should be impossible to match
494 foreach($groups as $g)
495 $gs .= '|<' . intval($g) . '>';
497 $sql_extra = sprintf(
498 " AND ( `allow_cid` = '' OR `allow_cid` REGEXP '<%d>' )
499 AND ( `deny_cid` = '' OR NOT `deny_cid` REGEXP '<%d>' )
500 AND ( `allow_gid` = '' OR `allow_gid` REGEXP '%s' )
501 AND ( `deny_gid` = '' OR NOT `deny_gid` REGEXP '%s') ",
503 intval($_SESSION['visitor_id']),
504 intval($_SESSION['visitor_id']),
515 if($datatype == 'upload') {
516 if( ! (local_user() && ($_SESSION['uid'] == $a->data['user']['uid']))) {
517 notice( t('Permission denied.'));
520 $albumselect = '<select id="photos-upload-album-select" name="album" size="4">';
522 $albumselect .= '<option value="" selected="selected" > </option>';
523 if(count($a->data['albums'])) {
524 foreach($a->data['albums'] as $album) {
525 if(($album['album'] == '') || ($album['album'] == t('Contact Photos')))
527 $albumselect .= '<option value="' . $album['album'] . '">' . $album['album'] . '</option>';
530 $albumselect .= '</select>';
531 $tpl = file_get_contents('view/photos_upload.tpl');
532 $o .= replace_macros($tpl,array(
533 '$pagename' => t('Upload Photos'),
534 '$sessid' => session_id(),
535 '$newalbum' => t('New album name: '),
536 '$existalbumtext' => t('or existing album name: '),
537 '$filestext' => t('Select files to upload: '),
538 '$albumselect' => $albumselect,
539 '$permissions' => t('Permissions'),
540 '$aclselect' => populate_acl($a->user),
541 '$archive' => $a->get_baseurl() . '/jumploader_z.jar',
542 '$nojava' => t('Use the following controls only if the Java uploader (above) fails to launch.'),
543 '$uploadurl' => $a->get_baseurl() . '/photos',
544 '$submit' => t('Submit')
551 if($datatype == 'album') {
553 $album = hex2bin($datum);
555 $r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` = '%s'
556 $sql_extra GROUP BY `resource-id`",
557 intval($a->data['user']['uid']),
561 $a->set_pager_total(count($r));
564 $r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` = '%s'
565 $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d",
566 intval($a->data['user']['uid']),
568 intval($a->pager['start']),
569 intval($a->pager['itemspage'])
572 $o .= '<h3>' . $album . '</h3>';
575 if(($album != t('Profile Photos')) && ($album != t('Contact Photos'))) {
576 if(local_user() && ($_SESSION['uid'] == $a->data['user']['uid'])) {
577 $edit_tpl = file_get_contents('view/album_edit.tpl');
578 $o .= replace_macros($edit_tpl,array(
579 '$nametext' => t('New album name: '),
581 '$hexalbum' => bin2hex($album),
582 '$submit' => t('Submit'),
583 '$dropsubmit' => t('Delete Album')
589 if(($album != t('Profile Photos')) && ($album != t('Contact Photos'))) {
590 if(local_user() && ($_SESSION['uid'] == $a->data['user']['uid'])) {
591 $o .= '<div id="album-edit-link"><a href="'. $a->get_baseurl() . '/photos/'
592 . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '/edit' . '">'
593 . t('Edit Album') . '</a></div>';
597 $tpl = file_get_contents('view/photo_album.tpl');
600 $o .= replace_macros($tpl,array(
602 '$photolink' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'],
603 '$phototitle' => t('View Photo'),
604 '$imgsrc' => $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['scale'] . '.jpg',
605 '$imgalt' => $rr['filename']
609 $o .= '<div id="photo-album-end"></div>';
615 if($datatype == 'image') {
617 require_once('security.php');
618 require_once('bbcode.php');
620 // fetch image, item containing image, then comments
622 $ph = q("SELECT * FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'
623 $sql_extra ORDER BY `scale` ASC ",
624 intval($a->data['user']['uid']),
629 notice( t('Photo not available') . EOL );
634 $hires = $lores = $ph[0];
636 if($ph[1]['scale'] == 2) {
637 // original is 640 or less, we can display it directly
638 $hires = $lores = $ph[0];
647 $o .= '<h3>' . '<a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($ph[0]['album']) . '">' . $ph[0]['album'] . '</a></h3>';
649 if(local_user() && ($ph[0]['uid'] == $_SESSION['uid'])) {
650 $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>';
654 $o .= '<a href="' . $a->get_baseurl() . '/photo/'
655 . $hires['resource-id'] . '-' . $hires['scale'] . '.jpg" title="'
656 . t('View Full Size') . '" ><img src="' . $a->get_baseurl() . '/photo/'
657 . $lores['resource-id'] . '-' . $lores['scale'] . '.jpg' . '" /></a>';
660 // Do we have an item for this photo?
662 $i1 = q("SELECT * FROM `item` WHERE `resource-id` = '%s' $sql_extra LIMIT 1",
667 $r = q("SELECT COUNT(*) AS `total`
668 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
669 WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0
670 AND NOT `item`.`type` IN ( 'remote', 'net-comment')
671 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
673 dbesc($i1[0]['uri']),
679 $a->set_pager_total($r[0]['total']);
682 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
683 `contact`.`name`, `contact`.`photo`, `contact`.`url`,
684 `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
685 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
686 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
687 WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0
688 AND NOT `item`.`type` IN ( 'remote', 'net-comment')
689 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
691 ORDER BY `parent` DESC, `id` ASC LIMIT %d ,%d ",
692 dbesc($i1[0]['uri']),
693 dbesc($i1[0]['uri']),
694 intval($a->pager['start']),
695 intval($a->pager['itemspage'])
700 $o .= '<div id="photo-caption" >' . $ph[0]['desc'] . '</div>';
702 if(count($i1) && strlen($i1[0]['tag'])) {
703 // parse tags and add links
704 $o .= '<div id="in-this-photo-text">' . t('In this photo: ') . '</div>';
705 $o .= '<div id="in-this-photo">' . $i1[0]['tag'] . '</div>';
709 $edit_tpl = file_get_contents('view/photo_edit.tpl');
710 $o .= replace_macros($edit_tpl, array(
711 '$id' => $ph[0]['id'],
712 '$resource_id' => $ph[0]['resource-id'],
713 '$capt_label' => t('Caption'),
714 '$caption' => $ph[0]['desc'],
715 '$tag_label' => t('Tags'),
716 '$tags' => $i1[0]['tag'],
717 '$item_id' => ((count($i1)) ? $i1[0]['id'] : 0),
718 '$submit' => t('Submit'),
719 '$delete' => t('Delete Photo')
725 // pull out how many people like the photo
727 $cmnt_tpl = file_get_contents('view/comment_item.tpl');
728 $tpl = file_get_contents('view/photo_item.tpl');
729 $return_url = $a->cmd;
731 if(can_write_wall($a,$a->data['user']['uid'])) {
732 if($i1[0]['last-child']) {
733 $o .= replace_macros($cmnt_tpl,array(
734 '$return_path' => $return_url,
735 '$type' => 'wall-comment',
736 '$id' => $i1[0]['id'],
737 '$parent' => $i1[0]['id'],
738 '$profile_uid' => $a->data['user']['uid'],
747 foreach($r as $item) {
751 $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
753 if(can_write_wall($a,$a->data['user']['uid'])) {
754 if($item['last-child']) {
755 $comment = replace_macros($cmnt_tpl,array(
756 '$return_path' => $return_url,
757 '$type' => 'wall-comment',
758 '$id' => $item['item_id'],
759 '$parent' => $item['parent'],
760 '$profile_uid' => $a->data['user']['uid'],
766 $profile_url = $item['url'];
769 if(local_user() && ($item['contact-uid'] == $_SESSION['uid']) && (strlen($item['dfrn-id'])) && (! $item['self'] ))
770 $profile_url = $redirect_url;
773 $profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']);
774 $profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb']);
775 $profile_link = $profile_url;
779 if(($item['contact-id'] == $_SESSION['visitor_id']) || ($item['uid'] == $_SESSION['uid']))
780 $drop = replace_macros(file_get_contents('view/wall_item_drop.tpl'), array('$id' => $item['id']));
783 $o .= replace_macros($template,array(
784 '$id' => $item['item_id'],
785 '$profile_url' => $profile_link,
786 '$name' => $profile_name,
787 '$thumb' => $profile_avatar,
788 '$title' => $item['title'],
789 '$body' => bbcode($item['body']),
790 '$ago' => relative_date($item['created']),
791 '$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''),
793 '$comment' => $comment
803 // Default - show recent photos with upload link (if applicable)
805 $r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s'
806 $sql_extra GROUP BY `resource-id`",
807 intval($a->data['user']['uid']),
808 dbesc( t('Contact Photos'))
811 $a->set_pager_total(count($r));
814 $r = q("SELECT `resource-id`, `album`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s'
815 $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d",
816 intval($a->data['user']['uid']),
817 dbesc( t('Contact Photos')),
818 intval($a->pager['start']),
819 intval($a->pager['itemspage'])
822 $o .= '<h3>' . t('Recent Photos') . '</h3>';
824 if( local_user() && ($_SESSION['uid'] == $a->data['user']['uid'])) {
825 $o .= '<div id="photo-top-links"><a id="photo-top-upload-link" href="'. $a->get_baseurl() . '/photos/'
826 . $a->data['user']['nickname'] . '/upload' . '">' . t('Upload New Photos') . '</a></div>';
829 $tpl = file_get_contents('view/photo_top.tpl');
832 $o .= replace_macros($tpl,array(
834 '$photolink' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname']
835 . '/image/' . $rr['resource-id'],
836 '$phototitle' => t('View Photo'),
837 '$imgsrc' => $a->get_baseurl() . '/photo/'
838 . $rr['resource-id'] . '-' . $rr['scale'] . '.jpg',
839 '$albumlink' => $a->get_baseurl . '/photos/'
840 . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']),
841 '$albumname' => $rr['album'],
842 '$albumalt' => t('View Album'),
843 '$imgalt' => $rr['filename']
847 $o .= '<div id="photo-top-end"></div>';