rest of the consensus porting work and integration into friendica
Credits to Mike Macgirvin for the code
This commit is contained in:
		
					parent
					
						
							
								0077494396
							
						
					
				
			
			
				commit
				
					
						f5c7006f30
					
				
			
		
					 10 changed files with 285 additions and 149 deletions
				
			
		|  | @ -491,7 +491,11 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { | ||||||
| 	$cmnt_tpl    = get_markup_template('comment_item.tpl'); | 	$cmnt_tpl    = get_markup_template('comment_item.tpl'); | ||||||
| 	$hide_comments_tpl = get_markup_template('hide_comments.tpl'); | 	$hide_comments_tpl = get_markup_template('hide_comments.tpl'); | ||||||
| 
 | 
 | ||||||
| 	$conv_responses = array(array('like'),array('dislike'),array('agree'),array('disagree'),array('abstain'),array('attendyes'),array('attendno'),array('attendmaybe')); | 	$conv_responses = array( | ||||||
|  | 		'like' => array('title' => t('Likes','title')),'dislike' => array('title' => t('Dislikes','title')), | ||||||
|  | 		'agree' => array('title' => t('Agree','title')),'disagree' => array('title' => t('Disagree','title')), 'abstain' => array('title' => t('Abstain','title')),  | ||||||
|  | 		'attendyes' => array('title' => t('Attending','title')), 'attendno' => array('title' => t('Not attending','title')), 'attendmaybe' => array('title' => t('Might attend','title')) | ||||||
|  | 	); | ||||||
| 
 | 
 | ||||||
| 	// array with html for each thread (parent+comments)
 | 	// array with html for each thread (parent+comments)
 | ||||||
| 	$threads = array(); | 	$threads = array(); | ||||||
|  | @ -740,19 +744,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 				// Can we put this after the visibility check?
 | 				// Can we put this after the visibility check?
 | ||||||
| 				like_puller($a, $item, $conv_responses, 'like'); | 				builtin_activity_puller($item, $conv_responses); | ||||||
| 				like_puller($a, $item, $conv_responses, 'dislike'); |  | ||||||
| 
 |  | ||||||
| //				if($item['object-type'] === ACTIVITY_OBJ_EVENT) {
 |  | ||||||
| 					like_puller($a, $item, $conv_responses, 'attendyes'); |  | ||||||
| 					like_puller($a, $item, $conv_responses, 'attendno'); |  | ||||||
| 					like_puller($a, $item, $conv_responses, 'attendmaybe'); |  | ||||||
| logger('responses: ' . print_r($conv_responses,true)); |  | ||||||
| 				 |  | ||||||
| 
 |  | ||||||
| 				like_puller($a, $item, $conv_responses, 'agree'); |  | ||||||
| 				like_puller($a, $item, $conv_responses, 'disagree'); |  | ||||||
| 				like_puller($a, $item, $conv_responses, 'abstain'); |  | ||||||
| 
 | 
 | ||||||
| 				// Only add what is visible
 | 				// Only add what is visible
 | ||||||
| 				if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) { | 				if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) { | ||||||
|  | @ -916,42 +908,44 @@ function item_photo_menu($item){ | ||||||
| 	return $o; | 	return $o; | ||||||
| }} | }} | ||||||
| 
 | 
 | ||||||
| if(! function_exists('like_puller')) { | /** | ||||||
| function like_puller($a,$item,&$arr,$mode) { |  * @brief Checks item to see if it is one of the builtin activities (like/dislike, event attendance, consensus items, etc.) | ||||||
| 
 |  * Increments the count of each matching activity and adds a link to the author as needed. | ||||||
|  |  * | ||||||
|  |  * @param array $a (not used) | ||||||
|  |  * @param array $item | ||||||
|  |  * @param array &$conv_responses (already created with builtin activity structure) | ||||||
|  |  * @return void | ||||||
|  |  */ | ||||||
|  | if(! function_exists(builtin_activity_puller)) { | ||||||
|  | function builtin_activity_puller($item, &$conv_responses) { | ||||||
|  | 	foreach($conv_responses as $mode => $v) { | ||||||
| 		$url = ''; | 		$url = ''; | ||||||
| 		$sparkle = ''; | 		$sparkle = ''; | ||||||
|  | 
 | ||||||
| 		switch($mode) { | 		switch($mode) { | ||||||
| 			case 'like': | 			case 'like': | ||||||
| 		case 'unlike': |  | ||||||
| 				$verb = ACTIVITY_LIKE; | 				$verb = ACTIVITY_LIKE; | ||||||
| 				break; | 				break; | ||||||
| 			case 'dislike': | 			case 'dislike': | ||||||
| 		case 'undislike': |  | ||||||
| 				$verb = ACTIVITY_DISLIKE; | 				$verb = ACTIVITY_DISLIKE; | ||||||
| 				break; | 				break; | ||||||
| 			case 'agree': | 			case 'agree': | ||||||
| 		case 'unagree': |  | ||||||
| 				$verb = ACTIVITY_AGREE; | 				$verb = ACTIVITY_AGREE; | ||||||
| 				break; | 				break; | ||||||
| 			case 'disagree': | 			case 'disagree': | ||||||
| 		case 'undisagree': |  | ||||||
| 				$verb = ACTIVITY_DISAGREE; | 				$verb = ACTIVITY_DISAGREE; | ||||||
| 				break; | 				break; | ||||||
| 			case 'abstain': | 			case 'abstain': | ||||||
| 		case 'unabstain': |  | ||||||
| 				$verb = ACTIVITY_ABSTAIN; | 				$verb = ACTIVITY_ABSTAIN; | ||||||
| 				break; | 				break; | ||||||
| 			case 'attendyes': | 			case 'attendyes': | ||||||
| 		case 'unattendyes': |  | ||||||
| 				$verb = ACTIVITY_ATTEND; | 				$verb = ACTIVITY_ATTEND; | ||||||
| 				break; | 				break; | ||||||
| 			case 'attendno': | 			case 'attendno': | ||||||
| 		case 'unattendno': |  | ||||||
| 				$verb = ACTIVITY_ATTENDNO; | 				$verb = ACTIVITY_ATTENDNO; | ||||||
| 				break; | 				break; | ||||||
| 			case 'attendmaybe': | 			case 'attendmaybe': | ||||||
| 		case 'unattendmaybe': |  | ||||||
| 				$verb = ACTIVITY_ATTENDMAYBE; | 				$verb = ACTIVITY_ATTENDMAYBE; | ||||||
| 				break; | 				break; | ||||||
| 			default: | 			default: | ||||||
|  | @ -959,64 +953,57 @@ function like_puller($a,$item,&$arr,$mode) { | ||||||
| 				break; | 				break; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| logger('verb: ' . $verb); | 		if((activity_match($item['verb'], $verb)) && ($item['id'] != $item['parent'])) { | ||||||
| if($verb === ACTIVITY_ATTENDNO) |  | ||||||
| 	logger('item: ' . $item['verb']); |  | ||||||
| 
 |  | ||||||
| 	if((activity_match($item['verb'],$verb)) && ($item['id'] != $item['parent'])) { |  | ||||||
| logger('match:' . $verb); |  | ||||||
| 			$url = $item['author-link']; | 			$url = $item['author-link']; | ||||||
| 			if((local_user()) && (local_user() == $item['uid']) && ($item['network'] === NETWORK_DFRN) && (! $item['self']) && (link_compare($item['author-link'],$item['url']))) { | 			if((local_user()) && (local_user() == $item['uid']) && ($item['network'] === NETWORK_DFRN) && (! $item['self']) && (link_compare($item['author-link'],$item['url']))) { | ||||||
| 			$url = $a->get_baseurl(true) . '/redir/' . $item['contact-id']; | 				$url = z_root(true) . '/redir/' . $item['contact-id']; | ||||||
| 				$sparkle = ' class="sparkle" '; | 				$sparkle = ' class="sparkle" '; | ||||||
| 			} | 			} | ||||||
| 			else  | 			else  | ||||||
| 				$url = zrl($url); | 				$url = zrl($url); | ||||||
| 			 | 			 | ||||||
|  | 			$url = '<a href="'. $url . '"'. $sparkle .'>' . $item['author-name'] . '</a>'; | ||||||
|  | 
 | ||||||
| 			if(! $item['thr-parent']) | 			if(! $item['thr-parent']) | ||||||
| 				$item['thr-parent'] = $item['parent-uri']; | 				$item['thr-parent'] = $item['parent-uri']; | ||||||
| 
 | 
 | ||||||
| 		if(! ((isset($arr[$mode][$item['thr-parent'] . '-l'])) && (is_array($arr[$mode][$item['thr-parent'] . '-l'])))) | 			if(! ((isset($conv_responses[$mode][$item['thr-parent'] . '-l']))  | ||||||
| 			$arr[$mode][$item['thr-parent'] . '-l'] = array(); | 				&& (is_array($conv_responses[$mode][$item['thr-parent'] . '-l'])))) | ||||||
| 		if(! isset($arr[$mode][$item['thr-parent']])) | 				$conv_responses[$mode][$item['thr-parent'] . '-l'] = array(); | ||||||
| 			$arr[$mode][$item['thr-parent']] = 1; |  | ||||||
| 		else |  | ||||||
| 			$arr[$mode][$item['thr-parent']] ++; |  | ||||||
| 
 | 
 | ||||||
| 		$arr[$mode][$item['thr-parent'] . '-l'][] = '<a href="'. $url . '"'. $sparkle .'>' . $item['author-name'] . '</a>'; | 			// only list each unique author once
 | ||||||
| 	} | 			if(in_array($url,$conv_responses[$mode][$item['thr-parent'] . '-l'])) | ||||||
|  | 				continue; | ||||||
|  | 
 | ||||||
|  | 			if(! isset($conv_responses[$mode][$item['thr-parent']])) | ||||||
|  | 				$conv_responses[$mode][$item['thr-parent']] = 1; | ||||||
|  | 			else | ||||||
|  | 				$conv_responses[$mode][$item['thr-parent']] ++; | ||||||
|  | 
 | ||||||
|  | 			$conv_responses[$mode][$item['thr-parent'] . '-l'][] = $url; | ||||||
|  | 
 | ||||||
|  | 			// there can only be one activity verb per item so if we found anything, we can stop looking
 | ||||||
| 			return; | 			return; | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
| }} | }} | ||||||
| 
 | 
 | ||||||
| // Format the like/dislike text for a profile item
 | // Format the vote text for a profile item
 | ||||||
| // $cnt = number of people who like/dislike the item
 | // $cnt = number of people who vote the item
 | ||||||
| // $arr = array of pre-linked names of likers/dislikers
 | // $arr = array of pre-linked names of likers/dislikers
 | ||||||
| // $type = one of 'like, 'dislike'
 | // $type = one of 'like, 'dislike', 'attendyes', 'attendno', 'attendmaybe', 'agree', 'disagree', 'abstain'
 | ||||||
| // $id  = item id
 | // $id  = item id
 | ||||||
| // returns formatted text
 | // returns formatted text
 | ||||||
| 
 | 
 | ||||||
| if(! function_exists('format_like')) { | if(! function_exists('format_like')) { | ||||||
| function format_like($cnt,$arr,$type,$id) { | function format_like($cnt,$arr,$type,$id) { | ||||||
| 	$o = ''; | 	$o = ''; | ||||||
| 	if($cnt == 1) | 	$expanded = ''; | ||||||
| 		$o .= (($type === 'like') ? sprintf( t('%s likes this.'), $arr[0]) : sprintf( t('%s doesn\'t like this.'), $arr[0])) . EOL ; |  | ||||||
| 	else { |  | ||||||
| 		$spanatts = "class=\"fakelink\" onclick=\"openClose('{$type}list-$id');\""; |  | ||||||
| 		switch($type) { |  | ||||||
| 			case 'like': |  | ||||||
| 				$phrase = sprintf( t('<span  %1$s>%2$d people</span> like this'), $spanatts, $cnt); |  | ||||||
| 				break; |  | ||||||
| 			case 'dislike': |  | ||||||
| 				$phrase = sprintf( t('<span  %1$s>%2$d people</span> don\'t like this'), $spanatts, $cnt); |  | ||||||
| 				break; |  | ||||||
| 		} |  | ||||||
| 		$phrase .= EOL ; |  | ||||||
| 		$o .= replace_macros(get_markup_template('voting_fakelink.tpl'), array( |  | ||||||
| 			'$phrase' => $phrase, |  | ||||||
| 			'$type' => $type, |  | ||||||
| 			'$id' => $id |  | ||||||
| 		)); |  | ||||||
| 
 | 
 | ||||||
|  | 	if($cnt == 1) | ||||||
|  | 		$likers = $arr[0]; | ||||||
|  | 
 | ||||||
|  | 	else { | ||||||
| 		$total = count($arr); | 		$total = count($arr); | ||||||
| 		if($total >= MAX_LIKERS) | 		if($total >= MAX_LIKERS) | ||||||
| 			$arr = array_slice($arr, 0, MAX_LIKERS - 1); | 			$arr = array_slice($arr, 0, MAX_LIKERS - 1); | ||||||
|  | @ -1029,9 +1016,76 @@ function format_like($cnt,$arr,$type,$id) { | ||||||
| 			$str = implode(', ', $arr); | 			$str = implode(', ', $arr); | ||||||
| 			$str .= sprintf( t(', and %d other people'), $total - MAX_LIKERS ); | 			$str .= sprintf( t(', and %d other people'), $total - MAX_LIKERS ); | ||||||
| 		} | 		} | ||||||
| 		$str = (($type === 'like') ? sprintf( t('%s like this.'), $str) : sprintf( t('%s don\'t like this.'), $str)); | 
 | ||||||
| 		$o .= "\t" . '<div class="wall-item-' . $type . '-expanded" id="' . $type . 'list-' . $id . '" style="display: none;" >' . $str . '</div>'; | 		$likers = $str; | ||||||
| 	} | 	} | ||||||
|  | 
 | ||||||
|  | 	// Phrase if there is only one liker. In other cases it will be uses for the expanded
 | ||||||
|  | 	// list which show all likers
 | ||||||
|  | 	switch($type) { | ||||||
|  | 		case 'like' : | ||||||
|  | 			$phrase = sprintf( t('%s likes this.'), $likers); | ||||||
|  | 			break; | ||||||
|  | 		case 'dislike' : | ||||||
|  | 			$phrase = sprintf( t('%s doesn\'t like this.'), $likers); | ||||||
|  | 			break; | ||||||
|  | 		case 'attendyes' : | ||||||
|  | 			$phrase = sprintf( t('%s attends.'), $likers); | ||||||
|  | 			break; | ||||||
|  | 		case 'attendno' : | ||||||
|  | 			$phrase = sprintf( t('%s doesn\'t attend.'), $likers); | ||||||
|  | 			break; | ||||||
|  | 		case 'attendmaybe' : | ||||||
|  | 			$phrase = sprintf( t('%s attends maybe.'), $likers); | ||||||
|  | 			break; | ||||||
|  | 		case 'agree' : | ||||||
|  | 			$phrase = sprintf( t('%s agrees.'), $likers); | ||||||
|  | 			break; | ||||||
|  | 		case 'disagree' : | ||||||
|  | 			$phrase = sprintf( t('%s doesn\'t agree.'), $likers); | ||||||
|  | 			break; | ||||||
|  | 		case 'abstain' : | ||||||
|  | 			$phrase = sprintf( t('%s abstains.'), $likers); | ||||||
|  | 			break; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	if($cnt > 1) { | ||||||
|  | 		$spanatts = "class=\"fakelink\" onclick=\"openClose('{$type}list-$id');\""; | ||||||
|  | 		$expanded .= "\t" . '<div class="wall-item-' . $type . '-expanded" id="' . $type . 'list-' . $id . '" style="display: none;" >' . $phrase . EOL . '</div>'; | ||||||
|  | 		switch($type) { | ||||||
|  | 			case 'like': | ||||||
|  | 				$phrase = sprintf( t('<span  %1$s>%2$d people</span> like this'), $spanatts, $cnt); | ||||||
|  | 				break; | ||||||
|  | 			case 'dislike': | ||||||
|  | 				$phrase = sprintf( t('<span  %1$s>%2$d people</span> don\'t like this'), $spanatts, $cnt); | ||||||
|  | 				break; | ||||||
|  | 			case 'attendyes': | ||||||
|  | 				$phrase = sprintf( t('<span  %1$s>%2$d people</span> attend'), $spanatts, $cnt); | ||||||
|  | 				break; | ||||||
|  | 			case 'attendno': | ||||||
|  | 				$phrase = sprintf( t('<span  %1$s>%2$d people</span> don\'t attend'), $spanatts, $cnt); | ||||||
|  | 				break; | ||||||
|  | 			case 'attendmaybe': | ||||||
|  | 				$phrase = sprintf( t('<span  %1$s>%2$d people</span> anttend maybe'), $spanatts, $cnt); | ||||||
|  | 			case 'agree': | ||||||
|  | 				$phrase = sprintf( t('<span  %1$s>%2$d people</span> agree'), $spanatts, $cnt); | ||||||
|  | 				break; | ||||||
|  | 			case 'disagree': | ||||||
|  | 				$phrase = sprintf( t('<span  %1$s>%2$d people</span> don\'t agree'), $spanatts, $cnt); | ||||||
|  | 				break; | ||||||
|  | 			case 'abstain': | ||||||
|  | 				$phrase = sprintf( t('<span  %1$s>%2$d people</span> abstains'), $spanatts, $cnt); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	$phrase .= EOL ; | ||||||
|  | 	$o .= replace_macros(get_markup_template('voting_fakelink.tpl'), array( | ||||||
|  | 		'$phrase' => $phrase, | ||||||
|  | 		'$type' => $type, | ||||||
|  | 		'$id' => $id | ||||||
|  | 	)); | ||||||
|  | 	$o .= $expanded; | ||||||
|  | 
 | ||||||
| 	return $o; | 	return $o; | ||||||
| }} | }} | ||||||
| 
 | 
 | ||||||
|  | @ -1049,6 +1103,8 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) { | ||||||
| 	if( local_user() && feature_enabled(local_user(),'richtext') ) | 	if( local_user() && feature_enabled(local_user(),'richtext') ) | ||||||
| 		$plaintext = false; | 		$plaintext = false; | ||||||
| 
 | 
 | ||||||
|  | 	$voting = feature_enabled(local_user(),'consensus_tools'); | ||||||
|  | 
 | ||||||
| 	$tpl = get_markup_template('jot-header.tpl'); | 	$tpl = get_markup_template('jot-header.tpl'); | ||||||
| 	$a->page['htmlhead'] .= replace_macros($tpl, array( | 	$a->page['htmlhead'] .= replace_macros($tpl, array( | ||||||
| 		'$newpost' => 'true', | 		'$newpost' => 'true', | ||||||
|  | @ -1126,6 +1182,9 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) { | ||||||
| 		'$shortsetloc' => t('set location'), | 		'$shortsetloc' => t('set location'), | ||||||
| 		'$noloc' => t('Clear browser location'), | 		'$noloc' => t('Clear browser location'), | ||||||
| 		'$shortnoloc' => t('clear location'), | 		'$shortnoloc' => t('clear location'), | ||||||
|  | 		'$voting' => t('Toggle voting'), | ||||||
|  | 		'$feature_voting' => $voting, | ||||||
|  | 		'$consensus' => 0, | ||||||
| 		'$title' => $x['title'], | 		'$title' => $x['title'], | ||||||
| 		'$placeholdertitle' => t('Set title'), | 		'$placeholdertitle' => t('Set title'), | ||||||
| 		'$category' => $x['category'], | 		'$category' => $x['category'], | ||||||
|  | @ -1311,10 +1370,19 @@ function get_responses($conv_responses,$response_verbs,$ob,$item) { | ||||||
| 			$ret[$v]['list_part'] = ''; | 			$ret[$v]['list_part'] = ''; | ||||||
| 		} | 		} | ||||||
| 		$ret[$v]['button'] = get_response_button_text($v,$ret[$v]['count']); | 		$ret[$v]['button'] = get_response_button_text($v,$ret[$v]['count']); | ||||||
|  | 		$ret[$v]['title'] = $conv_responses[$v]['title']; | ||||||
| 	} | 	} | ||||||
| 	$ret['count'] = count($ret); | 
 | ||||||
|  | 	$count = 0; | ||||||
|  | 	foreach($ret as $key) { | ||||||
|  | 		if ($key['count'] == true) | ||||||
|  | 			$count++; | ||||||
|  | 	} | ||||||
|  | 	$ret['count'] = $count; | ||||||
|  | 
 | ||||||
| 	return $ret; | 	return $ret; | ||||||
| } | } | ||||||
|  | 
 | ||||||
| function get_response_button_text($v,$count) { | function get_response_button_text($v,$count) { | ||||||
| 	switch($v) { | 	switch($v) { | ||||||
| 		case 'like': | 		case 'like': | ||||||
|  | @ -1335,7 +1403,7 @@ function get_response_button_text($v,$count) { | ||||||
| 		case 'agree': | 		case 'agree': | ||||||
| 			return tt('Agree','Agrees',$count,'noun'); | 			return tt('Agree','Agrees',$count,'noun'); | ||||||
| 			break; | 			break; | ||||||
| 		case 'agree': | 		case 'disagree': | ||||||
| 			return tt('Disagree','Disagrees',$count,'noun'); | 			return tt('Disagree','Disagrees',$count,'noun'); | ||||||
| 			break; | 			break; | ||||||
| 		case 'abstain': | 		case 'abstain': | ||||||
|  |  | ||||||
|  | @ -31,6 +31,7 @@ function get_features() { | ||||||
| 			array('richtext',       t('Richtext Editor'),			t('Enable richtext editor')), | 			array('richtext',       t('Richtext Editor'),			t('Enable richtext editor')), | ||||||
| 			array('preview',        t('Post Preview'),			t('Allow previewing posts and comments before publishing them')), | 			array('preview',        t('Post Preview'),			t('Allow previewing posts and comments before publishing them')), | ||||||
| 			array('aclautomention',	t('Auto-mention Forums'),		t('Add/remove mention when a fourm page is selected/deselected in ACL window.')), | 			array('aclautomention',	t('Auto-mention Forums'),		t('Add/remove mention when a fourm page is selected/deselected in ACL window.')), | ||||||
|  | 			array('consensus_tools', t('Enable voting tools'),		t('Provide a class of post which others can vote on'),false), | ||||||
| 		), | 		), | ||||||
| 
 | 
 | ||||||
| 		// Network sidebar widgets
 | 		// Network sidebar widgets
 | ||||||
|  |  | ||||||
|  | @ -102,6 +102,7 @@ function editpost_content(&$a) { | ||||||
| 	 | 	 | ||||||
| 	//$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
 | 	//$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
 | ||||||
| 
 | 
 | ||||||
|  | 	$voting = feature_enabled(local_user(),'consensus_tools'); | ||||||
| 
 | 
 | ||||||
| 	$o .= replace_macros($tpl,array( | 	$o .= replace_macros($tpl,array( | ||||||
| 		'$return_path' => $_SESSION['return_url'], | 		'$return_path' => $_SESSION['return_url'], | ||||||
|  | @ -121,6 +122,11 @@ function editpost_content(&$a) { | ||||||
| 		'$shortsetloc' => t('set location'), | 		'$shortsetloc' => t('set location'), | ||||||
| 		'$noloc' => t('Clear browser location'), | 		'$noloc' => t('Clear browser location'), | ||||||
| 		'$shortnoloc' => t('clear location'), | 		'$shortnoloc' => t('clear location'), | ||||||
|  | 		'$voting' => t('Toggle voting'), | ||||||
|  | 		'$feature_voting' => $voting, | ||||||
|  | 
 | ||||||
|  | 		// we need a solution for the red flags to make consensus work
 | ||||||
|  | 		'$consensus' => (($itm[0]['item_flags'] & ITEM_CONSENSUS) ? 1 : 0), | ||||||
| 		'$wait' => t('Please wait'), | 		'$wait' => t('Please wait'), | ||||||
| 		'$permset' => t('Permission settings'), | 		'$permset' => t('Permission settings'), | ||||||
| 		'$ptyp' => $itm[0]['type'], | 		'$ptyp' => $itm[0]['type'], | ||||||
|  |  | ||||||
							
								
								
									
										10
									
								
								mod/item.php
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								mod/item.php
									
										
									
									
									
								
							|  | @ -51,6 +51,7 @@ function item_post(&$a) { | ||||||
| 	$message_id = ((x($_REQUEST,'message_id') && $api_source)  ? strip_tags($_REQUEST['message_id'])       : ''); | 	$message_id = ((x($_REQUEST,'message_id') && $api_source)  ? strip_tags($_REQUEST['message_id'])       : ''); | ||||||
| 
 | 
 | ||||||
| 	$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : ''); | 	$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : ''); | ||||||
|  | 	$consensus = intval($_REQUEST['consensus']); | ||||||
| 	$preview = ((x($_REQUEST,'preview')) ? intval($_REQUEST['preview']) : 0); | 	$preview = ((x($_REQUEST,'preview')) ? intval($_REQUEST['preview']) : 0); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -655,6 +656,15 @@ function item_post(&$a) { | ||||||
| 	if(!$thr_parent) | 	if(!$thr_parent) | ||||||
| 		$thr_parent = $uri; | 		$thr_parent = $uri; | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | 	/* * | ||||||
|  | 	 * to make consensus work, red requests the consensus flag from boot.php | ||||||
|  | 	 * this have to be inserted into the lower $datarray | ||||||
|  | 	 *  | ||||||
|  | 	 *	if($consensus) | ||||||
|  | 	 *		$item_flags |= ITEM_CONSENSUS; | ||||||
|  | 	 */ | ||||||
|  | 
 | ||||||
| 	$datarray = array(); | 	$datarray = array(); | ||||||
| 	$datarray['uid']           = $profile_uid; | 	$datarray['uid']           = $profile_uid; | ||||||
| 	$datarray['type']          = $post_type; | 	$datarray['type']          = $post_type; | ||||||
|  |  | ||||||
							
								
								
									
										14
									
								
								mod/like.php
									
										
									
									
									
								
							
							
						
						
									
										14
									
								
								mod/like.php
									
										
									
									
									
								
							|  | @ -132,11 +132,21 @@ function like_content(&$a) { | ||||||
| 	// See if we've been passed a return path to redirect to
 | 	// See if we've been passed a return path to redirect to
 | ||||||
| 	$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : ''); | 	$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : ''); | ||||||
| 
 | 
 | ||||||
|  | 	$verbs = " '".dbesc($activity)."' "; | ||||||
| 
 | 
 | ||||||
| 	$r = q("SELECT `id`, `guid` FROM `item` WHERE `verb` = '%s' AND `deleted` = 0
 | 	// event participation and consensus items are essentially radio toggles. If you make a subsequent choice,
 | ||||||
|  | 	// we need to eradicate your first choice. 
 | ||||||
|  | 	if($activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE) { | ||||||
|  | 		$verbs = " '" . dbesc(ACTIVITY_ATTEND) . "','" . dbesc(ACTIVITY_ATTENDNO) . "','" . dbesc(ACTIVITY_ATTENDMAYBE) . "' "; | ||||||
|  | 	} | ||||||
|  | 	if($activity === ACTIVITY_AGREE || $activity === ACTIVITY_DISAGREE || $activity === ACTIVITY_ABSTAIN) { | ||||||
|  | 		$verbs = " '" . dbesc(ACTIVITY_AGREE) . "','" . dbesc(ACTIVITY_DISAGREE) . "','" . dbesc(ACTIVITY_ABSTAIN) . "' "; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	$r = q("SELECT `id`, `guid` FROM `item` WHERE `verb` IN ( $verbs ) AND `deleted` = 0
 | ||||||
| 		AND `contact-id` = %d AND `uid` = %d | 		AND `contact-id` = %d AND `uid` = %d | ||||||
| 		AND (`parent` = '%s' OR `parent-uri` = '%s' OR `thr-parent` = '%s') LIMIT 1",
 | 		AND (`parent` = '%s' OR `parent-uri` = '%s' OR `thr-parent` = '%s') LIMIT 1",
 | ||||||
| 		dbesc($activity), intval($contact['id']), intval($owner_uid), | 		intval($contact['id']), intval($owner_uid), | ||||||
| 		dbesc($item_id), dbesc($item_id), dbesc($item['uri']) | 		dbesc($item_id), dbesc($item_id), dbesc($item['uri']) | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -175,7 +175,6 @@ class Item extends BaseObject { | ||||||
| 			} | 			} | ||||||
| 		}*/ | 		}*/ | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 		// 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'); | ||||||
| 			$response_verbs[] = 'dislike'; | 			$response_verbs[] = 'dislike'; | ||||||
|  | @ -183,43 +182,33 @@ class Item extends BaseObject { | ||||||
| 			$response_verbs[] = 'attendyes'; | 			$response_verbs[] = 'attendyes'; | ||||||
| 			$response_verbs[] = 'attendno'; | 			$response_verbs[] = 'attendno'; | ||||||
| 			$response_verbs[] = 'attendmaybe'; | 			$response_verbs[] = 'attendmaybe'; | ||||||
|  | 			if($conv->is_writable()) { | ||||||
| 				$isevent = true; | 				$isevent = true; | ||||||
| 				$attend = array( t('I will attend'), t('I will not attend'), t('I might attend')); | 				$attend = array( t('I will attend'), t('I will not attend'), t('I might attend')); | ||||||
| 			} | 			} | ||||||
| 		$consensus = (($item['item_flags'] & ITEM_CONSENSUS)? true : false); | 		} | ||||||
|  | 
 | ||||||
|  | 		// red part for consensus
 | ||||||
|  | 		// we need a solution in friendica for missing item_flags
 | ||||||
|  | 		// to test $consensus with friendica set $consensus = true
 | ||||||
|  | 		// $consensus = (($item['item_flags'] & ITEM_CONSENSUS)? true : false);
 | ||||||
|  | 		$consensus = false; | ||||||
|  | 
 | ||||||
| 		if($consensus) { | 		if($consensus) { | ||||||
| 			$response_verbs[] = 'agree'; | 			$response_verbs[] = 'agree'; | ||||||
| 			$response_verbs[] = 'disagree'; | 			$response_verbs[] = 'disagree'; | ||||||
| 			$response_verbs[] = 'abstain'; | 			$response_verbs[] = 'abstain'; | ||||||
|  | 			if($conv->is_writable()) { | ||||||
|  | 				$conlabels  = array( t('I agree'), t('I disagree'), t('I abstain')); | ||||||
|  | 				$canvote    = true; | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
| 		$responses = get_responses($conv_responses,$response_verbs,$this,$item); | 		$responses = get_responses($conv_responses,$response_verbs,$this,$item); | ||||||
| 
 | 
 | ||||||
| 		// like_button_label from red -> needs to be removed
 | 		foreach ($response_verbs as $value=>$verbs) { | ||||||
| 		//$like_button_label = tt('Like','Likes',$like_count,'noun');
 | 			$responses[$verbs][output]  = ((x($conv_responses[$verbs],$item['uri'])) ? format_like($conv_responses[$verbs][$item['uri']],$conv_responses[$verbs][$item['uri'] . '-l'],$verbs,$item['uri']) : ''); | ||||||
| 
 | 
 | ||||||
| 		// another part from red - it is here for compatility - maybe removed later
 |  | ||||||
| 		$like_count = ((x($conv_responses['like'],$item['uri'])) ? $conv_responses['like'][$item['uri']] : ''); |  | ||||||
| 		$like_list = ((x($conv_responses['like'],$item['uri'])) ? $conv_responses['like'][$item['uri'] . '-l'] : ''); |  | ||||||
| 		if (count($like_list) > MAX_LIKERS) { |  | ||||||
| 			$like_list_part = array_slice($like_list, 0, MAX_LIKERS); |  | ||||||
| 			array_push($like_list_part, '<a href="#" data-toggle="modal" data-target="#likeModal-' . $this->get_id() . '"><b>' . t('View all') . '</b></a>'); |  | ||||||
| 		} else { |  | ||||||
| 			$like_list_part = ''; |  | ||||||
| 		} | 		} | ||||||
| 		$like_button_label = tt('Like','Likes',$like_count,'noun'); |  | ||||||
| 		$dislike_count = ((x($conv_responses['dislike'],$item['uri'])) ? $conv_responses['dislike'][$item['uri']] : ''); |  | ||||||
| 		$dislike_list = ((x($conv_responses['dislike'],$item['uri'])) ? $conv_responses['dislike'][$item['uri'] . '-l'] : ''); |  | ||||||
| 		$dislike_button_label = tt('Dislike','Dislikes',$dislike_count,'noun'); |  | ||||||
| 		if (count($dislike_list) > MAX_LIKERS) { |  | ||||||
| 			$dislike_list_part = array_slice($dislike_list, 0, MAX_LIKERS); |  | ||||||
| 			array_push($dislike_list_part, '<a href="#" data-toggle="modal" data-target="#dislikeModal-' . $this->get_id() . '"><b>' . t('View all') . '</b></a>'); |  | ||||||
| 		} else { |  | ||||||
| 			$dislike_list_part = ''; |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		$like    = ((x($conv_responses['like'],$item['uri'])) ? format_like($conv_responses['like'][$item['uri']],$conv_responses['like'][$item['uri'] . '-l'],'like',$item['uri']) : ''); |  | ||||||
|     		$dislike = ((x($conv_responses['dislike'],$item['uri'])) ? format_like($conv_responses['dislike'][$item['uri']],$conv_responses['dislike'][$item['uri'] . '-l'],'dislike',$item['uri']) : ''); |  | ||||||
| 		$like    = ((x($conv_responses['like'],$item['uri'])) ? format_like($conv_responses['like'][$item['uri']],$conv_responses['like'][$item['uri'] . '-l'],'like',$item['uri']) : ''); |  | ||||||
| 
 | 
 | ||||||
| 		/* | 		/* | ||||||
| 		 * We should avoid doing this all the time, but it depends on the conversation mode | 		 * We should avoid doing this all the time, but it depends on the conversation mode | ||||||
|  | @ -332,7 +321,7 @@ class Item extends BaseObject { | ||||||
| 
 | 
 | ||||||
| 		// Disable features that aren't available in several networks
 | 		// Disable features that aren't available in several networks
 | ||||||
| 		if (($item["item_network"] != NETWORK_DFRN) AND isset($buttons["dislike"])) { | 		if (($item["item_network"] != NETWORK_DFRN) AND isset($buttons["dislike"])) { | ||||||
| 			unset($buttons["dislike"]); | 			unset($buttons["dislike"],$isevent,$consensus); | ||||||
| 			$tagger = ''; | 			$tagger = ''; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | @ -370,6 +359,9 @@ class Item extends BaseObject { | ||||||
| 			'guid' => $item['guid'], | 			'guid' => $item['guid'], | ||||||
| 			'isevent' => $isevent, | 			'isevent' => $isevent, | ||||||
| 			'attend' => $attend, | 			'attend' => $attend, | ||||||
|  | 			'consensus' => $consensus, | ||||||
|  | 			'conlabels' => $conlabels, | ||||||
|  | 			'canvote'   => $canvote, | ||||||
| 			'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])), | 			'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])), | ||||||
| 			'olinktitle' => sprintf( t('View %s\'s profile @ %s'), $this->get_owner_name(), ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])), | 			'olinktitle' => sprintf( t('View %s\'s profile @ %s'), $this->get_owner_name(), ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])), | ||||||
| 			'to' => t('to'), | 			'to' => t('to'), | ||||||
|  | @ -403,8 +395,8 @@ class Item extends BaseObject { | ||||||
| 			'filer'     => ((feature_enabled($conv->get_profile_owner(),'filing')) ? $filer : ''), | 			'filer'     => ((feature_enabled($conv->get_profile_owner(),'filing')) ? $filer : ''), | ||||||
| 			'drop' => $drop, | 			'drop' => $drop, | ||||||
| 			'vote' => $buttons, | 			'vote' => $buttons, | ||||||
| 			'like' => $like, | 			'like' => $responses['like']['output'], | ||||||
|                         'dislike'   => $dislike, | 			'dislike'   => $responses['dislike']['output'], | ||||||
| 			'responses' => $responses, | 			'responses' => $responses, | ||||||
| 			'switchcomment' => t('Comment'), | 			'switchcomment' => t('Comment'), | ||||||
| 			'comment' => $this->get_comment_box($indent), | 			'comment' => $this->get_comment_box($indent), | ||||||
|  |  | ||||||
|  | @ -333,6 +333,17 @@ function enableOnUser(){ | ||||||
| 
 | 
 | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	function toggleVoting() { | ||||||
|  | 		if($('#jot-consensus').val() > 0) { | ||||||
|  | 			$('#jot-consensus').val(0); | ||||||
|  | 			$('#profile-voting').removeClass('icon-check').addClass('icon-check-empty'); | ||||||
|  | 		} | ||||||
|  | 		else { | ||||||
|  | 			$('#jot-consensus').val(1); | ||||||
|  | 			$('#profile-voting').removeClass('icon-check-empty').addClass('icon-check'); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	function jotClearLocation() { | 	function jotClearLocation() { | ||||||
| 		$('#jot-coord').val(''); | 		$('#jot-coord').val(''); | ||||||
| 		$('#profile-nolocation-wrapper').hide(); | 		$('#profile-nolocation-wrapper').hide(); | ||||||
|  |  | ||||||
|  | @ -54,6 +54,12 @@ | ||||||
| 		<a id="profile-nolocation" class="icon noglobe" title="{{$noloc|escape:'html'}}" onclick="jotClearLocation();return false;"></a> | 		<a id="profile-nolocation" class="icon noglobe" title="{{$noloc|escape:'html'}}" onclick="jotClearLocation();return false;"></a> | ||||||
| 	</div>  | 	</div>  | ||||||
| 
 | 
 | ||||||
|  | 	{{if $feature_voting}} | ||||||
|  | 		<div id="profile-voting-wrapper" style="display: {{$visitor}};" > | ||||||
|  | 			<a id="profile-voting" class="icon icon-check-empty" title="{{$voting|escape:'html'}}" onclick="toggleVoting();return false;"></a> | ||||||
|  | 		</div> | ||||||
|  | 	{{/if}} | ||||||
|  | 
 | ||||||
| 	<div id="profile-jot-perms" class="profile-jot-perms" style="display: {{$pvisit}};" > | 	<div id="profile-jot-perms" class="profile-jot-perms" style="display: {{$pvisit}};" > | ||||||
| 		<a href="#profile-jot-acl-wrapper" id="jot-perms-icon" class="icon {{$lockstate}}"  title="{{$permset|escape:'html'}}" ></a>{{$bang}} | 		<a href="#profile-jot-acl-wrapper" id="jot-perms-icon" class="icon {{$lockstate}}"  title="{{$permset|escape:'html'}}" ></a>{{$bang}} | ||||||
| 	</div> | 	</div> | ||||||
|  |  | ||||||
|  | @ -1347,11 +1347,15 @@ section.minimal { | ||||||
|   width: 100%; |   width: 100%; | ||||||
|   margin-bottom: 0.3em; |   margin-bottom: 0.3em; | ||||||
| } | } | ||||||
| .wall-item-container .wall-item-actions-social { | .wall-item-container .wall-item-actions-social,  | ||||||
|  | .wall-item-container .wall-item-actions-isevent, | ||||||
|  | .wall-item-container .wall-item-actions-canvote { | ||||||
|   float: left; |   float: left; | ||||||
|   margin-bottom: 1px; |   margin-bottom: 1px; | ||||||
| } | } | ||||||
| .wall-item-container .wall-item-actions-social a { | .wall-item-container .wall-item-actions-social a,  | ||||||
|  | .wall-item-container .wall-item-actions-isevent a,  | ||||||
|  | .wall-item-container .wall-item-actions-canvote a{ | ||||||
|   float: left; |   float: left; | ||||||
|   margin-right: 1em; |   margin-right: 1em; | ||||||
|   cursor: pointer; |   cursor: pointer; | ||||||
|  | @ -1863,6 +1867,11 @@ section.minimal { | ||||||
|   margin-left: 15px; |   margin-left: 15px; | ||||||
|   cursor: pointer; |   cursor: pointer; | ||||||
| } | } | ||||||
|  | #profile-voting-wrapper { | ||||||
|  |   float: left; | ||||||
|  |   margin-left: 15px; | ||||||
|  |   cursor: pointer; | ||||||
|  | } | ||||||
| #profile-smiley-wrapper { | #profile-smiley-wrapper { | ||||||
|   float: left; |   float: left; | ||||||
|   margin-left: 15px; |   margin-left: 15px; | ||||||
|  |  | ||||||
|  | @ -118,7 +118,26 @@ | ||||||
|                                 <a role="button" id="filer-{{$item.id}}" onclick="itemFiler({{$item.id}}); return false;" class="filer-item filer-icon" title="{{$item.filer}}"><i class="icon-folder-close icon-large"><span class="sr-only">{{$item.filer}}</span></i></a> |                                 <a role="button" id="filer-{{$item.id}}" onclick="itemFiler({{$item.id}}); return false;" class="filer-item filer-icon" title="{{$item.filer}}"><i class="icon-folder-close icon-large"><span class="sr-only">{{$item.filer}}</span></i></a> | ||||||
| 			{{/if}} | 			{{/if}} | ||||||
| 			</div> | 			</div> | ||||||
|  | 
 | ||||||
| 			<div class="wall-item-location">{{$item.location}} {{$item.postopts}}</div> | 			<div class="wall-item-location">{{$item.location}} {{$item.postopts}}</div> | ||||||
|  | 
 | ||||||
|  | 			{{if $item.isevent}} | ||||||
|  | 			<div class="clear"></div> | ||||||
|  | 			<div class="wall-item-actions-isevent"> | ||||||
|  | 				<a href="#" id="attendyes-{{$item.id}}" title="{{$item.attend.0}}" onclick="dolike({{$item.id}},'attendyes'); return false;"><i class="icon-ok icon-large"></i></a> | ||||||
|  | 				<a href="#" id="attendno-{{$item.id}}" title="{{$item.attend.1}}" onclick="dolike({{$item.id}},'attendno'); return false;"><i class="icon-remove icon-large"></i></a> | ||||||
|  | 				<a href="#" id="attendmaybe-{{$item.id}}" title="{{$item.attend.2}}" onclick="dolike({{$item.id}},'attendmaybe'); return false;"><i class="icon-question icon-large"></i></a> | ||||||
|  | 			</div> | ||||||
|  | 			{{/if}} | ||||||
|  | 
 | ||||||
|  | 			{{if $item.canvote}}<!--Consensus isn't implemented at this time. It's just for testing. --> | ||||||
|  | 			<div class="clear"></div> | ||||||
|  | 			<div class="wall-item-actions-canvote"> | ||||||
|  | 				<a href="#" id="attendyes-{{$item.id}}" title="{{$item.conlabels.0}}" onclick="dolike({{$item.id}},'agree'); return false;"><i class="icon-ok icon-large"></i></a> | ||||||
|  | 				<a href="#" id="attendno-{{$item.id}}" title="{{$item.conlabels.1}}" onclick="dolike({{$item.id}},'disagree'); return false;"><i class="icon-remove icon-large"></i></a> | ||||||
|  | 				<a href="#" id="attendmaybe-{{$item.id}}" title="{{$item.conlabels.2}}" onclick="dolike({{$item.id}},'abstain'); return false;"><i class="icon-question icon-large"></i></a> | ||||||
|  | 			</div> | ||||||
|  | 			{{/if}} | ||||||
| 			<div class="wall-item-actions-tools"> | 			<div class="wall-item-actions-tools"> | ||||||
| 
 | 
 | ||||||
| 				{{if $item.drop.pagedrop}} | 				{{if $item.drop.pagedrop}} | ||||||
|  | @ -137,8 +156,12 @@ | ||||||
| 	<div class="wall-item-bottom"> | 	<div class="wall-item-bottom"> | ||||||
| 		<div class="wall-item-links"> | 		<div class="wall-item-links"> | ||||||
| 		</div> | 		</div> | ||||||
| 		<div class="wall-item-like" id="wall-item-like-{{$item.id}}">{{$item.like}}</div> | 		{{if $item.responses}} | ||||||
| 		<div class="wall-item-dislike" id="wall-item-dislike-{{$item.id}}">{{$item.dislike}}</div>	 | 			{{foreach $item.responses as $verb=>$response}} | ||||||
|  | 				<div class="wall-item-{{$verb}}" id="wall-item-{{$verb}}-{{$item.id}}">{{$response.output}}</div> | ||||||
|  | 			{{/foreach}} | ||||||
|  | 		{{/if}} | ||||||
|  | 		 | ||||||
| 	</div> | 	</div> | ||||||
| 	 | 	 | ||||||
| 	{{if $item.threaded}}{{if $item.comment}} | 	{{if $item.threaded}}{{if $item.comment}} | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 rabuzarus
				rabuzarus