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 $tpl = get_markup_template("photos_head.tpl");
73 $a->page['htmlhead'] .= replace_macros($tpl,array(
74 '$ispublic' => t('everybody')
84 function photos_post(&$a) {
86 logger('mod-photos: photos_post: begin' , LOGGER_DEBUG);
89 logger('mod_photos: REQUEST ' . print_r($_REQUEST,true), LOGGER_DATA);
90 logger('mod_photos: FILES ' . print_r($_FILES,true), LOGGER_DATA);
92 $phototypes = Photo::supportedTypes();
97 $page_owner_uid = $a->data['user']['uid'];
98 $community_page = (($a->data['user']['page-flags'] == PAGE_COMMUNITY) ? true : false);
100 if((local_user()) && (local_user() == $page_owner_uid))
103 if($community_page && remote_user()) {
104 $r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
105 intval(remote_user()),
106 intval($page_owner_uid)
110 $visitor = remote_user();
116 notice( t('Permission denied.') . EOL );
120 $r = q("SELECT `contact`.*, `user`.`nickname` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
121 WHERE `user`.`uid` = %d AND `self` = 1 LIMIT 1",
122 intval($page_owner_uid)
126 notice( t('Contact information unavailable') . EOL);
127 logger('photos_post: unable to locate contact record for page owner. uid=' . $page_owner_uid);
131 $owner_record = $r[0];
134 if(($a->argc > 3) && ($a->argv[2] === 'album')) {
135 $album = hex2bin($a->argv[3]);
137 if($album === t('Profile Photos') || $album === 'Contact Photos' || $album === t('Contact Photos')) {
138 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
139 return; // NOTREACHED
142 $r = q("SELECT count(*) FROM `photo` WHERE `album` = '%s' AND `uid` = %d",
144 intval($page_owner_uid)
147 notice( t('Album not found.') . EOL);
148 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
149 return; // NOTREACHED
152 $newalbum = notags(trim($_POST['albumname']));
153 if($newalbum != $album) {
154 q("UPDATE `photo` SET `album` = '%s' WHERE `album` = '%s' AND `uid` = %d",
157 intval($page_owner_uid)
159 $newurl = str_replace(bin2hex($album),bin2hex($newalbum),$_SESSION['photo_return']);
160 goaway($a->get_baseurl() . '/' . $newurl);
161 return; // NOTREACHED
165 if($_POST['dropalbum'] == t('Delete Album')) {
169 // get the list of photos we are about to delete
172 $r = q("SELECT distinct(`resource-id`) as `rid` FROM `photo` WHERE `contact-id` = %d AND `uid` = %d AND `album` = '%s'",
174 intval($page_owner_uid),
179 $r = q("SELECT distinct(`resource-id`) as `rid` FROM `photo` WHERE `uid` = %d AND `album` = '%s'",
180 intval(local_user()),
186 $res[] = "'" . dbesc($rr['rid']) . "'" ;
190 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
191 return; // NOTREACHED
194 $str_res = implode(',', $res);
196 // remove the associated photos
198 q("DELETE FROM `photo` WHERE `resource-id` IN ( $str_res ) AND `uid` = %d",
199 intval($page_owner_uid)
202 // find and delete the corresponding item with all the comments and likes/dislikes
204 $r = q("SELECT `parent-uri` FROM `item` WHERE `resource-id` IN ( $str_res ) AND `uid` = %d",
205 intval($page_owner_uid)
209 q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
210 dbesc(datetime_convert()),
211 dbesc($rr['parent-uri']),
212 intval($page_owner_uid)
215 $drop_id = intval($rr['id']);
217 // send the notification upstream/downstream as the case may be
220 proc_run('php',"include/notifier.php","drop","$drop_id");
224 goaway($a->get_baseurl() . '/photos/' . $a->data['user']['nickname']);
225 return; // NOTREACHED
228 if(($a->argc > 2) && (x($_POST,'delete')) && ($_POST['delete'] == t('Delete Photo'))) {
230 // same as above but remove single photo
233 $r = q("SELECT `id`, `resource-id` FROM `photo` WHERE `contact-id` = %d AND `uid` = %d AND `resource-id` = '%s' LIMIT 1",
235 intval($page_owner_uid),
240 $r = q("SELECT `id`, `resource-id` FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' LIMIT 1",
241 intval(local_user()),
246 q("DELETE FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'",
247 intval($page_owner_uid),
248 dbesc($r[0]['resource-id'])
250 $i = q("SELECT * FROM `item` WHERE `resource-id` = '%s' AND `uid` = %d LIMIT 1",
251 dbesc($r[0]['resource-id']),
252 intval($page_owner_uid)
255 q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
256 dbesc(datetime_convert()),
257 dbesc(datetime_convert()),
259 intval($page_owner_uid)
262 $url = $a->get_baseurl();
263 $drop_id = intval($i[0]['id']);
266 proc_run('php',"include/notifier.php","drop","$drop_id");
270 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
271 return; // NOTREACHED
274 if(($a->argc > 2) && ((x($_POST,'desc') !== false) || (x($_POST,'newtag') !== false)) || (x($_POST,'albname') !== false)) {
277 $desc = ((x($_POST,'desc')) ? notags(trim($_POST['desc'])) : '');
278 $rawtags = ((x($_POST,'newtag')) ? notags(trim($_POST['newtag'])) : '');
279 $item_id = ((x($_POST,'item_id')) ? intval($_POST['item_id']) : 0);
280 $albname = ((x($_POST,'albname')) ? notags(trim($_POST['albname'])) : '');
281 $str_group_allow = perms2str($_POST['group_allow']);
282 $str_contact_allow = perms2str($_POST['contact_allow']);
283 $str_group_deny = perms2str($_POST['group_deny']);
284 $str_contact_deny = perms2str($_POST['contact_deny']);
286 $resource_id = $a->argv[2];
288 if(! strlen($albname))
289 $albname = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y');
292 if((x($_POST,'rotate') !== false) &&
293 ( (intval($_POST['rotate']) == 1) || (intval($_POST['rotate']) == 2) )) {
296 $r = q("select * from photo where `resource-id` = '%s' and uid = %d and scale = 0 limit 1",
298 intval($page_owner_uid)
301 $ph = new Photo($r[0]['data'], $r[0]['type']);
302 if($ph->is_valid()) {
303 $rotate_deg = ( (intval($_POST['rotate']) == 1) ? 270 : 90 );
304 $ph->rotate($rotate_deg);
306 $width = $ph->getWidth();
307 $height = $ph->getHeight();
309 $x = q("update photo set data = '%s', height = %d, width = %d where `resource-id` = '%s' and uid = %d and scale = 0 limit 1",
310 dbesc($ph->imageString()),
314 intval($page_owner_uid)
317 if($width > 640 || $height > 640) {
318 $ph->scaleImage(640);
319 $width = $ph->getWidth();
320 $height = $ph->getHeight();
322 $x = q("update photo set data = '%s', height = %d, width = %d where `resource-id` = '%s' and uid = %d and scale = 1 limit 1",
323 dbesc($ph->imageString()),
327 intval($page_owner_uid)
331 if($width > 320 || $height > 320) {
332 $ph->scaleImage(320);
333 $width = $ph->getWidth();
334 $height = $ph->getHeight();
336 $x = q("update photo set data = '%s', height = %d, width = %d where `resource-id` = '%s' and uid = %d and scale = 2 limit 1",
337 dbesc($ph->imageString()),
341 intval($page_owner_uid)
348 $p = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d ORDER BY `scale` DESC",
350 intval($page_owner_uid)
353 $ext = $phototypes[$p[0]['type']];
354 $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",
357 dbesc($str_contact_allow),
358 dbesc($str_group_allow),
359 dbesc($str_contact_deny),
360 dbesc($str_group_deny),
362 intval($page_owner_uid)
366 /* Don't make the item visible if the only change was the album name */
369 if($p[0]['desc'] !== $desc || strlen($rawtags))
374 // Create item container
377 $uri = item_new_uri($a->get_hostname(),$page_owner_uid);
381 $arr['uid'] = $page_owner_uid;
383 $arr['parent-uri'] = $uri;
384 $arr['type'] = 'photo';
386 $arr['resource-id'] = $p[0]['resource-id'];
387 $arr['contact-id'] = $owner_record['id'];
388 $arr['owner-name'] = $owner_record['name'];
389 $arr['owner-link'] = $owner_record['url'];
390 $arr['owner-avatar'] = $owner_record['thumb'];
391 $arr['author-name'] = $owner_record['name'];
392 $arr['author-link'] = $owner_record['url'];
393 $arr['author-avatar'] = $owner_record['thumb'];
394 $arr['title'] = $title;
395 $arr['allow_cid'] = $p[0]['allow_cid'];
396 $arr['allow_gid'] = $p[0]['allow_gid'];
397 $arr['deny_cid'] = $p[0]['deny_cid'];
398 $arr['deny_gid'] = $p[0]['deny_gid'];
399 $arr['last-child'] = 1;
400 $arr['visible'] = $visibility;
403 $arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']'
404 . '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.'. $ext . '[/img]'
407 $item_id = item_store($arr);
412 $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
414 intval($page_owner_uid)
418 $old_tag = $r[0]['tag'];
419 $old_inform = $r[0]['inform'];
422 if(strlen($rawtags)) {
427 // if the new tag doesn't have a namespace specifier (@foo or #foo) give it a hashtag
429 $x = substr($rawtags,0,1);
430 if($x !== '@' && $x !== '#')
431 $rawtags = '#' . $rawtags;
434 $tags = get_tags($rawtags);
437 foreach($tags as $tag) {
440 if(strpos($tag,'@') === 0) {
441 $name = substr($tag,1);
442 if((strpos($name,'@')) || (strpos($name,'http://'))) {
444 $links = @lrdd($name);
446 foreach($links as $link) {
447 if($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page')
448 $profile = $link['@attributes']['href'];
449 if($link['@attributes']['rel'] === 'salmon') {
450 $salmon = '$url:' . str_replace(',','%sc',$link['@attributes']['href']);
457 $taginfo[] = array($newname,$profile,$salmon);
463 if(strrpos($newname,'+'))
464 $tagcid = intval(substr($newname,strrpos($newname,'+') + 1));
467 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
472 elseif(strstr($name,'_') || strstr($name,' ')) {
473 $newname = str_replace('_',' ',$name);
474 $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
476 intval($page_owner_uid)
480 $r = q("SELECT * FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1",
483 intval($page_owner_uid)
487 $newname = $r[0]['name'];
488 $profile = $r[0]['url'];
489 $notify = 'cid:' . $r[0]['id'];
496 if(substr($notify,0,4) === 'cid:')
497 $taginfo[] = array($newname,$profile,$notify,$r[0],'@[url=' . str_replace(',','%2c',$profile) . ']' . $newname . '[/url]');
499 $taginfo[] = array($newname,$profile,$notify,null,$str_tags .= '@[url=' . $profile . ']' . $newname . '[/url]');
500 if(strlen($str_tags))
502 $profile = str_replace(',','%2c',$profile);
503 $str_tags .= '@[url=' . $profile . ']' . $newname . '[/url]';
510 if(strlen($newtag) && strlen($str_tags))
512 $newtag .= $str_tags;
514 $newinform = $old_inform;
515 if(strlen($newinform) && strlen($inform))
517 $newinform .= $inform;
519 $r = q("UPDATE `item` SET `tag` = '%s', `inform` = '%s', `edited` = '%s', `changed` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
522 dbesc(datetime_convert()),
523 dbesc(datetime_convert()),
525 intval($page_owner_uid)
529 foreach($p as $scales) {
530 if(intval($scales['scale']) == 2) {
534 if(intval($scales['scale']) == 4) {
540 if(count($taginfo)) {
541 foreach($taginfo as $tagged) {
543 $uri = item_new_uri($a->get_hostname(),$page_owner_uid);
547 $arr['uid'] = $page_owner_uid;
549 $arr['parent-uri'] = $uri;
550 $arr['type'] = 'activity';
552 $arr['contact-id'] = $owner_record['id'];
553 $arr['owner-name'] = $owner_record['name'];
554 $arr['owner-link'] = $owner_record['url'];
555 $arr['owner-avatar'] = $owner_record['thumb'];
556 $arr['author-name'] = $owner_record['name'];
557 $arr['author-link'] = $owner_record['url'];
558 $arr['author-avatar'] = $owner_record['thumb'];
560 $arr['allow_cid'] = $p[0]['allow_cid'];
561 $arr['allow_gid'] = $p[0]['allow_gid'];
562 $arr['deny_cid'] = $p[0]['deny_cid'];
563 $arr['deny_gid'] = $p[0]['deny_gid'];
564 $arr['last-child'] = 1;
566 $arr['verb'] = ACTIVITY_TAG;
567 $arr['object-type'] = ACTIVITY_OBJ_PERSON;
568 $arr['target-type'] = ACTIVITY_OBJ_PHOTO;
569 $arr['tag'] = $tagged[4];
570 $arr['inform'] = $tagged[2];
572 $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]' ;
573 $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" ;
575 $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $tagged[0] . '</title><id>' . $tagged[1] . '/' . $tagged[0] . '</id>';
576 $arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $tagged[1] . '" />' . "\n");
578 $arr['object'] .= xmlify('<link rel="photo" type="'.$p[0]['type'].'" href="' . $tagged[3]['photo'] . '" />' . "\n");
579 $arr['object'] .= '</link></object>' . "\n";
581 $arr['target'] = '<target><type>' . ACTIVITY_OBJ_PHOTO . '</type><title>' . $p[0]['desc'] . '</title><id>'
582 . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . '</id>';
583 $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>';
585 $item_id = item_store($arr);
587 q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1",
588 dbesc($a->get_baseurl() . '/display/' . $owner_record['nickname'] . '/' . $item_id),
589 intval($page_owner_uid),
593 proc_run('php',"include/notifier.php","tag","$item_id");
600 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
601 return; // NOTREACHED
606 * default post action - upload a photo
609 call_hooks('photo_post_init', $_POST);
612 * Determine the album to use
615 $album = notags(trim($_REQUEST['album']));
616 $newalbum = notags(trim($_REQUEST['newalbum']));
618 logger('mod/photos.php: photos_post(): album= ' . $album . ' newalbum= ' . $newalbum , LOGGER_DEBUG);
620 if(! strlen($album)) {
621 if(strlen($newalbum))
624 $album = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y');
629 * We create a wall item for every photo, but we don't want to
630 * overwhelm the data stream with a hundred newly uploaded photos.
631 * So we will make the first photo uploaded to this album in the last several hours
632 * visible by default, the rest will become visible over time when and if
633 * they acquire comments, likes, dislikes, and/or tags
637 $r = q("SELECT * FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `created` > UTC_TIMESTAMP() - INTERVAL 3 HOUR ",
639 intval($page_owner_uid)
641 if((! count($r)) || ($album == t('Profile Photos')))
646 if(intval($_REQUEST['not_visible']) || $_REQUEST['not_visible'] === 'true')
649 $str_group_allow = perms2str(((is_array($_REQUEST['group_allow'])) ? $_REQUEST['group_allow'] : explode(',',$_REQUEST['group_allow'])));
650 $str_contact_allow = perms2str(((is_array($_REQUEST['contact_allow'])) ? $_REQUEST['contact_allow'] : explode(',',$_REQUEST['contact_allow'])));
651 $str_group_deny = perms2str(((is_array($_REQUEST['group_deny'])) ? $_REQUEST['group_deny'] : explode(',',$_REQUEST['group_deny'])));
652 $str_contact_deny = perms2str(((is_array($_REQUEST['contact_deny'])) ? $_REQUEST['contact_deny'] : explode(',',$_REQUEST['contact_deny'])));
654 $ret = array('src' => '', 'filename' => '', 'filesize' => 0, 'type' => '');
656 call_hooks('photo_post_file',$ret);
658 if(x($ret,'src') && x($ret,'filesize')) {
660 $filename = $ret['filename'];
661 $filesize = $ret['filesize'];
662 $type = $ret['type'];
665 $src = $_FILES['userfile']['tmp_name'];
666 $filename = basename($_FILES['userfile']['name']);
667 $filesize = intval($_FILES['userfile']['size']);
668 $type = $_FILES['userfile']['type'];
670 if ($type=="") $type=guess_image_type($filename);
672 logger('photos: upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes', LOGGER_DEBUG);
674 $maximagesize = get_config('system','maximagesize');
676 if(($maximagesize) && ($filesize > $maximagesize)) {
677 notice( t('Image exceeds size limit of ') . $maximagesize . EOL);
680 call_hooks('photo_post_end',$foo);
685 notice( t('Image file is empty.') . EOL);
688 call_hooks('photo_post_end',$foo);
692 logger('mod/photos.php: photos_post(): loading the contents of ' . $src , LOGGER_DEBUG);
694 $imagedata = @file_get_contents($src);
698 $r = q("select sum(octet_length(data)) as total from photo where uid = %d and scale = 0 and album != 'Contact Photos' ",
699 intval($a->data['user']['uid'])
702 $limit = service_class_fetch($a->data['user']['uid'],'photo_upload_limit');
704 if(($limit !== false) && (($r[0]['total'] + strlen($imagedata)) > $limit)) {
705 notice( upgrade_message() . EOL );
708 call_hooks('photo_post_end',$foo);
713 $ph = new Photo($imagedata, $type);
715 if(! $ph->is_valid()) {
716 logger('mod/photos.php: photos_post(): unable to process image' , LOGGER_DEBUG);
717 notice( t('Unable to process image.') . EOL );
720 call_hooks('photo_post_end',$foo);
727 $max_length = get_config('system','max_image_length');
729 $max_length = MAX_IMAGE_LENGTH;
731 $ph->scaleImage($max_length);
733 $width = $ph->getWidth();
734 $height = $ph->getHeight();
738 $photo_hash = photo_new_resource();
740 $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);
743 logger('mod/photos.php: photos_post(): image store failed' , LOGGER_DEBUG);
744 notice( t('Image upload failed.') . EOL );
748 if($width > 640 || $height > 640) {
749 $ph->scaleImage(640);
750 $ph->store($page_owner_uid, $visitor, $photo_hash, $filename, $album, 1, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
754 if($width > 320 || $height > 320) {
755 $ph->scaleImage(320);
756 $ph->store($page_owner_uid, $visitor, $photo_hash, $filename, $album, 2, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
760 $basename = basename($filename);
761 $uri = item_new_uri($a->get_hostname(), $page_owner_uid);
763 // Create item container
767 $arr['uid'] = $page_owner_uid;
769 $arr['parent-uri'] = $uri;
770 $arr['type'] = 'photo';
772 $arr['resource-id'] = $photo_hash;
773 $arr['contact-id'] = $owner_record['id'];
774 $arr['owner-name'] = $owner_record['name'];
775 $arr['owner-link'] = $owner_record['url'];
776 $arr['owner-avatar'] = $owner_record['thumb'];
777 $arr['author-name'] = $owner_record['name'];
778 $arr['author-link'] = $owner_record['url'];
779 $arr['author-avatar'] = $owner_record['thumb'];
781 $arr['allow_cid'] = $str_contact_allow;
782 $arr['allow_gid'] = $str_group_allow;
783 $arr['deny_cid'] = $str_contact_deny;
784 $arr['deny_gid'] = $str_group_deny;
785 $arr['last-child'] = 1;
786 $arr['visible'] = $visible;
789 $arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo_hash . ']'
790 . '[img]' . $a->get_baseurl() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/img]'
793 $item_id = item_store($arr);
796 q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1",
797 dbesc($a->get_baseurl() . '/display/' . $owner_record['nickname'] . '/' . $item_id),
798 intval($page_owner_uid),
804 proc_run('php', "include/notifier.php", 'wall-new', $item_id);
806 call_hooks('photo_post_end',intval($item_id));
808 // addon uploaders should call "killme()" [e.g. exit] within the photo_post_end hook
809 // if they do not wish to be redirected
811 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
817 function photos_content(&$a) {
821 // photos/name/upload
822 // photos/name/upload/xxxxx (xxxxx is album name)
823 // photos/name/album/xxxxx
824 // photos/name/album/xxxxx/edit
825 // photos/name/image/xxxxx
826 // photos/name/image/xxxxx/edit
829 if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
830 notice( t('Public access denied.') . EOL);
835 require_once('include/bbcode.php');
836 require_once('include/security.php');
837 require_once('include/conversation.php');
839 if(! x($a->data,'user')) {
840 notice( t('No photos selected') . EOL );
844 $phototypes = Photo::supportedTypes();
846 $_SESSION['photo_return'] = $a->cmd;
853 $datatype = $a->argv[2];
854 $datum = $a->argv[3];
856 elseif(($a->argc > 2) && ($a->argv[2] === 'upload'))
857 $datatype = 'upload';
859 $datatype = 'summary';
867 // Setup permissions structures
873 $remote_contact = false;
875 $owner_uid = $a->data['user']['uid'];
877 $community_page = (($a->data['user']['page-flags'] == PAGE_COMMUNITY) ? true : false);
879 if((local_user()) && (local_user() == $owner_uid))
882 if($community_page && remote_user()) {
883 $r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
884 intval(remote_user()),
890 $remote_contact = true;
891 $visitor = remote_user();
896 // perhaps they're visiting - but not a community page, so they wouldn't have write access
898 if(remote_user() && (! $visitor)) {
899 $contact_id = $_SESSION['visitor_id'];
900 $groups = init_groups_visitor($contact_id);
901 $r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
902 intval(remote_user()),
907 $remote_contact = true;
911 if(! $remote_contact) {
913 $contact_id = $_SESSION['cid'];
914 $contact = $a->contact;
918 if($a->data['user']['hidewall'] && (local_user() != $owner_uid) && (! $remote_contact)) {
919 notice( t('Access to this item is restricted.') . EOL);
923 $sql_extra = permissions_sql($owner_uid,$remote_contact,$groups);
928 $_is_owner = (local_user() && (local_user() == $owner_uid));
929 $o .= profile_tabs($a,$_is_owner, $a->data['user']['nickname']);
936 if($datatype === 'upload') {
938 notice( t('Permission denied.'));
943 $selname = (($datum) ? hex2bin($datum) : '');
949 $albumselect .= '<option value="" ' . ((! $selname) ? ' selected="selected" ' : '') . '> </option>';
950 if(count($a->data['albums'])) {
951 foreach($a->data['albums'] as $album) {
952 if(($album['album'] === '') || ($album['album'] === 'Contact Photos') || ($album['album'] === t('Contact Photos')))
954 $selected = (($selname === $album['album']) ? ' selected="selected" ' : '');
955 $albumselect .= '<option value="' . $album['album'] . '"' . $selected . '>' . $album['album'] . '</option>';
959 $celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false);
963 $ret = array('post_url' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'],
964 'addon_text' => $uploader,
965 'default_upload' => true);
968 call_hooks('photo_upload_form',$ret);
970 $default_upload = '<input id="photos-upload-choose" type="file" name="userfile" /> <div class="photos-upload-submit-wrapper" >
971 <input type="submit" name="submit" value="' . t('Submit') . '" id="photos-upload-submit" /> </div>';
974 $r = q("select sum(octet_length(data)) as total from photo where uid = %d and scale = 0 and album != 'Contact Photos' ",
975 intval($a->data['user']['uid'])
979 $limit = service_class_fetch($a->data['user']['uid'],'photo_upload_limit');
980 if($limit !== false) {
981 $usage_message = sprintf( t("You have used %1$.2f Mbytes of %2$.2f Mbytes photo storage."), $r[0]['total'] / 1024000, $limit / 1024000 );
984 $usage_message = sprintf( t('You have used %1$.2f Mbytes of photo storage.'), $r[0]['total'] / 1024000 );
988 $tpl = get_markup_template('photos_upload.tpl');
989 $o .= replace_macros($tpl,array(
990 '$pagename' => t('Upload Photos'),
991 '$sessid' => session_id(),
992 '$usage' => $usage_message,
993 '$nickname' => $a->data['user']['nickname'],
994 '$newalbum' => t('New album name: '),
995 '$existalbumtext' => t('or existing album name: '),
996 '$nosharetext' => t('Do not show a status post for this upload'),
997 '$albumselect' => template_escape($albumselect),
998 '$permissions' => t('Permissions'),
999 '$aclselect' => (($visitor) ? '' : template_escape(populate_acl($a->user, $celeb))),
1000 '$uploader' => $ret['addon_text'],
1001 '$default' => (($ret['default_upload']) ? $default_upload : ''),
1002 '$uploadurl' => $ret['post_url']
1009 if($datatype === 'album') {
1011 $album = hex2bin($datum);
1013 $r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` = '%s'
1014 AND `scale` <= 4 $sql_extra GROUP BY `resource-id`",
1019 $a->set_pager_total(count($r));
1020 $a->set_pager_itemspage(20);
1023 $r = q("SELECT `resource-id`, `id`, `filename`, type, max(`scale`) AS `scale`, `desc` FROM `photo` WHERE `uid` = %d AND `album` = '%s'
1024 AND `scale` <= 4 $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d",
1027 intval($a->pager['start']),
1028 intval($a->pager['itemspage'])
1031 $o .= '<h3>' . $album . '</h3>';
1033 if($cmd === 'edit') {
1034 if(($album !== t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) {
1036 $edit_tpl = get_markup_template('album_edit.tpl');
1037 $o .= replace_macros($edit_tpl,array(
1038 '$nametext' => t('New album name: '),
1039 '$nickname' => $a->data['user']['nickname'],
1040 '$album' => template_escape($album),
1041 '$hexalbum' => bin2hex($album),
1042 '$submit' => t('Submit'),
1043 '$dropsubmit' => t('Delete Album')
1049 if(($album !== t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) {
1051 $o .= '<div id="album-edit-link"><a href="'. $a->get_baseurl() . '/photos/'
1052 . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '/edit' . '">'
1053 . t('Edit Album') . '</a></div>';
1059 $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>';
1062 $tpl = get_markup_template('photo_album.tpl');
1064 $twist = 'rotright';
1065 foreach($r as $rr) {
1066 if($twist == 'rotright')
1069 $twist = 'rotright';
1071 $ext = $phototypes[$rr['type']];
1073 $o .= replace_macros($tpl,array(
1075 '$twist' => ' ' . $twist . rand(2,4),
1076 '$photolink' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'],
1077 '$phototitle' => t('View Photo'),
1078 '$imgsrc' => $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['scale'] . '.' .$ext,
1079 '$imgalt' => template_escape($rr['filename']),
1080 '$desc'=> template_escape($rr['desc'])
1084 $o .= '<div id="photo-album-end"></div>';
1092 if($datatype === 'image') {
1097 // fetch image, item containing image, then comments
1099 $ph = q("SELECT * FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'
1100 $sql_extra ORDER BY `scale` ASC ",
1106 $ph = q("SELECT `id` FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'
1112 notice( t('Permission denied. Access to this item may be restricted.'));
1114 notice( t('Photo not available') . EOL );
1121 $prvnxt = q("SELECT `resource-id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `scale` = 0
1122 $sql_extra ORDER BY `created` DESC ",
1123 dbesc($ph[0]['album']),
1127 if(count($prvnxt)) {
1128 for($z = 0; $z < count($prvnxt); $z++) {
1129 if($prvnxt[$z]['resource-id'] == $ph[0]['resource-id']) {
1133 $prv = count($prvnxt) - 1;
1134 if($nxt >= count($prvnxt))
1139 $edit_suffix = ((($cmd === 'edit') && ($can_post)) ? '/edit' : '');
1140 $prevlink = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . $edit_suffix;
1141 $nextlink = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . $edit_suffix;
1146 $hires = $lores = $ph[0];
1147 if(count($ph) > 1) {
1148 if($ph[1]['scale'] == 2) {
1149 // original is 640 or less, we can display it directly
1150 $hires = $lores = $ph[0];
1158 $album_link = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($ph[0]['album']);
1162 if($can_post && ($ph[0]['uid'] == $owner_uid)) {
1164 'edit' => array($a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $datum . (($cmd === 'edit') ? '' : '/edit'), (($cmd === 'edit') ? t('View photo') : t('Edit photo'))),
1165 'profile'=>array($a->get_baseurl() . '/profile_photo/use/'.$ph[0]['resource-id'], t('Use as profile photo')),
1169 $lock = ( ( ($ph[0]['uid'] == local_user()) && (strlen($ph[0]['allow_cid']) || strlen($ph[0]['allow_gid'])
1170 || strlen($ph[0]['deny_cid']) || strlen($ph[0]['deny_gid'])) )
1171 ? t('Private Message')
1177 if( $cmd === 'edit') {
1178 $tpl = get_markup_template('photo_edit_head.tpl');
1179 $a->page['htmlhead'] .= replace_macros($tpl,array(
1180 '$prevlink' => $prevlink,
1181 '$nextlink' => $nextlink
1186 $prevlink = array($prevlink, '<div class="icon prev"></div>') ;
1189 'href' => $a->get_baseurl() . '/photo/' . $hires['resource-id'] . '-' . $hires['scale'] . '.' . $phototypes[$hires['type']],
1190 'title'=> t('View Full Size'),
1191 'src' => $a->get_baseurl() . '/photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?f=&_u=' . datetime_convert('','','','ymdhis')
1195 $nextlink = array($nextlink, '<div class="icon next"></div>');
1198 // Do we have an item for this photo?
1200 $linked_items = q("SELECT * FROM `item` WHERE `resource-id` = '%s' $sql_extra LIMIT 1",
1203 if(count($linked_items)) {
1204 $link_item = $linked_items[0];
1205 $r = q("SELECT COUNT(*) AS `total`
1206 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
1207 WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0 and `item`.`moderated` = 0
1208 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
1209 AND `item`.`uid` = %d
1211 dbesc($link_item['uri']),
1212 dbesc($link_item['uri']),
1213 intval($link_item['uid'])
1218 $a->set_pager_total($r[0]['total']);
1221 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
1222 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`,
1223 `contact`.`rel`, `contact`.`thumb`, `contact`.`self`,
1224 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
1225 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
1226 WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0 and `item`.`moderated` = 0
1227 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
1228 AND `item`.`uid` = %d
1230 ORDER BY `parent` DESC, `id` ASC LIMIT %d ,%d ",
1231 dbesc($link_item['uri']),
1232 dbesc($link_item['uri']),
1233 intval($link_item['uid']),
1234 intval($a->pager['start']),
1235 intval($a->pager['itemspage'])
1239 if((local_user()) && (local_user() == $link_item['uid'])) {
1240 q("UPDATE `item` SET `unseen` = 0 WHERE `parent` = %d and `uid` = %d",
1241 intval($link_item['parent']),
1242 intval(local_user())
1249 if(count($linked_items) && strlen($link_item['tag'])) {
1250 $arr = explode(',',$link_item['tag']);
1251 // parse tags and add links
1253 foreach($arr as $t) {
1254 if(strlen($tag_str))
1256 $tag_str .= bbcode($t);
1258 $tags = array(t('Tags: '), $tag_str);
1259 if($cmd === 'edit') {
1260 $tags[] = $a->get_baseurl() . '/tagrm/' . $link_item['id'];
1261 $tags[] = t('[Remove any tag]');
1267 if(($cmd === 'edit') && ($can_post)) {
1268 $edit_tpl = get_markup_template('photo_edit.tpl');
1269 $edit = replace_macros($edit_tpl, array(
1270 '$id' => $ph[0]['id'],
1271 '$rotatecw' => t('Rotate CW (right)'),
1272 '$rotateccw' => t('Rotate CCW (left)'),
1273 '$album' => template_escape($ph[0]['album']),
1274 '$newalbum' => t('New album name'),
1275 '$nickname' => $a->data['user']['nickname'],
1276 '$resource_id' => $ph[0]['resource-id'],
1277 '$capt_label' => t('Caption'),
1278 '$caption' => template_escape($ph[0]['desc']),
1279 '$tag_label' => t('Add a Tag'),
1280 '$tags' => $link_item['tag'],
1281 '$permissions' => t('Permissions'),
1282 '$aclselect' => template_escape(populate_acl($ph[0])),
1283 '$help_tags' => t('Example: @bob, @Barbara_Jensen, @jim@example.com, #California, #camping'),
1284 '$item_id' => ((count($linked_items)) ? $link_item['id'] : 0),
1285 '$submit' => t('Submit'),
1286 '$delete' => t('Delete Photo')
1290 if(count($linked_items)) {
1292 $cmnt_tpl = get_markup_template('comment_item.tpl');
1293 $tpl = get_markup_template('photo_item.tpl');
1294 $return_url = $a->cmd;
1296 $like_tpl = get_markup_template('like_noshare.tpl');
1300 if($can_post || can_write_wall($a,$owner_uid)) {
1301 $likebuttons = replace_macros($like_tpl,array(
1302 '$id' => $link_item['id'],
1303 '$likethis' => t("I like this \x28toggle\x29"),
1304 '$nolike' => t("I don't like this \x28toggle\x29"),
1305 '$share' => t('Share'),
1306 '$wait' => t('Please wait')
1312 if($can_post || can_write_wall($a,$owner_uid)) {
1313 if($link_item['last-child']) {
1314 $comments .= replace_macros($cmnt_tpl,array(
1315 '$return_path' => '',
1316 '$jsreload' => $return_url,
1317 '$type' => 'wall-comment',
1318 '$id' => $link_item['id'],
1319 '$parent' => $link_item['id'],
1320 '$profile_uid' => $owner_uid,
1321 '$mylink' => $contact['url'],
1322 '$mytitle' => t('This is you'),
1323 '$myphoto' => $contact['thumb'],
1324 '$comment' => t('Comment'),
1325 '$submit' => t('Submit'),
1326 '$preview' => t('Preview'),
1342 foreach($r as $item) {
1343 like_puller($a,$item,$alike,'like');
1344 like_puller($a,$item,$dlike,'dislike');
1347 $like = ((isset($alike[$link_item['id']])) ? format_like($alike[$link_item['id']],$alike[$link_item['id'] . '-l'],'like',$link_item['id']) : '');
1348 $dislike = ((isset($dlike[$link_item['id']])) ? format_like($dlike[$link_item['id']],$dlike[$link_item['id'] . '-l'],'dislike',$link_item['id']) : '');
1352 if($can_post || can_write_wall($a,$owner_uid)) {
1353 if($link_item['last-child']) {
1354 $comments .= replace_macros($cmnt_tpl,array(
1355 '$return_path' => '',
1356 '$jsreload' => $return_url,
1357 '$type' => 'wall-comment',
1358 '$id' => $link_item['id'],
1359 '$parent' => $link_item['id'],
1360 '$profile_uid' => $owner_uid,
1361 '$mylink' => $contact['url'],
1362 '$mytitle' => t('This is you'),
1363 '$myphoto' => $contact['thumb'],
1364 '$comment' => t('Comment'),
1365 '$submit' => t('Submit'),
1372 foreach($r as $item) {
1377 if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE))) && ($item['id'] != $item['parent']))
1380 $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
1382 if($can_post || can_write_wall($a,$owner_uid)) {
1384 if($item['last-child']) {
1385 $comments .= replace_macros($cmnt_tpl,array(
1386 '$return_path' => '',
1387 '$jsreload' => $return_url,
1388 '$type' => 'wall-comment',
1389 '$id' => $item['item_id'],
1390 '$parent' => $item['parent'],
1391 '$profile_uid' => $owner_uid,
1392 '$mylink' => $contact['url'],
1393 '$mytitle' => t('This is you'),
1394 '$myphoto' => $contact['thumb'],
1395 '$comment' => t('Comment'),
1396 '$submit' => t('Submit'),
1403 if(local_user() && ($item['contact-uid'] == local_user())
1404 && ($item['network'] == 'dfrn') && (! $item['self'] )) {
1405 $profile_url = $redirect_url;
1406 $sparkle = ' sparkle';
1409 $profile_url = $item['url'];
1413 $diff_author = (($item['url'] !== $item['author-link']) ? true : false);
1415 $profile_name = (((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']);
1416 $profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $item['thumb']);
1418 $profile_link = $profile_url;
1422 if(($item['contact-id'] == remote_user()) || ($item['uid'] == local_user()))
1423 $drop = replace_macros(get_markup_template('photo_drop.tpl'), array('$id' => $item['id'], '$delete' => t('Delete')));
1426 $comments .= replace_macros($template,array(
1427 '$id' => $item['item_id'],
1428 '$profile_url' => $profile_link,
1429 '$name' => template_escape($profile_name),
1430 '$thumb' => $profile_avatar,
1431 '$sparkle' => $sparkle,
1432 '$title' => template_escape($item['title']),
1433 '$body' => template_escape(bbcode($item['body'])),
1434 '$ago' => relative_date($item['created']),
1435 '$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''),
1437 '$comment' => $comment
1442 $paginate = paginate($a);
1445 $photo_tpl = get_markup_template('photo_view.tpl');
1446 $o .= replace_macros($photo_tpl, array(
1447 '$id' => $ph[0]['id'],
1448 '$album' => array($album_link,template_escape($ph[0]['album'])),
1452 '$prevlink' => $prevlink,
1453 '$nextlink' => $nextlink,
1454 '$desc' => $ph[0]['desc'],
1455 '$tags' => template_escape($tags),
1457 '$likebuttons' => $likebuttons,
1458 '$like' => template_escape($like),
1459 '$dislike' => template_escape($dislike),
1460 '$comments' => $comments,
1461 '$paginate' => $paginate,
1467 // Default - show recent photos with upload link (if applicable)
1470 $r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
1471 $sql_extra GROUP BY `resource-id`",
1472 intval($a->data['user']['uid']),
1473 dbesc('Contact Photos'),
1474 dbesc( t('Contact Photos'))
1477 $a->set_pager_total(count($r));
1478 $a->set_pager_itemspage(20);
1481 $r = q("SELECT `resource-id`, `id`, `filename`, type, `album`, max(`scale`) AS `scale` FROM `photo`
1482 WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
1483 $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d",
1484 intval($a->data['user']['uid']),
1485 dbesc('Contact Photos'),
1486 dbesc( t('Contact Photos')),
1487 intval($a->pager['start']),
1488 intval($a->pager['itemspage'])
1495 $twist = 'rotright';
1496 foreach($r as $rr) {
1497 if($twist == 'rotright')
1500 $twist = 'rotright';
1501 $ext = $phototypes[$rr['type']];
1505 'twist' => ' ' . $twist . rand(2,4),
1506 'link' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'],
1507 'title' => t('View Photo'),
1508 'src' => $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.' . $ext,
1509 'alt' => template_escape($rr['filename']),
1511 'link' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']),
1512 'name' => template_escape($rr['album']),
1513 'alt' => t('View Album'),
1520 $tpl = get_markup_template('photos_recent.tpl');
1521 $o .= replace_macros($tpl,array(
1522 '$title' => t('Recent Photos'),
1523 '$can_post' => $can_post,
1524 '$upload' => array(t('Upload New Photos'), $a->get_baseurl().'/photos/'.$a->data['user']['nickname'].'/upload'),
1525 '$photos' => $photos,