]> gitweb.fluxo.info Git - drupal/muamba.git/commitdiff
Allow request of unavailable items (#42)
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 17 Nov 2011 16:49:00 +0000 (14:49 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Thu, 17 Nov 2011 16:49:00 +0000 (14:49 -0200)
muamba-widget.tpl.php
muamba.admin.inc
muamba.business.inc

index 9a0916a08a11a4d584de66113d35dc1f01e67f0d..34a05cd7e8231e0ca7c2f7b031589f0d07393cf8 100644 (file)
@@ -22,13 +22,22 @@ if ($node->uid != $user->uid) {
     return;
   }
   elseif (!$available && $transactions['uid'] != $user->uid) {
-    $content .= theme('image',
-      array(
-        'path'  => $path .'/images/unavailable.png',
-        'alt'   => t('Item unavailable'),
-        'title' => t('Item unavailable'),
-      )
-    );
+    if (variable_get('muamba_allow_request_unavailable', FALSE) == TRUE) {
+      $content .= theme('muamba_widget_icon', array(
+        'status' => MUAMBA_REQUESTED,
+        'id'     => $node->nid,
+        'size'   => $size,
+      ));
+    }
+    else {
+      $content .= theme('image',
+        array(
+          'path'  => $path .'/images/unavailable.png',
+          'alt'   => t('Item unavailable'),
+          'title' => t('Item unavailable'),
+        )
+      );
+    }
   }
   elseif ($transactions['uid'] == $user->uid) {
     $content .= theme('muamba_widget_requester', array(
index cafc7b3a600da35806c96989710d6445edcfbee8..456fc88f39e4ce59ee5ca186d306e0cd72c8c354 100644 (file)
@@ -13,7 +13,14 @@ function muamba_config_form($form, &$form_state) {
     '#type'          => 'checkbox',
     '#title'         => t('Reject all pending requests upon acceptance'),
     '#default_value' => variable_get('muamba_reject_all_on_accept', FALSE),
-    '#description'   => t('Cancel all other requests of an item upon acceptance'),
+    '#description'   => t('Cancel all other requests of an item upon acceptance.'),
+  );
+
+  $form['muamba_allow_request_unavailable'] = array(
+    '#type'          => 'checkbox',
+    '#title'         => t('Allow request of unavailable items'),
+    '#default_value' => variable_get('muamba_allow_request_unavailable', FALSE),
+    '#description'   => t('Makes possible users request items that are not currently available.'),
   );
 
   return system_settings_form($form);
index 9aea8eed8e32f1789210a2beb17496ad82c59ca3..6c0d236e1c418c6b6478db86ef9bcc766d9d7d43 100644 (file)
@@ -131,8 +131,9 @@ function muamba() {
  */
 function muamba_request($nid) {
   global $user;
-  $nid  = (int) $nid;
-  $node = node_load($nid);
+  $nid               = (int) $nid;
+  $node              = node_load($nid);
+  $allow_unavailable = variable_get('muamba_allow_request_unavailable', FALSE);
 
   // Access check
   if (!muamba_has_request_access($node)) {
@@ -145,7 +146,7 @@ function muamba_request($nid) {
   }
 
   // Check if the item is available
-  if (!muamba_check_availability($nid)) {
+  if (!muamba_check_availability($nid) && $allow_unavailable == FALSE) {
     return t('Item not available');
   }