aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/attach.php12
-rw-r--r--include/bbcode.php2
-rw-r--r--include/channel.php1
-rw-r--r--include/group.php18
-rw-r--r--include/network.php24
-rw-r--r--include/photos.php14
-rw-r--r--include/taxonomy.php2
-rw-r--r--include/text.php6
8 files changed, 58 insertions, 21 deletions
diff --git a/include/attach.php b/include/attach.php
index 78efde51f..33545b12a 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -423,6 +423,8 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$observer = array();
+ $dosync = ((array_key_exists('nosync',$arr) && $arr['nosync']) ? 0 : 1);
+
if($observer_hash) {
$x = q("select * from xchan where xchan_hash = '%s' limit 1",
dbesc($observer_hash)
@@ -829,6 +831,8 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
if($arr['description'])
$args['description'] = $arr['description'];
+ $args['deliver'] = $dosync;
+
$p = photo_upload($channel,$observer,$args);
if($p['success']) {
$ret['body'] = $p['body'];
@@ -865,10 +869,12 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
call_hooks('photo_upload_end',$ret);
}
- $sync = attach_export_data($channel,$hash);
+ if($dosync) {
+ $sync = attach_export_data($channel,$hash);
- if($sync)
- build_sync_packet($channel['channel_id'],array('file' => array($sync)));
+ if($sync)
+ build_sync_packet($channel['channel_id'],array('file' => array($sync)));
+ }
return $ret;
}
diff --git a/include/bbcode.php b/include/bbcode.php
index b720355af..0bf326506 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -493,7 +493,7 @@ function bb_code($match) {
function bb_highlight($match) {
if(in_array(strtolower($match[1]),['php','css','mysql','sql','abap','diff','html','perl','ruby',
- 'vbscript','avrc','dtd','java','xml','cpp','python','javascript','js','sh']))
+ 'vbscript','avrc','dtd','java','xml','cpp','python','javascript','js','json','sh']))
return text_highlight($match[2],strtolower($match[1]));
return $match[0];
}
diff --git a/include/channel.php b/include/channel.php
index 92c274105..90dfb2bf6 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -1224,6 +1224,7 @@ function advanced_profile(&$a) {
$things = get_things(App::$profile['profile_guid'],App::$profile['profile_uid']);
+
// logger('mod_profile: things: ' . print_r($things,true), LOGGER_DATA);
return replace_macros($tpl, array(
diff --git a/include/group.php b/include/group.php
index a4938b848..10853ff6b 100644
--- a/include/group.php
+++ b/include/group.php
@@ -17,7 +17,7 @@ function group_add($uid,$name,$public = 0) {
$z = q("SELECT * FROM `groups` WHERE `id` = %d LIMIT 1",
intval($r)
);
- if(count($z) && $z[0]['deleted']) {
+ if(($z) && $z[0]['deleted']) {
/*$r = q("UPDATE `groups` SET `deleted` = 0 WHERE `uid` = %d AND `gname` = '%s' LIMIT 1",
intval($uid),
dbesc($name)
@@ -129,7 +129,7 @@ function group_byname($uid,$name) {
intval($uid),
dbesc($name)
);
- if(count($r))
+ if($r)
return $r[0]['id'];
return false;
}
@@ -178,11 +178,11 @@ function group_add_member($uid,$name,$member,$gid = 0) {
intval($gid),
dbesc($member)
);
- if(count($r))
+ if($r)
return true; // You might question this, but
// we indicate success because the group member was in fact created
// -- It was just created at another time
- if(! count($r))
+ if(! $r)
$r = q("INSERT INTO `group_member` (`uid`, `gid`, `xchan`)
VALUES( %d, %d, '%s' ) ",
intval($uid),
@@ -205,7 +205,7 @@ function group_get_members($gid) {
intval(local_channel()),
intval(local_channel())
);
- if(count($r))
+ if($r)
$ret = $r;
}
return $ret;
@@ -218,7 +218,7 @@ function group_get_members_xchan($gid) {
intval($gid),
intval(local_channel())
);
- if(count($r)) {
+ if($r) {
foreach($r as $rr) {
$ret[] = $rr['xchan'];
}
@@ -236,7 +236,7 @@ function mini_group_select($uid,$group = '') {
intval($uid)
);
$grps[] = array('name' => '', 'hash' => '0', 'selected' => '');
- if(count($r)) {
+ if($r) {
foreach($r as $rr) {
$grps[] = array('name' => $rr['gname'], 'id' => $rr['hash'], 'selected' => (($group == $rr['hash']) ? 'true' : ''));
}
@@ -279,7 +279,7 @@ function group_side($every="connections",$each="group",$edit = false, $group_id
$member_of = groups_containing(local_channel(),$cid);
}
- if(count($r)) {
+ if($r) {
foreach($r as $rr) {
$selected = (($group_id == $rr['id']) ? ' group-selected' : '');
@@ -356,7 +356,7 @@ function groups_containing($uid,$c) {
);
$ret = array();
- if(count($r)) {
+ if($r) {
foreach($r as $rr)
$ret[] = $rr['gid'];
}
diff --git a/include/network.php b/include/network.php
index a595a03d1..062f2c2bf 100644
--- a/include/network.php
+++ b/include/network.php
@@ -29,6 +29,8 @@ function get_capath() {
* * \b nobody => only return the header
* * \b filep => stream resource to write body to. header and body are not returned when using this option.
* * \b custom => custom request method: e.g. 'PUT', 'DELETE'
+ * * \b cookiejar => cookie file (write)
+ * * \B cookiefile => cookie file (read)
*
* @return array an associative array with:
* * \e int \b return_code => HTTP return code or 0 if timeout or failure
@@ -60,6 +62,8 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
@curl_setopt($ch, CURLOPT_HEADER, $false);
}
+
+
if(x($opts,'headers'))
@curl_setopt($ch, CURLOPT_HTTPHEADER, $opts['headers']);
@@ -82,6 +86,11 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
@curl_setopt($ch, CURLOPT_USERPWD, $opts['http_auth']);
}
+ if(x($opts,'cookiejar'))
+ @curl_setopt($ch, CURLOPT_COOKIEJAR, $opts['cookiejar']);
+ if(x($opts,'cookiefile'))
+ @curl_setopt($ch, CURLOPT_COOKIEFILE, $opts['cookiefile']);
+
@curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,
((x($opts,'novalidate') && intval($opts['novalidate'])) ? false : true));
@@ -180,6 +189,10 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
*/
function z_post_url($url,$params, $redirects = 0, $opts = array()) {
+// logger('url: ' . $url);
+// logger('params: ' . print_r($params,true));
+// logger('opts: ' . print_r($opts,true));
+
$ret = array('return_code' => 0, 'success' => false, 'header' => "", 'body' => "");
$ch = curl_init($url);
@@ -205,14 +218,15 @@ function z_post_url($url,$params, $redirects = 0, $opts = array()) {
if(x($opts,'headers')) {
@curl_setopt($ch, CURLOPT_HTTPHEADER, $opts['headers']);
-logger('headers: ' . print_r($opts['headers'],true) . 'redir: ' . $redirects);
}
if(x($opts,'nobody'))
@curl_setopt($ch, CURLOPT_NOBODY, $opts['nobody']);
- if(x($opts,'custom'))
+ if(x($opts,'custom')) {
@curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $opts['custom']);
+ @curl_setopt($ch, CURLOPT_POST,0);
+ }
if(x($opts,'timeout') && intval($opts['timeout'])) {
@@ -228,6 +242,12 @@ logger('headers: ' . print_r($opts['headers'],true) . 'redir: ' . $redirects);
@curl_setopt($ch, CURLOPT_USERPWD, $opts['http_auth']);
}
+
+ if(x($opts,'cookiejar'))
+ @curl_setopt($ch, CURLOPT_COOKIEJAR, $opts['cookiejar']);
+ if(x($opts,'cookiefile'))
+ @curl_setopt($ch, CURLOPT_COOKIEFILE, $opts['cookiefile']);
+
@curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,
((x($opts,'novalidate') && intval($opts['novalidate'])) ? false : true));
diff --git a/include/photos.php b/include/photos.php
index c64d662ea..da6118b38 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -41,6 +41,10 @@ function photo_upload($channel, $observer, $args) {
else
$visible = 0;
+ $deliver = true;
+ if(array_key_exists('deliver',$args))
+ $deliver = intval($args['deliver']);
+
// Set to default channel permissions. If the parent directory (album) has permissions set,
// use those instead. If we have specific permissions supplied, they take precedence over
// all other settings. 'allow_cid' being passed from an external source takes priority over channel settings.
@@ -330,7 +334,7 @@ function photo_upload($channel, $observer, $args) {
if($item['mid'] === $item['parent_mid']) {
- $item['body'] = $args['body'];
+ $item['body'] = $summary;
$item['obj_type'] = ACTIVITY_OBJ_PHOTO;
$item['obj'] = json_encode($object);
@@ -355,14 +359,14 @@ function photo_upload($channel, $observer, $args) {
if(($item['edited'] > $r[0]['edited']) || $force) {
$item['id'] = $r[0]['id'];
$item['uid'] = $channel['channel_id'];
- item_store_update($item);
+ item_store_update($item,false,$deliver);
continue;
}
}
else {
$item['aid'] = $channel['channel_account_id'];
$item['uid'] = $channel['channel_id'];
- $item_result = item_store($item);
+ $item_result = item_store($item,false,$deliver);
}
}
}
@@ -414,10 +418,10 @@ function photo_upload($channel, $observer, $args) {
- $result = item_store($arr);
+ $result = item_store($arr,false,$deliver);
$item_id = $result['item_id'];
- if($visible)
+ if($visible && $deliver)
Zotlabs\Daemon\Master::Summon(array('Notifier', 'wall-new', $item_id));
}
diff --git a/include/taxonomy.php b/include/taxonomy.php
index 177215fe8..067bd3246 100644
--- a/include/taxonomy.php
+++ b/include/taxonomy.php
@@ -400,7 +400,7 @@ function get_things($profile_hash,$uid) {
if(! $things[$rr['obj_verb']])
$things[$rr['obj_verb']] = array();
- $things[$rr['obj_verb']][] = array('term' => $rr['obj_term'],'url' => $rr['obj_url'],'img' => $rr['obj_imgurl'], 'profile' => $rr['profile_name'],'term_hash' => $rr['obj_obj'], 'likes' => $l,'like_count' => count($l),'like_label' => tt('Like','Likes',count($l),'noun'));
+ $things[$rr['obj_verb']][] = array('term' => $rr['obj_term'],'url' => $rr['obj_url'],'img' => $rr['obj_imgurl'], 'editurl' => z_root() . '/thing/' . $rr['obj_obj'], 'profile' => $rr['profile_name'],'term_hash' => $rr['obj_obj'], 'likes' => $l,'like_count' => count($l),'like_label' => tt('Like','Likes',count($l),'noun'));
}
$sorted_things = array();
if($things) {
diff --git a/include/text.php b/include/text.php
index 50a3d8892..22f4556a8 100644
--- a/include/text.php
+++ b/include/text.php
@@ -2887,6 +2887,12 @@ function text_highlight($s,$lang) {
if($lang === 'js')
$lang = 'javascript';
+ if($lang === 'json') {
+ $lang = 'javascript';
+ if(! strpos(trim($s),"\n"))
+ $s = jindent($s);
+ }
+
if(! strpos('Text_Highlighter',get_include_path())) {
set_include_path(get_include_path() . PATH_SEPARATOR . 'library/Text_Highlighter');
}