aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-02-29 19:34:23 -0800
committerredmatrix <git@macgirvin.com>2016-02-29 19:34:23 -0800
commit91bb4bdf508ab87951a3e01ac3632cffc7bff07d (patch)
treecbe4dc7b0e4641ea677c159cb6871adf0b40f6db /include
parentbe2b7c0b5f7f9b8080affbb4bc44c5adda18e82f (diff)
parent2d45f9f385a5738d2126f66c0e5467533e6838c2 (diff)
downloadvolse-hubzilla-91bb4bdf508ab87951a3e01ac3632cffc7bff07d.tar.gz
volse-hubzilla-91bb4bdf508ab87951a3e01ac3632cffc7bff07d.tar.bz2
volse-hubzilla-91bb4bdf508ab87951a3e01ac3632cffc7bff07d.zip
Merge https://github.com/redmatrix/hubzilla into pending_merge
Diffstat (limited to 'include')
-rw-r--r--include/attach.php49
-rw-r--r--include/bbcode.php6
-rw-r--r--include/identity.php96
-rw-r--r--include/photos.php8
4 files changed, 80 insertions, 79 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/identity.php b/include/identity.php
index 478079d39..380556246 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -904,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.
*
@@ -937,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);
@@ -965,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)
@@ -1079,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);
@@ -1351,10 +1361,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);
@@ -1364,7 +1370,7 @@ function advanced_profile(&$a) {
'$canlike' => (($profile['canlike'])? true : false),
'$likethis' => t('Like this thing'),
'$profile' => $profile,
- '$edit' => $edit,
+ '$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.