aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2011-11-17 14:49:00 -0200
committerSilvio Rhatto <rhatto@riseup.net>2011-11-17 14:49:00 -0200
commitf092db08f0125d94040487eac8ba4c0950230359 (patch)
treed45468c41896182454832bc482b705c1cd734863
parent0b268a9ba9201c187c9f83bb21793bb9f2bc7e56 (diff)
downloadmuamba-f092db08f0125d94040487eac8ba4c0950230359.tar.gz
muamba-f092db08f0125d94040487eac8ba4c0950230359.tar.bz2
Allow request of unavailable items (#42)
-rw-r--r--muamba-widget.tpl.php23
-rw-r--r--muamba.admin.inc9
-rw-r--r--muamba.business.inc7
3 files changed, 28 insertions, 11 deletions
diff --git a/muamba-widget.tpl.php b/muamba-widget.tpl.php
index 9a0916a..34a05cd 100644
--- a/muamba-widget.tpl.php
+++ b/muamba-widget.tpl.php
@@ -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(
diff --git a/muamba.admin.inc b/muamba.admin.inc
index cafc7b3..456fc88 100644
--- a/muamba.admin.inc
+++ b/muamba.admin.inc
@@ -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);
diff --git a/muamba.business.inc b/muamba.business.inc
index 9aea8ee..6c0d236 100644
--- a/muamba.business.inc
+++ b/muamba.business.inc
@@ -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');
}