Index: INSTALL.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/skype_status/INSTALL.txt,v retrieving revision 1.3 diff -u -p -r1.3 INSTALL.txt --- INSTALL.txt 3 Mar 2009 02:20:11 -0000 1.3 +++ INSTALL.txt 23 Feb 2010 22:35:02 -0000 @@ -2,18 +2,13 @@ REQUIREMENTS ------------ -This module requires Drupal 6.x and PHP 5.2.x (or newer), as well as the -Profile module (included in Drupal) and the RDF module [1]. - -[1] http://drupal.org/project/rdf - +This module requires the Profile module (included in Drupal). INSTALLATION ------------ - 1. Copy all the module files into a subdirectory called - sites/all/modules/skype_status/ under your Drupal installation - directory. + 1. Extract the module into sites/all/modules/skype_status/ + under your Drupal installation directory. 2. Go to Administer >> Site building >> Modules and enable the Skype Status module. @@ -31,10 +26,6 @@ INSTALLATION 5. Go to My account, click Edit, input your Skype ID into the profile field you created in step 3, and click Save; when your profile page is displayed, you should see your Skype status and your Skype ID should - have become converted to a callto:// link. - - Note that there may be significant delay (even up to 10-15 seconds) the - first time that your status is retrieved; however, subsequent updates - should complete well within a second. + have become converted to a skype:// link. 6. (See README.txt for information on submitting bug reports.) Index: README.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/skype_status/README.txt,v retrieving revision 1.2 diff -u -p -r1.2 README.txt --- README.txt 3 Mar 2009 01:44:10 -0000 1.2 +++ README.txt 23 Feb 2010 22:35:02 -0000 @@ -2,7 +2,7 @@ Skype Status for Drupal 6.x =========================== -This is a development version of the Skype Status module currently being +This is the Skype Status module currently being developed for Drupal 6.x under the auspices of the project at: Index: skype_status.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/skype_status/skype_status.admin.inc,v retrieving revision 1.2 diff -u -p -r1.2 skype_status.admin.inc --- skype_status.admin.inc 3 Mar 2009 01:46:38 -0000 1.2 +++ skype_status.admin.inc 23 Feb 2010 22:35:02 -0000 @@ -6,22 +6,39 @@ function skype_status_admin_settings() { $form = array(); - $fields = array(); $result = db_query("SELECT * FROM {profile_fields} WHERE type = 'textfield' ORDER BY category, weight"); + while ($field = db_fetch_object($result)) { $fields[$field->name] = t('%category - @title', array('%category' => $field->category, '@title' => $field->title)); } - $form['profile'] = array('#type' => 'fieldset', '#title' => t('User profiles')); - $form['profile']['skype_status_profile_field'] = array('#type' => 'radios', '#title' => t('Profile field for Skype ID'), '#options' => $fields, '#default_value' => SKYPE_STATUS_PROFILE_FIELD, '#required' => TRUE, '#description' => t('Select the custom profile field that contains users\' Skype IDs. Note that users who have not filled out this profile field will be ignored when updating status information from Skype\'s web presence service API.')); - - $form['cache'] = array('#type' => 'fieldset', '#title' => t('Cache status information')); - $period = drupal_map_assoc(array(60, 180, 300, 600, 900, 1800, 2700, 3600), 'format_interval'); - $form['cache']['skype_status_cache_lifetime'] = array('#type' => 'select', '#title' => t('Cache statuses for'), '#default_value' => SKYPE_STATUS_CACHE_LIFETIME, '#options' => $period, '#description' => t('To avoid unnecessarily burdening both your Drupal site and Skype\'s web presence service API, users\' online status information is cached locally for a set duration before being re-requested. This option determines the minimum cache lifetime, that is, the minimum amount of time that will elapse before an individual user\'s status can be re-requested. A larger cache lifetime offers better performance at the risk of somewhat stale status information.')); - - $form['reset'] = array('#type' => 'fieldset', '#title' => t('Reset cache'), '#description' => t('To reset the cached online status information for all users, press the button below. This will cause the users\' status to be retrieved on-demand the next time it is needed for display purposes.')); - $form['reset']['clear'] = array('#type' => 'submit', '#value' => t('Clear cached statuses'), '#submit' => array('skype_status_clear_cache')); + $form['profile'] = array( + '#type' => 'fieldset', + '#title' => t('User profiles') + ); + $form['profile']['skype_status_profile_field'] = array( + '#type' => 'radios', + '#title' => t('Profile field for Skype ID'), + '#options' => $fields, + '#default_value' => variable_get('skype_status_profile_field', ''), + '#required' => TRUE, + '#description' => t('Select the custom profile field that contains users\' Skype IDs. Note that users who have not filled out this profile field will be ignored when updating status information from Skype\'s web presence service API.') + ); + $form['images'] = array( + '#type' => 'fieldset', + '#title' => t('Skype Images'), + '#description' => t('Choose the imageset you would like to use for skype status.') + ); + $form['images']['skype_status_buttonstyle'] = array( + '#type' => 'radios', + '#title' => t('Button style preference.'), + '#options' => array( + 'balloon' => '', + 'bigclassic' => '', + ), + '#default_value' => variable_get('skype_status_buttonstyle', 'bigclassic'), + ); return system_settings_form($form); } Index: skype_status.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/skype_status/skype_status.info,v retrieving revision 1.2 diff -u -p -r1.2 skype_status.info --- skype_status.info 3 Mar 2009 01:39:44 -0000 1.2 +++ skype_status.info 23 Feb 2010 22:35:02 -0000 @@ -2,6 +2,4 @@ name = Skype Status description = Retrieves Skype online status information for users. dependencies[] = profile -dependencies[] = rdf core = 6.x -php = 5.2 Index: skype_status.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/skype_status/skype_status.install,v retrieving revision 1.2 diff -u -p -r1.2 skype_status.install --- skype_status.install 3 Mar 2009 01:46:38 -0000 1.2 +++ skype_status.install 23 Feb 2010 22:35:02 -0000 @@ -15,7 +15,14 @@ function skype_status_enable() { * Implementation of hook_install(). */ function skype_status_install() { - rdf_db_create_repository('skype_status', array('dc:title' => t('Skype Status'), 'dc:description' => '')); +} + +/** + * Implementation of hook_update(). + */ +function skype_status_update_6100(&$sandbox) { + db_query("DROP TABLE {rdf_data_skype_status}"); + variable_del('skype_status_cache_lifetime'); } /** @@ -23,6 +30,5 @@ function skype_status_install() { */ function skype_status_uninstall() { variable_del('skype_status_profile_field'); - variable_del('skype_status_cache_lifetime'); - rdf_db_delete_repository('skype_status'); + variable_del('skype_status_buttonstyle'); } Index: skype_status.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/skype_status/skype_status.module,v retrieving revision 1.5 diff -u -p -r1.5 skype_status.module --- skype_status.module 3 Mar 2009 02:18:01 -0000 1.5 +++ skype_status.module 23 Feb 2010 22:35:02 -0000 @@ -1,17 +1,6 @@ array( - 'skype_status' => array( - 'update' => array( - 'runs when' => t('When a user\'s Skype presence status changes'), - ), - ), - ), - ); -} - -/** * Implementation of hook_profile_alter(). */ function skype_status_profile_alter(&$account) { - $field = SKYPE_STATUS_PROFILE_FIELD; + $field = variable_get('skype_status_profile_field', ''); if (!empty($account->$field)) { - $language = !empty($account->language) ? $account->language : 'en'; // FIXME - $status = skype_status_get_code($account) != SKYPE_STATUS_UNKNOWN ? skype_status_get($account, $language) : ''; - $output = theme('skype_status', $account->$field, $status); + $name = $account->$field; + $ename = rawurlencode($name); + $buttonstyle = variable_get('skype_status_buttonstyle', 'bigclassic'); + $output = theme('skype_status', $name, $ename, $buttonstyle); $account->content['Contact details'][$field]['#value'] = $output; } } /** - * Implementation of hook_user(). - */ -function skype_status_user($op, &$edit, &$account, $category = NULL) { - switch ($op) { - case 'delete': - $field = SKYPE_STATUS_PROFILE_FIELD; - if (!empty($account->$field)) { - $url = sprintf(SKYPE_STATUS_URL, $account->$field); - rdf_delete(NULL, NULL, NULL, array('repository' => 'skype_status', 'context' => $url)); - rdf_delete($url, dcterms::valid, NULL, array('repository' => 'skype_status')); - } - break; - } -} - -/** - * Implementation of hook_user_operations(). - */ -function skype_status_user_operations() { - return array( - 'skype_status' => array( - 'label' => t('Update the Skype status of the selected users'), - 'callback' => 'skype_status_operations_update', - ), - ); -} - -/** * Implementation of hook_theme() */ function skype_status_theme() { return array( 'skype_status' => array( - 'arguments' => array('name' => NULL, 'status' => NULL), + 'arguments' => array( + 'name' => NULL, + 'ename' => NULL, + 'buttonstyle' => NULL + ), ), ); } -////////////////////////////////////////////////////////////////////////////// -// Operations callbacks - -function skype_status_operations_update($accounts) { - foreach ($accounts as $uid) { - if (($account = user_load(array('uid' => (int)$uid))) !== FALSE) { - skype_status_update($account); - } - } -} - -////////////////////////////////////////////////////////////////////////////// -// Theming callbacks - -function theme_skype_status($name, $status = '') { - return $status ? - t('@name (%status)', array('@name' => $name, '%status' => $status)) : - t('@name', array('@name' => $name)); -} - -////////////////////////////////////////////////////////////////////////////// -// Skype Status API - -function skype_status_clear_cache() { - rdf_delete(NULL, NULL, NULL, array('repository' => 'skype_status')); - drupal_set_message(t('Cached status information cleared for all users.')); -} - -function skype_status_get_code($account) { - return (int)skype_status_get($account, 'num'); -} - -function skype_status_get($account, $language = 'en', $update = TRUE) { - $field = SKYPE_STATUS_PROFILE_FIELD; - if (!empty($account->$field)) { - $url = sprintf(SKYPE_STATUS_URL, $account->$field); - - if ($update && skype_status_has_expired($url)) { - skype_status_update($account); - } - - $data = rdf_query('urn:skype:skype.com:skypeweb/1.1', 'http://www.skype.com/go/skypewebpresence', NULL, array('context' => $url, 'language' => $language, 'repository' => 'skype_status')); - $data = rdf_normalize($data); - if (!empty($data)) { - foreach (rdf_select_values($data) as $literal) { - if (is_object($literal) && $literal->language == $language) { - return $literal->value; - } - } - } - } -} - -function skype_status_has_expired($url) { - $data = rdf_normalize(rdf_query($url, dcterms::valid, NULL, array('repository' => 'skype_status'))); - if (empty($data)) { - return TRUE; - } - foreach (rdf_select_values($data) as $literal) { - if (!empty($literal->value)) { - $age = gmmktime() - strtotime((string)$literal->value); - return $age > SKYPE_STATUS_CACHE_LIFETIME; - } - } -} - -function skype_status_update($account, $log = TRUE) { - $field = SKYPE_STATUS_PROFILE_FIELD; - if (!empty($account->$field)) { - if ($log) { - timer_start('skype_status'); - } - - // Retrieve and parse the user-specific RDF/XML file containing Skype status - $url = sprintf(SKYPE_STATUS_URL, $account->$field); - $text = file_get_contents($url); - $data = rdf_unserialize($text, array('format' => 'rdf+xml', 'uri' => $url)); - - // Limit all present RDF operations to our private repository - rdf_use_repository('skype_status'); - - // Delete all existing statements from the named graph - rdf_delete(NULL, NULL, NULL, array('context' => $url)); - - // Insert each retrieved statement into the named graph - rdf_insert_all($data, array('context' => $url)); - - // Update the timestamp used for the cache lifetime calculation - rdf_delete($url, dcterms::valid, NULL); - rdf_insert($url, dcterms::valid, rdf_datetime()); - - // Unlimit future RDF operations - rdf_use_repository(); - - module_invoke_all('skype_status', 'update', $account); - - if ($log) { - list(, $time) = array_values(timer_stop('skype_status')); - watchdog('skype status', 'Updated Skype status: %name (stored @triples statements, processing time @time).', array('%name' => $account->name, '@triples' => count($data), '@time' => format_plural(round($time / 1000.0, 2), '1 second', '@count seconds')), WATCHDOG_NOTICE, l(t('view'), 'user/' . $account->uid)); - } - return TRUE; - } -} +/** + * Theme function for skype_status + */ +function theme_skype_status($name, $ename, $buttonstyle) { + $alt = t('Status for %s', array($name)); + return '' . $alt . ''; +} \ No newline at end of file