? itewak_upload_imagecache_default_presets.patch
? itweak_upload_imagecache_default_presets.patch
Index: itweak_upload.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/itweak_upload/Attic/itweak_upload.install,v
retrieving revision 1.1.2.4
diff -u -p -r1.1.2.4 itweak_upload.install
--- itweak_upload.install	8 Aug 2009 03:33:51 -0000	1.1.2.4
+++ itweak_upload.install	12 Sep 2009 23:31:17 -0000
@@ -21,98 +21,6 @@ function _itweak_upload_add_permission($
   }
 }
 
-/*
- * Install ImageCache presets
- */
-function _itweak_upload_install_imagecache_presets() {
-  $ret = array();
-  if (!module_exists('imagecache')) {
-    $msg = t('Tried installing ImageCache preset for iTweak Upload module, but ImageCache module is not present. ImageCache presets for iTweak Upload module were not installed.');
-//    drupal_set_message($msg);
-    $ret[] = array('success' => FALSE, 'query' => $msg);
-  }
-  else {
-    $imagecache_presets = array(
-      array(
-        'presetname' => 'AttachmentThumbnail',
-      ),
-    );
-
-    $imagecache_actions = array(
-      'AttachmentThumbnail' => array(
-        'action' => 'imagecache_scale_and_crop',
-        'data' => array(
-          'width' => 60,
-          'height' => 60,
-          'upscale' => 1,
-        ),
-        'weight' => 0,
-      ),
-    );
-  
-    //need to install preset, id will be returned by function,
-    //then install action add presetid to action prior to install:
-    $perms = array();
-    foreach ($imagecache_presets as $preset) {
-      // Check if preset already exists
-      $exists = imagecache_preset_by_name($preset['presetname']);
-      if (count($exists)) {
-        $msg = t('ImageCache preset "%name" already exists, id=%id. Leaving unchanged. Will use it by default in "iTweak Upload". Please check the preset and its permissions!', array('%id' => $exists['presetid'], '%name' => $exists['presetname']));
-      }
-      else {
-        $preset = imagecache_preset_save($preset);
-        $imagecache_actions[$preset['presetname']]['presetid'] = $preset['presetid'];
-        imagecache_action_save($imagecache_actions[$preset['presetname']]);
-        $msg = t('Created ImageCache preset "%name", id=%id.', array('%id' => $preset['presetid'], '%name' => $preset['presetname']));
-        $perms[] = 'view imagecache ' . $preset['presetname'];
-      }
-//      drupal_set_message($msg);
-      $ret[] = array('success' => TRUE, 'query' => $msg);
-    }
-
-    // Add default permissions to new presets
-    if (count($perms)) {
-      // Which roles ids should be allowed to view the preset by default:
-      $allow_roles = array(1, 2);
-
-      // Get role names
-      $result = db_query('SELECT r.rid, r.name FROM {role} r WHERE r.rid IN (%s)', implode(', ', $allow_roles));
-      $roles = array();
-      while ($role = db_fetch_object($result)) {
-        $roles[$role->rid] = $role->name;
-      }
-      $perms = implode(', ', $perms);
-      foreach ($roles as $rid => $role) {
-        $res = _itweak_upload_add_permission($rid, $perms);
-	if ($res['success']) {
-	  $res['query'] = t('Added permissions "%perms" to role %role.', array('%perms' => $perms, '%role' => $role) );
-	}
-	$ret[] = $res;
-      }
-    }
-  }
-  return $ret;
-}
-
-/**
- * Implementation of hook_install()
- */
-function itweak_upload_install() {
-  $ret = _itweak_upload_install_imagecache_presets();
-  if (!$ret[0]['success']) drupal_set_message($ret[0]['query']);
-
-//??  cache_clear_all('theme_registry', 'cache', TRUE);
-}
-
-/**
- * Implementation of hook_update_N()
- */
-function itweak_upload_update_6000() {
-  $ret = array();
-  $ret += _itweak_upload_install_imagecache_presets();
-  return $ret;
-}
-
 /**
  * Implementation of hook_requirements()
  */
Index: itweak_upload.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/itweak_upload/itweak_upload.module,v
retrieving revision 1.1.2.13
diff -u -p -r1.1.2.13 itweak_upload.module
--- itweak_upload.module	8 Aug 2009 03:33:51 -0000	1.1.2.13
+++ itweak_upload.module	12 Sep 2009 23:31:17 -0000
@@ -61,6 +61,28 @@ function _itweak_upload_isimage($file) {
   return (strpos($file->filemime, 'image/') === 0);
 }
 
+function itweak_upload_imagecache_default_presets(){
+  $presets = array();
+  
+  $presets['AttachmentThumbnail'] = array(
+    'presetname' => 'AttachmentThumbnail', 
+    'actions' => array(
+      0 => array(
+        'weight' => '0', 
+        'module' => 'imagecache', 
+        'action' => 'imagecache_scale_and_crop', 
+        'data' => array(
+          'width' => 60, 
+          'height' => 60, 
+          'upscale' => 1 
+        ) 
+      ) 
+    ) 
+  );
+  
+  return $presets;
+}
+
 /**
  * Implementation of hook_itweak_upload_preview().
  * @param $file
