]> git.mxchange.org Git - friendica.git/blobdiff - mod/photos.php
quattro: add "view in context" link in search results
[friendica.git] / mod / photos.php
old mode 100644 (file)
new mode 100755 (executable)
index 90d5100..466fe44
@@ -39,7 +39,7 @@ function photos_init(&$a) {
                        $o .= '</div>';
                        
                        $o .= '<div id="side-bar-photos-albums" class="widget">';
-                       $o .= '<h3>' . '<a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '">' . t('Photo Albums') . '</a></h4>';
+                       $o .= '<h3>' . '<a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '">' . t('Photo Albums') . '</a></h3>';
                                        
                        $o .= '<ul>';
                        foreach($albums as $album) {
@@ -49,9 +49,15 @@ function photos_init(&$a) {
 
                                if((! strlen($album['album'])) || ($album['album'] === 'Contact Photos') || ($album['album'] === t('Contact Photos')))
                                        continue;
-                               $o .= '<li>' . '<a href="photos/' . $a->argv[1] . '/album/' . bin2hex($album['album']) . '" />' . $album['album'] . '</a></li>'; 
+                               $o .= '<li>' . '<a href="photos/' . $a->argv[1] . '/album/' . bin2hex($album['album']) . '" >' . $album['album'] . '</a></li>'; 
                        }
                        $o .= '</ul>';
+
+                       if(local_user() && $a->data['user']['uid'] == local_user()) {
+                               $o .= '<div id="photo-albums-upload-link"><a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload" >' .t('Upload New Photos') . '</a></div>';
+                       }
+
+                       $o .= '</div>';
                }
 
                if(! x($a->page,'aside'))
@@ -92,15 +98,11 @@ EOT;
 
 function photos_post(&$a) {
 
-       logger('mod/photos.php: photos_post(): begin' , 'LOGGER_DEBUG');
+       logger('mod-photos: photos_post: begin' , 'LOGGER_DEBUG');
 
-       foreach($_REQUEST AS $key => $val) {
-               logger('mod/photos.php: photos_post(): $_REQUEST key: ' . $key . ' val: ' . $val , 'LOGGER_DEBUG');
-       }
 
-       foreach($_FILES AS $key => $val) {
-               logger('mod/photos.php: photos_post(): $_FILES key: ' . $key . ' val: ' . $val , 'LOGGER_DEBUG');
-       }
+       logger('mod_photos: REQUEST ' . print_r($_REQUEST,true), LOGGER_DATA);
+       logger('mod_photos: FILES '   . print_r($_FILES,true), LOGGER_DATA);
 
        $can_post  = false;
        $visitor   = 0;
@@ -352,6 +354,7 @@ function photos_post(&$a) {
                        $arr['deny_gid']      = $p[0]['deny_gid'];
                        $arr['last-child']    = 1;
                        $arr['visible']       = $visibility;
+                       $arr['origin']        = 1;
                        
                        $arr['body']          = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']' 
                                                . '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.jpg' . '[/img]' 
@@ -411,7 +414,18 @@ function photos_post(&$a) {
                                                }
                                                else {
                                                        $newname = $name;
-                                                       if(strstr($name,'_') || strstr($name,' ')) {
+                                                       $alias = '';
+                                                       $tagcid = 0;
+                                                       if(strrpos($newname,'+'))
+                                                               $tagcid = intval(substr($newname,strrpos($newname,'+') + 1));
+
+                                                       if($tagcid) {
+                                                               $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
+                                                                       intval($tagcid),
+                                                                       intval($profile_uid)
+                                                               );
+                                                       }
+                                                       elseif(strstr($name,'_') || strstr($name,' ')) {
                                                                $newname = str_replace('_',' ',$name);
                                                                $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
                                                                        dbesc($newname),
@@ -510,7 +524,7 @@ function photos_post(&$a) {
                                        $arr['target-type']   = ACTIVITY_OBJ_PHOTO;
                                        $arr['tag']           = $tagged[4];
                                        $arr['inform']        = $tagged[2];
-
+                                       $arr['origin']        = 1;
                                        $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]' ;
                                        $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 . '.jpg' . '[/img][/url]' . "\n" ;
 
@@ -584,6 +598,9 @@ function photos_post(&$a) {
                $visible = 1;
        else
                $visible = 0;
+       
+       if(intval($_REQUEST['not_visible']) || $_REQUEST['not_visible'] === 'true')
+               $visible = 0;
 
        $str_group_allow   = perms2str(((is_array($_REQUEST['group_allow']))   ? $_REQUEST['group_allow']   : explode(',',$_REQUEST['group_allow'])));
        $str_contact_allow = perms2str(((is_array($_REQUEST['contact_allow'])) ? $_REQUEST['contact_allow'] : explode(',',$_REQUEST['contact_allow'])));
@@ -696,6 +713,8 @@ function photos_post(&$a) {
        $arr['deny_gid']      = $str_group_deny;
        $arr['last-child']    = 1;
        $arr['visible']       = $visible;
+       $arr['origin']        = 1;
+
        $arr['body']          = '[url=' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo_hash . ']' 
                                . '[img]' . $a->get_baseurl() . "/photo/{$photo_hash}-{$smallest}.jpg" . '[/img]' 
                                . '[/url]';
@@ -729,6 +748,7 @@ function photos_content(&$a) {
        // URLs:
        // photos/name
        // photos/name/upload
+       // photos/name/upload/xxxxx (xxxxx is album name)
        // photos/name/album/xxxxx
        // photos/name/album/xxxxx/edit
        // photos/name/image/xxxxx
@@ -832,18 +852,8 @@ function photos_content(&$a) {
        $o = "";
 
        // tabs
-       $tpl = get_markup_template('profile_tabs.tpl');
        $_is_owner = (local_user() && (local_user() == $owner_uid));
-       $o .= replace_macros($tpl,array(
-               '$url' => $a->get_baseurl() . '/profile/' .$a->data['user']['nickname'],
-               '$phototab' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'],
-               '$status' => t('Status'),
-               '$profile' => t('Profile'),
-               '$photos' => t('Photos'),
-               '$events' => (($_is_owner) ? t('Events') : ''),
-               '$notes' => (($_is_owner) ?     t('Personal Notes') : ''),
-               '$activetab' => "photos",
-       ));     
+       $o .= profile_tabs($a,$_is_owner, $a->data['user']['nickname']);        
 
        //
        // dispatch request
@@ -855,14 +865,21 @@ function photos_content(&$a) {
                        notice( t('Permission denied.'));
                        return;
                }
+
+
+               $selname = (($datum) ? hex2bin($datum) : '');
+
+
                $albumselect = '<select id="photos-upload-album-select" name="album" size="4">';
 
-               $albumselect .= '<option value="" selected="selected" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>';
+               
+               $albumselect .= '<option value="" ' . ((! $selname) ? ' selected="selected" ' : '') . '>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>';
                if(count($a->data['albums'])) {
                        foreach($a->data['albums'] as $album) {
                                if(($album['album'] === '') || ($album['album'] === 'Contact Photos') || ($album['album'] === t('Contact Photos')))
                                        continue;
-                               $albumselect .= '<option value="' . $album['album'] . '">' . $album['album'] . '</option>';
+                               $selected = (($selname === $album['album']) ? ' selected="selected" ' : '');
+                               $albumselect .= '<option value="' . $album['album'] . '"' . $selected . '>' . $album['album'] . '</option>';
                        }
                }
 
@@ -892,6 +909,7 @@ function photos_content(&$a) {
                        '$nickname' => $a->data['user']['nickname'],
                        '$newalbum' => t('New album name: '),
                        '$existalbumtext' => t('or existing album name: '),
+                       '$nosharetext' => t('Do not show a status post for this upload'),
                        '$albumselect' => template_escape($albumselect),
                        '$permissions' => t('Permissions'),
                        '$aclselect' => (($visitor) ? '' : template_escape(populate_acl($a->user, $celeb))),
@@ -952,6 +970,11 @@ function photos_content(&$a) {
                                }
                        }
                }
+
+               if($can_post) {
+                       $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>';
+               }
+
                $tpl = get_markup_template('photo_album.tpl');
                if(count($r))
                        foreach($r as $rr) {
@@ -1080,7 +1103,7 @@ function photos_content(&$a) {
                        $link_item = $linked_items[0];
                        $r = q("SELECT COUNT(*) AS `total`
                                FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
-                               WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0
+                               WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0 and `item`.`moderated` = 0
                                AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
                                AND `item`.`uid` = %d 
                                $sql_extra ",
@@ -1099,7 +1122,7 @@ function photos_content(&$a) {
                                `contact`.`rel`, `contact`.`thumb`, `contact`.`self`, 
                                `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
                                FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
-                               WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0
+                               WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0 and `item`.`moderated` = 0
                                AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
                                AND `item`.`uid` = %d
                                $sql_extra
@@ -1197,6 +1220,7 @@ function photos_content(&$a) {
                                                        '$myphoto' => $contact['thumb'],
                                                        '$comment' => t('Comment'),
                                                        '$submit' => t('Submit'),
+                                                       '$preview' => t('Preview'),
                                                        '$ww' => ''
                                                ));
                                        }
@@ -1361,30 +1385,36 @@ function photos_content(&$a) {
                intval($a->pager['itemspage'])
        );
 
-       $o .= '<h3>' . t('Recent Photos') . '</h3>';
 
-       if($can_post) {
-               $o .= '<div id="photo-top-links"><a id="photo-top-upload-link" href="'. $a->get_baseurl() . '/photos/' 
-                       . $a->data['user']['nickname'] . '/upload' . '">' . t('Upload New Photos') . '</a></div>';
-       }
 
-       $tpl = get_markup_template('photo_top.tpl');
+       $photos = array();
        if(count($r)) {
                foreach($r as $rr) {
-                       $o .= replace_macros($tpl,array(
-                               '$id'         => $rr['id'],
-                               '$photolink'  => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'],
-                               '$phototitle' => t('View Photo'),
-                               '$imgsrc'     => $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.jpg',
-                               '$albumlink'  => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']),
-                               '$albumname'  => template_escape($rr['album']),
-                               '$albumalt'   => t('View Album'),
-                               '$imgalt'     => template_escape($rr['filename'])
-                       ));
-
+                       $photos[] = array(
+                               'id'       => $rr['id'],
+                               'link'          => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'],
+                               'title'         => t('View Photo'),
+                               'src'           => $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.jpg',
+                               'alt'           => template_escape($rr['filename']),
+                               'album' => array(
+                                       'link'  => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']),
+                                       'name'  => template_escape($rr['album']),
+                                       'alt'   => t('View Album'),
+                               ),
+                               
+                       );
                }
-               $o .= '<div id="photo-top-end"></div>';
        }
+       
+       $tpl = get_markup_template('photos_recent.tpl'); 
+       $o .= replace_macros($tpl,array(
+               '$title' => t('Recent Photos'),
+               '$can_post' => $can_post,
+               '$upload' => array(t('Upload New Photos'), $a->get_baseurl().'/photos/'.$a->data['user']['nickname'].'/upload'),
+               '$photos' => $photos,
+       ));
+
+       
        $o .= paginate($a);
        return $o;
 }