From 23b630b52dad2ffd700f72b2a76691d558244c25 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Mon, 26 Sep 2011 10:14:44 -0300 Subject: Some fixes at business logic --- muamba.business.inc | 59 ++++++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 28 deletions(-) (limited to 'muamba.business.inc') diff --git a/muamba.business.inc b/muamba.business.inc index 22c5d92..3fcb76c 100644 --- a/muamba.business.inc +++ b/muamba.business.inc @@ -87,32 +87,6 @@ function muamba_check_user_request($nid, $uid) { return FALSE; } -/** - * 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. * @@ -120,9 +94,10 @@ function muamba_release($nid, $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) { } -- cgit v1.2.3