Created
February 2, 2011 22:35
-
-
Save xurizaemon/808606 to your computer and use it in GitHub Desktop.
spot the diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
? .svn | |
? activitystream_delicious/.svn | |
? activitystream_digg/.svn | |
? activitystream_feed/.svn | |
? activitystream_flickr/.svn | |
? activitystream_flickr/PEAR/.svn | |
? activitystream_flickr/PEAR/DB/.svn | |
? activitystream_flickr/PEAR/HTTP/.svn | |
? activitystream_flickr/PEAR/HTTP/Request/.svn | |
? activitystream_flickr/PEAR/Net/.svn | |
? activitystream_lastfm/.svn | |
? activitystream_twitter/.svn | |
? translations/.svn | |
? views/.svn | |
cvs diff: Diffing . | |
Index: activitystream.install | |
=================================================================== | |
RCS file: /cvs/drupal-contrib/contributions/modules/activitystream/activitystream.install,v | |
retrieving revision 1.3.2.5 | |
diff -u -p -r1.3.2.5 activitystream.install | |
--- activitystream.install 25 Nov 2009 05:19:35 -0000 1.3.2.5 | |
+++ activitystream.install 2 Feb 2011 22:34:44 -0000 | |
@@ -87,3 +87,32 @@ function activitystream_update_1() { | |
function activitystream_update_2() { | |
db_query("UPDATE {system} SET weight = 100 WHERE name = 'activitystream'"); | |
} | |
+ | |
+/** | |
+ * Add an activitystream_deleted table so that we don't re-create | |
+ * previously deleted items. | |
+ */ | |
+function activitystream_update_6010() { | |
+ $schema['activitystream_deleted'] = array( | |
+ 'description' => 'Record previously deleted AS items, so we do not import them again', | |
+ 'fields' => array( | |
+ 'uid' => array( | |
+ 'type' => 'int', | |
+ 'not null' => TRUE, | |
+ 'default' => 0, | |
+ 'unsigned' => TRUE, | |
+ 'description' => 'The user whose AS this item was deleted from' | |
+ ), | |
+ 'guid' => array( | |
+ 'type' => 'varchar', | |
+ 'not null' => TRUE, | |
+ 'default' => '', | |
+ 'length' => 255, | |
+ 'description' => 'The GUID of this item' | |
+ ), | |
+ ) | |
+ ) ; | |
+ $ret = array(); | |
+ db_create_table($ret, 'activitystream_deleted', $schema['activitystream_deleted']); | |
+ return $ret; | |
+} | |
\ No newline at end of file | |
Index: activitystream.module | |
=================================================================== | |
RCS file: /cvs/drupal-contrib/contributions/modules/activitystream/activitystream.module,v | |
retrieving revision 1.2.2.18 | |
diff -u -p -r1.2.2.18 activitystream.module | |
--- activitystream.module 25 Nov 2009 05:19:35 -0000 1.2.2.18 | |
+++ activitystream.module 2 Feb 2011 22:34:45 -0000 | |
@@ -144,6 +144,12 @@ function activitystream_access($op, $nod | |
function activitystream_nodeapi(&$node, $op, $arg = 0) { | |
switch ($op) { | |
case 'delete': | |
+ $sql = 'SELECT nid, guid FROM {activitystream} WHERE nid = %d' ; | |
+ $qry = db_query($sql, $node->nid) ; | |
+ if ( $res = db_fetch_object( $qry ) ) { | |
+ $sql = "INSERT INTO {activitystream_deleted} ( uid, guid ) VALUES ( %d, '%s' )" ; | |
+ db_query($sql, $node->uid, $res->guid) ; | |
+ } | |
$result = db_query('DELETE FROM {activitystream} WHERE nid = %d', $node->nid); | |
} | |
} | |
@@ -164,6 +170,7 @@ function activitystream_form(&$node) { | |
); | |
$form['body_field'] = node_body_field($node, t($type->body_label), $type->min_word_count); | |
+ $form['buttons']['#weight'] = 99 ; | |
return $form; | |
} | |
@@ -497,7 +504,7 @@ function activitystream_cron() { | |
* @return | |
* The number of users updated | |
*/ | |
-function activitystream_update_streams(&$users, $use_queue = TRUE) { | |
+function activitystream_update_streams(&$users, $use_queue = FALSE) { | |
$use_job_queue = module_exists('job_queue') ? TRUE : FALSE; | |
$processed_users = array(); | |
foreach ($users as $user) { | |
@@ -693,8 +700,10 @@ function activitystream_save_node($activ | |
$node->status = 1; | |
} | |
} | |
+ | |
+ | |
// Has the source changed? If not, we don't want to update the node | |
- $source_changed = ((strpos($activity['title'], $node->title) !== FALSE) && $node->body == $activity['body']) ? false : true; | |
+ $source_changed = ( (strpos($activity['title'], $node->title) !== FALSE ) && $node->body == $activity['body'] ) ? false : true; | |
if ($source_changed || $new) { | |
// Only save if if the source has changed or this is a new item | |
@@ -710,6 +719,17 @@ function activitystream_save_node($activ | |
} | |
} | |
+ // Has this node been imported previously, then deleted? If so, we | |
+ // want to bail out here. This needs to happen AFTER the node | |
+ // object is set up, because that's where we'll get to see | |
+ // $node->uid | |
+ $sql = "SELECT uid, guid FROM {activitystream_deleted} WHERE uid = %d and guid = '%s'" ; | |
+ $qry = db_query($sql, $user->uid, $activity['guid']) ; | |
+ if ( $res = db_fetch_array( $qry ) ) { | |
+ watchdog('activitystream', t("Ignoring %title from %user's %name as it was previously deleted.", array('%title'=>$node->title, '%user' => $user->name, '%name'=>$name))); | |
+ return FALSE ; | |
+ } | |
+ | |
if ($new) { | |
node_invoke($node, 'prepare'); | |
node_invoke_nodeapi($node, 'prepare'); | |
cvs diff: Diffing activitystream_delicious | |
cvs diff: Diffing activitystream_digg | |
cvs diff: Diffing activitystream_feed | |
cvs diff: Diffing activitystream_flickr | |
Index: activitystream_flickr/activitystream_flickr.module | |
=================================================================== | |
RCS file: /cvs/drupal-contrib/contributions/modules/activitystream/activitystream_flickr/activitystream_flickr.module,v | |
retrieving revision 1.2.2.6 | |
diff -u -p -r1.2.2.6 activitystream_flickr.module | |
--- activitystream_flickr/activitystream_flickr.module 9 Nov 2009 22:41:49 -0000 1.2.2.6 | |
+++ activitystream_flickr/activitystream_flickr.module 2 Feb 2011 22:34:48 -0000 | |
@@ -32,19 +32,34 @@ function activitystream_flickr_streamapi | |
watchdog('activitystream', 'Unable to connect to Flickr: error code: '. $error_code .' '. $error_msg, WATCHDOG_ERROR); | |
return; | |
} | |
+ | |
if (!$baseurl = $f->urls_getUserPhotos($person['id'])) { | |
watchdog('activitystream', 'Unable to connect to Flickr: error code: '. $error_code .' '. $error_msg, WATCHDOG_ERROR); | |
return; | |
} | |
- if (!$photos = $f->people_getPublicPhotos($person['id'], NULL, NULL, 10)) { | |
- watchdog('activitystream', 'Unable to get photos from Flickr: error code: '. $error_code .' '. $error_msg, WATCHDOG_ERROR); | |
+ | |
+ $feeds = variable_get('activitystream_flickr_import_default',_activitystream_flickr_import_defaults()) ; | |
+ | |
+ if ( $feeds[1] == 1 ) { | |
+ if (!$photos = $f->people_getPublicPhotos($person['id'], NULL, NULL, 10)) { | |
+ watchdog('activitystream', 'Unable to get photos from Flickr: error code: '. $error_code .' '. $error_msg, WATCHDOG_ERROR); | |
+ } | |
+ $photoitems = activitystream_flickr_build_items($photos, 'photo', $f); | |
+ } | |
+ else { | |
+ $photoitems = array() ; | |
+ } | |
+ | |
+ if ( $feeds[2] == 2 ) { | |
+ if (!$favorites = $f->favorites_getPublicList($person['id'], NULL, NULL, NULL, 10)) { | |
+ watchdog('activitystream', 'Unable to get Favorites Flickr: error code: '. $error_code .' '. $error_msg, WATCHDOG_ERROR); | |
+ } | |
+ $favoriteitems = activitystream_flickr_build_items($favorites, 'favorite', $f); | |
} | |
- if (!$favorites = $f->favorites_getPublicList($person['id'], NULL, NULL, NULL, 10)) { | |
- watchdog('activitystream', 'Unable to get Faorites Flickr: error code: '. $error_code .' '. $error_msg, WATCHDOG_ERROR); | |
+ else { | |
+ $favoriteitems = array() ; | |
} | |
- | |
- $photoitems = activitystream_flickr_build_items($photos, 'photo', $f); | |
- $favoriteitems = activitystream_flickr_build_items($favorites, 'favorite', $f); | |
+ | |
$items = array_merge($photoitems, $favoriteitems); | |
return $items; | |
@@ -92,9 +107,30 @@ function activitystream_flickr_activitys | |
'#default_value' => variable_get('activitystream_flickr_key', ''), | |
'#required' => FALSE | |
); | |
+ $form['activitystream_flickr']['activitystream_flickr_import_default'] = array( | |
+ '#type' => 'checkboxes', | |
+ '#title' => t('Default import settings'), | |
+ '#options' => _activitystream_flickr_import_options(), | |
+ '#default_value' => variable_get('activitystream_flickr_import_default',_activitystream_flickr_import_defaults()), | |
+ '#description' => t('Which items to import.'), | |
+ ); | |
return $form; | |
} | |
+function _activitystream_flickr_import_options() { | |
+ $options = array( | |
+ 1 => 'Import Uploaded Photos', | |
+ 2 => 'Import Favourite Photos', | |
+ ) ; | |
+ return $options ; | |
+} | |
+ | |
+function _activitystream_flickr_import_defaults() { | |
+ foreach( _activitystream_flickr_import_options() as $k => $v ) { | |
+ $defaults[] = $k ; | |
+ } | |
+ return $defaults ; | |
+} | |
/* | |
* Implement a user settings form hook. Modules should build a form | |
* using an array that mirrors the Drupal form API. activitystream.module | |
cvs diff: Diffing activitystream_flickr/PEAR | |
cvs diff: Diffing activitystream_flickr/PEAR/DB | |
cvs diff: Diffing activitystream_flickr/PEAR/HTTP | |
cvs diff: Diffing activitystream_flickr/PEAR/HTTP/Request | |
cvs diff: Diffing activitystream_flickr/PEAR/Net | |
cvs diff: Diffing activitystream_lastfm | |
cvs diff: Diffing activitystream_twitter | |
cvs diff: Diffing translations | |
cvs diff: Diffing views |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment