From 7645b440e893959846da2e8984c2a0a7e8c62a3b Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 2 Feb 2013 01:58:11 -0800 Subject: more progress on photos api --- include/attach.php | 11 +++ include/photos.php | 38 ++++++++- mod/network.php | 4 +- mod/photos.php | 245 ++--------------------------------------------------- version.inc | 2 +- 5 files changed, 57 insertions(+), 243 deletions(-) diff --git a/include/attach.php b/include/attach.php index b2c57f36f..e4ef28637 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1,5 +1,14 @@ get_baseurl() . '/photos/' . $channel['channel_address'] . '/image/' . $photo['resource_id'] . ']' + . '[img]' . $a->get_baseurl() . '/photo/' . $photo['resource_id'] . '-' . $photo['scale'] . '[/img]' + . '[/url]'; + + $item_id = item_store($arr); + return $item_id; + +} \ No newline at end of file diff --git a/mod/network.php b/mod/network.php index cca69dc52..4176f0047 100644 --- a/mod/network.php +++ b/mod/network.php @@ -707,8 +707,8 @@ function network_content(&$a, $update = 0, $load = false) { if(! $update) $o .= alt_pager($a,count($items)); -// logger('parent dba_timer: ' . sprintf('%01.4f',$first - $start)); -// logger('child dba_timer: ' . sprintf('%01.4f',$second - $first)); + logger('parent dba_timer: ' . sprintf('%01.4f',$first - $start)); + logger('child dba_timer: ' . sprintf('%01.4f',$second - $first)); return $o; diff --git a/mod/photos.php b/mod/photos.php index 127ea4893..101cb20b2 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -305,41 +305,7 @@ function photos_post(&$a) { $visibility = 1; if(! $item_id) { - - // Create item container - - $item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP; - $item_restrict = (($visibility) ? ITEM_HIDDEN : ITEM_VISIBLE); - - $title = ''; - $uri = item_message_id(); - - $arr = array(); - - $arr['aid'] = $a->data['channel']['channel_account_id']; - $arr['uid'] = $page_owner_uid; - $arr['uri'] = $uri; - $arr['parent_uri'] = $uri; - $arr['item_flags'] = $item_flags; - $arr['item_restrict'] = $item_restrict; - $arr['resource_type'] = 'photo'; - $arr['resource_id'] = $p[0]['resource_id']; - $arr['owner_xchan'] = $a->data['channel']['channel_hash']; - $arr['author_xchan'] = $a->data['channel']['channel_hash']; // FIXME for AUTH guests - - $arr['title'] = $title; - $arr['allow_cid'] = $p[0]['allow_cid']; - $arr['allow_gid'] = $p[0]['allow_gid']; - $arr['deny_cid'] = $p[0]['deny_cid']; - $arr['deny_gid'] = $p[0]['deny_gid']; - - - - $arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $p[0]['resource_id'] . ']' - . '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource_id'] . '-' . $p[0]['scale'] . '[/img]' - . '[/url]'; - - $item_id = item_store($arr); + $item_id = photos_create_item($a->data['channel'],get_observer_hash(),$p[0],$visibility); } @@ -559,213 +525,14 @@ function photos_post(&$a) { * default post action - upload a photo */ - call_hooks('photo_post_init', $_POST); - - /** - * Determine the album to use - */ - - $album = notags(trim($_REQUEST['album'])); - $newalbum = notags(trim($_REQUEST['newalbum'])); - - logger('mod/photos.php: photos_post(): album= ' . $album . ' newalbum= ' . $newalbum , LOGGER_DEBUG); - - if(! strlen($album)) { - if(strlen($newalbum)) - $album = $newalbum; - else - $album = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y'); - } - - /** - * - * We create a wall item for every photo, but we don't want to - * overwhelm the data stream with a hundred newly uploaded photos. - * So we will make the first photo uploaded to this album in the last several hours - * visible by default, the rest will become visible over time when and if - * they acquire comments, likes, dislikes, and/or tags - * - */ - - $r = q("SELECT * FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `created` > UTC_TIMESTAMP() - INTERVAL 3 HOUR ", - dbesc($album), - intval($page_owner_uid) - ); - if((! count($r)) || ($album == t('Profile Photos'))) - $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']))); - $str_group_deny = perms2str(((is_array($_REQUEST['group_deny'])) ? $_REQUEST['group_deny'] : explode(',',$_REQUEST['group_deny']))); - $str_contact_deny = perms2str(((is_array($_REQUEST['contact_deny'])) ? $_REQUEST['contact_deny'] : explode(',',$_REQUEST['contact_deny']))); - - $ret = array('src' => '', 'filename' => '', 'filesize' => 0, 'type' => ''); - - call_hooks('photo_post_file',$ret); - - if(x($ret,'src') && x($ret,'filesize')) { - $src = $ret['src']; - $filename = $ret['filename']; - $filesize = $ret['filesize']; - $type = $ret['type']; - } - else { - $src = $_FILES['userfile']['tmp_name']; - $filename = basename($_FILES['userfile']['name']); - $filesize = intval($_FILES['userfile']['size']); - $type = $_FILES['userfile']['type']; - } - if ($type=="") $type=guess_image_type($filename); - - logger('photos: upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes', LOGGER_DEBUG); - - $maximagesize = get_config('system','maximagesize'); - - if(($maximagesize) && ($filesize > $maximagesize)) { - notice( t('Image exceeds size limit of ') . $maximagesize . EOL); - @unlink($src); - $foo = 0; - call_hooks('photo_post_end',$foo); - return; - } - - if(! $filesize) { - notice( t('Image file is empty.') . EOL); - @unlink($src); - $foo = 0; - call_hooks('photo_post_end',$foo); - return; - } - - logger('mod/photos.php: photos_post(): loading the contents of ' . $src , LOGGER_DEBUG); - - $imagedata = @file_get_contents($src); - - - - $r = q("select sum(size) as total from photo where uid = %d and scale = 0 ", - intval($a->data['channel']['channel_id']) - ); - - $limit = service_class_fetch($a->data['channel']['channel_id'],'photo_upload_limit'); - - if(($limit !== false) && (($r[0]['total'] + strlen($imagedata)) > $limit)) { - notice( upgrade_message() . EOL ); - @unlink($src); - $foo = 0; - call_hooks('photo_post_end',$foo); - killme(); - } - - - $ph = new Photo($imagedata, $type); - - if(! $ph->is_valid()) { - logger('mod/photos.php: photos_post(): unable to process image' , LOGGER_DEBUG); - notice( t('Unable to process image.') . EOL ); - @unlink($src); - $foo = 0; - call_hooks('photo_post_end',$foo); - killme(); - } - - $ph->orient($src); - @unlink($src); - - $max_length = get_config('system','max_image_length'); - if(! $max_length) - $max_length = MAX_IMAGE_LENGTH; - if($max_length > 0) - $ph->scaleImage($max_length); - - $width = $ph->getWidth(); - $height = $ph->getHeight(); - - $smallest = 0; - - $photo_hash = photo_new_resource(); - - $page_owner_aid = $a->data['channel']['channel_account_id']; - $r = $ph->store($page_owner_aid, $page_owner_uid, $visitor, $photo_hash, $filename, $album, 0 , 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny); - - if(! $r) { - logger('mod/photos.php: photos_post(): image store failed' , LOGGER_DEBUG); - notice( t('Image upload failed.') . EOL ); - killme(); - } - - if($width > 640 || $height > 640) { - $ph->scaleImage(640); - $ph->store($page_owner_aid, $page_owner_uid, $visitor, $photo_hash, $filename, $album, 1, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny); - $smallest = 1; - } - - if($width > 320 || $height > 320) { - $ph->scaleImage(320); - $ph->store($page_owner_aid, $page_owner_uid, $visitor, $photo_hash, $filename, $album, 2, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny); - $smallest = 2; - } - - $basename = basename($filename); - $uri = item_message_id(); - - - // Create item container - - $item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP; - $item_restrict = (($visibility) ? ITEM_HIDDEN : ITEM_VISIBLE); - $title = ''; - $uri = item_message_id(); - - $arr = array(); - - $arr['aid'] = $a->data['channel']['channel_account_id']; - $arr['uid'] = $page_owner_uid; - $arr['uri'] = $uri; - $arr['parent_uri'] = $uri; - $arr['item_flags'] = $item_flags; - $arr['item_restrict'] = $item_restrict; - $arr['resource_type'] = 'photo'; - $arr['resource_id'] = $photo_hash; - $arr['owner_xchan'] = $a->data['channel']['channel_hash']; - $arr['author_xchan'] = $a->data['channel']['channel_hash']; // FIXME for AUTH guests - $arr['title'] = $title; - $arr['allow_cid'] = $str_contact_allow; - $arr['allow_gid'] = $str_group_allow; - $arr['deny_cid'] = $str_contact_deny; - $arr['deny_gid'] = $str_group_deny; - - - $arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $photo_hash . ']' - . '[img]' . $a->get_baseurl() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/img]' - . '[/url]'; - - $item_id = item_store($arr); - - if($item_id) { - q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1", - dbesc($a->get_baseurl() . '/display/' . $owner_record['nickname'] . '/' . $item_id), - intval($page_owner_uid), - intval($item_id) - ); - } - - if($visible) - proc_run('php', "include/notifier.php", 'wall-new', $item_id); - - call_hooks('photo_post_end',intval($item_id)); - - // addon uploaders should call "killme()" [e.g. exit] within the photo_post_end hook - // if they do not wish to be redirected + $r = photo_upload($a->channel,$a->get_observer(), $_REQUEST); + if(! $r['success']) { + notice($r['message'] . EOL); + } goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); - // NOTREACHED + } diff --git a/version.inc b/version.inc index 629a3deb4..c1c5fa011 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2013-01-31.217 +2013-02-01.218 -- cgit v1.2.3 From ed277f82f4def28fdedd5d6f8e763d8e1c0714ce Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 2 Feb 2013 03:11:23 -0800 Subject: searchable flag logic reversed --- include/zot.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/zot.php b/include/zot.php index a1169ea3b..5afa9d496 100644 --- a/include/zot.php +++ b/include/zot.php @@ -229,8 +229,10 @@ function zot_refresh($them,$channel = null) { $j = json_decode($result['body'],true); - if(! (($j) && ($j['success']))) + if(! (($j) && ($j['success']))) { + logger('zot_refresh: result not decodable'); return false; + } $x = import_xchan($j); @@ -548,10 +550,10 @@ function import_xchan($arr) { && ($arr['site']['url'] != z_root())) $arr['searchable'] = false; - + $hidden = (1 - intval($arr['searchable'])); // Be careful - XCHAN_FLAGS_HIDDEN should evaluate to 1 - if(($r[0]['xchan_flags'] & XCHAN_FLAGS_HIDDEN) != $arr['searchable']) + if(($r[0]['xchan_flags'] & XCHAN_FLAGS_HIDDEN) != $hidden) $new_flags = $r[0]['xchan_flags'] ^ XCHAN_FLAGS_HIDDEN; else $new_flags = $r[0]['xchan_flags']; -- cgit v1.2.3 From d4a6e5e5137995b7a818601f6cf69672ace9d2f7 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 2 Feb 2013 03:54:17 -0800 Subject: add post_wall to forum permission defaults --- view/js/mod_connections.js | 1 + 1 file changed, 1 insertion(+) diff --git a/view/js/mod_connections.js b/view/js/mod_connections.js index 485e2244b..33fc61883 100644 --- a/view/js/mod_connections.js +++ b/view/js/mod_connections.js @@ -57,6 +57,7 @@ function connectForum() { $('#me_id_perms_view_storage').attr('checked','checked'); $('#me_id_perms_view_pages').attr('checked','checked'); $('#me_id_perms_send_stream').attr('checked','checked'); + $('#me_id_perms_post_wall').attr('checked','checked'); $('#me_id_perms_post_comments').attr('checked','checked'); $('#me_id_perms_post_mail').attr('checked','checked'); $('#me_id_perms_tag_deliver').attr('checked','checked'); -- cgit v1.2.3 From e2dd38b0bcf8a24faf102c808a5590093964e094 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 2 Feb 2013 04:38:40 -0800 Subject: ensure that stored tag terms are taken after term expansion, e.g. @"Mike Macgirvin" and not @"mike+2" --- mod/item.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mod/item.php b/mod/item.php index 8d01a12f8..080413be9 100644 --- a/mod/item.php +++ b/mod/item.php @@ -434,7 +434,7 @@ function item_post(&$a) { 'uid' => $profile_uid, 'type' => $success['termtype'], 'otype' => TERM_OBJ_POST, - 'term' => substr($tag,1), + 'term' => $success['term'], 'url' => $success['url'] ); } @@ -853,7 +853,7 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) { $str_tags .= ','; $str_tags .= $newtag; } - return array('replaced' => $replaced, 'termtype' => $termtype, 'url' => $url, 'contact' => $r[0]); + return array('replaced' => $replaced, 'termtype' => $termtype, 'term' => $basetag, 'url' => $url, 'contact' => $r[0]); } //is it a person tag? if(strpos($tag,'@') === 0) { @@ -965,7 +965,7 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) { } } - return array('replaced' => $replaced, 'termtype' => $termtype, 'url' => $url, 'contact' => $r[0]); + return array('replaced' => $replaced, 'termtype' => $termtype, 'term' => $newname, 'url' => $url, 'contact' => $r[0]); } -- cgit v1.2.3 From 5c6c4395f4ab7924cad619d3a1ca4cee69219769 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 2 Feb 2013 04:47:30 -0800 Subject: Communication of mention tags were garbled --- include/items.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/items.php b/include/items.php index 5afb0816d..7a00754e6 100755 --- a/include/items.php +++ b/include/items.php @@ -635,7 +635,7 @@ function decode_tags($t) { $ret = array(); foreach($t as $x) { $tag = array(); - $tag['term'] = htmlentities($x['term'], ENT_COMPAT,'UTF-8',false); + $tag['term'] = htmlentities($x['tag'], ENT_COMPAT,'UTF-8',false); $tag['url'] = htmlentities($x['url'], ENT_COMPAT,'UTF-8',false); switch($x['type']) { case 'hashtag': -- cgit v1.2.3