aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--muamba.business.inc19
-rw-r--r--muamba.theme.inc6
2 files changed, 18 insertions, 7 deletions
diff --git a/muamba.business.inc b/muamba.business.inc
index 1afce9f..59fa834 100644
--- a/muamba.business.inc
+++ b/muamba.business.inc
@@ -23,13 +23,19 @@ function muamba_ongoing() {
* @param $type
* Transaction perspective (sent or received).
*
- * @param $status
- * Current transaction status.
+ * @param $transaction
+ * Transaction data.
*
* @return
* Array of available action codes.
*/
-function muamba_actions_available($type = 'sent', $status) {
+function muamba_actions_available($type = 'sent', $transaction = array()) {
+ if (empty($transaction)) {
+ return array();
+ }
+
+ $status = $transaction['status'];
+
if ($type == 'sent') {
switch ($status) {
case MUAMBA_REQUESTED:
@@ -64,9 +70,14 @@ function muamba_actions_available($type = 'sent', $status) {
switch ($status) {
case MUAMBA_REQUESTED:
$actions = array(
- MUAMBA_ACCEPTED,
MUAMBA_REJECTED,
);
+
+ // Owner can just accept requests for available items.
+ if (muamba_check_availability($transaction['nid'])) {
+ $actions[] = MUAMBA_ACCEPTED;
+ }
+
break;
case MUAMBA_ACCEPTED:
diff --git a/muamba.theme.inc b/muamba.theme.inc
index 9707a0f..ef169bf 100644
--- a/muamba.theme.inc
+++ b/muamba.theme.inc
@@ -36,7 +36,7 @@ function theme_muamba_transactions($variables) {
foreach($transactions as $transaction) {
$actions = array();
- foreach (muamba_actions_available($type, $transaction['status']) as $action) {
+ foreach (muamba_actions_available($type, $transaction) as $action) {
$callback = muamba_actions($action);
$actions[] = l(t($callback), 'muamba/'. $callback .'/'. $transaction['mid']);
}
@@ -174,7 +174,7 @@ function theme_muamba_widget_owner($variables) {
$content .= '<br />';
}
- foreach (muamba_actions_available('received', $transaction['status']) as $action) {
+ foreach (muamba_actions_available('received', $transaction) as $action) {
$content .= theme('muamba_widget_icon', array(
'status' => $action,
'id' => $transaction['mid'],
@@ -193,7 +193,7 @@ function theme_muamba_widget_requester($variables) {
$transaction = $variables['transaction'];
$size = $variables['size'];
- foreach (muamba_actions_available('sent', $transaction['status']) as $action) {
+ foreach (muamba_actions_available('sent', $transaction) as $action) {
$content .= theme('muamba_widget_icon', array(
'status' => $action,
'id' => $transaction['mid'],