? flickrstickr5.patch
Index: flickrstickr.info
===================================================================
RCS file: flickrstickr.info
diff -N flickrstickr.info
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ flickrstickr.info	29 Sep 2007 23:42:17 -0000
@@ -0,0 +1,5 @@
+flickrstickr.info:
+name = FlickrStickr
+description = Enable flickr image inserter in your node forms.
+dependencies = flickr
+package = Flickr
Index: flickrstickr.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/flickrstickr/flickrstickr.module,v
retrieving revision 1.27
diff -u -r1.27 flickrstickr.module
--- flickrstickr.module	2 Mar 2007 11:29:37 -0000	1.27
+++ flickrstickr.module	29 Sep 2007 23:42:18 -0000
@@ -42,24 +42,22 @@
 }
 
 /**
- * Determine wheter this site is drupal 4.7 or not
- *
- * @return bool True if version is 4.7
- */
-function flickrstickr_isdrupal47() {
-  static $new_API;
-  if (!isset ($new_API)) {
-    $new_API = function_exists('drupal_get_form');
-  }
-  return $new_API;
-}
-
-/**
  * implements hook_menu
  */
 function flickrstickr_menu($may_cache) {
   $items = array();
-  if (!$may_cache) {
+  //if ($may_cache) {
+    $items[] = array(
+        'path'               => 'admin/settings/flickrstickr',
+        'title'              => t('Flickrstickr'),
+        'description' => t('Set the API key'),
+        'callback' => 'drupal_get_form',
+	'callback arguments' => array('flickrstickr_admin_settings'),
+        'access'  => user_access("flickrstickr admin"),
+        'type'               => MENU_NORMAL_ITEM,
+    );
+
+
     $items[] = array('path' => 'flickrstickr/xml/user',
                      'title' => t('xml proxy'),
                      'callback' => 'flickrstickr_proxy_user',
@@ -72,10 +70,28 @@
                      'access' => TRUE,
                      'type' => MENU_CALLBACK,
                      'weight' => 5);
-  }
+  //}
   return $items;
 }
 
+/* for drupal 5 */
+function flickrstickr_admin_settings () {
+  $form['flickrstickr_flickrkey'] = array('#type' => 'textfield',
+                                                      '#title' => t('Flickrapi key'),
+						      '#required' => TRUE,
+                                                      //'#default_value' => flickrstickr_getapikey(),
+						      '#default_value' => variable_get('flickrstickr_flickrkey', ''),
+						      '#description' => t('API Key from Flickr'),
+                                                      '#maxlength' => 36,
+                                                      '#size' => 36);
+  return system_settings_form($form);
+
+}
+
+
+
+
+
 /**
  * Public ajax proxy for user search
  * Bcause the javascript restriction
@@ -159,10 +175,12 @@
                                                            '#description' => t('TODO'),
                                                            '#required' => TRUE);*/
 
-    if (flickrstickr_isdrupal47()) {
-      return $form;
-    }
-    else {
+    // not required for drupal 5
+    //if (flickrstickr_isdrupal47()) {
+    //  return $form;
+    //}
+    //else {
+    /*
       $group = "";
       foreach ($form['flickrstickr'] as $key => $value) {
         if (preg_match('/\#/', $key)) {
@@ -176,7 +194,8 @@
         }
       }
       return array(array('title ' => t('Flickr sticker settings'), 'data' => form_group(t('Flickrstickr'), $group), 'weight' => 2));
-    }
+    //}
+    */
   }
   return array();
 }
@@ -204,11 +223,12 @@
   global $user;
   global $base_url;
   $flickrstickr = flickrstickr_getuserparam();
-  $base_path = '';
-  if (flickrstickr_isdrupal47()) {
-    $base_path = base_path();
-  }
-  drupal_set_html_head('<link rel="stylesheet" type="text/css" href="'. $base_path. drupal_get_path('module', 'flickrstickr').'/flickrstickr.css" media="screen" />');
+  $base_path = base_path();
+ 
+  // changed for drupal 5
+  //drupal_set_html_head('<link rel="stylesheet" type="text/css" href="'. $base_path. drupal_get_path('module', 'flickrstickr').'/flickrstickr.css" media="screen" />');
+
+drupal_add_css(drupal_get_path('module', 'flickrstickr').'/flickrstickr.css');
   drupal_set_html_head('<script src="'. $base_path. drupal_get_path('module', 'flickrstickr'). '/flickrstickr.js"></script>');
   // This line is needed because of floating image selector
   drupal_set_html_head('<!-- compliance patch for microsoft browsers --><!--[if lt IE 7]><script src="'. $base_path. drupal_get_path('module', 'flickrstickr'). '/ie7/ie7-standard-p.js" type="text/javascript"></script><![endif]-->');
@@ -231,8 +251,17 @@
   $ret .= '</table>';
   $ret .= '</div>';
   $ret .= '<p id="flickrsettings">';
-  $ret .= t('User') .': <input id="flickrstickr_user" type="text" name="user" value="'. $flickrstickr['username'] .'" onkeypress="return handleEnter(event)" />';
-  $ret .= t('Tag') .': <input id="flickrstickr_tag" type="text" name="tag"  onkeypress="return handleEnter(event)" />';
+  
+// Option One: allow users to only select their own images
+  $identity=$user;
+  flickr_user("load", $edit, $identity, $cat);
+  $fidentity = $user->flickr['identifier'];
+  $ret .= '<input id="flickrstickr_user" type="hidden" name="user" value="'. $fidentity.'" onkeypress="return handleEnter(event)" />';
+
+// Option Two: allow users to select anyone's images (uncomment to enable this option)
+  //$ret .= t('Flickr Username') .': <input id="flickrstickr_user" type="text" name="user" value="'. $flickrstickr['username'] .'" onkeypress="return handleEnter(event)" />';
+
+  $ret .= t('Flickr Tag') .': <input id="flickrstickr_tag" type="text" name="tag"  onkeypress="return handleEnter(event)" />';
   // If you want to add a new size, just add a new element to this array. (but this should be put into settings?)
   $options_size = array('|200' => t('Default'),
                         '|100' => t('Thumbnail'),
@@ -292,7 +321,7 @@
  */
 function flickrstickr_getuserparam() {
   global $user;
-  $flickrstickr['link']     = (isset($user->flickrstickr_link) ? $user->flickrstickr_link : "none");
+  $flickrstickr['link']     = (isset($user->flickrstickr_link) ? $user->flickrstickr_link : "yes");
   $flickrstickr['imgno']    = (isset($user->flickrstickr_imgno) ? $user->flickrstickr_imgno : 10);
   $flickrstickr['size']     = (isset($user->flickrstickr_size) ? $user->flickrstickr_size : "100");
   $flickrstickr['format']   = (isset($user->flickrstickr_format) ? $user->flickrstickr_format : "filter");
@@ -310,17 +339,25 @@
 
 /**
  * implements hook_help
+ * replaced 
+function flickrstickr_help($section) {
+  switch ($section) {
+  }
+  return $output;
+}
  */
+
 function flickrstickr_help($section) {
   switch ($section) {
     case 'admin/modules#description':
-      $output = t("Enable flickr image inserter in your node forms.");
-      break;
+      return t("Enable flickr image inserter in your node forms.");
   }
-  return $output;
 }
 
 
+
+
+
 global $user;
 $node = array('uid' => $user->uid, 'name' => $user->name, 'type' => 'image');
 
@@ -734,29 +771,6 @@
   return array('flickrstickr access', 'flickrstickr admin');
 }
 
-
-
-/**
-* implements hook_settings
-*/
-function flickrstickr_settings() {
-  if (!function_exists('_image_build_derivatives')) {
-    drupal_set_message(t('Flickrstickr requires image module. Please install or enable it!'), 'error');
-  }
-  if (!user_access('flickrstickr admin')) {
-    drupal_access_denied();
-  }
-
-  $form['settings'] = array('#type' => 'fieldset',
-                            '#title' => t('FlickrStickr settings'));
-  $form['settings']['flickrstickr_flickrkey'] = array('#type' => 'textfield',
-                                                      '#title' => t('Flickrapi key'),
-                                                      '#default_value' => flickrstickr_getapikey(),
-                                                      '#maxlength' => 36,
-                                                      '#size' => 36);
-  return $form;
-}
-
 /**
  * Test if the <var>$host</var> is alive
  *
