--- flickrstickr5/flickrstickr.module	2007-08-23 18:19:03.000000000 -0400
+++ flickrstickr/flickrstickr.module	2007-03-02 06:29:37.000000000 -0500
@@ -42,22 +42,24 @@ function flickrstickr_file_put_contents(
 }
 
 /**
+ * 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) {
-    $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,
-    );
-
-
+  if (!$may_cache) {
     $items[] = array('path' => 'flickrstickr/xml/user',
                      'title' => t('xml proxy'),
                      'callback' => 'flickrstickr_proxy_user',
@@ -70,28 +72,10 @@ function flickrstickr_menu($may_cache) {
                      '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
@@ -175,12 +159,10 @@ function flickrstickr_user($type, & $edi
                                                            '#description' => t('TODO'),
                                                            '#required' => TRUE);*/
 
-    // not required for drupal 5
-    //if (flickrstickr_isdrupal47()) {
-    //  return $form;
-    //}
-    //else {
-    /*
+    if (flickrstickr_isdrupal47()) {
+      return $form;
+    }
+    else {
       $group = "";
       foreach ($form['flickrstickr'] as $key => $value) {
         if (preg_match('/\#/', $key)) {
@@ -194,8 +176,7 @@ function flickrstickr_user($type, & $edi
         }
       }
       return array(array('title ' => t('Flickr sticker settings'), 'data' => form_group(t('Flickrstickr'), $group), 'weight' => 2));
-    //}
-    */
+    }
   }
   return array();
 }
@@ -223,12 +204,11 @@ function _flickrstickr_htmlpart() {
   global $user;
   global $base_url;
   $flickrstickr = flickrstickr_getuserparam();
-  $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');
+  $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" />');
   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]-->');
@@ -251,17 +231,8 @@ drupal_add_css(drupal_get_path('module',
   $ret .= '</table>';
   $ret .= '</div>';
   $ret .= '<p id="flickrsettings">';
-  
-// 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)" />';
+  $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)" />';
   // 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'),
@@ -321,7 +292,7 @@ drupal_add_css(drupal_get_path('module',
  */
 function flickrstickr_getuserparam() {
   global $user;
-  $flickrstickr['link']     = (isset($user->flickrstickr_link) ? $user->flickrstickr_link : "yes");
+  $flickrstickr['link']     = (isset($user->flickrstickr_link) ? $user->flickrstickr_link : "none");
   $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");
@@ -339,25 +310,17 @@ function flickrstickr_getapikey() {
 
 /**
  * implements hook_help
- * replaced 
-function flickrstickr_help($section) {
-  switch ($section) {
-  }
-  return $output;
-}
  */
-
 function flickrstickr_help($section) {
   switch ($section) {
     case 'admin/modules#description':
-      return t("Enable flickr image inserter in your node forms.");
+      $output = t("Enable flickr image inserter in your node forms.");
+      break;
   }
+  return $output;
 }
 
 
-
-
-
 global $user;
 $node = array('uid' => $user->uid, 'name' => $user->name, 'type' => 'image');
 
@@ -771,6 +734,29 @@ function flickrstickr_perm() {
   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
  *
