aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/attach.php49
-rw-r--r--include/bbcode.php6
-rw-r--r--include/config.php66
-rw-r--r--include/crypto.php2
-rw-r--r--include/identity.php123
-rw-r--r--include/photos.php8
-rw-r--r--include/widgets.php2
-rw-r--r--include/zot.php25
8 files changed, 194 insertions, 87 deletions
diff --git a/include/attach.php b/include/attach.php
index 78114b415..2777b5813 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -1243,7 +1243,7 @@ function attach_delete($channel_id, $resource, $is_photo = 0) {
$channel_address = (($c) ? $c[0]['channel_address'] : 'notfound');
$photo_sql = (($is_photo) ? " and is_photo = 1 " : '');
- $r = q("SELECT hash, flags, is_dir, is_photo, folder FROM attach WHERE hash = '%s' AND uid = %d $photo_sql limit 1",
+ $r = q("SELECT hash, os_storage, flags, is_dir, is_photo, folder FROM attach WHERE hash = '%s' AND uid = %d $photo_sql limit 1",
dbesc($resource),
intval($channel_id)
);
@@ -1471,7 +1471,7 @@ function pipe_streams($in, $out) {
* @param string $deny_cid
* @param string $deny_gid
* @param string $verb
- * @param boolean $no_activity
+ * @param boolean $notify
*/
function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $verb, $notify) {
@@ -1517,13 +1517,21 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid,
$mid = item_message_id();
- $arr = array();
+ $objtype = ACTIVITY_OBJ_FILE;
+ $arr = array();
+ $arr['aid'] = get_account_id();
+ $arr['uid'] = $channel_id;
$arr['item_wall'] = 1;
$arr['item_origin'] = 1;
$arr['item_unseen'] = 1;
-
- $objtype = ACTIVITY_OBJ_FILE;
+ $arr['author_xchan'] = $poster['xchan_hash'];
+ $arr['owner_xchan'] = $poster['xchan_hash'];
+ $arr['title'] = '';
+ $arr['item_hidden'] = 1;
+ $arr['obj_type'] = $objtype;
+ $arr['resource_id'] = $object['hash'];
+ $arr['resource_type'] = 'attach';
$private = (($arr_allow_cid[0] || $arr_allow_gid[0] || $arr_deny_cid[0] || $arr_deny_gid[0]) ? 1 : 0);
@@ -1551,9 +1559,8 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid,
}
+ //send update activity and create a new one
if($update && $verb == 'post' ) {
- //send update activity and create a new one
-
//updates should be sent to everybody with recursive perms and all eventual former allowed members ($object['allow_cid'] etc.).
$u_arr_allow_cid = array_unique(array_merge($arr_allow_cid, expand_acl($object['allow_cid'])));
$u_arr_allow_gid = array_unique(array_merge($arr_allow_gid, expand_acl($object['allow_gid'])));
@@ -1564,24 +1571,15 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid,
$u_mid = item_message_id();
- $arr['aid'] = get_account_id();
- $arr['uid'] = $channel_id;
$arr['mid'] = $u_mid;
$arr['parent_mid'] = $u_mid;
- $arr['author_xchan'] = $poster['xchan_hash'];
- $arr['owner_xchan'] = $poster['xchan_hash'];
- $arr['title'] = '';
$arr['allow_cid'] = perms2str($u_arr_allow_cid);
$arr['allow_gid'] = perms2str($u_arr_allow_gid);
$arr['deny_cid'] = perms2str($u_arr_deny_cid);
$arr['deny_gid'] = perms2str($u_arr_deny_gid);
- $arr['item_hidden'] = 1;
$arr['item_private'] = $private;
$arr['verb'] = ACTIVITY_UPDATE;
- $arr['obj_type'] = $objtype;
$arr['object'] = $u_jsonobject;
- $arr['resource_id'] = $object['hash'];
- $arr['resource_type'] = 'attach';
$arr['body'] = '';
$post = item_store($arr);
@@ -1597,32 +1595,25 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid,
//notice( t('File activity updated') . EOL);
}
+ //don't create new activity if notify was not enabled
if(! $notify) {
return;
}
- $arr = array();
+ //don't create new activity if we have an update request but there is no item to update
+ //this can e.g. happen when deleting images
+ if(! $y && $verb == 'update') {
+ return;
+ }
- $arr['aid'] = get_account_id();
- $arr['uid'] = $channel_id;
$arr['mid'] = $mid;
$arr['parent_mid'] = $mid;
- $arr['item_wall'] = 1;
- $arr['item_origin'] = 1;
- $arr['item_unseen'] = 1;
- $arr['author_xchan'] = $poster['xchan_hash'];
- $arr['owner_xchan'] = $poster['xchan_hash'];
- $arr['title'] = '';
$arr['allow_cid'] = perms2str($arr_allow_cid);
$arr['allow_gid'] = perms2str($arr_allow_gid);
$arr['deny_cid'] = perms2str($arr_deny_cid);
$arr['deny_gid'] = perms2str($arr_deny_gid);
- $arr['item_hidden'] = 1;
$arr['item_private'] = $private;
$arr['verb'] = (($update) ? ACTIVITY_UPDATE : ACTIVITY_POST);
- $arr['obj_type'] = $objtype;
- $arr['resource_id'] = $object['hash'];
- $arr['resource_type'] = 'attach';
$arr['object'] = (($update) ? $u_jsonobject : $jsonobject);
$arr['body'] = '';
diff --git a/include/bbcode.php b/include/bbcode.php
index a8372d728..477436475 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -684,7 +684,11 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false)
}
// Check for centered text
if (strpos($Text,'[/center]') !== false) {
- $Text = preg_replace("(\[center\](.*?)\[\/center\])ism", "<div style=\"text-align:center;\">$1</div>", $Text);
+ $Text = preg_replace("(\[center\](.*?)\[\/center\])ism", "<div style=\"text-align:center;\">$1</div>", $Text);
+ }
+ // Check for footer
+ if (strpos($Text,'[/footer]') !== false) {
+ $Text = preg_replace("(\[footer\](.*?)\[\/footer\])ism", "<div class=\"wall-item-footer\">$1</div>", $Text);
}
// Check for list text
$Text = str_replace("[*]", "<li>", $Text);
diff --git a/include/config.php b/include/config.php
index f65e4a470..51d4e99ac 100644
--- a/include/config.php
+++ b/include/config.php
@@ -549,4 +549,68 @@ function set_aconfig($account_id, $family, $key, $value) {
function del_aconfig($account_id, $family, $key) {
return del_xconfig('a_' . $account_id, $family, $key);
-} \ No newline at end of file
+}
+
+
+function load_abconfig($chash,$xhash) {
+ $r = q("select * from abconfig where chan = '%s' and xchan = '%s'",
+ dbesc($chash),
+ dbesc($xhash)
+ );
+ return $r;
+}
+
+function get_abconfig($chash,$xhash,$family,$key) {
+ $r = q("select * from abconfig where chan = '%s' and xchan = '%s' and cat = '%s' and k = '%s' limit 1",
+ dbesc($chash),
+ dbesc($xhash),
+ dbesc($family),
+ dbesc($key)
+ );
+ if($r) {
+ return ((preg_match('|^a:[0-9]+:{.*}$|s', $r[0]['v'])) ? unserialize($r[0]['v']) : $r[0]['v']);
+ }
+ return false;
+}
+
+
+function set_abconfig($chash,$xhash,$family,$key,$value) {
+
+ $dbvalue = ((is_array($value)) ? serialize($value) : $value);
+ $dbvalue = ((is_bool($dbvalue)) ? intval($dbvalue) : $dbvalue);
+
+ if(get_abconfig($chash,$xhash,$family,$key) === false) {
+ $r = q("insert into abconfig ( chan, xchan, cat, k, v ) values ( '%s', '%s', '%s', '%s', '%s' ) ",
+ dbesc($chash),
+ dbesc($xhash),
+ dbesc($family),
+ dbesc($key),
+ dbesc($dbvalue)
+ );
+ }
+ else {
+ $r = q("update abconfig set v = '%s' where chan = '%s' and xchan = '%s' and cat = '%s' and k = '%s' ",
+ dbesc($dbvalue),
+ dbesc($chash),
+ dbesc($xhash),
+ dbesc($family),
+ dbesc($key)
+ );
+ }
+ if($r)
+ return $value;
+ return false;
+}
+
+
+function del_abconfig($chash,$xhash,$family,$key) {
+
+ $r = q("delete from abconfig where chan = '%s' and xchan = '%s' and cat = '%s' and k = '%s' ",
+ dbesc($chash),
+ dbesc($xhash),
+ dbesc($family),
+ dbesc($key)
+ );
+
+ return $r;
+}
diff --git a/include/crypto.php b/include/crypto.php
index 50ec2a3a6..94a6b4a58 100644
--- a/include/crypto.php
+++ b/include/crypto.php
@@ -20,7 +20,7 @@ function rsa_verify($data,$sig,$key,$alg = 'sha256') {
if(intval(OPENSSL_ALGO_SHA256) && $alg === 'sha256')
$alg = OPENSSL_ALGO_SHA256;
- $verify = openssl_verify($data,$sig,$key,$alg);
+ $verify = @openssl_verify($data,$sig,$key,$alg);
if(! $verify) {
logger('openssl_verify: ' . openssl_error_string(),LOGGER_NORMAL,LOG_ERR);
diff --git a/include/identity.php b/include/identity.php
index caf2de710..382b096fe 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -505,8 +505,12 @@ function identity_basic_export($channel_id, $items = false) {
if($r) {
$ret['abook'] = $r;
- foreach($r as $rr)
- $xchans[] = $rr['abook_xchan'];
+ for($x = 0; $x < count($ret['abook']); $x ++) {
+ $xchans[] = $ret['abook'][$x]['abook_chan'];
+ $abconfig = load_abconfig($ret['channel']['channel_hash'],$ret['abook'][$x]['abook_xchan']);
+ if($abconfig)
+ $ret['abook'][$x]['abconfig'] = $abconfig;
+ }
stringify_array_elms($xchans);
}
@@ -900,6 +904,55 @@ function profile_load(&$a, $nickname, $profile = '') {
}
+function profile_edit_menu($uid) {
+
+ $a = get_app();
+ $ret = array();
+
+ $is_owner = (($uid == local_channel()) ? true : false);
+
+ // show edit profile to profile owner
+ if($is_owner) {
+ $ret['menu'] = array(
+ 'chg_photo' => t('Change profile photo'),
+ 'entries' => array(),
+ );
+
+ $multi_profiles = feature_enabled(local_channel(), 'multi_profiles');
+ if($multi_profiles) {
+ $ret['multi'] = 1;
+ $ret['edit'] = array($a->get_baseurl(). '/profiles', t('Edit Profiles'), '', t('Edit'));
+ $ret['menu']['cr_new'] = t('Create New Profile');
+ }
+ else {
+ $ret['edit'] = array($a->get_baseurl() . '/profiles/' . $uid, t('Edit Profile'), '', t('Edit'));
+ }
+
+ $r = q("SELECT * FROM profile WHERE uid = %d",
+ local_channel()
+ );
+
+ if($r) {
+ foreach($r as $rr) {
+ if(!($multi_profiles || $rr['is_default']))
+ continue;
+ $ret['menu']['entries'][] = array(
+ 'photo' => $rr['thumb'],
+ 'id' => $rr['id'],
+ 'alt' => t('Profile Image'),
+ 'profile_name' => $rr['profile_name'],
+ 'isdefault' => $rr['is_default'],
+ 'visible_to_everybody' => t('Visible to everybody'),
+ 'edit_visibility' => t('Edit visibility'),
+ );
+ }
+ }
+ }
+
+ return $ret;
+
+}
+
/**
* @brief Formats a profile for display in the sidebar.
*
@@ -933,13 +986,9 @@ function profile_sidebar($profile, $block = 0, $show_connect = true, $zcard = fa
head_set_icon($profile['thumb']);
- $is_owner = (($profile['uid'] == local_channel()) ? true : false);
-
if(is_sys_channel($profile['uid']))
$show_connect = false;
-
-
$profile['picdate'] = urlencode($profile['picdate']);
call_hooks('profile_sidebar_enter', $profile);
@@ -961,42 +1010,6 @@ function profile_sidebar($profile, $block = 0, $show_connect = true, $zcard = fa
$connect_url = z_root() . '/connect/' . $profile['channel_address'];
}
- // show edit profile to yourself
- if($is_owner) {
- $profile['menu'] = array(
- 'chg_photo' => t('Change profile photo'),
- 'entries' => array(),
- );
-
- $multi_profiles = feature_enabled(local_channel(), 'multi_profiles');
- if($multi_profiles) {
- $profile['edit'] = array($a->get_baseurl(). '/profiles', t('Profiles'),"", t('Manage/edit profiles'));
- $profile['menu']['cr_new'] = t('Create New Profile');
- }
- else
- $profile['edit'] = array($a->get_baseurl() . '/profiles/' . $profile['id'], t('Edit Profile'),'',t('Edit Profile'));
-
- $r = q("SELECT * FROM `profile` WHERE `uid` = %d",
- local_channel());
-
- if($r) {
- foreach($r as $rr) {
- if(!($multi_profiles || $rr['is_default']))
- continue;
- $profile['menu']['entries'][] = array(
- 'photo' => $rr['thumb'],
- 'id' => $rr['id'],
- 'alt' => t('Profile Image'),
- 'profile_name' => $rr['profile_name'],
- 'isdefault' => $rr['is_default'],
- 'visible_to_everybody' => t('visible to everybody'),
- 'edit_visibility' => t('Edit visibility'),
- );
- }
- }
- }
-
-
if((x($profile,'address') == 1)
|| (x($profile,'locality') == 1)
|| (x($profile,'region') == 1)
@@ -1075,6 +1088,7 @@ function profile_sidebar($profile, $block = 0, $show_connect = true, $zcard = fa
'$reddress' => $reddress,
'$rating' => $z,
'$contact_block' => $contact_block,
+ '$editmenu' => profile_edit_menu($profile['uid'])
));
$arr = array('profile' => &$profile, 'entry' => &$o);
@@ -1239,6 +1253,24 @@ function advanced_profile(&$a) {
if($a->profile['name']) {
+ $profile_fields_basic = get_profile_fields_basic();
+ $profile_fields_advanced = get_profile_fields_advanced();
+
+ $advanced = ((feature_enabled($a->profile['profile_uid'],'advanced_profiles')) ? true : false);
+ if($advanced)
+ $fields = $profile_fields_advanced;
+ else
+ $fields = $profile_fields_basic;
+
+ $clean_fields = array();
+ if($fields) {
+ foreach($fields as $k => $v) {
+ $clean_fields[] = trim($k);
+ }
+ }
+
+
+
$tpl = get_markup_template('profile_advanced.tpl');
$profile = array();
@@ -1347,10 +1379,6 @@ function advanced_profile(&$a) {
$profile['extra_fields'] = $a->profile['extra_fields'];
}
-
- $is_owner = (($a->profile['profile_uid'] == local_channel()) ? true : false);
- $edit = (($is_owner) ? array('link' => $a->get_baseurl() . '/profiles/' . $a->profile['profile_uid'], 'label' => t('Edit')) : '');
-
$things = get_things($a->profile['profile_guid'],$a->profile['profile_uid']);
// logger('mod_profile: things: ' . print_r($things,true), LOGGER_DATA);
@@ -1360,7 +1388,8 @@ function advanced_profile(&$a) {
'$canlike' => (($profile['canlike'])? true : false),
'$likethis' => t('Like this thing'),
'$profile' => $profile,
- '$edit' => $edit,
+ '$fields' => $clean_fields,
+ '$editmenu' => profile_edit_menu($a->profile['profile_uid']),
'$things' => $things
));
}
diff --git a/include/photos.php b/include/photos.php
index be18600de..5dd5f3c62 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -300,7 +300,7 @@ function photo_upload($channel, $observer, $args) {
$activity_format = sprintf(t('%1$s posted %2$s to %3$s','photo_upload'), $author_link, $photo_link, $album_link);
- $summary = $activity_format . "\n\n" . (($args['body']) ? $args['body'] . "\n\n" : '');
+ $summary = (($args['body']) ? $args['body'] : '') . '[footer]' . $activity_format . '[/footer]';
$obj_body = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash . ']'
. $tag . z_root() . "/photo/{$photo_hash}-{$scale}." . $ph->getExt() . '[/zmg]'
@@ -391,8 +391,8 @@ function photo_upload($channel, $observer, $args) {
$arr['deny_cid'] = $ac['deny_cid'];
$arr['deny_gid'] = $ac['deny_gid'];
$arr['verb'] = ACTIVITY_POST;
- $arr['obj_type'] = ACTIVITY_OBJ_PHOTO;
- $arr['object'] = json_encode($object);
+ $arr['obj_type'] = ACTIVITY_OBJ_PHOTO;
+ $arr['object'] = json_encode($object);
$arr['tgt_type'] = ACTIVITY_OBJ_ALBUM;
$arr['target'] = json_encode($target);
$arr['item_wall'] = 1;
@@ -400,7 +400,7 @@ function photo_upload($channel, $observer, $args) {
$arr['item_thread_top'] = 1;
$arr['item_private'] = intval($acl->is_private());
$arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid'];
- $arr['body'] = $summary;
+ $arr['body'] = $summary;
// this one is tricky because the item and the photo have the same permissions, those of the photo.
diff --git a/include/widgets.php b/include/widgets.php
index a995fdf1c..aa0be87d6 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -1197,7 +1197,7 @@ function widget_forums($arr) {
$perms_sql = item_permissions_sql(local_channel()) . item_normal();
- $r1 = q("select * from abook left join xchan on abook_xchan = xchan_hash where ( xchan_pubforum = 1 or ((abook_their_perms & %d ) != 0 and (abook_their_perms & %d ) = 0) ) and abook_channel = %d order by xchan_name $limit ",
+ $r1 = q("select * from abook left join xchan on abook_xchan = xchan_hash where ( xchan_pubforum = 1 or ((abook_their_perms & %d ) != 0 and (abook_their_perms & %d ) = 0) ) and xchan_deleted = 0 and abook_channel = %d order by xchan_name $limit ",
intval(PERMS_W_TAGWALL),
intval(PERMS_W_STREAM),
intval(local_channel())
diff --git a/include/zot.php b/include/zot.php
index de841f956..a60a50d8f 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -522,6 +522,11 @@ function zot_refresh($them, $channel = null, $force = false) {
unset($new_connection[0]['abook_id']);
unset($new_connection[0]['abook_account']);
unset($new_connection[0]['abook_channel']);
+
+ $abconfig = load_abconfig($channel['channel_hash'],$new_connection['abook_xchan']);
+ if($abconfig)
+ $new_connection['abconfig'] = $abconfig;
+
build_sync_packet($channel['channel_id'], array('abook' => $new_connection));
}
}
@@ -2971,6 +2976,8 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) {
logger('build_sync_packet: packet: ' . print_r($info,true), LOGGER_DATA, LOG_DEBUG);
+ $total = count($synchubs);
+
foreach($synchubs as $hub) {
$hash = random_string();
$n = zot_build_packet($channel,'notify',$env_recips,$hub['hubloc_sitekey'],$hash);
@@ -2984,7 +2991,9 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) {
));
proc_run('php', 'include/deliver.php', $hash);
- if($interval)
+ $total = $total - 1;
+
+ if($interval && $total)
@time_sleep_until(microtime(true) + (float) $interval);
}
}
@@ -3120,6 +3129,11 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
foreach($arr['abook'] as $abook) {
+ $abconfig = null;
+
+ if(array_key_exists('abconfig',$abook) && is_array($abook['abconfig']) && count($abook['abconfig']))
+ $abconfig = $abook['abconfig'];
+
if(! array_key_exists('abook_blocked',$abook)) {
// convert from redmatrix
$abook['abook_blocked'] = (($abook['abook_flags'] & 0x0001) ? 1 : 0);
@@ -3210,8 +3224,13 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
}
}
-
-
+ if($abconfig) {
+ // @fixme does not handle sync of del_abconfig
+ foreach($abconfig as $abc) {
+ if($abc['chan'] === $channel['channel_hash'])
+ set_abconfig($abc['chan'],$abc['xchan'],$abc['cat'],$abc['k'],$abc['v']);
+ }
+ }
}
}