| 1 |
<?php |
<?php |
| 2 |
// $Id: rpg_message.module,v 1.1 2007/11/26 21:20:32 aaron Exp $ |
// $Id: rpg_message.module,v 1.2 2008/03/08 00:31:03 aaron Exp $ |
| 3 |
|
|
| 4 |
define('RPG_MESSAGE_LIMIT_DEFAULT', 25); // default number of messages to output |
define('RPG_MESSAGE_LIMIT_DEFAULT', 25); // default number of messages to output |
| 5 |
|
|
| 40 |
|
|
| 41 |
function _rpg_message_block_pc_messages() { |
function _rpg_message_block_pc_messages() { |
| 42 |
global $rpg; |
global $rpg; |
| 43 |
|
$count = 0; |
| 44 |
if ($rpg['pc']) { |
if ($rpg['pc']) { |
| 45 |
|
$items = array(); |
| 46 |
$messages = rpg_messages($rpg['pc'], NULL, NULL, variable_get('rpg_message_block_pc_messages_limit', 10)); |
$messages = rpg_messages($rpg['pc'], NULL, NULL, variable_get('rpg_message_block_pc_messages_limit', 10)); |
| 47 |
foreach ($messages as $message) { |
foreach ($messages as $message) { |
| 48 |
$items[] = $message['message']; |
$classes = 'rpg-message-item rpg-message-item-'. $message['type']; |
| 49 |
|
if (!$count) { |
| 50 |
|
$classes .= ' first'; |
| 51 |
|
} |
| 52 |
|
$items[] = array('data' => theme('rpg_message', $message['type'], $message), 'id' => 'rpg-message-item-'. $count++, 'class' => $classes); |
| 53 |
|
} |
| 54 |
|
if ($count) { |
| 55 |
|
$items[$count-1]['class'] .= ' last'; |
| 56 |
} |
} |
| 57 |
return theme('item_list', $items); |
return theme('item_list', $items); |
| 58 |
} |
} |
| 145 |
* if true, then check to see if we need to delete the message source |
* if true, then check to see if we need to delete the message source |
| 146 |
* otherwise, postpone until end of page processing (TODO) |
* otherwise, postpone until end of page processing (TODO) |
| 147 |
* @param $fetch_original_message |
* @param $fetch_original_message |
| 148 |
* if true, we return the original message array as $message['message']; |
* if true, we return the original message array as $message['data']; |
| 149 |
* @return |
* @return |
| 150 |
* returns an associative array of messages, each in the following form: |
* returns an associative array of messages, each in the following form: |
| 151 |
* $mid => array( |
* $mid => array( |
| 185 |
$messages = array(); |
$messages = array(); |
| 186 |
while ($result = db_fetch_array($results)) { |
while ($result = db_fetch_array($results)) { |
| 187 |
if ($fetch_original_message) { |
if ($fetch_original_message) { |
| 188 |
$result['message'] = unserialize($result['data']); |
$result['data'] = unserialize($result['data']); |
|
unset($result['data']); |
|
| 189 |
} |
} |
| 190 |
$messages[$result['mid']] = $result; |
$messages[$result['mid']] = $result; |
| 191 |
} |
} |
| 272 |
* 'msg', 'who_msg', 'target_msg', 'with_msg' |
* 'msg', 'who_msg', 'target_msg', 'with_msg' |
| 273 |
*/ |
*/ |
| 274 |
function theme_rpg_message($which, $message) { |
function theme_rpg_message($which, $message) { |
| 275 |
|
static $count = 0; |
| 276 |
if ($message[$which . '_theme']) { |
if ($message[$which . '_theme']) { |
| 277 |
$output = theme($message[$which . '_theme'], $message); |
$output = theme($message[$which . '_theme'], $message); |
| 278 |
} |
} |
| 283 |
$output = theme("rpg_message_$which", $message); |
$output = theme("rpg_message_$which", $message); |
| 284 |
} |
} |
| 285 |
if (!$output && $message[$which]) { |
if (!$output && $message[$which]) { |
| 286 |
$output = check_plain($message[$which]); |
$output = t($message[$which]); |
| 287 |
} |
} |
| 288 |
if (!$output && ($which != 'msg')) { |
if (!$output && ($which != 'message')) { |
| 289 |
// careful, this is recursive, so don't change $which if you override this function... |
// careful, this is recursive, so don't change $which if you override this function... |
| 290 |
$output = theme('rpg_message', 'msg', $message); |
return theme('rpg_message', 'message', $message); |
| 291 |
|
} |
| 292 |
|
if ($output) { |
| 293 |
|
$output = '<div id="rpg-message-'. $count++ .'" class="rpg-message rpg-message-'. $which .'">'. $output .'</div>'; |
| 294 |
} |
} |
| 295 |
return $output; |
return $output; |
| 296 |
} |
} |