]> git.mxchange.org Git - friendica.git/commitdiff
add micro profile photo
authorFriendika <info@friendika.com>
Fri, 5 Nov 2010 06:50:32 +0000 (23:50 -0700)
committerFriendika <info@friendika.com>
Fri, 5 Nov 2010 06:50:32 +0000 (23:50 -0700)
12 files changed:
boot.php
database.sql
images/default-profile-mm.jpg [new file with mode: 0644]
include/Photo.php
include/items.php
mod/dfrn_confirm.php
mod/follow.php
mod/photo.php
mod/photos.php
mod/profile_photo.php
mod/register.php
update.php

index f652063852804db08362870296bde015db2cb16b..48770a2b21b197c4d54c32f6b0f4399a1e8add1a 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -2,7 +2,7 @@
 
 set_time_limit(0);
 
-define ( 'BUILD_ID',               1014   );
+define ( 'BUILD_ID',               1015   );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.0'  );
 
 define ( 'EOL',                    "<br />\r\n"     );
index 33f1e7949754b8d949f00316f0eadd7c88829370..8f068e59d91d40bdf66b95e0ea72692959f254fd 100644 (file)
@@ -59,6 +59,7 @@ CREATE TABLE IF NOT EXISTS `contact` (
   `nick` char(255) NOT NULL,
   `photo` text NOT NULL, 
   `thumb` text NOT NULL,
+  `micro` text NOT NULL,
   `site-pubkey` text NOT NULL,
   `issued-id` char(255) NOT NULL,
   `dfrn-id` char(255) NOT NULL,
diff --git a/images/default-profile-mm.jpg b/images/default-profile-mm.jpg
new file mode 100644 (file)
index 0000000..79c1a85
Binary files /dev/null and b/images/default-profile-mm.jpg differ
index ca9ae0703c3162e1d0d853d4131b9b5a284fe0e7..98b11ab39ff05eda68349677e294f2f087656e12 100644 (file)
@@ -235,8 +235,18 @@ function import_profile_photo($photo,$uid,$cid) {
                if($r === false)
                        $photo_failure = true;
 
+               $img->scaleImage(48);
+
+               $r = $img->store($uid, $cid, $hash, $filename, t('Contact Photos'), 6 );
+
+               if($r === false)
+                       $photo_failure = true;
+
+
+
                $photo = $a->get_baseurl() . '/photo/' . $hash . '-4.jpg';
                $thumb = $a->get_baseurl() . '/photo/' . $hash . '-5.jpg';
+               $micro = $a->get_baseurl() . '/photo/' . $hash . '-6.jpg';
        }
        else
                $photo_failure = true;
@@ -244,8 +254,9 @@ function import_profile_photo($photo,$uid,$cid) {
        if($photo_failure) {
                $photo = $a->get_baseurl() . '/images/default-profile.jpg';
                $thumb = $a->get_baseurl() . '/images/default-profile-sm.jpg';
+               $micro = $a->get_baseurl() . '/images/default-profile-mm.jpg';
        }
 
-       return(array($photo,$thumb));
+       return(array($photo,$thumb,$micro));
 
 }
index a1aaecc8a9edf8a02ba9f4a4033842f27a0394fb..323117e6cab2487b890ba4a5faa2e1e0a56de998 100644 (file)
@@ -792,6 +792,10 @@ function consume_feed($xml,$importer,$contact, &$hub) {
                                
                                $img->scaleImage(80);
                                $r = $img->store($contact['uid'], $contact['id'], $hash, basename($photo_url), t('Contact Photos') , 5);
+
+                               $img->scaleImage(48);
+                               $r = $img->store($contact['uid'], $contact['id'], $hash, basename($photo_url), t('Contact Photos') , 6);
+
                                if($r)
                                        q("UPDATE `contact` SET `avatar-date` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1",
                                                dbesc(datetime_convert()),
index 705f74f1355bb77c738b7ab085dece8c903f8b24..4a5fe1114f50cf39a4f91b5875f4c0c75d836e10 100644 (file)
@@ -238,7 +238,8 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                                $new_relation = REL_BUD;
 
                        $r = q("UPDATE `contact` SET `photo` = '%s', 
-                               `thumb` = '%s', 
+                               `thumb` = '%s',
+                               `micro` = '%s', 
                                `rel` = %d, 
                                `name-date` = '%s', 
                                `uri-date` = '%s', 
@@ -250,6 +251,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                        ",
                                dbesc($photos[0]),
                                dbesc($photos[1]),
+                               dbesc($photos[2]),
                                intval($new_relation),
                                dbesc(datetime_convert()),
                                dbesc(datetime_convert()),
@@ -281,7 +283,8 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                        );
 
                        $r = q("UPDATE `contact` SET `photo` = '%s', 
-                               `thumb` = '%s', 
+                               `thumb` = '%s',
+                               `micro` = '%s', 
                                `name-date` = '%s', 
                                `uri-date` = '%s', 
                                `avatar-date` = '%s', 
@@ -293,6 +296,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
                        ",
                                dbesc($photos[0]),
                                dbesc($photos[1]),
+                               dbesc($photos[2]),
                                dbesc(datetime_convert()),
                                dbesc(datetime_convert()),
                                dbesc(datetime_convert()),
index 235353f7ab027d53ad0748d89c9d7d2629e893f3..d839a04d4a5afeeb0c0edf0c8f64b20dabed0125 100644 (file)
@@ -122,7 +122,8 @@ function follow_post(&$a) {
        $photos = import_profile_photo($vcard['photo'],local_user(),$contact_id);
 
        $r = q("UPDATE `contact` SET `photo` = '%s', 
-                       `thumb` = '%s', 
+                       `thumb` = '%s',
+                       `micro` = '%s', 
                        `name-date` = '%s', 
                        `uri-date` = '%s', 
                        `avatar-date` = '%s'
@@ -130,6 +131,7 @@ function follow_post(&$a) {
                ",
                        dbesc($photos[0]),
                        dbesc($photos[1]),
+                       dbesc($photos[2]),
                        dbesc(datetime_convert()),
                        dbesc(datetime_convert()),
                        dbesc(datetime_convert()),
index 4e0b85b451f03085c914226890d7ed9c9b3269d0..d4abb041a0db95981aa7d31852880437ee2b0990 100644 (file)
@@ -16,15 +16,22 @@ function photo_init(&$a) {
                        return; // NOTREACHED
        }
 
+       $default = 'images/default-profile.jpg';
+
        if(isset($type)) {
                switch($type) {
 
                        case 'profile':
                                $resolution = 4;
                                break;
+                       case 'micro':
+                               $resolution = 6;
+                               $default = 'images/default-profile-mm.jpg';
+                               break;
                        case 'avatar':
                        default:
                                $resolution = 5;
+                               $default = 'images/default-profile-sm.jpg';
                                break;
                }
 
@@ -38,9 +45,7 @@ function photo_init(&$a) {
                        $data = $r[0]['data'];
                }
                if(! isset($data)) {
-                       $data = file_get_contents(($resolution == 5) 
-                               ? 'images/default-profile-sm.jpg' 
-                               : 'images/default-profile.jpg');
+                       $data = file_get_contents($default);
                }
        }
        else {
index a3aa69216284050557ac135e973f5f61b9b2e52d..f3eccd12799e6bc9f51e7eaf26039a71e28d2d7e 100644 (file)
@@ -312,9 +312,9 @@ function photos_post(&$a) {
                                                }
                                                if($profile) {
                                                        if(substr($notify,0,4) === 'cid:')
-                                                               $taginfo[] = array($newname,$profile,$notify,$r[0]);
+                                                               $taginfo[] = array($newname,$profile,$notify,$r[0],'@[url=' . str_replace(',','%2c',$profile) . ']' . $newname  . '[/url]');
                                                        else
-                                                               $taginfo[] = array($newname,$profile,$notify,null);
+                                                               $taginfo[] = array($newname,$profile,$notify,null,$str_tags .= '@[url=' . $profile . ']' . $newname     . '[/url]');
                                                        if(strlen($str_tags))
                                                                $str_tags .= ',';
                                                        $profile = str_replace(',','%2c',$profile);
@@ -384,6 +384,7 @@ function photos_post(&$a) {
                                        $arr['verb']          = ACTIVITY_TAG;
                                        $arr['object-type']   = ACTIVITY_OBJ_PERSON;
                                        $arr['target-type']   = ACTIVITY_OBJ_PHOTO;
+                                       $arr['tag']           = $tagged[4];
                                        $arr['inform']        = $tagged[2];
 
                                        $arr['body']          = '[url=' . $tagged[1] . ']' . $tagged[0] . '[/url]' . ' ' . t('was tagged in a') . ' ' . '[url=' . $a->get_baseurl() . '/photos/' . $contact_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . t('photo') . '[/url]' . ' ' . t('by') . ' ' . '[url=' . $contact_record['url'] . ']' . $contact_record['name'] . '[/url]' ;
index b21d9162a01e3622ccf6ec8a8abfc6e1f66efe5b..32ace62f0583580dd7060de3ca487712189c6dfb 100644 (file)
@@ -68,6 +68,13 @@ function profile_photo_post(&$a) {
                                if($r === false)
                                        notice( t('Image size reduction [80] failed.') . EOL );
 
+                               $im->scaleImage(48);
+
+                               $r = $im->store(local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 6, 1);
+                       
+                               if($r === false)
+                                       notice( t('Image size reduction [48] failed.') . EOL );
+
                                // Unset the profile photo flag from any other photos I own
 
                                $r = q("UPDATE `photo` SET `profile` = 0 WHERE `profile` = 1 AND `resource-id` != '%s' AND `uid` = %d",
index 52c3863ebdf92361c349a43ddaa2c7401792d6c6..5c62c129435d9ba2ffc1bc1e14f5e95671666395 100644 (file)
@@ -161,15 +161,16 @@ function register_post(&$a) {
                                intval($newuid));
                        return;
                }
-               $r = q("INSERT INTO `contact` ( `uid`, `created`, `self`, `name`, `nick`, `photo`, `thumb`, `blocked`, `pending`, `url`,
+               $r = q("INSERT INTO `contact` ( `uid`, `created`, `self`, `name`, `nick`, `photo`, `thumb`, `micro`, `blocked`, `pending`, `url`,
                        `request`, `notify`, `poll`, `confirm`, `name-date`, `uri-date`, `avatar-date` )
-                       VALUES ( %d, '%s', 1, '%s', '%s', '%s', '%s', 0, 0, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
+                       VALUES ( %d, '%s', 1, '%s', '%s', '%s', '%s', '%s', 0, 0, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
                        intval($newuid),
                        datetime_convert(),
                        dbesc($username),
                        dbesc($nickname),
                        dbesc($a->get_baseurl() . "/photo/profile/{$newuid}.jpg"),
                        dbesc($a->get_baseurl() . "/photo/avatar/{$newuid}.jpg"),
+                       dbesc($a->get_baseurl() . "/photo/micro/{$newuid}.jpg"),
                        dbesc($a->get_baseurl() . "/profile/$nickname"),
                        dbesc($a->get_baseurl() . "/dfrn_request/$nickname"),
                        dbesc($a->get_baseurl() . "/dfrn_notify/$nickname"),
index 68367343d44962f0f36dcd81ad44b2240c6f29b8..dfa54af593cdbc1b0998df8605f4fb648276004e 100644 (file)
@@ -101,4 +101,32 @@ function update_1012() {
 function update_1013() {
        q("ALTER TABLE `item` ADD `target-type` CHAR( 255 ) NOT NULL 
                AFTER `object` , ADD `target` TEXT NOT NULL AFTER `target-type`");
-} 
\ No newline at end of file
+} 
+
+function update_1014() {
+       require_once('include/Photo.php');
+       q("ALTER TABLE `contact` ADD `micro` TEXT NOT NULL AFTER `thumb` ");
+       $r = q("SELECT * FROM `photo` WHERE `scale` = 4");
+       if(count($r)) {
+               foreach($r as $rr) {
+                       $ph = new Photo($rr['data']);
+                       if($ph->is_valid()) {
+                               $ph->scaleImage(48);
+                               $ph->store($rr['uid'],$rr['contact-id'],$rr['resource-id'],$rr['filename'],$rr['album'],6,(($rr['profile']) ? 1 : 0));
+                       }
+               }
+       }
+       $r = q("SELECT * FROM `contact` WHERE 1");
+       if(count($r)) {
+               foreach($r as $rr) {            
+                       if(stristr($rr['thumb'],'avatar'))
+                               q("UPDATE `contact` SET `micro` = '%s' WHERE `id` = %d LIMIT 1",
+                                       dbesc(str_replace('avatar','micro',$rr['thumb'])),
+                                       intval($rr['id']));
+                       else
+                               q("UPDATE `contact` SET `micro` = '%s' WHERE `id` = %d LIMIT 1",
+                                       dbesc(str_replace('5.jpg','6.jpg',$rr['thumb'])),
+                                       intval($rr['id']));
+               }
+       }
+}
\ No newline at end of file