This commit is contained in:
redmatrix 2016-02-29 19:34:23 -08:00
commit 91bb4bdf50
9 changed files with 9774 additions and 92 deletions

View file

@ -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'] = '';

View file

@ -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);

View file

@ -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
));
}

View file

@ -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.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1243,6 +1243,11 @@ img.mail-conv-sender-photo {
font-size: $font_size;
}
.wall-item-footer {
font-size: $body_font_size;
margin-top: 2em;
}
.wall-item-content-wrapper {
background-color: $item_colour;
border-top-right-radius: $radiuspx;

View file

@ -12,8 +12,19 @@
<i class="icon-thumbs-up-alt" title="{{$profile.likethis}}"></i>
</button>
{{/if}}
{{if $edit}}
<a href="{{$edit.link}}" class="btn btn-primary btn-xs"><i class="icon-pencil"></i>&nbsp;{{$edit.label}}</a>
{{if $editmenu.multi}}
<a class="btn btn-primary btn-xs dropdown-toggle" data-toggle="dropdown" href="#" ><i class="icon-pencil"></i>&nbsp;{{$editmenu.edit.3}}</a>
<ul class="dropdown-menu" role="menu">
{{foreach $editmenu.menu.entries as $e}}
<li>
<a href="profiles/{{$e.id}}"><img class="dropdown-menu-img-xs" src='{{$e.photo}}'>{{$e.profile_name}}<div class='clear'></div></a>
</li>
{{/foreach}}
<li><a href="profile_photo" >{{$editmenu.menu.chg_photo}}</a></li>
{{if $editmenu.menu.cr_new}}<li><a href="profiles/new" id="profile-listing-new-link">{{$editmenu.menu.cr_new}}</a></li>{{/if}}
</ul>
{{else}}
<a class="btn btn-primary btn-xs" href="{{$editmenu.edit.0}}" ><i class="icon-pencil"></i>&nbsp;{{$editmenu.edit.3}}</a>
{{/if}}
</div>
<h2>{{$title}}</h2>

View file

@ -6,19 +6,21 @@
<div class="connect-btn-wrapper"><a href="{{$connect_url}}" class="btn btn-block btn-success btn-sm"><i class="icon-plus"></i> {{$connect}}</a></div>
{{/if}}
{{if ! $zcard}}
{{if $profile.edit}}
{{if $editmenu.multi}}
<div class="dropdown">
<a class="profile-edit-side-link dropdown-toggle" data-toggle="dropdown" title="{{$profile.edit.3}}" href="#" ><i class="icon-pencil" title="{{$profile.edit.1}}" ></i></a>
<a class="profile-edit-side-link dropdown-toggle" data-toggle="dropdown" href="#" ><i class="icon-pencil" title="{{$editmenu.edit.1}}"></i></a>
<ul class="dropdown-menu" role="menu">
{{foreach $profile.menu.entries as $e}}
{{foreach $editmenu.menu.entries as $e}}
<li>
<a href="profiles/{{$e.id}}"><img class="dropdown-menu-img-xs" src='{{$e.photo}}'>{{$e.profile_name}}<div class='clear'></div></a>
<a href="profiles/{{$e.id}}"><img class="dropdown-menu-img-xs" src='{{$e.photo}}'>{{$e.profile_name}}</a>
</li>
{{/foreach}}
<li><a href="profile_photo" >{{$profile.menu.chg_photo}}</a></li>
{{if $profile.menu.cr_new}}<li><a href="profiles/new" id="profile-listing-new-link">{{$profile.menu.cr_new}}</a></li>{{/if}}
<li><a href="profile_photo" >{{$editmenu.menu.chg_photo}}</a></li>
{{if $editmenu.menu.cr_new}}<li><a href="profiles/new" id="profile-listing-new-link">{{$editmenu.menu.cr_new}}</a></li>{{/if}}
</ul>
</div>
{{else}}
<a class="profile-edit-side-link" href="{{$editmenu.edit.0}}" ><i class="icon-pencil" title="{{$editmenu.edit.1}}"></i></a>
{{/if}}
{{/if}}
@ -27,9 +29,6 @@
{{if $reddress}}<div class="reddress" oncopy="return false;">{{$profile.reddress}}</div>{{/if}}
{{/if}}
{{if $pdesc}}<div class="title">{{$profile.pdesc}}</div>{{/if}}
{{if $location}}
<dl class="location"><dt class="location-label">{{$location}}</dt>
<dd class="adr">
@ -45,7 +44,6 @@
{{/if}}
{{if $gender}}<dl class="mf"><dt class="gender-label">{{$gender}}</dt> <dd class="x-gender">{{$profile.gender}}</dd></dl>{{/if}}
{{if $marital}}<dl class="marital"><dt class="marital-label"><span class="heart">&hearts;</span>{{$marital}}</dt><dd class="marital-text">{{$profile.marital}}</dd></dl>{{/if}}