aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2011-09-26 10:14:44 -0300
committerSilvio Rhatto <rhatto@riseup.net>2011-09-26 10:14:44 -0300
commit23b630b52dad2ffd700f72b2a76691d558244c25 (patch)
treeee62f4186fe4d6dc7efb492fd0859604ea032c1b
parentb69edbdb6464618a8e45a8e5e484a7e267794fd4 (diff)
downloadmuamba-23b630b52dad2ffd700f72b2a76691d558244c25.tar.gz
muamba-23b630b52dad2ffd700f72b2a76691d558244c25.tar.bz2
Some fixes at business logic
-rw-r--r--muamba.business.inc59
-rw-r--r--muamba.module2
2 files changed, 32 insertions, 29 deletions
diff --git a/muamba.business.inc b/muamba.business.inc
index 22c5d92..3fcb76c 100644
--- a/muamba.business.inc
+++ b/muamba.business.inc
@@ -88,41 +88,16 @@ function muamba_check_user_request($nid, $uid) {
}
/**
- * Release an item requested by a given user.
- *
- * @param $nid
- * Item nid.
- *
- * @param $uid
- * Requester user uid.
- *
- * @todo
- */
-function muamba_release($nid, $uid) {
- global $user;
-
- $nid = (int) $nid;
- $node = node_load($nid);
-
- if (!$node || $node->type != MUAMBA_NODE_TYPE) {
- drupal_not_found();
- }
-
- if ($node->uid != $user->uid) {
- // TODO: not node owner
- }
-}
-
-/**
* Get the requests sent or received.
*
* @param $uid
* Requester user uid.
*/
function muamba_get_transactions($uid, $type = 'sent', $status = MUAMBA_REQUESTED) {
- $uid = (int) $uid;
+ $uid = (int) $uid;
+ $query = db_select('muamba', 'm');
- if ($type = 'sent') {
+ if ($type == 'sent') {
$query
->condition('m.uid', $uid, '=')
->condition('m.status', $status, '=');
@@ -140,6 +115,12 @@ function muamba_get_transactions($uid, $type = 'sent', $status = MUAMBA_REQUESTE
* Transaction management page.
*/
function muamba() {
+ global $user;
+
+ $transactions = muamba_get_transactions($user->uid);
+ dpm($transactions);
+
+ return t('Muamba management page');
}
/**
@@ -147,6 +128,8 @@ function muamba() {
*
* @param $mid
* Transaction id.
+ *
+ * @todo
*/
function muamba_accept($mid) {
}
@@ -156,6 +139,8 @@ function muamba_accept($mid) {
*
* @param $mid
* Transaction id.
+ *
+ * @todo
*/
function muamba_reject($mid) {
}
@@ -165,15 +150,33 @@ function muamba_reject($mid) {
*
* @param $mid
* Transaction id.
+ *
+ * @todo
*/
function muamba_release($mid) {
+ global $user;
+
+ // TODO: load nid from db
+ $nid = (int) $nid;
+ $node = node_load($nid);
+
+ if (!$node || $node->type != MUAMBA_NODE_TYPE) {
+ drupal_not_found();
+ }
+
+ if ($node->uid != $user->uid) {
+ // TODO: not node owner
+ }
}
+
/**
* Return an item.
*
* @param $mid
* Transaction id.
+ *
+ * @todo
*/
function muamba_return($mid) {
}
diff --git a/muamba.module b/muamba.module
index f88e00b..43857d9 100644
--- a/muamba.module
+++ b/muamba.module
@@ -34,7 +34,7 @@ function muamba_menu() {
$items['muamba'] = array(
'title' => 'My items',
'page callback' => 'muamba',
- 'access arguments' => array(),
+ 'access arguments' => array('access content'),
'type' => MENU_SUGGESTED_ITEM,
'file' => 'muamba.business.inc',
);