more permissions tweaking

This commit is contained in:
friendica 2015-02-10 21:21:18 -08:00
parent 583af02f71
commit e8bdf2b8d7
4 changed files with 21 additions and 7 deletions

View File

@ -136,30 +136,40 @@ class Item extends BaseObject {
$location = format_location($item); $location = format_location($item);
$isevent = false; $isevent = false;
$attend = null; $attend = null;
$canvote = false;
// process action responses - e.g. like/dislike/attend/agree/whatever // process action responses - e.g. like/dislike/attend/agree/whatever
$response_verbs = array('like'); $response_verbs = array('like');
if(feature_enabled($conv->get_profile_owner(),'dislike')) if(feature_enabled($conv->get_profile_owner(),'dislike'))
$response_verbs[] = 'dislike'; $response_verbs[] = 'dislike';
if($item['obj_type'] === ACTIVITY_OBJ_EVENT && $this->is_commentable()) { if($item['obj_type'] === ACTIVITY_OBJ_EVENT) {
$response_verbs[] = 'attendyes'; $response_verbs[] = 'attendyes';
$response_verbs[] = 'attendno'; $response_verbs[] = 'attendno';
$response_verbs[] = 'attendmaybe'; $response_verbs[] = 'attendmaybe';
$isevent = true; if($this->is_commentable()) {
$attend = array( t('I will attend'), t('I will not attend'), t('I might attend')); $isevent = true;
$attend = array( t('I will attend'), t('I will not attend'), t('I might attend'));
}
} }
$consensus = ((($item['item_flags'] & ITEM_CONSENSUS) && $this->is_commentable()) ? true : false); $consensus = (($item['item_flags'] & ITEM_CONSENSUS) ? true : false);
if($consensus) { if($consensus) {
$response_verbs[] = 'agree'; $response_verbs[] = 'agree';
$response_verbs[] = 'disagree'; $response_verbs[] = 'disagree';
$response_verbs[] = 'abstain'; $response_verbs[] = 'abstain';
$conlabels = array( t('I agree'), t('I disagree'), t('I abstain')); if($this->is_commentable()) {
$conlabels = array( t('I agree'), t('I disagree'), t('I abstain'));
$canvote = true;
}
} }
if(! feature_enabled($conv->get_profile_owner(),'dislike'))
unset($conv_responses['dislike']);
$responses = get_responses($conv_responses,$response_verbs,$this,$item); $responses = get_responses($conv_responses,$response_verbs,$this,$item);
$like_button_label = tt('Like','Likes',$like_count,'noun'); $like_button_label = tt('Like','Likes',$like_count,'noun');
$like_count = ((x($conv_responses['like'],$item['mid'])) ? $conv_responses['like'][$item['mid']] : ''); $like_count = ((x($conv_responses['like'],$item['mid'])) ? $conv_responses['like'][$item['mid']] : '');
@ -284,6 +294,7 @@ class Item extends BaseObject {
'attend' => $attend, 'attend' => $attend,
'consensus' => $consensus, 'consensus' => $consensus,
'conlabels' => $conlabels, 'conlabels' => $conlabels,
'canvote' => $canvote,
'linktitle' => sprintf( t('View %s\'s profile - %s'), $profile_name, $item['author']['xchan_addr']), 'linktitle' => sprintf( t('View %s\'s profile - %s'), $profile_name, $item['author']['xchan_addr']),
'olinktitle' => sprintf( t('View %s\'s profile - %s'), $this->get_owner_name(), $item['owner']['xchan_addr']), 'olinktitle' => sprintf( t('View %s\'s profile - %s'), $this->get_owner_name(), $item['owner']['xchan_addr']),
'llink' => $item['llink'], 'llink' => $item['llink'],

View File

@ -1038,6 +1038,7 @@ function builtin_activity_puller($item, &$conv_responses) {
$conv_responses[$mode][$item['thr_parent'] . '-l'][] = $url; $conv_responses[$mode][$item['thr_parent'] . '-l'][] = $url;
} }
} }
} }
// Format the like/dislike text for a profile item // Format the like/dislike text for a profile item
@ -1648,6 +1649,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
function get_responses($conv_responses,$response_verbs,$ob,$item) { function get_responses($conv_responses,$response_verbs,$ob,$item) {
$ret = array(); $ret = array();
foreach($response_verbs as $v) { foreach($response_verbs as $v) {
$ret[$v] = array(); $ret[$v] = array();
@ -1665,6 +1667,7 @@ function get_responses($conv_responses,$response_verbs,$ob,$item) {
$ret[$v]['title'] = $conv_responses[$v]['title']; $ret[$v]['title'] = $conv_responses[$v]['title'];
} }
$ret['count'] = count($ret); $ret['count'] = count($ret);
//logger('ret: ' . print_r($ret,true));
return $ret; return $ret;
} }

View File

@ -77,7 +77,7 @@
</button> </button>
{{/if}} {{/if}}
{{if $item.consensus}} {{if $item.canvote}}
<button type="button" title="{{$item.conlabels.0}}" class="btn btn-default btn-sm" onclick="dolike({{$item.id}},'agree'); return false;"> <button type="button" title="{{$item.conlabels.0}}" class="btn btn-default btn-sm" onclick="dolike({{$item.id}},'agree'); return false;">
<i class="icon-check" ></i> <i class="icon-check" ></i>
</button> </button>

View File

@ -78,7 +78,7 @@
</button> </button>
{{/if}} {{/if}}
{{if $item.consensus}} {{if $item.canvote}}
<button type="button" title="{{$item.conlabels.0}}" class="btn btn-default btn-sm" onclick="dolike({{$item.id}},'agree'); return false;"> <button type="button" title="{{$item.conlabels.0}}" class="btn btn-default btn-sm" onclick="dolike({{$item.id}},'agree'); return false;">
<i class="icon-check" ></i> <i class="icon-check" ></i>
</button> </button>