aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorThomas Willingham <founder@kakste.com>2013-02-02 14:56:17 +0000
committerThomas Willingham <founder@kakste.com>2013-02-02 14:56:17 +0000
commit0f13ae0ade10d6d2b0ef185ae6d6cc2d35831433 (patch)
tree7d6ac98d5f0b4e10ef86ba0f312401830c751250 /mod
parent1633f95db8a004055e51d1580fa4394527ca8a91 (diff)
parent5c6c4395f4ab7924cad619d3a1ca4cee69219769 (diff)
downloadvolse-hubzilla-0f13ae0ade10d6d2b0ef185ae6d6cc2d35831433.tar.gz
volse-hubzilla-0f13ae0ade10d6d2b0ef185ae6d6cc2d35831433.tar.bz2
volse-hubzilla-0f13ae0ade10d6d2b0ef185ae6d6cc2d35831433.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'mod')
-rw-r--r--mod/item.php6
-rw-r--r--mod/network.php4
-rw-r--r--mod/photos.php245
3 files changed, 11 insertions, 244 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]);
}
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
+
}