Plugin Directory

Changeset 196389


Ignore:
Timestamp:
01/21/2010 08:38:42 PM (16 years ago)
Author:
zeeg
Message:

Support for group_keys

Location:
lifestream/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • lifestream/trunk/CHANGES

    r193355 r196389  
     10.99.9.7
     2
     3* Added WoW Armory extension by gizzmo.
     4* Events can now be grouped by any value, not just the event key (but still are date-based).
     5* Installation should now work on installs that do not use MyISAM.
     6
    170.99.9.6
    28
  • lifestream/trunk/extensions/README

    r120013 r196389  
    1212
    1313    $lifestream->register_feed('ClassName');
     14
     15Also, please fill out the AUTHOR constant in your plugin. It will be modified as changes are submitted:
     16
     17    class LifeStream_WoWArmoryFeed extends LifeStream_Feed {
     18        const ID            = 'wowarmory';
     19        const NAME          = 'WoW Armory';
     20        const URL           = 'http://www.wowarmory.com/';
     21        const DESCRIPTION   = 'Display your character\'s Activity feed. (Achievement, Boss Kills, Loot)';
     22        const AUTHOR        = '<Put your name in here, as well as any names who committed to this extension>'
     23    }
     24
     25The easiest way to contribute your extension back to the main project is by using GitHub.
     26
     271. Create an account on GitHub.com
     282. Visit http://github.com/dcramer/wp-lifestream and "Fork".
     293. On your new Fork, do a clone of your repository: `git clone git://github.com/<your username>/wp-lifestream.git`
     304. Add your extension in extensions/
     315. TEST, TEST, TEST!
     326. Visit http://github.com/dcramer/wp-lifestream and click "Pull Request" and write a brief description of your changes.
     337. Wait for the authors of wp-lifestream to accept your contributions.
  • lifestream/trunk/extensions/github/extension.inc.php

    r195894 r196389  
    4444            $data['branch'] = $repo[0];
    4545            $data['repository'] = $repo[1];
    46             $data['groupid'] = $data['repository'];
     46            $data['group_key'] = $data['repository'];
    4747            return $data;
    4848        }
  • lifestream/trunk/inc/core.php

    r195894 r196389  
    1818}
    1919
    20 function lifestream_array_key_pop($array, $key)
     20function lifestream_array_key_pop($array, $key, $default=null)
    2121{
    2222    $value = @$array[$key];
    2323    unset($array[$key]);
     24    if (!$value) $value = $default;
    2425    return $value;
    2526}
     
    10711072                                $values['feed_label'] = $_POST['feed_label'];
    10721073                                $values['icon_url'] = $_POST['icon_url'];
    1073                                 $values['auto_icon'] = $_POST['auto_icon'];
     1074                                $values['auto_icon'] = @$_POST['auto_icon'];
    10741075                                if ($_POST['owner'] != $instance->owner_id && current_user_can('manage_options'))
    10751076                                {
     
    16811682          `version` int(11) default 0 NOT NULL,
    16821683          `key` char(16) NOT NULL,
     1684          `group_key` char(32) NOT NULL,
    16831685          `owner` varchar(128) NOT NULL,
    16841686          `owner_id` int(11) NOT NULL,
    16851687          PRIMARY KEY  (`id`),
    16861688          INDEX `feed` (`feed`),
    1687           UNIQUE `feed_id` (`feed_id`, `key`, `owner_id`, `link`)
    1688         ) ENGINE=MyISAM;");
     1689          UNIQUE `feed_id` (`feed_id`, `group_key`, `owner_id`, `link`)
     1690        );");
    16891691
    16901692        $this->safe_query("CREATE TABLE IF NOT EXISTS `".$wpdb->prefix."lifestream_event_group` (
     
    17001702          `version` int(11) default 0 NOT NULL,
    17011703          `key` char(16) NOT NULL,
     1704          `group_key` char(32) NOT NULL,
    17021705          `owner` varchar(128) NOT NULL,
    17031706          `owner_id` int(11) NOT NULL,
    17041707          PRIMARY KEY  (`id`),
    17051708          INDEX `feed` (`feed`),
    1706           INDEX `feed_id` (`feed_id`, `key`, `owner_id`, `timestamp`)
    1707         ) ENGINE=MyISAM;");
     1709          INDEX `feed_id` (`feed_id`, `group_key`, `owner_id`, `timestamp`)
     1710        );");
    17081711
    17091712        $this->safe_query("CREATE TABLE IF NOT EXISTS `".$wpdb->prefix."lifestream_feeds` (
     
    17181721          INDEX `owner_id` (`owner_id`),
    17191722          PRIMARY KEY  (`id`)
    1720         ) ENGINE=MyISAM;");
     1723        );");
    17211724
    17221725        $this->safe_query("CREATE TABLE IF NOT EXISTS `".$wpdb->prefix."lifestream_error_log` (
     
    17301733          INDEX `has_viewed` (`has_viewed`),
    17311734          PRIMARY KEY  (`id`)
    1732         ) ENGINE=MyISAM;");
     1735        );");
    17331736
    17341737        if (!$version) return;
     
    17781781        {
    17791782            $wpdb->query("UPDATE `".$wpdb->prefix."lifestream_feeds` SET `active` = 1");
     1783        }
     1784        if (version_compare($version, '0.99.9.7', '<'))
     1785        {
     1786            $wpdb->query("ALTER IGNORE TABLE `".$wpdb->prefix."lifestream_event` ADD `group_key` char(32) NOT NULL AFTER `key`, DROP KEY `feed_id`, ADD UNIQUE `feed_id` (`feed_id`, `group_key`, `owner_id`, `link`)");
     1787            $wpdb->query("ALTER IGNORE TABLE `".$wpdb->prefix."lifestream_event_group` ADD `group_key` char(32) NOT NULL AFTER `key`, DROP KEY `feed_id`, ADD UNIQUE `feed_id` (`feed_id`, `group_key`, `owner_id`, `timestamp`)");
     1788            $wpdb->query("UPDATE `".$wpdb->prefix."lifestream_event` SET `group_key` = md5(`key`)");
     1789            $wpdb->query("UPDATE `".$wpdb->prefix."lifestream_event_group` SET `group_key` = md5(`key`)");
    17801790        }
    17811791    }
     
    22962306            $date = lifestream_array_key_pop($item, 'date');
    22972307            $key = lifestream_array_key_pop($item, 'key');
     2308            $group_key = md5(lifestream_array_key_pop($item, 'group_key', $key));
     2309
    22982310            if (!($date > 0)) $date = $default_timestamp;
    22992311           
     
    23122324            }
    23132325           
    2314             $affected = $wpdb->query($wpdb->prepare("INSERT IGNORE INTO `".$wpdb->prefix."lifestream_event` (`feed_id`, `feed`, `link`, `data`, `timestamp`, `version`, `key`, `owner`, `owner_id`) VALUES (%d, %s, %s, %s, %d, %d, %s, %s, %d)", $this->id, $this->get_constant('ID'), $link_key, serialize($item), $date, $this->get_constant('VERSION'), $key, $this->owner, $this->owner_id));
     2326            $affected = $wpdb->query($wpdb->prepare("INSERT IGNORE INTO `".$wpdb->prefix."lifestream_event` (`feed_id`, `feed`, `link`, `data`, `timestamp`, `version`, `key`, `group_key`, `owner`, `owner_id`) VALUES (%d, %s, %s, %s, %d, %d, %s, %s, %s, %d)", $this->id, $this->get_constant('ID'), $link_key, serialize($item), $date, $this->get_constant('VERSION'), $key, $group_key, $this->owner, $this->owner_id));
    23152327            if ($affected)
    23162328            {
     
    23182330                $item['date'] = $date;
    23192331                $item['key'] = $key;
    2320 
     2332                $item['group_key'] = $group_key;
    23212333                $total += 1;
    23222334
     
    23242336                if ($this->get_option('grouped') && $this->get_constant('CAN_GROUP') && constant(sprintf('%s::%s', $label, 'CAN_GROUP')))
    23252337                {
    2326                     if (!array_key_exists($key, $grouped)) $grouped[$key] = array();
    2327                     $grouped[$key][date('m d Y', $date)] = $date;
     2338                    if (!array_key_exists($group_key, $grouped)) $grouped[$group_key] = array();
     2339                    $grouped[$group_key][date('m d Y', $date)] = $date;
    23282340                }
    23292341                else
     
    23382350        }
    23392351        // Grouping them by key
    2340         foreach ($grouped as $key=>$dates)
     2352        foreach ($grouped as $group_key=>$dates)
    23412353        {
    23422354            // Grouping them by date
     
    23452357                // Get all of the current events for this date
    23462358                // (including the one we affected just now)
    2347                 $results =& $wpdb->get_results($wpdb->prepare("SELECT `data`, `link` FROM `".$wpdb->prefix."lifestream_event` WHERE `feed_id` = %d AND `visible` = 1 AND DATE(FROM_UNIXTIME(`timestamp`)) = DATE(FROM_UNIXTIME(%d)) AND `key` = %s", $this->id, $date, $key));
     2359                $results =& $wpdb->get_results($wpdb->prepare("SELECT `data`, `link` FROM `".$wpdb->prefix."lifestream_event` WHERE `feed_id` = %d AND `visible` = 1 AND DATE(FROM_UNIXTIME(`timestamp`)) = DATE(FROM_UNIXTIME(%d)) AND `group_key` = %s", $this->id, $date, $group_key));
    23482360                $events = array();
    23492361                foreach ($results as &$result)
     
    23552367
    23562368                // First let's see if the group already exists in the database
    2357                 $group =& $wpdb->get_results($wpdb->prepare("SELECT `id` FROM `".$wpdb->prefix."lifestream_event_group` WHERE `feed_id` = %d AND DATE(FROM_UNIXTIME(`timestamp`)) = DATE(FROM_UNIXTIME(%d)) AND `key` = %s LIMIT 0, 1", $this->id, $date, $key));
     2369                $group =& $wpdb->get_results($wpdb->prepare("SELECT `id` FROM `".$wpdb->prefix."lifestream_event_group` WHERE `feed_id` = %d AND DATE(FROM_UNIXTIME(`timestamp`)) = DATE(FROM_UNIXTIME(%d)) AND `group_key` = %s LIMIT 0, 1", $this->id, $date, $group_key));
    23582370                if (count($group) == 1)
    23592371                {
     
    23632375                else
    23642376                {
    2365                     $wpdb->query($wpdb->prepare("INSERT INTO `".$wpdb->prefix."lifestream_event_group` (`feed_id`, `feed`, `data`, `total`, `timestamp`, `version`, `key`, `owner`, `owner_id`) VALUES(%d, %s, %s, %d, %d, %d, %s, %s, %d)", $this->id, $this->get_constant('ID'), serialize($events), count($events), $date, $this->get_constant('VERSION'), $key, $this->owner, $this->owner_id));
     2377                    $wpdb->query($wpdb->prepare("INSERT INTO `".$wpdb->prefix."lifestream_event_group` (`feed_id`, `feed`, `data`, `total`, `timestamp`, `version`, `key`, `group_key`, `owner`, `owner_id`) VALUES(%d, %s, %s, %d, %d, %d, %s, %s, %s, %d)", $this->id, $this->get_constant('ID'), serialize($events), count($events), $date, $this->get_constant('VERSION'), $key, $group_key, $this->owner, $this->owner_id));
    23662378                }
    23672379            }
     
    23712383            $date = lifestream_array_key_pop($item, 'date');
    23722384            $key = lifestream_array_key_pop($item, 'key');
    2373             $wpdb->query($wpdb->prepare("INSERT INTO `".$wpdb->prefix."lifestream_event_group` (`feed_id`, `feed`, `event_id`, `data`, `timestamp`, `total`, `version`, `key`, `owner`, `owner_id`) VALUES(%d, %s, %d, %s, %d, 1, %d, %s, %s, %d)", $this->id, $this->get_constant('ID'), $item['id'], serialize(array($item)), $date, $this->get_constant('VERSION'), $key, $this->owner, $this->owner_id));
     2385            $group_key = lifestream_array_key_pop($item, 'group_key');
     2386
     2387            $wpdb->query($wpdb->prepare("INSERT INTO `".$wpdb->prefix."lifestream_event_group` (`feed_id`, `feed`, `event_id`, `data`, `timestamp`, `total`, `version`, `key`, `group_key`, `owner`, `owner_id`) VALUES(%d, %s, %d, %s, %d, 1, %d, %s, %s, %s, %d)", $this->id, $this->get_constant('ID'), $item['id'], serialize(array($item)), $date, $this->get_constant('VERSION'), $key, $group_key, $this->owner, $this->owner_id));
    23742388        }
    23752389        $wpdb->query($wpdb->prepare("UPDATE `".$wpdb->prefix."lifestream_feeds` SET `timestamp` = UNIX_TIMESTAMP() WHERE `id` = %d", $this->id));
  • lifestream/trunk/inc/widget.php

    r194062 r196389  
    3030    $args = array(
    3131        'limit'=>$options['amount'],
    32         'feed_ids'=>$options['feeds'],
    33         'hide_metadata'=>$options['hide_metadata'],
    34         'break_groups'=>$options['break_groups'] ? true : false,
     32        'feed_ids'=>@$options['feeds'],
     33        'hide_metadata'=>@$options['hide_metadata'],
     34        'break_groups'=>@$options['break_groups'] ? true : false,
    3535        'event_total_max'=>-1,
    3636        'date_interval'=>-1,
     
    158158    <p>
    159159        <label>
    160             <input type="checkbox" name="lifestream[<?php echo $number; ?>][break_groups]" value="1"<?php if ($current_options['break_groups']) echo ' checked = "checked"'; ?>/>
     160            <input type="checkbox" name="lifestream[<?php echo $number; ?>][break_groups]" value="1"<?php if (@$current_options['break_groups']) echo ' checked = "checked"'; ?>/>
    161161            <?php $lifestream->_e('Break up grouped events.'); ?>
    162162        </label><br />
     
    164164    <p>
    165165        <label>
    166             <input type="checkbox" name="lifestream[<?php echo $number; ?>][hide_metadata]" value="1"<?php if ($current_options['hide_metadata']) echo ' checked = "checked"'; ?>/>
     166            <input type="checkbox" name="lifestream[<?php echo $number; ?>][hide_metadata]" value="1"<?php if (@$current_options['hide_metadata']) echo ' checked = "checked"'; ?>/>
    167167            <?php $lifestream->_e('Hide meta data, such as the time.'); ?>
    168168        </label><br />
     
    172172        <select multiple="multiple" style="width: 92%; height: 80px;" name="lifestream[<?php echo $number; ?>][feeds][]">
    173173            <?php foreach ($feeds as &$feed) { ?>
    174                 <option value="<?php echo $feed->id; ?>"<?php if (in_array((string)$feed->id, (array)$current_options['feeds'])) echo ' selected="selected"'; ?>><?php echo $feed->get_public_name(); ?> (<?php echo $feed->get_feed_display(); ?>)</option>
     174                <option value="<?php echo $feed->id; ?>"<?php if (in_array((string)$feed->id, @(array)$current_options['feeds'])) echo ' selected="selected"'; ?>><?php echo $feed->get_public_name(); ?> (<?php echo $feed->get_feed_display(); ?>)</option>
    175175            <?php } ?>
    176176        </select>
  • lifestream/trunk/lifestream.php

    r194062 r196389  
    44Plugin URI: http://www.enthropia.com/labs/wp-lifestream/
    55Description: Displays your activity from various social networks. (Requires PHP 5 and MySQL 5)
    6 Version: 0.99.9.6
     6Version: 0.99.9.7-PRE
    77Author: David Cramer <[email protected]>
    88Author URI: http://www.davidcramer.net
     
    1818}
    1919
    20 define('LIFESTREAM_VERSION', '0.99.9.6');
     20define('LIFESTREAM_VERSION', '0.99.9.7');
    2121define('LIFESTREAM_PLUGIN_FILE', plugin_basename(__FILE__));
    2222define('LIFESTREAM_PATH', dirname(__FILE__));
  • lifestream/trunk/readme.txt

    r193745 r196389  
    166166* Foursquare
    167167* Ustream
     168* World of Warcraft Armory
     169
     170Want to add your own? See extensions/README for more information.
    168171
    169172== Localization ==
Note: See TracChangeset for help on using the changeset viewer.