aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CREDITS.txt3
-rw-r--r--images/basket.orig.pngbin0 -> 166367 bytes
-rw-r--r--images/basket.pngbin0 -> 19642 bytes
-rw-r--r--images/home.orig.pngbin0 -> 111561 bytes
-rw-r--r--images/inbox.orig.pngbin0 -> 104961 bytes
-rw-r--r--muamba-widget.tpl.php2
-rw-r--r--muamba.info1
-rw-r--r--muamba.install9
-rw-r--r--muamba.misc.inc91
-rw-r--r--muamba.module41
10 files changed, 139 insertions, 8 deletions
diff --git a/CREDITS.txt b/CREDITS.txt
index ba1a841..ee91239 100644
--- a/CREDITS.txt
+++ b/CREDITS.txt
@@ -14,3 +14,6 @@ http://www.openclipart.org/detail/152557/capitalism-kills-by-worker-152557
http://www.openclipart.org/detail/2213/crystal-earth-recycle-by-kuba
http://www.openclipart.org/detail/27073/recycling-by-egore911
http://www.openclipart.org/detail/57079/recover-symbol-by-doctormo
+http://www.openclipart.org/detail/147421/home-by-netalloy-147421
+http://www.openclipart.org/detail/107473/folder-inbox-by-anonymous
+http://www.openclipart.org/detail/160369/eshop-by-lbear
diff --git a/images/basket.orig.png b/images/basket.orig.png
new file mode 100644
index 0000000..8a57989
--- /dev/null
+++ b/images/basket.orig.png
Binary files differ
diff --git a/images/basket.png b/images/basket.png
new file mode 100644
index 0000000..33e689d
--- /dev/null
+++ b/images/basket.png
Binary files differ
diff --git a/images/home.orig.png b/images/home.orig.png
new file mode 100644
index 0000000..112c0b4
--- /dev/null
+++ b/images/home.orig.png
Binary files differ
diff --git a/images/inbox.orig.png b/images/inbox.orig.png
new file mode 100644
index 0000000..a106ae4
--- /dev/null
+++ b/images/inbox.orig.png
Binary files differ
diff --git a/muamba-widget.tpl.php b/muamba-widget.tpl.php
index ff5c140..1b2a598 100644
--- a/muamba-widget.tpl.php
+++ b/muamba-widget.tpl.php
@@ -16,7 +16,7 @@ drupal_add_css($path .'/muamba.css');
$icon = theme('image',
array(
- 'path' => $path .'/images/request.png',
+ 'path' => $path .'/images/basket.png',
'alt' => t('Request item'),
'title' => t('Request item'),
)
diff --git a/muamba.info b/muamba.info
index 0b16b58..05c134e 100644
--- a/muamba.info
+++ b/muamba.info
@@ -9,3 +9,4 @@ dependencies[] = strongarm
dependencies[] = muamba_interface
dependencies[] = muamba_system
dependencies[] = privatemsg
+dependencies[] = l10n_update
diff --git a/muamba.install b/muamba.install
index 6e68603..ab0bcef 100644
--- a/muamba.install
+++ b/muamba.install
@@ -5,9 +5,18 @@
* Muamba installation functions.
*/
+/**
+ * Implements hook_install()
+ */
function muamba_install() {
}
+/**
+ * Implements hook_schema()
+ *
+ * @todo
+ * Add privatemsg thread_id into muamba table.
+ */
function muamba_schema() {
$schema['muamba'] = array(
'description' => 'The base table for muamba assets.',
diff --git a/muamba.misc.inc b/muamba.misc.inc
index 25fceac..c164664 100644
--- a/muamba.misc.inc
+++ b/muamba.misc.inc
@@ -16,14 +16,95 @@ function muamba_request($nid) {
$nid = (int) $nid;
$node = node_load($nid);
- if (!$node) {
- // TODO: error
- return;
+ if (!$node || $node->type != MUAMBA_NODE_TYPE) {
+ drupal_not_found();
}
global $user;
- // TODO: check if user is not blocked?
- privatemsg_new_thread(array(user_load($node->uid)), 'User request', 'User has requested an item');
+ // TODO: check if user has permission to access the node.
+ // TODO: check if user is not blocked by privatemsg?
+
+ // Check if user already requested the item
+ if (muamba_check_user_request($nid, $user->uid)) {
+ // TODO
+ }
+
+ // Issue item request
+ // TODO
+
+ // Notify item owner
+ privatemsg_new_thread(array(user_load($node->uid)), t('Item request'), 'User has requested an item');
+
+ // User output
return t('You have requested an item');
}
+
+/**
+ * Check if user already requested an item.
+ *
+ * @param $nid
+ * Item nid.
+ *
+ * @param $uid
+ * Requester user nid.
+ *
+ * @return
+ * TRUE if user already requested an item, FALSE otherwise.
+ */
+function muamba_check_user_request($nid, $uid) {
+ if (!is_int($nid) || !is_int($uid)) {
+ return FALSE;
+ }
+
+ $query = db_select('muamba', 'm');
+
+ $query
+ ->condition('m.nid', $nid, '=')
+ ->condition('m.uid', $uid, '=');
+
+ $result = $query->countQuery()->execute()->fetchField();
+
+ if ($result > 0) {
+ return TRUE;
+ }
+
+ 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.
+ *
+ * @param $uid
+ * Requester user uid.
+ *
+ * @todo
+ */
+function muamba_get_requests($nid, $type = 'sent') {
+}
diff --git a/muamba.module b/muamba.module
index 8a2da28..a36b268 100644
--- a/muamba.module
+++ b/muamba.module
@@ -6,6 +6,11 @@
*/
/**
+ * Definitions.
+ */
+define('MUAMBA_NODE_TYPE', 'muamba');
+
+/**
* Implements hook_permission()
*/
function muamba_permission() {
@@ -22,13 +27,45 @@ function muamba_permission() {
*/
function muamba_menu() {
$items['muamba/request'] = array(
- 'title' => 'Request item',
+ 'title' => 'Request an item',
'page callback' => 'muamba_request',
'access arguments' => array('request item'),
'type' => MENU_SUGGESTED_ITEM,
'file' => 'muamba.misc.inc',
);
+ $items['muamba/accept'] = array(
+ 'title' => 'Accept an item request',
+ 'page callback' => 'muamba_accept',
+ 'access arguments' => array('accept item'),
+ 'type' => MENU_SUGGESTED_ITEM,
+ 'file' => 'muamba.misc.inc',
+ );
+
+ $items['muamba/reject'] = array(
+ 'title' => 'Reject an item request',
+ 'page callback' => 'muamba_reject',
+ 'access arguments' => array('reject item'),
+ 'type' => MENU_SUGGESTED_ITEM,
+ 'file' => 'muamba.misc.inc',
+ );
+
+ $items['muamba/release'] = array(
+ 'title' => 'Release an item',
+ 'page callback' => 'muamba_release',
+ 'access arguments' => array('release item'),
+ 'type' => MENU_SUGGESTED_ITEM,
+ 'file' => 'muamba.misc.inc',
+ );
+
+ $items['muamba/return'] = array(
+ 'title' => 'Return an item',
+ 'page callback' => 'muamba_return',
+ 'access arguments' => array('return item'),
+ 'type' => MENU_SUGGESTED_ITEM,
+ 'file' => 'muamba.misc.inc',
+ );
+
return $items;
}
@@ -43,7 +80,7 @@ function muamba_node_view($node, $view_mode, $langcode) {
global $user;
// Do not show widget to the owner or on non-muamba content types
- if ($node->uid == $user->uid || $node->type != 'muamba') {
+ if ($node->uid == $user->uid || $node->type != MUAMBA_NODE_TYPE) {
return;
}