]> gitweb.fluxo.info Git - drupal/muamba.git/commitdiff
New business logic
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 6 Oct 2011 18:54:34 +0000 (15:54 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Thu, 6 Oct 2011 18:54:34 +0000 (15:54 -0300)
muamba.business.inc
muamba.misc.inc
muamba.module

index eabd351d66e70d2ac0d30303ec8cf856ee62ef7e..708d97ebb0481d1fd7de00ba59dfa095d07eca69 100644 (file)
@@ -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) {
 }
index 0b857bd963df196a14c9315728f508e51cc93c53..b5c11114635eda0da3486952ee03cb5651189efd 100644 (file)
@@ -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) {
index fd6fd7444ef336a532393f2aa4054abc2279e895..f425d3e1f4775575c54657457d26cab56e3d5f48 100644 (file)
  */
 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',
   );