]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #1929 from rabuzarus/event-attendance
authorTobias Diekershoff <tobias.diekershoff@gmx.net>
Mon, 12 Oct 2015 13:10:03 +0000 (15:10 +0200)
committerTobias Diekershoff <tobias.diekershoff@gmx.net>
Mon, 12 Oct 2015 13:10:03 +0000 (15:10 +0200)
port of reds event attendance feature

16 files changed:
boot.php
include/conversation.php
include/delivery.php
include/features.php
include/items.php
include/notifier.php
mod/editpost.php
mod/like.php
mod/network.php
mod/photos.php
mod/profile.php
object/Conversation.php
object/Item.php
view/templates/jot-header.tpl
view/theme/vier/style.css
view/theme/vier/templates/wall_thread.tpl

index 497a87ce9ee5dd543b23df2914bdc93147df3601..20c243c2406bdbf19646e7a11cc71ed7c1ae8fc1 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -270,6 +270,10 @@ define ( 'NAMESPACE_ATOM1',           'http://www.w3.org/2005/Atom' );
 
 define ( 'ACTIVITY_LIKE',        NAMESPACE_ACTIVITY_SCHEMA . 'like' );
 define ( 'ACTIVITY_DISLIKE',     NAMESPACE_DFRN            . '/dislike' );
+define ( 'ACTIVITY_ATTEND',      NAMESPACE_ZOT             . '/activity/attendyes' );
+define ( 'ACTIVITY_ATTENDNO',    NAMESPACE_ZOT             . '/activity/attendno' );
+define ( 'ACTIVITY_ATTENDMAYBE', NAMESPACE_ZOT             . '/activity/attendmaybe' );
+
 define ( 'ACTIVITY_OBJ_HEART',   NAMESPACE_DFRN            . '/heart' );
 
 define ( 'ACTIVITY_FRIEND',      NAMESPACE_ACTIVITY_SCHEMA . 'make-friend' );
index 107fb84ea94dd1e5cd092bb5581d8f598c9e07ac..0907b5dce23cfe2ac0b569a3a9e5453c44dbe4c7 100644 (file)
@@ -100,7 +100,11 @@ function localize_item(&$item){
                $item['body'] = item_redir_and_replace_images($extracted['body'], $extracted['images'], $item['contact-id']);
 
        $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
-       if (activity_match($item['verb'],ACTIVITY_LIKE) || activity_match($item['verb'],ACTIVITY_DISLIKE)){
+       if (activity_match($item['verb'],ACTIVITY_LIKE) 
+               || activity_match($item['verb'],ACTIVITY_DISLIKE)
+               || activity_match($item['verb'],ACTIVITY_ATTEND)
+               || activity_match($item['verb'],ACTIVITY_ATTENDNO)
+               || activity_match($item['verb'],ACTIVITY_ATTENDMAYBE)){
 
                $r = q("SELECT * from `item`,`contact` WHERE
                                `item`.`contact-id`=`contact`.`id` AND `item`.`uri`='%s';",
@@ -139,6 +143,15 @@ function localize_item(&$item){
                elseif(activity_match($item['verb'],ACTIVITY_DISLIKE)) {
                        $bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
                }
+               elseif(activity_match($item['verb'],ACTIVITY_ATTEND)) {
+                       $bodyverb = t('%1$s attends %2$s\'s %3$s');
+               }
+               elseif(activity_match($item['verb'],ACTIVITY_ATTENDNO)) {
+                       $bodyverb = t('%1$s doesn\'t attend %2$s\'s %3$s');
+               }
+               elseif(activity_match($item['verb'],ACTIVITY_ATTENDMAYBE)) {
+                       $bodyverb = t('%1$s attends maybe %2$s\'s %3$s');
+               }
                $item['body'] = sprintf($bodyverb, $author, $objauthor, $plink);
 
        }
@@ -341,8 +354,15 @@ function count_descendants($item) {
 
 function visible_activity($item) {
 
-       if(activity_match($item['verb'],ACTIVITY_LIKE) || activity_match($item['verb'],ACTIVITY_DISLIKE))
-               return false;
+       // likes (etc.) can apply to other things besides posts. Check if they are post children, 
+       // in which case we handle them specially
+
+       $hidden_activities = array(ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE);
+       foreach($hidden_activities as $act) {
+               if(activity_match($item['verb'],$act)) {
+                       return false;
+               }
+       }
 
        if(activity_match($item['verb'],ACTIVITY_FOLLOW) && $item['object-type'] === ACTIVITY_OBJ_NOTE) {
                if(! (($item['self']) && ($item['uid'] == local_user()))) {
@@ -484,8 +504,10 @@ 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');
 
-       $alike = array();
-       $dlike = array();
+       $conv_responses = array(
+               'like' => array('title' => t('Likes','title')), 'dislike' => array('title' => t('Dislikes','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();
@@ -734,8 +756,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
 
 
                                // Can we put this after the visibility check?
-                               like_puller($a,$item,$alike,'like');
-                               like_puller($a,$item,$dlike,'dislike');
+                               builtin_activity_puller($item, $conv_responses);
 
                                // Only add what is visible
                                if($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
@@ -755,7 +776,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
                                }
                        }
 
-                       $threads = $conv->get_template_data($alike, $dlike);
+                       $threads = $conv->get_template_data($conv_responses);
 
                        if(!$threads) {
                                logger('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG);
@@ -921,65 +942,93 @@ function item_photo_menu($item){
        return $o;
 }}
 
-if(! function_exists('like_puller')) {
-function like_puller($a,$item,&$arr,$mode) {
-
-       $url = '';
-       $sparkle = '';
-       $verb = (($mode === 'like') ? ACTIVITY_LIKE : ACTIVITY_DISLIKE);
+/**
+ * @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 = '';
 
-       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 = $a->get_baseurl(true) . '/redir/' . $item['contact-id'];
-                       $sparkle = ' class="sparkle" ';
+               switch($mode) {
+                       case 'like':
+                               $verb = ACTIVITY_LIKE;
+                               break;
+                       case 'dislike':
+                               $verb = ACTIVITY_DISLIKE;
+                               break;
+                       case 'attendyes':
+                               $verb = ACTIVITY_ATTEND;
+                               break;
+                       case 'attendno':
+                               $verb = ACTIVITY_ATTENDNO;
+                               break;
+                       case 'attendmaybe':
+                               $verb = ACTIVITY_ATTENDMAYBE;
+                               break;
+                       default:
+                               return;
+                               break;
                }
-               else
-                       $url = zrl($url);
 
-               if(! $item['thr-parent'])
-                       $item['thr-parent'] = $item['parent-uri'];
+               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 .'>' . htmlentities($item['author-name']) . '</a>';
 
-               if(! ((isset($arr[$item['thr-parent'] . '-l'])) && (is_array($arr[$item['thr-parent'] . '-l']))))
-                       $arr[$item['thr-parent'] . '-l'] = array();
-               if(! isset($arr[$item['thr-parent']]))
-                       $arr[$item['thr-parent']] = 1;
-               else
-                       $arr[$item['thr-parent']] ++;
-               $arr[$item['thr-parent'] . '-l'][] = '<a href="'. $url . '"'. $sparkle .'>' . htmlentities($item['author-name']) . '</a>';
+                       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();
+
+                       // 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
-// $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'
 // $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);
@@ -992,9 +1041,67 @@ 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;
+       }
+
+       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;
 }}
 
@@ -1258,3 +1365,51 @@ function render_location_dummy($item) {
        if ($item['coord'] != "")
                return $item['coord'];
 }
+
+function get_responses($conv_responses,$response_verbs,$ob,$item) {
+       $ret = array();
+       foreach($response_verbs as $v) {
+               $ret[$v] = array();
+               $ret[$v]['count'] = ((x($conv_responses[$v],$item['uri'])) ? $conv_responses[$v][$item['uri']] : '');
+               $ret[$v]['list']  = ((x($conv_responses[$v],$item['uri'])) ? $conv_responses[$v][$item['uri'] . '-l'] : '');
+               if(count($ret[$v]['list']) > MAX_LIKERS) {
+                       $ret[$v]['list_part'] = array_slice($ret[$v]['list'], 0, MAX_LIKERS);
+                       array_push($ret[$v]['list_part'], '<a href="#" data-toggle="modal" data-target="#' . $v . 'Modal-' 
+                               . (($ob) ? $ob->get_id() : $item['id']) . '"><b>' . t('View all') . '</b></a>');
+               }
+               else {
+                       $ret[$v]['list_part'] = '';
+               }
+               $ret[$v]['button'] = get_response_button_text($v,$ret[$v]['count']);
+               $ret[$v]['title'] = $conv_responses[$v]['title'];
+       }
+
+       $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':
+                       return tt('Like','Likes',$count,'noun');
+                       break;
+               case 'dislike':
+                       return tt('Dislike','Dislikes',$count,'noun');
+                       break;
+               case 'attendyes':
+                       return tt('Attending','Attending',$count,'noun');
+                       break;
+               case 'attendno':
+                       return tt('Not Attending','Not Attending',$count,'noun');
+                       break;
+               case 'attendmaybe':
+                       return tt('Undecided','Undecided',$count,'noun');
+                       break;
+       }
+}
index a913e131701866d86e4d1a8d42ca159a3dbb0a16..659add2ad61af1f6b05653a04e39c1da8409074f 100644 (file)
@@ -520,11 +520,16 @@ function delivery_run(&$argv, &$argc){
                                if((! $contact['pubkey']) && (! $public_message))
                                        break;
 
-                               if($target_item['verb'] === ACTIVITY_DISLIKE) {
-                                       // unsupported
-                                       break;
+                               $unsupported_activities = array(ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE);
+
+                               //don't transmit activities which are not supported by diaspora
+                               foreach($unsupported_activities as $act) {
+                                       if(activity_match($target_item['verb'],$act)) {
+                                               break 2;
+                                       }
                                }
-                               elseif(($target_item['deleted']) && ($target_item['uri'] === $target_item['parent-uri'])) {
+
+                               if(($target_item['deleted']) && ($target_item['uri'] === $target_item['parent-uri'])) {
                                        // top-level retraction
                                        logger('delivery: diaspora retract: ' . $loc);
 
index 5450c7fab02c70d845870a4933d8d4ca9097329b..1307132a64fce66236e08c5f599833f0ea144db0 100644 (file)
@@ -30,7 +30,7 @@ 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.')),
                ),
 
index 5c7aa52e6fa70df0822da0aa9eb873bd3f06826c..4e86a5200af6d3a74e2e1939c624d0bca07555da 100644 (file)
@@ -2765,7 +2765,11 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
                                $datarray['parent-uri'] = $parent_uri;
                                $datarray['uid'] = $importer['uid'];
                                $datarray['contact-id'] = $contact['id'];
-                               if((activity_match($datarray['verb'],ACTIVITY_LIKE)) || (activity_match($datarray['verb'],ACTIVITY_DISLIKE))) {
+                               if(($datarray['verb'] === ACTIVITY_LIKE)
+                                       || ($datarray['verb'] === ACTIVITY_DISLIKE)
+                                       || ($datarray['verb'] === ACTIVITY_ATTEND)
+                                       || ($datarray['verb'] === ACTIVITY_ATTENDNO)
+                                       || ($datarray['verb'] === ACTIVITY_ATTENDMAYBE)) {
                                        $datarray['type'] = 'activity';
                                        $datarray['gravity'] = GRAVITY_LIKE;
                                        // only one like or dislike per person
@@ -3752,7 +3756,11 @@ function local_delivery($importer,$data) {
                                $datarray['owner-avatar'] = $own[0]['thumb'];
                                $datarray['contact-id'] = $importer['id'];
 
-                               if(($datarray['verb'] === ACTIVITY_LIKE) || ($datarray['verb'] === ACTIVITY_DISLIKE)) {
+                               if(($datarray['verb'] === ACTIVITY_LIKE) 
+                                       || ($datarray['verb'] === ACTIVITY_DISLIKE)
+                                       || ($datarray['verb'] === ACTIVITY_ATTEND)
+                                       || ($datarray['verb'] === ACTIVITY_ATTENDNO)
+                                       || ($datarray['verb'] === ACTIVITY_ATTENDMAYBE)) {
                                        $is_like = true;
                                        $datarray['type'] = 'activity';
                                        $datarray['gravity'] = GRAVITY_LIKE;
@@ -3941,7 +3949,11 @@ function local_delivery($importer,$data) {
                                $datarray['parent-uri'] = $parent_uri;
                                $datarray['uid'] = $importer['importer_uid'];
                                $datarray['contact-id'] = $importer['id'];
-                               if(($datarray['verb'] == ACTIVITY_LIKE) || ($datarray['verb'] == ACTIVITY_DISLIKE)) {
+                               if(($datarray['verb'] === ACTIVITY_LIKE) 
+                                       || ($datarray['verb'] === ACTIVITY_DISLIKE)
+                                       || ($datarray['verb'] === ACTIVITY_ATTEND)
+                                       || ($datarray['verb'] === ACTIVITY_ATTENDNO)
+                                       || ($datarray['verb'] === ACTIVITY_ATTENDMAYBE)) {
                                        $datarray['type'] = 'activity';
                                        $datarray['gravity'] = GRAVITY_LIKE;
                                        // only one like or dislike per person
index d4d254f1c9a82a628aad02b43bef658a189b4c17..0f9cc804646928ad70dd1ef813b5088243949334 100644 (file)
@@ -908,11 +908,16 @@ function notifier_run(&$argv, &$argc){
                                        if(! $contact['pubkey'])
                                                break;
 
-                                       if($target_item['verb'] === ACTIVITY_DISLIKE) {
-                                               // unsupported
-                                               break;
+                                       $unsupported_activities = array(ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE);
+
+                                       //don't transmit activities which are not supported by diaspora
+                                       foreach($unsupported_activities as $act) {
+                                               if(activity_match($target_item['verb'],$act)) {
+                                                       break 2;
+                                               }
                                        }
-                                       elseif(($target_item['deleted']) && (($target_item['uri'] === $target_item['parent-uri']) || $followup)) {
+
+                                       if(($target_item['deleted']) && (($target_item['uri'] === $target_item['parent-uri']) || $followup)) {
                                                // send both top-level retractions and relayable retractions for owner to relay
                                                diaspora_send_retraction($target_item,$owner,$contact);
                                                break;
index b039341023c7e00140e23d295f32af321087797d..0cf6d0d4cf7320f7b1812036f99de0d4d8740879 100644 (file)
@@ -93,15 +93,14 @@ 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));
 
        $o .= replace_macros($tpl,array(
                '$return_path' => $_SESSION['return_url'],
index bbb07289659257b4efdbda20fc294139509427d6..90782687d3dc5669501fe1065ccc015cab6c7f34 100755 (executable)
@@ -26,6 +26,18 @@ function like_content(&$a) {
                case 'undislike':
                        $activity = ACTIVITY_DISLIKE;
                        break;
+               case 'attendyes':
+               case 'unattendyes':
+                       $activity = ACTIVITY_ATTEND;
+                       break;
+               case 'attendno':
+               case 'unattendno':
+                       $activity = ACTIVITY_ATTENDNO;
+                       break;
+               case 'attendmaybe':
+               case 'unattendmaybe':
+                       $activity = ACTIVITY_ATTENDMAYBE;
+                       break;
                default:
                        return;
                        break;
@@ -108,11 +120,18 @@ 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)."' ";
+
+       // event participation 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) . "' ";
+       }
 
-       $r = q("SELECT `id`, `guid` FROM `item` WHERE `verb` = '%s' AND `deleted` = 0
+       $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'])
        );
 
@@ -147,6 +166,8 @@ function like_content(&$a) {
        $uri = item_new_uri($a->get_hostname(),$owner_uid);
 
        $post_type = (($item['resource-id']) ? t('photo') : t('status'));
+       if($item['obj_type'] === ACTIVITY_OBJ_EVENT)
+               $post_type = t('event');
        $objtype = (($item['resource-id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE );
        $link = xmlify('<link rel="alternate" type="text/html" href="' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ;
        $body = $item['body'];
@@ -166,6 +187,12 @@ EOT;
                $bodyverb = t('%1$s likes %2$s\'s %3$s');
        if($verb === 'dislike')
                $bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
+       if($verb === 'attendyes')
+               $bodyverb = t('%1$s is attending %2$s\'s %3$s');
+       if($verb === 'attendno')
+               $bodyverb = t('%1$s is not attending %2$s\'s %3$s');
+       if($verb === 'attendmaybe')
+               $bodyverb = t('%1$s may attend %2$s\'s %3$s');
 
        if(! isset($bodyverb))
                        return; 
index 3d14455cdf634c8ba3c96da1429a3b31f1114705..dfd7c013007fbdb39618ee681764652df3252f29 100644 (file)
@@ -732,7 +732,10 @@ function network_content(&$a, $update = 0) {
                // Fetch a page full of parent items for this page
                if($update) {
                        if (!get_config("system", "like_no_comment"))
-                               $sql_extra4 = "(`item`.`deleted` = 0 OR `item`.`verb` = '".ACTIVITY_LIKE."' OR `item`.`verb` = '".ACTIVITY_DISLIKE."')";
+                               $sql_extra4 = "(`item`.`deleted` = 0
+                                               OR `item`.`verb` = '".ACTIVITY_LIKE."' OR `item`.`verb` = '".ACTIVITY_DISLIKE."'
+                                               OR `item`.`verb` = '".ACTIVITY_ATTEND."' OR `item`.`verb` = '".ACTIVITY_ATTENDNO."'
+                                               OR `item`.`verb` = '".ACTIVITY_ATTENDMAYBE."')";
                        else
                                $sql_extra4 = "`item`.`deleted` = 0 AND `item`.`verb` = '".ACTIVITY_POST."'";
 
index 03021e55018ba678805c701d7065580b77e237ae..5ca973d16637d4db92434c2d43fbb6a1313827f9 100644 (file)
@@ -1635,18 +1635,22 @@ function photos_content(&$a) {
                        $like = '';
                        $dislike = '';
 
+                       $conv_responses = array(
+                               'like' => array('title' => t('Likes','title')),'dislike' => array('title' => t('Dislikes','title')),
+                               'attendyes' => array('title' => t('Attending','title')), 'attendno' => array('title' => t('Not attending','title')), 'attendmaybe' => array('title' => t('Might attend','title'))
+                       );
+
 
 
                        // display comments
                        if(count($r)) {
 
                                foreach($r as $item) {
-                                       like_puller($a,$item,$alike,'like');
-                                       like_puller($a,$item,$dlike,'dislike');
+                                       builtin_activity_puller($item, $conv_responses);
                                }
 
-                               $like    = ((isset($alike[$link_item['id']])) ? format_like($alike[$link_item['id']],$alike[$link_item['id'] . '-l'],'like',$link_item['id']) : '');
-                               $dislike = ((isset($dlike[$link_item['id']])) ? format_like($dlike[$link_item['id']],$dlike[$link_item['id'] . '-l'],'dislike',$link_item['id']) : '');
+                               $like    = ((x($conv_responses['like'],$link_item['uri'])) ? format_like($conv_responses['like'][$link_item['uri']],$conv_responses['like'][$link_item['uri'] . '-l'],'like',$link_item['id']) : '');
+                               $dislike = ((x($conv_responses['dislike'],$link_item['uri'])) ? format_like($conv_responses['dislike'][$link_item['uri']],$conv_responses['dislike'][$link_item['uri'] . '-l'],'dislike',$link_item['id']) : '');
 
 
 
@@ -1765,6 +1769,12 @@ function photos_content(&$a) {
                        $paginate = paginate($a);
                }
 
+
+               $response_verbs = array('like');
+               if(feature_enabled($owner_uid,'dislike'))
+                       $response_verbs[] = 'dislike';
+               $responses = get_responses($conv_responses,$response_verbs,'',$link_item);
+
                $photo_tpl = get_markup_template('photo_view.tpl');
 
                if($a->theme['template_engine'] === 'internal') {
@@ -1796,6 +1806,7 @@ function photos_content(&$a) {
                        '$likebuttons' => $likebuttons,
                        '$like' => $like_e,
                        '$dislike' => $dikslike_e,
+                       'responses' => $responses,
                        '$comments' => $comments,
                        '$paginate' => $paginate,
                ));
index 608971d08d38dd1dce47516b4d1ca2ae5dbd6d88..b7b76cbb5bbe60c30003096513a370142f2d5e41 100644 (file)
@@ -221,8 +221,10 @@ function profile_content(&$a, $update = 0) {
                        FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
                        AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
                        WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND
-                       (`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE ."' OR item.verb = '" . ACTIVITY_DISLIKE . "')
-                       and `item`.`moderated` = 0 and `item`.`unseen` = 1
+                       (`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE ."'
+                       OR item.verb = '" . ACTIVITY_DISLIKE . "' OR item.verb = '" . ACTIVITY_ATTEND . "'
+                       OR item.verb = '" . ACTIVITY_ATTENDNO . "' OR item.verb = '" . ACTIVITY_ATTENDMAYBE . "')
+                       AND `item`.`moderated` = 0 and `item`.`unseen` = 1
                        AND `item`.`wall` = 1
                        $sql_extra
                        ORDER BY `item`.`created` DESC",
index fd1e282cabf6ce7525c40e80c73d05b3d2938ccc..94eed94d5f9eaa8661d6a9508b4be21a0512ff90 100644 (file)
@@ -126,7 +126,7 @@ class Conversation extends BaseObject {
         *      _ The data requested on success
         *      _ false on failure
         */
-       public function get_template_data($alike, $dlike) {
+       public function get_template_data($conv_responses) {
                global $a;
                $result = array();
 
@@ -136,7 +136,7 @@ class Conversation extends BaseObject {
                        if($item->get_data_value('network') === NETWORK_MAIL && local_user() != $item->get_data_value('uid'))
                                continue;
 
-                       $item_data = $item->get_template_data($alike, $dlike);
+                       $item_data = $item->get_template_data($conv_responses);
 
                        if(!$item_data) {
                                logger('[ERROR] Conversation::get_template_data : Failed to get item template data ('. $item->get_id() .').', LOGGER_DEBUG);
index 63fa43d3e25eb2feb41e78f8cab56a84bb2432d7..3050365f921fd23ad463ccf354a3cdae9bbab71e 100644 (file)
@@ -81,7 +81,7 @@ class Item extends BaseObject {
         *      _ The data requested on success
         *      _ false on failure
         */
-       public function get_template_data($alike, $dlike, $thread_level=1) {
+       public function get_template_data($conv_responses, $thread_level=1) {
                require_once("mod/proxy.php");
 
                $result = array();
@@ -175,8 +175,26 @@ class Item extends BaseObject {
                        }
                }*/
 
-               $like    = ((x($alike,$item['uri'])) ? format_like($alike[$item['uri']],$alike[$item['uri'] . '-l'],'like',$item['uri']) : '');
-               $dislike = ((x($dlike,$item['uri'])) ? format_like($dlike[$item['uri']],$dlike[$item['uri'] . '-l'],'dislike',$item['uri']) : '');
+               // process action responses - e.g. like/dislike/attend/agree/whatever
+               $response_verbs = array('like');
+               if(feature_enabled($conv->get_profile_owner(),'dislike'))
+                       $response_verbs[] = 'dislike';
+               if($item['object-type'] === ACTIVITY_OBJ_EVENT) {
+                       $response_verbs[] = 'attendyes';
+                       $response_verbs[] = 'attendno';
+                       $response_verbs[] = 'attendmaybe';
+                       if($conv->is_writable()) {
+                               $isevent = true;
+                               $attend = array( t('I will attend'), t('I will not attend'), t('I might attend'));
+                       }
+               }
+
+               $responses = get_responses($conv_responses,$response_verbs,$this,$item);
+
+               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']) : '');
+
+               }
 
                /*
                 * We should avoid doing this all the time, but it depends on the conversation mode
@@ -291,7 +309,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);
                        $tagger = '';
                }
 
@@ -331,6 +349,8 @@ class Item extends BaseObject {
                        'text' => $text_e,
                        'id' => $this->get_id(),
                        'guid' => urlencode($item['guid']),
+                       'isevent' => $isevent,
+                       'attend' => $attend,
                        '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'), htmlentities($this->get_owner_name()), ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])),
                        'to' => t('to'),
@@ -364,15 +384,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' => $comment,
                        '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),
                );
@@ -387,7 +408,7 @@ class Item extends BaseObject {
                $nb_children = count($children);
                if($nb_children > 0) {
                        foreach($children as $child) {
-                               $result['children'][] = $child->get_template_data($alike, $dlike, $thread_level + 1);
+                               $result['children'][] = $child->get_template_data($conv_responses, $thread_level + 1);
                        }
                        // Collapse
                        if(($nb_children > 2) || ($thread_level > 1)) {
index 8d009fd40cdd1f81bdabb65fb63a6379fbbaa1e8..cb841c314d5194cb610fc9eff36edf7c7c48b268 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,7 @@ function enableOnUser(){
                                return false;
                        });
                });
-               
+
        }
 
        function jotClearLocation() {
index d6d13b9d3c9b88b12f556cb815b67c43f23c4677..1c03edc6bfbce09d10a962e2a3de3d84bb07327a 100644 (file)
@@ -1347,11 +1347,13 @@ 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 {
   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 {
   float: left;
   margin-right: 1em;
   cursor: pointer;
index 25b97a0cc5747968faa198b1c5ccdad3f14ba961..e6b0de84bd538b6000f3736eec7ba8c16e8d3830 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}}
+
                        <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}}