diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2011-10-06 15:54:34 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2011-10-06 15:54:34 -0300 |
commit | 924fb6e2bdcdf46a21684d61d018cc3132dd4f04 (patch) | |
tree | b3f3360e7f4073b7ba0a62882e15de1ab6b6fa11 | |
parent | 6ac290695fc15a0c81260d172b1e9d7f54f1a715 (diff) | |
download | muamba-924fb6e2bdcdf46a21684d61d018cc3132dd4f04.tar.gz muamba-924fb6e2bdcdf46a21684d61d018cc3132dd4f04.tar.bz2 |
New business logic
-rw-r--r-- | muamba.business.inc | 61 | ||||
-rw-r--r-- | muamba.misc.inc | 10 | ||||
-rw-r--r-- | muamba.module | 35 |
3 files changed, 72 insertions, 34 deletions
diff --git a/muamba.business.inc b/muamba.business.inc index eabd351..708d97e 100644 --- a/muamba.business.inc +++ b/muamba.business.inc @@ -32,6 +32,12 @@ function muamba_actions_available($type = 'sent', $status) { ); break; + case MUAMBA_LOST: + $actions = array( + MUAMBA_RETURN, + ); + break; + default: $actions = array(); } @@ -47,13 +53,21 @@ function muamba_actions_available($type = 'sent', $status) { case MUAMBA_ACCEPTED: $actions = array( - MUAMBA_RELEASED, + MUAMBA_RECOVERED, + MUAMBA_LOST; ); break; case MUAMBA_RETURNED: $actions = array( - MUAMBA_RELEASED, + MUAMBA_RECOVERED, + MUAMBA_LOST; + ); + break; + + case MUAMBA_LOST: + $actions = array( + MUAMBA_RECOVERED, ); break; @@ -101,6 +115,8 @@ function muamba_request($nid) { return t('The item owner has blocked you from asking this item.'); } + // TODO: check if the item is available + // Check if user already requested the item if (muamba_check_user_request($nid, $user->uid)) { return t('You already requested this item.'); @@ -186,14 +202,36 @@ function muamba_reject($mid) { } /** - * Release a transaction. + * Cancel a request. + * + * @param $mid + * Transaction id. + * + * @todo + */ +function muamba_cancel($mid) { +} + +/** + * Return an item. + * + * @param $mid + * Transaction id. + * + * @todo + */ +function muamba_return($mid) { +} + +/** + * Recover an item. * * @param $mid * Transaction id. * * @todo */ -function muamba_release($mid) { +function muamba_recover($mid) { global $user; // TODO: load nid from db @@ -210,23 +248,12 @@ function muamba_release($mid) { } /** - * Return an item. - * - * @param $mid - * Transaction id. - * - * @todo - */ -function muamba_return($mid) { -} - -/** - * Cancel a request. + * Report a lost item. * * @param $mid * Transaction id. * * @todo */ -function muamba_cancel($mid) { +function muamba_lost($mid) { } diff --git a/muamba.misc.inc b/muamba.misc.inc index 0b857bd..b5c1111 100644 --- a/muamba.misc.inc +++ b/muamba.misc.inc @@ -42,9 +42,10 @@ function muamba_statuses($code = NULL) { MUAMBA_REQUESTED => 'requested', MUAMBA_ACCEPTED => 'accepted', MUAMBA_REJECTED => 'rejected', - MUAMBA_RELEASED => 'released', - MUAMBA_RETURNED => 'returned', MUAMBA_CANCELLED => 'cancelled', + MUAMBA_RETURNED => 'returned', + MUAMBA_RECOVERED => 'recovered', + MUAMBA_LOST => 'lost', ); if ($code == NULL) { @@ -69,9 +70,10 @@ function muamba_actions($code = NULL) { MUAMBA_REQUESTED => 'request', MUAMBA_ACCEPTED => 'accept', MUAMBA_REJECTED => 'reject', - MUAMBA_RELEASED => 'release', - MUAMBA_RETURNED => 'return', MUAMBA_CANCELLED => 'cancel', + MUAMBA_RETURNED => 'return', + MUAMBA_RECOVERED => 'recover', + MUAMBA_LOST => 'lost', ); if ($code == NULL) { diff --git a/muamba.module b/muamba.module index fd6fd74..f425d3e 100644 --- a/muamba.module +++ b/muamba.module @@ -10,11 +10,12 @@ */ define('MUAMBA_NODE_TYPE', 'muamba'); define('MUAMBA_REQUESTED', 0); -define('MUAMBA_ACCEPTED', 1); -define('MUAMBA_REJECTED', 2); -define('MUAMBA_RELEASED', 3); -define('MUAMBA_RETURNED', 4); -define('MUAMBA_CANCELLED', 5); +define('MUAMBA_ACCEPTED', 1); +define('MUAMBA_REJECTED', 2); +define('MUAMBA_CANCELLED', 3); +define('MUAMBA_RETURNED', 4); +define('MUAMBA_RECOVERED', 5); +define('MUAMBA_LOST', 6); // Load requirements. include_once('muamba.misc.inc'); @@ -68,10 +69,18 @@ function muamba_menu() { 'file' => 'muamba.business.inc', ); - $items['muamba/release'] = array( - 'title' => 'Release an item', - 'page callback' => 'muamba_release', - 'access arguments' => array('release item'), + $items['muamba/cancel'] = array( + 'title' => 'Cancel a request', + 'page callback' => 'muamba_cancel', + 'access arguments' => array('cancel item'), + 'type' => MENU_SUGGESTED_ITEM, + 'file' => 'muamba.business.inc', + ); + + $items['muamba/recover'] = array( + 'title' => 'Recover an item', + 'page callback' => 'muamba_recover', + 'access arguments' => array('recover item'), 'type' => MENU_SUGGESTED_ITEM, 'file' => 'muamba.business.inc', ); @@ -84,10 +93,10 @@ function muamba_menu() { 'file' => 'muamba.business.inc', ); - $items['muamba/cancel'] = array( - 'title' => 'Cancel a request', - 'page callback' => 'muamba_cancel', - 'access arguments' => array('cancel item'), + $items['muamba/lost'] = array( + 'title' => 'Report a lost item', + 'page callback' => 'muamba_lost', + 'access arguments' => array('lost item'), 'type' => MENU_SUGGESTED_ITEM, 'file' => 'muamba.business.inc', ); |