Plugin Directory

Changeset 668363


Ignore:
Timestamp:
02/15/2013 09:15:35 AM (13 years ago)
Author:
O-Zone
Message:

tagging version 0.1.4

Location:
wp-meetup-activity
Files:
3 edited
9 copied

Legend:

Unmodified
Added
Removed
  • wp-meetup-activity/tags/0.1.4/default.css

    r589800 r668363  
    1919    color: #fff;
    2020}
     21
     22.wpmeetupactivity-event-widget-box {
     23    clear: both;
     24}
     25
     26.wpmeetupactivity-event-widget-box-title {
     27    font-size: 1.2em;
     28    padding: 1px;
     29}
     30
     31.wpmeetupactivity-event-widget-cal-box {
     32    float: left;
     33    width: 54px;
     34    height: 54px;
     35    border-radius: 5px;
     36    padding: 4px;
     37    margin: 2px;
     38    background: #3B5998;
     39    text-align: center;
     40}
     41
     42.wpmeetupactivity-event-widget-cal-box-day {
     43    font-size: 2em;
     44    color: #fff;
     45    text-align: center;
     46}
     47
     48.wpmeetupactivity-event-widget-cal-box-month {
     49    font-size: 0.8em;
     50    color: #fff;
     51    text-align: center;
     52}
     53
     54.wpmeetupactivity-event-widget-detail-box {
     55    font-size: 1.0em;
     56    text-align: justify;
     57    margin: 2px;
     58}
     59
     60.wpmeetupactivity-tipbox {
     61    padding: 8px;
     62    color: #333;
     63    font-size: 0.8em;
     64    background: #FF9;
     65    border: 1px solid #FC0;
     66    -moz-border-radius: 2px;
     67    border-radius: 2px;
     68    text-align: justify;
     69}
  • wp-meetup-activity/tags/0.1.4/readme.txt

    r592392 r668363  
    22Contributors: o-zone
    33Donate link: http://www.zerozone.it
    4 Tags: meetup, activity, meetup.com, group, facebook
     4Tags: meetup, activity, meetup.com, events, group
    55Requires at least: 3.0
    6 Tested up to: 3.4.1
     6Tested up to: 3.5.1
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
    99
    10 WP-Meetup-Activity display your groups latest activities (discussions, photos...) in a sidebar widget. Can also post directly to facebook pages new threads and replies
     10WP-Meetup-Activity display your groups latest activities (discussions, photos...) and events in a sidebar widget
    1111
    1212== Description ==
     
    22222. Activate the plugin through the 'Plugins' menu in WordPress
    23233. Add the widget wherever you want
    24 
    25 if you want to enable facebook Post-to-page feature, you need to create a new app:
    26 
    27 1. Open your browser to https://developers.facebook.com/apps
    28 2. Click on "Create new application" on top right
    29 3. Set domain URLs
    30 4. Write app Id and app secret on wp-meetup-activity setup page
    31 5. Connect widget with your Facebook application, allowing manage_pages and offline_access rights
     244. Set it up !
    3225
    3326== Frequently Asked Questions ==
     
    4740== Changelog ==
    4841
    49 = 0.1.3 =
    50 * Enable/disable Facebook support
    51 * Fixed some Facebook issue with other plugins (like "Facebook for Wordpress")
    52 
    53 = 0.1.2 =
    54 * Facebook support for Post-in-Page on new topics / reply
    55 * Minor bugs fixed
     42= 0.1.4 =
     43* Added Meetup events support
     44* Some bugs fixed and minor code cleanups
    5645
    5746= 0.1.1 =
     
    7564== Upgrade Notice ==
    7665
     66= 0.1.4 =
     67Added Meetup events support. Can you miss it ?
     68
    7769= 0.1.1 =
    7870Database should upgrade automatically but please deactivate and reactivate the plugin after upgrade.
  • wp-meetup-activity/tags/0.1.4/wp-meetup-activity.php

    r592392 r668363  
    33Plugin Name: WP Meetup Activity
    44Plugin URI: http://www.zerozone.it/wordpress-meetup-plugin/
    5 Description: Display group activity from Meetup.com in a widget for your wordpress
    6 Version: 0.1.3
     5Description: Display group activity and events from Meetup.com in a widget for your wordpress
     6Version: 0.1.4
    77Author: Michele "O-Zone" Pinassi
    88Author URI: http://www.zerozone.it/
    99
    10 Copyright 2012  Michele "O-Zone" Pinassi
     10Copyright 2012-2013  Michele "O-Zone" Pinassi
    1111
    1212    This program is free software; you can redistribute it and/or modify
     
    4444global $wpdb;
    4545
    46 define(WP_MEETUP_ACTIVITY,'0.1.3');
     46define(WP_MEETUP_ACTIVITY,'0.1.4');
    4747define(WP_MEETUP_ACTIVITY_TABLE, $wpdb->prefix."meetup_activity");
    4848
     
    7070    ) DEFAULT CHARSET = utf8;
    7171
     72    CREATE TABLE ".WP_MEETUP_ACTIVITY_TABLE."_events (
     73    id int(10) NOT NULL AUTO_INCREMENT,
     74    group_id INT(12) NOT NULL,
     75    event_id INT(12) NOT NULL,
     76    event_title TEXT NOT NULL,
     77    event_address TEXT NOT NULL,
     78    event_description TEXT NOT NULL,
     79    event_datetime DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL,
     80    event_updated DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL,
     81    is_public SMALLINT(1) NOT NULL,
     82    event_status VARCHAR(16) NOT NULL,
     83    event_url TEXT NOT NULL,
     84    yes_rsvp INT(5) NOT NULL,
     85    add_date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
     86    PRIMARY KEY id (id),
     87    UNIQUE KEY event_id (event_id)
     88    ) DEFAULT CHARSET = utf8;
     89
    7290    CREATE TABLE ".WP_MEETUP_ACTIVITY_TABLE."_groups (
    7391    group_id mediumint(10) NOT NULL,
     
    7795    ) DEFAULT CHARSET = utf8;";
    7896
     97
    7998    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    8099    dbDelta($sql);
     
    118137            $groupsArray[$act['group_id']] = $act['group_name'];
    119138       
    120             $wpdb->query($wpdb->prepare("INSERT INTO ".WP_MEETUP_ACTIVITY_TABLE."_groups (group_id, group_name, add_date) VALUES ( %d, %s, NOW())", $act['group_id'], $act['group_name']));
     139            $wpdb->query($wpdb->prepare("INSERT IGNORE INTO ".WP_MEETUP_ACTIVITY_TABLE."_groups (group_id, group_name, add_date) VALUES ( %d, %s, NOW())", $act['group_id'], $act['group_name']));
    121140        }
    122141        }
     
    230249}
    231250
     251function wpmeetupactivity_fetch_events($verbose=false) {
     252    global $wpdb;
     253
     254    $apikey = get_option('wpmeetupactivity_apikey');
     255
     256    $fb_options = get_option('wpmeetupactivity_fb_options');
     257    $fb_pages = $fb_options['pages'];
     258
     259    $groupsArray = get_option('wpmeetupactivity_groups');
     260
     261    if(count($groupsArray) > 0) {
     262    if($apikey) {
     263        try {
     264        $connection = new MeetupKeyAuthConnection($apikey);
     265        $m = new MeetupEvents($connection);
     266        foreach($groupsArray as $groupId) {
     267            $events = $m->getEvents(array('group_id' => $groupId));
     268
     269            foreach($events as $event) {
     270            /* Array ( [visibility] => public
     271                [status] => upcoming
     272                [maybe_rsvp_count] => 0
     273                [venue] => Array (
     274                [id] => 11656882
     275                [lon] => 11.35083
     276                [repinned] =>
     277                [name] => Circolo CRAL
     278                [address_1] => via Algero Rosi 6
     279                [lat] => 43.31786
     280                [country] => it
     281                [city] => Siena
     282                )
     283                [id] => 103939182
     284                [utc_offset] => 3600000
     285                [time] => 1360958400000
     286                [waitlist_count] => 0
     287                [created] => 1360515889000
     288                [yes_rsvp_count] => 10
     289                [updated] => 1360617331000
     290                [event_url] => http://www.meetup.com/Gruppo-di-Siena/events/[id]/
     291                [description] => descrizione evento....
     292                [headcount] => 0
     293                [name] => Incontro con l'economista Filippo Abbate
     294                [group] => Array (
     295                [id] => 209457
     296                [group_lat] => 43.319999694824
     297                [name] => Forum di Siena
     298                [group_lon] => 11.329999923706
     299                [join_mode] => open
     300                [urlname] => Gruppo-di-Siena
     301                [who] => Amici di Siena
     302                )
     303            )  */
     304
     305            $eventId = $event['id'];
     306           
     307            $eventUpdated = gmdate("Y-m-d H:i:s",intval($event['updated'])/1000);
     308           
     309            $eventVenue = $event['venue']['name'].','.$event['venue']['city'];
     310
     311            /* If event_id is already present, check for update. Else add new event_id row. */
     312            $result = $wpdb->get_row("SELECT id,TIMESTAMPDIFF(MINUTE,event_updated,'$eventUpdated') AS tDelta FROM ".WP_MEETUP_ACTIVITY_TABLE."_events WHERE group_id='$groupId' AND event_id='$eventId';", ARRAY_A);
     313           
     314            if($result) {
     315                // L'evento esiste gia
     316                if($result['tDelta'] > 0) {
     317                $result = $wpdb->query( $wpdb->prepare( "UPDATE ".WP_MEETUP_ACTIVITY_TABLE."_events SET event_title='%s', event_address='%s', event_description='%s', event_datetime='%s',  event_updated='%s', event_status='%s', yes_rsvp=%d WHERE event_id=$eventId;", $event['name'],  $eventVenue,  $event['description'], gmdate("Y-m-d H:i:s",intval($event['time'])/1000), $eventUpdated, $event['status'], intval($event['yes_rsvp_count'])));
     318                if($verbose) {
     319                    echo "<div class=\"updated\"><p><strong>";
     320                    if($result) {
     321                    echo __('Updated event '.$eventId.': '.$event['name'], $wpmeetupactivity_textdomain);
     322                    } else {
     323                    echo __('DB SQL Error: '.$wpdb->print_error(), $wpmeetupactivity_textdomain);
     324                    }
     325                    echo "</strong></p></div>";
     326                }
     327                }
     328            } else {
     329                // L'evento non esiste: aggiungilo al DB !
     330                $result = $wpdb->query( $wpdb->prepare("INSERT INTO ".WP_MEETUP_ACTIVITY_TABLE."_events (group_id, event_id, event_title, event_address, event_description, event_datetime, event_updated, is_public, event_status, event_url, yes_rsvp, add_date) VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', 1, '%s', '%s', %d, NOW())", $groupId, $eventId, $event['name'], $eventVenue, $event['description'], gmdate("Y-m-d H:i:s",intval($event['time'])/1000), $eventUpdated, $event['status'], $event['event_url'], intval($event['yes_rsvp_count'])));
     331                if($verbose) {
     332                echo "<div class=\"updated\"><p><strong>";
     333                if($result) {
     334                    echo __('Added new event '.$eventId.': '.$event['name'], $wpmeetupactivity_textdomain);
     335                } else {
     336                    echo __('DB SQL Error: '.$wpdb->print_error(), $wpmeetupactivity_textdomain);
     337                }
     338                echo "</strong></p></div>";
     339                }
     340            }
     341            }
     342        }
     343        } catch (Exception $e) {
     344        echo "Meetup API error: $e";
     345        }
     346    }
     347    }
     348}
     349
     350
    232351function wpmeetupactivity_plugin_menu() {
    233352    add_options_page('WP-Meetup-Activity Plugin Options', 'WP-Meetup-Activity', 8, __FILE__, 'wpmeetupactivity_plugin_options');
     
    236355function wpmeetupactivity_widget_init() {
    237356    if ( function_exists( 'wp_register_sidebar_widget' ) ) {
    238     wp_register_sidebar_widget('wpmeetupactivity','WP-Meetup-Activity', 'wpmeetupactivity_widget');
     357    wp_register_sidebar_widget('wpmeetupactivity','WP-Meetup-Activity', 'wpmeetupactivity_widget_activity');
     358    wp_register_sidebar_widget('wpmeetupevents','WP-Meetup-Events', 'wpmeetupactivity_widget_events');
    239359    } else {
    240     register_sidebar_widget('WP-Meetup-Activity', 'wpmeetupactivity_widget');
     360    // Deprecated function for older WP...
     361    register_sidebar_widget('WP-Meetup-Activity', 'wpmeetupactivity_widget_activity');
     362    register_sidebar_widget('WP-Meetup-Events', 'wpmeetupactivity_widget_events');
    241363    }
    242364}
    243365
    244366function wpmeetupactivity_register_styles() {
    245     wp_register_style('wpmeetupactivity', plugins_url('default.css', __FILE__), array(), '20120822', 'all' );
     367    wp_register_style('wpmeetupactivity', plugins_url('default.css', __FILE__), array(), '20130215', 'all' );
    246368    wp_enqueue_style('wpmeetupactivity');
    247369}
     
    262384}
    263385
    264 function wpmeetupactivity_widget($args) {
     386function wpmeetupactivity_widget_events($args) {
     387    global $wpdb;
     388
     389    $monthArray = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
     390
     391    extract($args);
     392
     393    $title = get_option('wpmeetupactivity_events_title');
     394    $desc = get_option('wpmeetupactivity_events_desc');
     395
     396    $groupsArray = get_option('wpmeetupactivity_groups');
     397    $my_prefs = get_option('wpmeetupactivity_prefs');
     398
     399    echo $before_widget;
     400    echo $before_title . $title . $after_title;
     401
     402    if(count($groupsArray) > 0) {
     403    $events = $wpdb->get_results("SELECT * FROM ".WP_MEETUP_ACTIVITY_TABLE."_events WHERE DATEDIFF(event_datetime,NOW()) >= 0 ORDER BY event_datetime ASC LIMIT 3;",ARRAY_A);
     404   
     405    if($events) {
     406        $c=0;
     407        foreach($events as $event) {
     408        $eventUrl = $event['event_url'];
     409        $eventDate = date_parse($event['event_datetime']);
     410        $eventTitle = $event['event_title'];
     411       
     412        echo "<div class='wpmeetupactivity-event-widget-box'>
     413            <div class='wpmeetupactivity-event-widget-cal-box'>
     414            <div class='wpmeetupactivity-event-widget-cal-box-day'>".$eventDate['day']."</div>
     415            <div class='wpmeetupactivity-event-widget-cal-box-month'>".$monthArray[$eventDate['month']-1]." ".$eventDate['year']."</div>
     416            </div>
     417            <div class='wpmeetupactivity-event-widget-detail-box'>
     418            <a href='$eventUrl' title='$eventTitle' alt='$eventTitle' target=_new'><b class='wpmeetupactivity-event-widget-box-title'>".((strlen($eventTitle) > 35) ? substr($eventTitle,0,32).'...' : $eventTitle)."</b></a>
     419            <p>";
     420        echo str_replace(array("%ADDRESS%","%RSVP_YES%"),array($event['event_address'],$event['yes_rsvp']),$desc);
     421        echo "  </p>
     422            </div>
     423        </div>";
     424        $c = $c+1;
     425        if($c >= $my_prefs['displayEvents']) {
     426            break;
     427        }
     428        }
     429    } else {
     430        echo "<b>No events planned yet !</b>";
     431    }
     432    } else {
     433    echo "<b>No groups selected: did you set up the plugin ?</b>";
     434    }
     435
     436    echo $after_widget;
     437}
     438
     439
     440function wpmeetupactivity_widget_activity($args) {
    265441    global $wpdb;
    266442
     
    328504               
    329505        $disp_cnt = $disp_cnt+1;
    330         if($disp_cnt > $my_prefs["displayAct"]) {
     506        if($disp_cnt > $my_prefs['displayAct']) {
    331507            break;
    332508        }
     
    369545function wpmeetupactivity_plugin_cron_hourly() {
    370546    wpmeetupactivity_fetch_activity();
     547    wpmeetupactivity_fetch_events();
    371548}
    372549
     
    585762
    586763    $my_prefs["displayAct"] = intval($_POST["wpmeetupactivity_prefs_displayact"]);
     764    $my_prefs["displayEvents"] = intval($_POST["wpmeetupactivity_prefs_displayevents"]);
    587765    $my_prefs["orderBy"] = intval($_POST["wpmeetupactivity_prefs_orderby"]);
    588766
    589767    // Salva opzioni
    590768    update_option('wpmeetupactivity_apikey',$_POST['wpmeetupactivity_apikey']);
    591     update_option('wpmeetupactivity_title',$_POST['wpmeetupactivity_title']);
     769    update_option('wpmeetupactivity_title',$_POST['wpmeetupactivity_activity_title']);
     770    update_option('wpmeetupactivity_events_title',$_POST['wpmeetupactivity_events_title']);
     771    update_option('wpmeetupactivity_events_desc',$_POST['wpmeetupactivity_events_desc']);
    592772    update_option('wpmeetupactivity_groups',$myGroups);
    593773    update_option('wpmeetupactivity_prefs',$my_prefs);
     
    635815        echo __('Activities DB purged.', $wpmeetupactivity_textdomain);
    636816        echo "</strong></p></div>";
     817
     818        $wpdb->get_results("TRUNCATE ".WP_MEETUP_ACTIVITY_TABLE."_events;");
     819
     820        echo "<div class=\"updated\"><p><strong>";
     821        echo __('Events DB purged.', $wpmeetupactivity_textdomain);
     822        echo "</strong></p></div>";
    637823    }
    638824   
     
    643829        echo "</strong></p></div>";
    644830    }
     831
     832    if($_POST["wpmeetupactivity_force_event_fetch"] == 'on') {
     833        wpmeetupactivity_fetch_events(true);
     834        echo "<div class=\"updated\"><p><strong>";
     835        echo __('Events fetched successfully.', $wpmeetupactivity_textdomain);
     836        echo "</strong></p></div>";
     837    }
    645838   
    646839    }
     
    648841    $apikey = get_option('wpmeetupactivity_apikey');
    649842    $title = get_option('wpmeetupactivity_title');
     843    $title_events = get_option('wpmeetupactivity_events_title');
     844    $events_desc = get_option('wpmeetupactivity_events_desc');
    650845
    651846    echo "<div class='wrap'><!-- WRAP -->
     
    687882    </p>
    688883        <p>
    689         <input type='checkbox' name='wpmeetupactivity_purge_act_db'> Purge activity database
     884        <input type='checkbox' name='wpmeetupactivity_force_event_fetch'> Force events fetch on save changes
     885    </p>
     886        <p>
     887        <input type='checkbox' name='wpmeetupactivity_purge_act_db'> Purge database
    690888    </p>
    691889    <p>
    692         <i>TIP: Select both checkboxes to re-initialize activities db with new, fresh, data !</i>
     890        <i>TIP: Select all checkboxes to re-initialize activities and events db with new, fresh, data !</i>
    693891    </p>
    694892    </fieldset>";
     
    696894    echo "<fieldset class='wpmeetupactivity-setup-fieldset'><legend> Miscellaneous settings </legend>
    697895    <p>
    698     Widget title: <input type='text' size='64' name='wpmeetupactivity_title' value='$title' />
    699     </p>
    700     <p>
     896    Activity widget title: <input type='text' size='64' name='wpmeetupactivity_activity_title' value='$title' />
     897    </p><p>
     898    Events widget title: <input type='text' size='64' name='wpmeetupactivity_events_title' value='$title_events' />
     899    </p><p>
    701900    <input type='checkbox' name='wpmeetupactivity_prefs_opennewwindows' ".wpmeetupactivity_is_checked($my_prefs["openInNewWindow"]).">  Open link in a new window
    702     </p>
    703     <p>
     901    </p><p>
    704902    <input type='checkbox' name='wpmeetupactivity_prefs_displayauthor' ".wpmeetupactivity_is_checked($my_prefs["displayAuthor"])."> Display post author name
    705     </p>
    706     <p>
     903    </p><p>
    707904    <input type='checkbox' name='wpmeetupactivity_prefs_displaydate' ".wpmeetupactivity_is_checked($my_prefs["displayDate"])."> Display post date
    708     </p>
    709     <p>
     905    </p><p>
    710906    Max number of activities to show: <select name='wpmeetupactivity_prefs_displayact'>
    711907        <option value=2 ".wpmeetupactivity_is_selected($my_prefs["displayAct"],2).">2</option>
     
    715911        <option value=20 ".wpmeetupactivity_is_selected($my_prefs["displayAct"],20).">20</option>
    716912    </select>
    717     </p>
    718     <p>
     913    </p><p>
    719914    Order activities by: <select name='wpmeetupactivity_prefs_orderby'>
    720915        <option value='add_date' ".wpmeetupactivity_is_selected($my_prefs["orderBy"],'add_date').">Add date</option>
    721916        <option value='chg_date' ".wpmeetupactivity_is_selected($my_prefs["orderBy"],'chg_date').">Change date</option>
    722917        <option value='ranking' ".wpmeetupactivity_is_selected($my_prefs["orderBy"],'ranking').">Ranking</option>
     918    </select>
     919    </p><p>
     920    Events widget description: <input type='text' size='128' name='wpmeetupactivity_events_desc' value='".((strlen($events_desc) > 0) ? $events_desc : "at %ADDRESS%. There are already %RSVP_YES% booked friends !")."' />
     921    <p class='wpmeetupactivity-tipbox'>You can use HTML tags and the following special variables: %ADDRESS%=Venue of the event | %RSVP_YES%=How many peoples will partecipate</p>
     922    </p><p>
     923    Max number of events to show: <select name='wpmeetupactivity_prefs_displayevents'>
     924        <option value=1 ".wpmeetupactivity_is_selected($my_prefs["displayEvents"],1).">1</option>
     925        <option value=2 ".wpmeetupactivity_is_selected($my_prefs["displayEvents"],2).">2</option>
     926        <option value=3 ".wpmeetupactivity_is_selected($my_prefs["displayEvents"],3).">3</option>
     927        <option value=4 ".wpmeetupactivity_is_selected($my_prefs["displayEvents"],4).">4</option>
     928        <option value=5 ".wpmeetupactivity_is_selected($my_prefs["displayEvents"],5).">5</option>
    723929    </select>
    724930    </p>
     
    751957    </p><p>
    752958        App Secret: <input type='text' size='128' name='wpmeetupactivity_fb_appsecret' value='".$fb_options['app_secret']."' />
    753     </p></fieldset>";
     959    </p>";
    754960    if ($fb_user) {
    755961        echo "<fieldset class='wpmeetupactivity-setup-fieldset'><legend> Facebook Post-on-Page </legend>
     
    782988    }
    783989    }
    784     echo "<p class='submit'><input type='submit' name='Submit' value='Save changes' /></p>
    785     </form>
    786     </div><!-- /WRAP -->";
     990    echo "</fieldset><p class='submit'><input type='submit' name='Submit' value='Save changes' /></p>
     991    </form></div><!-- /WRAP -->";
    787992}
    788993
  • wp-meetup-activity/trunk/default.css

    r589800 r668363  
    1919    color: #fff;
    2020}
     21
     22.wpmeetupactivity-event-widget-box {
     23    clear: both;
     24}
     25
     26.wpmeetupactivity-event-widget-box-title {
     27    font-size: 1.2em;
     28    padding: 1px;
     29}
     30
     31.wpmeetupactivity-event-widget-cal-box {
     32    float: left;
     33    width: 54px;
     34    height: 54px;
     35    border-radius: 5px;
     36    padding: 4px;
     37    margin: 2px;
     38    background: #3B5998;
     39    text-align: center;
     40}
     41
     42.wpmeetupactivity-event-widget-cal-box-day {
     43    font-size: 2em;
     44    color: #fff;
     45    text-align: center;
     46}
     47
     48.wpmeetupactivity-event-widget-cal-box-month {
     49    font-size: 0.8em;
     50    color: #fff;
     51    text-align: center;
     52}
     53
     54.wpmeetupactivity-event-widget-detail-box {
     55    font-size: 1.0em;
     56    text-align: justify;
     57    margin: 2px;
     58}
     59
     60.wpmeetupactivity-tipbox {
     61    padding: 8px;
     62    color: #333;
     63    font-size: 0.8em;
     64    background: #FF9;
     65    border: 1px solid #FC0;
     66    -moz-border-radius: 2px;
     67    border-radius: 2px;
     68    text-align: justify;
     69}
  • wp-meetup-activity/trunk/readme.txt

    r592392 r668363  
    22Contributors: o-zone
    33Donate link: http://www.zerozone.it
    4 Tags: meetup, activity, meetup.com, group, facebook
     4Tags: meetup, activity, meetup.com, events, group
    55Requires at least: 3.0
    6 Tested up to: 3.4.1
     6Tested up to: 3.5.1
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
    99
    10 WP-Meetup-Activity display your groups latest activities (discussions, photos...) in a sidebar widget. Can also post directly to facebook pages new threads and replies
     10WP-Meetup-Activity display your groups latest activities (discussions, photos...) and events in a sidebar widget
    1111
    1212== Description ==
     
    22222. Activate the plugin through the 'Plugins' menu in WordPress
    23233. Add the widget wherever you want
    24 
    25 if you want to enable facebook Post-to-page feature, you need to create a new app:
    26 
    27 1. Open your browser to https://developers.facebook.com/apps
    28 2. Click on "Create new application" on top right
    29 3. Set domain URLs
    30 4. Write app Id and app secret on wp-meetup-activity setup page
    31 5. Connect widget with your Facebook application, allowing manage_pages and offline_access rights
     244. Set it up !
    3225
    3326== Frequently Asked Questions ==
     
    4740== Changelog ==
    4841
    49 = 0.1.3 =
    50 * Enable/disable Facebook support
    51 * Fixed some Facebook issue with other plugins (like "Facebook for Wordpress")
    52 
    53 = 0.1.2 =
    54 * Facebook support for Post-in-Page on new topics / reply
    55 * Minor bugs fixed
     42= 0.1.4 =
     43* Added Meetup events support
     44* Some bugs fixed and minor code cleanups
    5645
    5746= 0.1.1 =
     
    7564== Upgrade Notice ==
    7665
     66= 0.1.4 =
     67Added Meetup events support. Can you miss it ?
     68
    7769= 0.1.1 =
    7870Database should upgrade automatically but please deactivate and reactivate the plugin after upgrade.
  • wp-meetup-activity/trunk/wp-meetup-activity.php

    r592392 r668363  
    33Plugin Name: WP Meetup Activity
    44Plugin URI: http://www.zerozone.it/wordpress-meetup-plugin/
    5 Description: Display group activity from Meetup.com in a widget for your wordpress
    6 Version: 0.1.3
     5Description: Display group activity and events from Meetup.com in a widget for your wordpress
     6Version: 0.1.4
    77Author: Michele "O-Zone" Pinassi
    88Author URI: http://www.zerozone.it/
    99
    10 Copyright 2012  Michele "O-Zone" Pinassi
     10Copyright 2012-2013  Michele "O-Zone" Pinassi
    1111
    1212    This program is free software; you can redistribute it and/or modify
     
    4444global $wpdb;
    4545
    46 define(WP_MEETUP_ACTIVITY,'0.1.3');
     46define(WP_MEETUP_ACTIVITY,'0.1.4');
    4747define(WP_MEETUP_ACTIVITY_TABLE, $wpdb->prefix."meetup_activity");
    4848
     
    7070    ) DEFAULT CHARSET = utf8;
    7171
     72    CREATE TABLE ".WP_MEETUP_ACTIVITY_TABLE."_events (
     73    id int(10) NOT NULL AUTO_INCREMENT,
     74    group_id INT(12) NOT NULL,
     75    event_id INT(12) NOT NULL,
     76    event_title TEXT NOT NULL,
     77    event_address TEXT NOT NULL,
     78    event_description TEXT NOT NULL,
     79    event_datetime DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL,
     80    event_updated DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL,
     81    is_public SMALLINT(1) NOT NULL,
     82    event_status VARCHAR(16) NOT NULL,
     83    event_url TEXT NOT NULL,
     84    yes_rsvp INT(5) NOT NULL,
     85    add_date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
     86    PRIMARY KEY id (id),
     87    UNIQUE KEY event_id (event_id)
     88    ) DEFAULT CHARSET = utf8;
     89
    7290    CREATE TABLE ".WP_MEETUP_ACTIVITY_TABLE."_groups (
    7391    group_id mediumint(10) NOT NULL,
     
    7795    ) DEFAULT CHARSET = utf8;";
    7896
     97
    7998    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    8099    dbDelta($sql);
     
    118137            $groupsArray[$act['group_id']] = $act['group_name'];
    119138       
    120             $wpdb->query($wpdb->prepare("INSERT INTO ".WP_MEETUP_ACTIVITY_TABLE."_groups (group_id, group_name, add_date) VALUES ( %d, %s, NOW())", $act['group_id'], $act['group_name']));
     139            $wpdb->query($wpdb->prepare("INSERT IGNORE INTO ".WP_MEETUP_ACTIVITY_TABLE."_groups (group_id, group_name, add_date) VALUES ( %d, %s, NOW())", $act['group_id'], $act['group_name']));
    121140        }
    122141        }
     
    230249}
    231250
     251function wpmeetupactivity_fetch_events($verbose=false) {
     252    global $wpdb;
     253
     254    $apikey = get_option('wpmeetupactivity_apikey');
     255
     256    $fb_options = get_option('wpmeetupactivity_fb_options');
     257    $fb_pages = $fb_options['pages'];
     258
     259    $groupsArray = get_option('wpmeetupactivity_groups');
     260
     261    if(count($groupsArray) > 0) {
     262    if($apikey) {
     263        try {
     264        $connection = new MeetupKeyAuthConnection($apikey);
     265        $m = new MeetupEvents($connection);
     266        foreach($groupsArray as $groupId) {
     267            $events = $m->getEvents(array('group_id' => $groupId));
     268
     269            foreach($events as $event) {
     270            /* Array ( [visibility] => public
     271                [status] => upcoming
     272                [maybe_rsvp_count] => 0
     273                [venue] => Array (
     274                [id] => 11656882
     275                [lon] => 11.35083
     276                [repinned] =>
     277                [name] => Circolo CRAL
     278                [address_1] => via Algero Rosi 6
     279                [lat] => 43.31786
     280                [country] => it
     281                [city] => Siena
     282                )
     283                [id] => 103939182
     284                [utc_offset] => 3600000
     285                [time] => 1360958400000
     286                [waitlist_count] => 0
     287                [created] => 1360515889000
     288                [yes_rsvp_count] => 10
     289                [updated] => 1360617331000
     290                [event_url] => http://www.meetup.com/Gruppo-di-Siena/events/[id]/
     291                [description] => descrizione evento....
     292                [headcount] => 0
     293                [name] => Incontro con l'economista Filippo Abbate
     294                [group] => Array (
     295                [id] => 209457
     296                [group_lat] => 43.319999694824
     297                [name] => Forum di Siena
     298                [group_lon] => 11.329999923706
     299                [join_mode] => open
     300                [urlname] => Gruppo-di-Siena
     301                [who] => Amici di Siena
     302                )
     303            )  */
     304
     305            $eventId = $event['id'];
     306           
     307            $eventUpdated = gmdate("Y-m-d H:i:s",intval($event['updated'])/1000);
     308           
     309            $eventVenue = $event['venue']['name'].','.$event['venue']['city'];
     310
     311            /* If event_id is already present, check for update. Else add new event_id row. */
     312            $result = $wpdb->get_row("SELECT id,TIMESTAMPDIFF(MINUTE,event_updated,'$eventUpdated') AS tDelta FROM ".WP_MEETUP_ACTIVITY_TABLE."_events WHERE group_id='$groupId' AND event_id='$eventId';", ARRAY_A);
     313           
     314            if($result) {
     315                // L'evento esiste gia
     316                if($result['tDelta'] > 0) {
     317                $result = $wpdb->query( $wpdb->prepare( "UPDATE ".WP_MEETUP_ACTIVITY_TABLE."_events SET event_title='%s', event_address='%s', event_description='%s', event_datetime='%s',  event_updated='%s', event_status='%s', yes_rsvp=%d WHERE event_id=$eventId;", $event['name'],  $eventVenue,  $event['description'], gmdate("Y-m-d H:i:s",intval($event['time'])/1000), $eventUpdated, $event['status'], intval($event['yes_rsvp_count'])));
     318                if($verbose) {
     319                    echo "<div class=\"updated\"><p><strong>";
     320                    if($result) {
     321                    echo __('Updated event '.$eventId.': '.$event['name'], $wpmeetupactivity_textdomain);
     322                    } else {
     323                    echo __('DB SQL Error: '.$wpdb->print_error(), $wpmeetupactivity_textdomain);
     324                    }
     325                    echo "</strong></p></div>";
     326                }
     327                }
     328            } else {
     329                // L'evento non esiste: aggiungilo al DB !
     330                $result = $wpdb->query( $wpdb->prepare("INSERT INTO ".WP_MEETUP_ACTIVITY_TABLE."_events (group_id, event_id, event_title, event_address, event_description, event_datetime, event_updated, is_public, event_status, event_url, yes_rsvp, add_date) VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', 1, '%s', '%s', %d, NOW())", $groupId, $eventId, $event['name'], $eventVenue, $event['description'], gmdate("Y-m-d H:i:s",intval($event['time'])/1000), $eventUpdated, $event['status'], $event['event_url'], intval($event['yes_rsvp_count'])));
     331                if($verbose) {
     332                echo "<div class=\"updated\"><p><strong>";
     333                if($result) {
     334                    echo __('Added new event '.$eventId.': '.$event['name'], $wpmeetupactivity_textdomain);
     335                } else {
     336                    echo __('DB SQL Error: '.$wpdb->print_error(), $wpmeetupactivity_textdomain);
     337                }
     338                echo "</strong></p></div>";
     339                }
     340            }
     341            }
     342        }
     343        } catch (Exception $e) {
     344        echo "Meetup API error: $e";
     345        }
     346    }
     347    }
     348}
     349
     350
    232351function wpmeetupactivity_plugin_menu() {
    233352    add_options_page('WP-Meetup-Activity Plugin Options', 'WP-Meetup-Activity', 8, __FILE__, 'wpmeetupactivity_plugin_options');
     
    236355function wpmeetupactivity_widget_init() {
    237356    if ( function_exists( 'wp_register_sidebar_widget' ) ) {
    238     wp_register_sidebar_widget('wpmeetupactivity','WP-Meetup-Activity', 'wpmeetupactivity_widget');
     357    wp_register_sidebar_widget('wpmeetupactivity','WP-Meetup-Activity', 'wpmeetupactivity_widget_activity');
     358    wp_register_sidebar_widget('wpmeetupevents','WP-Meetup-Events', 'wpmeetupactivity_widget_events');
    239359    } else {
    240     register_sidebar_widget('WP-Meetup-Activity', 'wpmeetupactivity_widget');
     360    // Deprecated function for older WP...
     361    register_sidebar_widget('WP-Meetup-Activity', 'wpmeetupactivity_widget_activity');
     362    register_sidebar_widget('WP-Meetup-Events', 'wpmeetupactivity_widget_events');
    241363    }
    242364}
    243365
    244366function wpmeetupactivity_register_styles() {
    245     wp_register_style('wpmeetupactivity', plugins_url('default.css', __FILE__), array(), '20120822', 'all' );
     367    wp_register_style('wpmeetupactivity', plugins_url('default.css', __FILE__), array(), '20130215', 'all' );
    246368    wp_enqueue_style('wpmeetupactivity');
    247369}
     
    262384}
    263385
    264 function wpmeetupactivity_widget($args) {
     386function wpmeetupactivity_widget_events($args) {
     387    global $wpdb;
     388
     389    $monthArray = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
     390
     391    extract($args);
     392
     393    $title = get_option('wpmeetupactivity_events_title');
     394    $desc = get_option('wpmeetupactivity_events_desc');
     395
     396    $groupsArray = get_option('wpmeetupactivity_groups');
     397    $my_prefs = get_option('wpmeetupactivity_prefs');
     398
     399    echo $before_widget;
     400    echo $before_title . $title . $after_title;
     401
     402    if(count($groupsArray) > 0) {
     403    $events = $wpdb->get_results("SELECT * FROM ".WP_MEETUP_ACTIVITY_TABLE."_events WHERE DATEDIFF(event_datetime,NOW()) >= 0 ORDER BY event_datetime ASC LIMIT 3;",ARRAY_A);
     404   
     405    if($events) {
     406        $c=0;
     407        foreach($events as $event) {
     408        $eventUrl = $event['event_url'];
     409        $eventDate = date_parse($event['event_datetime']);
     410        $eventTitle = $event['event_title'];
     411       
     412        echo "<div class='wpmeetupactivity-event-widget-box'>
     413            <div class='wpmeetupactivity-event-widget-cal-box'>
     414            <div class='wpmeetupactivity-event-widget-cal-box-day'>".$eventDate['day']."</div>
     415            <div class='wpmeetupactivity-event-widget-cal-box-month'>".$monthArray[$eventDate['month']-1]." ".$eventDate['year']."</div>
     416            </div>
     417            <div class='wpmeetupactivity-event-widget-detail-box'>
     418            <a href='$eventUrl' title='$eventTitle' alt='$eventTitle' target=_new'><b class='wpmeetupactivity-event-widget-box-title'>".((strlen($eventTitle) > 35) ? substr($eventTitle,0,32).'...' : $eventTitle)."</b></a>
     419            <p>";
     420        echo str_replace(array("%ADDRESS%","%RSVP_YES%"),array($event['event_address'],$event['yes_rsvp']),$desc);
     421        echo "  </p>
     422            </div>
     423        </div>";
     424        $c = $c+1;
     425        if($c >= $my_prefs['displayEvents']) {
     426            break;
     427        }
     428        }
     429    } else {
     430        echo "<b>No events planned yet !</b>";
     431    }
     432    } else {
     433    echo "<b>No groups selected: did you set up the plugin ?</b>";
     434    }
     435
     436    echo $after_widget;
     437}
     438
     439
     440function wpmeetupactivity_widget_activity($args) {
    265441    global $wpdb;
    266442
     
    328504               
    329505        $disp_cnt = $disp_cnt+1;
    330         if($disp_cnt > $my_prefs["displayAct"]) {
     506        if($disp_cnt > $my_prefs['displayAct']) {
    331507            break;
    332508        }
     
    369545function wpmeetupactivity_plugin_cron_hourly() {
    370546    wpmeetupactivity_fetch_activity();
     547    wpmeetupactivity_fetch_events();
    371548}
    372549
     
    585762
    586763    $my_prefs["displayAct"] = intval($_POST["wpmeetupactivity_prefs_displayact"]);
     764    $my_prefs["displayEvents"] = intval($_POST["wpmeetupactivity_prefs_displayevents"]);
    587765    $my_prefs["orderBy"] = intval($_POST["wpmeetupactivity_prefs_orderby"]);
    588766
    589767    // Salva opzioni
    590768    update_option('wpmeetupactivity_apikey',$_POST['wpmeetupactivity_apikey']);
    591     update_option('wpmeetupactivity_title',$_POST['wpmeetupactivity_title']);
     769    update_option('wpmeetupactivity_title',$_POST['wpmeetupactivity_activity_title']);
     770    update_option('wpmeetupactivity_events_title',$_POST['wpmeetupactivity_events_title']);
     771    update_option('wpmeetupactivity_events_desc',$_POST['wpmeetupactivity_events_desc']);
    592772    update_option('wpmeetupactivity_groups',$myGroups);
    593773    update_option('wpmeetupactivity_prefs',$my_prefs);
     
    635815        echo __('Activities DB purged.', $wpmeetupactivity_textdomain);
    636816        echo "</strong></p></div>";
     817
     818        $wpdb->get_results("TRUNCATE ".WP_MEETUP_ACTIVITY_TABLE."_events;");
     819
     820        echo "<div class=\"updated\"><p><strong>";
     821        echo __('Events DB purged.', $wpmeetupactivity_textdomain);
     822        echo "</strong></p></div>";
    637823    }
    638824   
     
    643829        echo "</strong></p></div>";
    644830    }
     831
     832    if($_POST["wpmeetupactivity_force_event_fetch"] == 'on') {
     833        wpmeetupactivity_fetch_events(true);
     834        echo "<div class=\"updated\"><p><strong>";
     835        echo __('Events fetched successfully.', $wpmeetupactivity_textdomain);
     836        echo "</strong></p></div>";
     837    }
    645838   
    646839    }
     
    648841    $apikey = get_option('wpmeetupactivity_apikey');
    649842    $title = get_option('wpmeetupactivity_title');
     843    $title_events = get_option('wpmeetupactivity_events_title');
     844    $events_desc = get_option('wpmeetupactivity_events_desc');
    650845
    651846    echo "<div class='wrap'><!-- WRAP -->
     
    687882    </p>
    688883        <p>
    689         <input type='checkbox' name='wpmeetupactivity_purge_act_db'> Purge activity database
     884        <input type='checkbox' name='wpmeetupactivity_force_event_fetch'> Force events fetch on save changes
     885    </p>
     886        <p>
     887        <input type='checkbox' name='wpmeetupactivity_purge_act_db'> Purge database
    690888    </p>
    691889    <p>
    692         <i>TIP: Select both checkboxes to re-initialize activities db with new, fresh, data !</i>
     890        <i>TIP: Select all checkboxes to re-initialize activities and events db with new, fresh, data !</i>
    693891    </p>
    694892    </fieldset>";
     
    696894    echo "<fieldset class='wpmeetupactivity-setup-fieldset'><legend> Miscellaneous settings </legend>
    697895    <p>
    698     Widget title: <input type='text' size='64' name='wpmeetupactivity_title' value='$title' />
    699     </p>
    700     <p>
     896    Activity widget title: <input type='text' size='64' name='wpmeetupactivity_activity_title' value='$title' />
     897    </p><p>
     898    Events widget title: <input type='text' size='64' name='wpmeetupactivity_events_title' value='$title_events' />
     899    </p><p>
    701900    <input type='checkbox' name='wpmeetupactivity_prefs_opennewwindows' ".wpmeetupactivity_is_checked($my_prefs["openInNewWindow"]).">  Open link in a new window
    702     </p>
    703     <p>
     901    </p><p>
    704902    <input type='checkbox' name='wpmeetupactivity_prefs_displayauthor' ".wpmeetupactivity_is_checked($my_prefs["displayAuthor"])."> Display post author name
    705     </p>
    706     <p>
     903    </p><p>
    707904    <input type='checkbox' name='wpmeetupactivity_prefs_displaydate' ".wpmeetupactivity_is_checked($my_prefs["displayDate"])."> Display post date
    708     </p>
    709     <p>
     905    </p><p>
    710906    Max number of activities to show: <select name='wpmeetupactivity_prefs_displayact'>
    711907        <option value=2 ".wpmeetupactivity_is_selected($my_prefs["displayAct"],2).">2</option>
     
    715911        <option value=20 ".wpmeetupactivity_is_selected($my_prefs["displayAct"],20).">20</option>
    716912    </select>
    717     </p>
    718     <p>
     913    </p><p>
    719914    Order activities by: <select name='wpmeetupactivity_prefs_orderby'>
    720915        <option value='add_date' ".wpmeetupactivity_is_selected($my_prefs["orderBy"],'add_date').">Add date</option>
    721916        <option value='chg_date' ".wpmeetupactivity_is_selected($my_prefs["orderBy"],'chg_date').">Change date</option>
    722917        <option value='ranking' ".wpmeetupactivity_is_selected($my_prefs["orderBy"],'ranking').">Ranking</option>
     918    </select>
     919    </p><p>
     920    Events widget description: <input type='text' size='128' name='wpmeetupactivity_events_desc' value='".((strlen($events_desc) > 0) ? $events_desc : "at %ADDRESS%. There are already %RSVP_YES% booked friends !")."' />
     921    <p class='wpmeetupactivity-tipbox'>You can use HTML tags and the following special variables: %ADDRESS%=Venue of the event | %RSVP_YES%=How many peoples will partecipate</p>
     922    </p><p>
     923    Max number of events to show: <select name='wpmeetupactivity_prefs_displayevents'>
     924        <option value=1 ".wpmeetupactivity_is_selected($my_prefs["displayEvents"],1).">1</option>
     925        <option value=2 ".wpmeetupactivity_is_selected($my_prefs["displayEvents"],2).">2</option>
     926        <option value=3 ".wpmeetupactivity_is_selected($my_prefs["displayEvents"],3).">3</option>
     927        <option value=4 ".wpmeetupactivity_is_selected($my_prefs["displayEvents"],4).">4</option>
     928        <option value=5 ".wpmeetupactivity_is_selected($my_prefs["displayEvents"],5).">5</option>
    723929    </select>
    724930    </p>
     
    751957    </p><p>
    752958        App Secret: <input type='text' size='128' name='wpmeetupactivity_fb_appsecret' value='".$fb_options['app_secret']."' />
    753     </p></fieldset>";
     959    </p>";
    754960    if ($fb_user) {
    755961        echo "<fieldset class='wpmeetupactivity-setup-fieldset'><legend> Facebook Post-on-Page </legend>
     
    782988    }
    783989    }
    784     echo "<p class='submit'><input type='submit' name='Submit' value='Save changes' /></p>
    785     </form>
    786     </div><!-- /WRAP -->";
     990    echo "</fieldset><p class='submit'><input type='submit' name='Submit' value='Save changes' /></p>
     991    </form></div><!-- /WRAP -->";
    787992}
    788993
Note: See TracChangeset for help on using the changeset viewer.