array( 'title' => t('Request an item'), 'description' => t('Request an item to be borrowed or donated.'), ), ); } /** * Implements hook_menu() */ function muamba_menu() { $items['admin/config/system/muamba'] = array( 'title' => 'Muamba Configuration', 'description' => 'Configure options for Muamba System', 'page callback' => 'drupal_get_form', 'page arguments' => array('muamba_config_form'), 'access arguments' => array('administer muamba'), 'file' => 'muamba.admin.inc', 'type' => MENU_NORMAL_ITEM, ); $items['muamba'] = array( 'title' => 'My items', 'page callback' => 'muamba', 'access arguments' => array('access content'), 'type' => MENU_SUGGESTED_ITEM, 'file' => 'muamba.business.inc', ); $items['muamba/request'] = array( 'title' => 'Request an item', 'page callback' => 'muamba_request', 'access arguments' => array('request item'), 'type' => MENU_SUGGESTED_ITEM, 'file' => 'muamba.business.inc', ); $items['muamba/accept'] = array( 'title' => 'Accept an item request', 'page callback' => 'muamba_accept', 'access arguments' => array('access content'), 'type' => MENU_SUGGESTED_ITEM, 'file' => 'muamba.business.inc', ); $items['muamba/reject'] = array( 'title' => 'Reject an item request', 'page callback' => 'muamba_reject', 'access arguments' => array('access content'), 'type' => MENU_SUGGESTED_ITEM, 'file' => 'muamba.business.inc', ); $items['muamba/cancel'] = array( 'title' => 'Cancel a request', 'page callback' => 'muamba_cancel', 'access arguments' => array('access content'), 'type' => MENU_SUGGESTED_ITEM, 'file' => 'muamba.business.inc', ); $items['muamba/recover'] = array( 'title' => 'Recover an item', 'page callback' => 'muamba_recover', 'access arguments' => array('access content'), 'type' => MENU_SUGGESTED_ITEM, 'file' => 'muamba.business.inc', ); $items['muamba/return'] = array( 'title' => 'Return an item', 'page callback' => 'muamba_return', 'access arguments' => array('access content'), 'type' => MENU_SUGGESTED_ITEM, 'file' => 'muamba.business.inc', ); $items['muamba/lost'] = array( 'title' => 'Report a lost item', 'page callback' => 'muamba_lost', 'access arguments' => array('access content'), 'type' => MENU_SUGGESTED_ITEM, 'file' => 'muamba.business.inc', ); return $items; } /** * Implements hook_node_view() */ function muamba_node_view($node, $view_mode, $langcode) { if ($view_mode == 'full') { $node->content['muamba'] = array( '#markup' => muamba_widget($node, 'big'), '#weight' => 100, ); return $node; } } /** * Implements hook_theme() */ function muamba_theme($existing, $type, $theme, $path) { return array( 'muamba_widget' => array( 'template' => 'muamba-widget', 'variables' => array( 'node' => NULL, 'transactions' => NULL, 'available' => NULL, 'size' => 'small', ), ), 'muamba_widget_owner' => array( 'variables' => array( 'transaction' => NULL, 'size' => 'small', ), 'file' => 'muamba.theme.inc', ), 'muamba_widget_requester' => array( 'variables' => array( 'transaction' => NULL, 'size' => 'small', ), 'file' => 'muamba.theme.inc', ), 'muamba_powered' => array( 'template' => 'muamba-powered', ), 'muamba_transactions' => array( 'variables' => array( 'transactions' => NULL, 'type' => NULL, ), 'file' => 'muamba.theme.inc', ), 'muamba_colorbox_link' => array( 'variables' => array( 'path' => NULL, 'text' => NULL, ), 'file' => 'muamba.theme.inc', ), 'muamba_request_message' => array( 'variables' => array( 'transaction' => NULL, ), 'file' => 'muamba.theme.inc', ), 'muamba_accept_message' => array( 'variables' => array( 'transaction' => NULL, ), 'file' => 'muamba.theme.inc', ), 'muamba_reject_message' => array( 'variables' => array( 'transaction' => NULL, ), 'file' => 'muamba.theme.inc', ), 'muamba_cancel_message' => array( 'variables' => array( 'transaction' => NULL, ), 'file' => 'muamba.theme.inc', ), 'muamba_return_message' => array( 'variables' => array( 'transaction' => NULL, ), 'file' => 'muamba.theme.inc', ), 'muamba_recover_message' => array( 'variables' => array( 'transaction' => NULL, ), 'file' => 'muamba.theme.inc', ), 'muamba_lost_message' => array( 'variables' => array( 'transaction' => NULL, ), 'file' => 'muamba.theme.inc', ), 'muamba_widget_icon' => array( 'variables' => array( 'status' => MUAMBA_REQUESTED, 'id' => NULL, 'size' => 'small', ), 'file' => 'muamba.theme.inc', ), ); } /** * Implements hook_block_info() */ function muamba_block_info() { $blocks['muamba_powered'] = array( 'info' => t('Muamba powered'), 'cache' => DRUPAL_NO_CACHE, 'status' => TRUE, 'region' => 'footer', ); return $blocks; } /** * Implements hook_block_view() */ function muamba_block_view($delta = '') { $block = array(); switch ($delta) { case 'muamba_powered': $block['subject'] = NULL; $block['content'] = theme('muamba_powered'); break; } return $block; } /** * Implements hook_privatemsg_view_alter() */ function muamba_privatemsg_view_alter(&$content) { $thread = $content['#thread']['thread_id']; $transaction = muamba_get_transaction($thread, 'thread_id'); if (!empty($transaction)) { global $user; $node = node_load($transaction['nid']); $available = muamba_check_availability($node->nid); $widget = ($node->uid == $user->uid) ? 'owner' : 'requester'; $bar = theme('muamba_widget_'. $widget, array( 'node' => $node, 'transaction' => $transaction, 'available' => $available, 'size' => 'big', )); $content['participants']['#markup'] = $bar . $content['participants']['#markup']; } } /** * Implements hook_node_delete() */ function muamba_node_delete($node) { db_delete('muamba') ->condition('nid', $node->nid) ->execute(); } /** * Implements hook_user_delete() */ function muamba_user_delete($account) { db_delete('muamba') ->condition('uid', $account->uid) ->execute(); db_delete('muamba') ->condition('owner', $account->uid) ->execute(); } /** * Implementes hook_views_data() */ function muamba_views_api() { return array( 'api' => 3, ); } /** * Implements hook_node_update() */ function muamba_node_update($node) { if ($node->type == MUAMBA_NODE_TYPE) { db_update('muamba') ->fields(array('owner' => $node->uid)) ->condition('nid', $node->nid, '=') ->execute(); } } /** * Implements hook_form_alter() */ function muamba_form_alter(&$form, &$form_state, $form_id) { // Remove bookmark option. if ($form_id == 'muamba_node_form') { unset($form['flag']); } }