condition('m.nid', $nid, '=') ->condition('m.uid', $uid, '=') ->condition('m.status', MUAMBA_REQUESTED, '='); $result = $query->countQuery()->execute()->fetchField(); if ($result > 0) { return TRUE; } return FALSE; } /** * Get the requests sent or received. * * @param $uid * Requester user uid. * * @param $type * Transaction type (sent or received). * * @param $status * Current transaction status. * * @return * Array of existing transactions. */ function muamba_get_transactions($uid, $type = 'sent', $status = NULL) { $uid = (int) $uid; $query = db_select('muamba', 'm'); $query->fields('m', array('mid', 'nid', 'uid', 'owner', 'status', 'thread_id')); if ($type == 'sent') { $query->condition('m.uid', $uid, '='); } else { $query->condition('m.owner', $uid, '='); } if ($status != NULL) { $query->condition('m.status', $status, '='); } $rows = array(); $results = $query->execute()->fetchAll(); // Sanitize the data before handing it off to the theme layer. foreach ($results as $entry) { $rows[] = array_map('check_plain', (array) $entry); } return $rows; } /** * Get a single transaction. * * @param $data * Transaction id or node object. * * @return * Transaction data. */ function muamba_get_transaction($data) { $query = db_select('muamba', 'm'); $query->fields('m', array('mid', 'nid', 'uid', 'owner', 'status', 'thread_id')); if (is_object($data)) { $query->condition('m.nid', $data->nid, '='); } else { $query->condition('m.mid', (int) $data, '='); } $rows = array(); $results = $query->execute()->fetchAll(); // Sanitize the data before handing it off to the theme layer. foreach ($results as $entry) { $rows[] = array_map('check_plain', (array) $entry); } if (isset($rows[0])) { return $rows[0]; } }