]> git.mxchange.org Git - friendica.git/commitdiff
rest of the consensus porting work and integration into friendica
authorrabuzarus <>
Wed, 3 Jun 2015 18:57:30 +0000 (20:57 +0200)
committerrabuzarus <trebor@central-unit>
Wed, 30 Sep 2015 12:38:13 +0000 (14:38 +0200)
Credits to Mike Macgirvin for the code

include/conversation.php
include/features.php
mod/editpost.php
mod/item.php
mod/like.php
object/Item.php
view/templates/jot-header.tpl
view/templates/jot.tpl
view/theme/vier/style.css
view/theme/vier/templates/wall_thread.tpl

index cdc7ba3bd8ca848ad2c8dec4f5977021c857be0b..4924470875a6ee14383809b0beca1758b1eafecf 100644 (file)
@@ -491,7 +491,11 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
        $cmnt_tpl    = get_markup_template('comment_item.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)
        $threads = array();
@@ -740,19 +744,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
 
 
                                // Can we put this after the visibility check?
-                               like_puller($a, $item, $conv_responses, 'like');
-                               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');
+                               builtin_activity_puller($item, $conv_responses);
 
                                // Only add what is visible
                                if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
@@ -916,107 +908,102 @@ function item_photo_menu($item){
        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 = '';
+               $sparkle = '';
 
-       $url = '';
-       $sparkle = '';
-       switch($mode) {
-               case 'like':
-               case 'unlike':
-                       $verb = ACTIVITY_LIKE;
-                       break;
-               case 'dislike':
-               case 'undislike':
-                       $verb = ACTIVITY_DISLIKE;
-                       break;
-               case 'agree':
-               case 'unagree':
-                       $verb = ACTIVITY_AGREE;
-                       break;
-               case 'disagree':
-               case 'undisagree':
-                       $verb = ACTIVITY_DISAGREE;
-                       break;
-               case 'abstain':
-               case 'unabstain':
-                       $verb = ACTIVITY_ABSTAIN;
-                       break;
-               case 'attendyes':
-               case 'unattendyes':
-                       $verb = ACTIVITY_ATTEND;
-                       break;
-               case 'attendno':
-               case 'unattendno':
-                       $verb = ACTIVITY_ATTENDNO;
-                       break;
-               case 'attendmaybe':
-               case 'unattendmaybe':
-                       $verb = ACTIVITY_ATTENDMAYBE;
-                       break;
-               default:
-                       return;
-                       break;
-       }
+               switch($mode) {
+                       case 'like':
+                               $verb = ACTIVITY_LIKE;
+                               break;
+                       case 'dislike':
+                               $verb = ACTIVITY_DISLIKE;
+                               break;
+                       case 'agree':
+                               $verb = ACTIVITY_AGREE;
+                               break;
+                       case 'disagree':
+                               $verb = ACTIVITY_DISAGREE;
+                               break;
+                       case 'abstain':
+                               $verb = ACTIVITY_ABSTAIN;
+                               break;
+                       case 'attendyes':
+                               $verb = ACTIVITY_ATTEND;
+                               break;
+                       case 'attendno':
+                               $verb = ACTIVITY_ATTENDNO;
+                               break;
+                       case 'attendmaybe':
+                               $verb = ACTIVITY_ATTENDMAYBE;
+                               break;
+                       default:
+                               return;
+                               break;
+               }
 
-logger('verb: ' . $verb);
-if($verb === ACTIVITY_ATTENDNO)
-       logger('item: ' . $item['verb']);
+               if((activity_match($item['verb'], $verb)) && ($item['id'] != $item['parent'])) {
+                       $url = $item['author-link'];
+                       if((local_user()) && (local_user() == $item['uid']) && ($item['network'] === NETWORK_DFRN) && (! $item['self']) && (link_compare($item['author-link'],$item['url']))) {
+                               $url = z_root(true) . '/redir/' . $item['contact-id'];
+                               $sparkle = ' class="sparkle" ';
+                       }
+                       else 
+                               $url = zrl($url);
+                       
+                       $url = '<a href="'. $url . '"'. $sparkle .'>' . $item['author-name'] . '</a>';
 
-       if((activity_match($item['verb'],$verb)) && ($item['id'] != $item['parent'])) {
-logger('match:' . $verb);
-               $url = $item['author-link'];
-               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'];
-                       $sparkle = ' class="sparkle" ';
-               }
-               else
-                       $url = zrl($url);
+                       if(! $item['thr-parent'])
+                               $item['thr-parent'] = $item['parent-uri'];
 
-               if(! $item['thr-parent'])
-                       $item['thr-parent'] = $item['parent-uri'];
+                       if(! ((isset($conv_responses[$mode][$item['thr-parent'] . '-l'])) 
+                               && (is_array($conv_responses[$mode][$item['thr-parent'] . '-l']))))
+                               $conv_responses[$mode][$item['thr-parent'] . '-l'] = array();
 
-               if(! ((isset($arr[$mode][$item['thr-parent'] . '-l'])) && (is_array($arr[$mode][$item['thr-parent'] . '-l']))))
-                       $arr[$mode][$item['thr-parent'] . '-l'] = array();
-               if(! isset($arr[$mode][$item['thr-parent']]))
-                       $arr[$mode][$item['thr-parent']] = 1;
-               else
-                       $arr[$mode][$item['thr-parent']] ++;
+                       // 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']] ++;
 
-               $arr[$mode][$item['thr-parent'] . '-l'][] = '<a href="'. $url . '"'. $sparkle .'>' . $item['author-name'] . '</a>';
+                       $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
-// $cnt = number of people who like/dislike the item
+// Format the vote text for a profile item
+// $cnt = number of people who vote the item
 // $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
 // returns formatted text
 
 if(! function_exists('format_like')) {
 function format_like($cnt,$arr,$type,$id) {
        $o = '';
+       $expanded = '';
+
        if($cnt == 1)
-               $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
-               ));
+               $likers = $arr[0];
 
+       else {
                $total = count($arr);
                if($total >= MAX_LIKERS)
                        $arr = array_slice($arr, 0, MAX_LIKERS - 1);
@@ -1029,9 +1016,76 @@ function format_like($cnt,$arr,$type,$id) {
                        $str = implode(', ', $arr);
                        $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;
 }}
 
@@ -1049,6 +1103,8 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
        if( local_user() && feature_enabled(local_user(),'richtext') )
                $plaintext = false;
 
+       $voting = feature_enabled(local_user(),'consensus_tools');
+
        $tpl = get_markup_template('jot-header.tpl');
        $a->page['htmlhead'] .= replace_macros($tpl, array(
                '$newpost' => 'true',
@@ -1126,6 +1182,9 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
                '$shortsetloc' => t('set location'),
                '$noloc' => t('Clear browser location'),
                '$shortnoloc' => t('clear location'),
+               '$voting' => t('Toggle voting'),
+               '$feature_voting' => $voting,
+               '$consensus' => 0,
                '$title' => $x['title'],
                '$placeholdertitle' => t('Set title'),
                '$category' => $x['category'],
@@ -1311,10 +1370,19 @@ function get_responses($conv_responses,$response_verbs,$ob,$item) {
                        $ret[$v]['list_part'] = '';
                }
                $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;
 }
+
 function get_response_button_text($v,$count) {
        switch($v) {
                case 'like':
@@ -1335,7 +1403,7 @@ function get_response_button_text($v,$count) {
                case 'agree':
                        return tt('Agree','Agrees',$count,'noun');
                        break;
-               case 'agree':
+               case 'disagree':
                        return tt('Disagree','Disagrees',$count,'noun');
                        break;
                case 'abstain':
index 091dfc6e9d0793a320ff3f33af0fc4841ab76272..b465fdbe039593eae657cf2666962fd1599912f7 100644 (file)
@@ -29,8 +29,9 @@ function get_features() {
                'composition' => array(
                        t('Post Composition Features'),
                        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('consensus_tools', t('Enable voting tools'),              t('Provide a class of post which others can vote on'),false),
                ),
 
                // Network sidebar widgets
index b039341023c7e00140e23d295f32af321087797d..4a3bdeddfec2106de9974f0ad5caed5e58b6dbcb 100644 (file)
@@ -93,15 +93,16 @@ function editpost_content(&$a) {
                $jotnets .= '<div class="profile-jot-net"><input type="checkbox" name="pubmail_enable"' . $selected . ' value="1" /> '
                . t("Post to Email") . '</div>';
        }*/
-                                       
+
 
 
        call_hooks('jot_tool', $jotplugins);
        //call_hooks('jot_networks', $jotnets);
 
        
-       //$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(
                '$return_path' => $_SESSION['return_url'],
@@ -121,6 +122,11 @@ function editpost_content(&$a) {
                '$shortsetloc' => t('set location'),
                '$noloc' => t('Clear browser 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'),
                '$permset' => t('Permission settings'),
                '$ptyp' => $itm[0]['type'],
index 91a94974e9a232cd0b7c1e2a55893fe0ee69c41b..3baf618ca8cb92fc3e8c5d44646688236a326a9b 100644 (file)
@@ -51,6 +51,7 @@ function item_post(&$a) {
        $message_id = ((x($_REQUEST,'message_id') && $api_source)  ? strip_tags($_REQUEST['message_id'])       : '');
 
        $return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
+       $consensus = intval($_REQUEST['consensus']);
        $preview = ((x($_REQUEST,'preview')) ? intval($_REQUEST['preview']) : 0);
 
 
@@ -655,6 +656,15 @@ function item_post(&$a) {
        if(!$thr_parent)
                $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['uid']           = $profile_uid;
        $datarray['type']          = $post_type;
index aef3473c30b56d953948cc09dcb8941d1cf82eb7..522fa8703939332e876be2b7ce3e0378acbce7b5 100755 (executable)
@@ -132,11 +132,21 @@ function like_content(&$a) {
        // See if we've been passed a return path to redirect to
        $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 (`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'])
        );
 
index e680e293629122771d52593b6fb8808779c61173..d27be50ee2db5bf0729cd935e5aeca3e88d3be2d 100644 (file)
@@ -175,7 +175,6 @@ class Item extends BaseObject {
                        }
                }*/
 
-
                // process action responses - e.g. like/dislike/attend/agree/whatever
                $response_verbs = array('like');
                        $response_verbs[] = 'dislike';
@@ -183,44 +182,34 @@ class Item extends BaseObject {
                        $response_verbs[] = 'attendyes';
                        $response_verbs[] = 'attendno';
                        $response_verbs[] = 'attendmaybe';
-                       $isevent = true;
-                       $attend = array( t('I will attend'), t('I will not attend'), t('I might attend'));
+                       if($conv->is_writable()) {
+                               $isevent = true;
+                               $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) {
                        $response_verbs[] = 'agree';
                        $response_verbs[] = 'disagree';
                        $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);
 
-               // like_button_label from red -> needs to be removed
-               //$like_button_label = tt('Like','Likes',$like_count,'noun');
+               foreach ($response_verbs as $value=>$verbs) {
+                       $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
                 * And the conv mode may change when we change the conv, or it changes its mode
@@ -332,7 +321,7 @@ class Item extends BaseObject {
 
                // Disable features that aren't available in several networks
                if (($item["item_network"] != NETWORK_DFRN) AND isset($buttons["dislike"])) {
-                       unset($buttons["dislike"]);
+                       unset($buttons["dislike"],$isevent,$consensus);
                        $tagger = '';
                }
 
@@ -370,6 +359,9 @@ class Item extends BaseObject {
                        'guid' => $item['guid'],
                        'isevent' => $isevent,
                        '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'])),
                        'olinktitle' => sprintf( t('View %s\'s profile @ %s'), $this->get_owner_name(), ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])),
                        'to' => t('to'),
@@ -403,16 +395,16 @@ class Item extends BaseObject {
                        'filer'     => ((feature_enabled($conv->get_profile_owner(),'filing')) ? $filer : ''),
                        'drop' => $drop,
                        'vote' => $buttons,
-                       'like' => $like,
-                        'dislike'   => $dislike,
+                       'like' => $responses['like']['output'],
+                       'dislike'   => $responses['dislike']['output'],
                        'responses' => $responses,
                        'switchcomment' => t('Comment'),
                        'comment' => $this->get_comment_box($indent),
                        'previewing' => ($conv->is_preview() ? ' preview ' : ''),
                        'wait' => t('Please wait'),
                        'thread_level' => $thread_level,
-                        'postopts' => $langstr,
-                        'edited' => $edited,
+                       'postopts' => $langstr,
+                       'edited' => $edited,
                        'network' => $item["item_network"],
                        'network_name' => network_to_name($item['item_network'], $profile_link),
                );
index 8d009fd40cdd1f81bdabb65fb63a6379fbbaa1e8..5095dc5d1a78c0d1d708093d45313690862626b7 100644 (file)
@@ -21,7 +21,7 @@ function initEditor(cb){
                        $(".jothidden").show();
                        if (typeof cb!="undefined") cb();
                        return;
-               }       
+               }
                tinyMCE.init({
                        theme : "advanced",
                        mode : "specific_textareas",
@@ -203,7 +203,7 @@ function enableOnUser(){
                                        else {
                                                checkedstr = $(this).val();
                                        }
-                               }       
+                               }
                        });
                        $.post('item', { dropitems: checkedstr }, function(data) {
                                window.location.reload();
@@ -330,7 +330,18 @@ function enableOnUser(){
                                return false;
                        });
                });
-               
+
+       }
+
+       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() {
index dfc6b2710415fb94b44585e597ef4cedf053ff37..5c60a5c09cf5936ad78dc3cba45af4c29bdaed24 100644 (file)
                <a id="profile-nolocation" class="icon noglobe" title="{{$noloc|escape:'html'}}" onclick="jotClearLocation();return false;"></a>
        </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}};" >
                <a href="#profile-jot-acl-wrapper" id="jot-perms-icon" class="icon {{$lockstate}}"  title="{{$permset|escape:'html'}}" ></a>{{$bang}}
        </div>
index 77ffb53fd1903bf9d7ee28f6f69ec16c51abf95f..526402f2e317c3de6c8ba4208039322541736ff4 100644 (file)
@@ -1347,11 +1347,15 @@ section.minimal {
   width: 100%;
   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;
   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;
   margin-right: 1em;
   cursor: pointer;
@@ -1863,6 +1867,11 @@ section.minimal {
   margin-left: 15px;
   cursor: pointer;
 }
+#profile-voting-wrapper {
+  float: left;
+  margin-left: 15px;
+  cursor: pointer;
+}
 #profile-smiley-wrapper {
   float: left;
   margin-left: 15px;
index 25b97a0cc5747968faa198b1c5ccdad3f14ba961..05fbc14d00dbfcbaeaf51c6bd0c8fb5ed621050c 100644 (file)
                                 <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}}
                        </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">
 
                                {{if $item.drop.pagedrop}}
        <div class="wall-item-bottom">
                <div class="wall-item-links">
                </div>
-               <div class="wall-item-like" id="wall-item-like-{{$item.id}}">{{$item.like}}</div>
-               <div class="wall-item-dislike" id="wall-item-dislike-{{$item.id}}">{{$item.dislike}}</div>      
+               {{if $item.responses}}
+                       {{foreach $item.responses as $verb=>$response}}
+                               <div class="wall-item-{{$verb}}" id="wall-item-{{$verb}}-{{$item.id}}">{{$response.output}}</div>
+                       {{/foreach}}
+               {{/if}}
+               
        </div>
        
        {{if $item.threaded}}{{if $item.comment}}