You are here

function heartbeat_decode_message_variables in Heartbeat 6.3

Same name and namespace in other branches
  1. 6.4 heartbeat.common.inc \heartbeat_decode_message_variables()
  2. 6.2 heartbeat.module \heartbeat_decode_message_variables()
  3. 7 heartbeat.module \heartbeat_decode_message_variables()

Decode heartbeat message variables

5 calls to heartbeat_decode_message_variables()
flag_heartbeat_form_alter in modules/flag_heartbeat/flag_heartbeat.module
Implementation of hook_form_alter().
HeartbeatActivity::set_data in includes/heartbeatactivity.inc
Set data into members
heartbeat_messages_edit in ./heartbeat.admin.inc
Function to maintain and administer heartbeat messages
heartbeat_messages_export_messages in ./heartbeat.admin.inc
Function to export messages to use as default
heartbeat_variables_compare in ./heartbeat.common.inc
compares variables that need to be included with variables that are already there and check their values to fit as default value in a textarea

File

./heartbeat.common.inc, line 12
Commonly functions used in heartbeat

Code

function heartbeat_decode_message_variables($string, $object = false) {

  // Variable string need to be cleared from spaces to decode properly
  $array = explode("-|-", $string);
  $variables = array();
  if (!empty($array)) {
    foreach ($array as $varvalue) {
      $parts = explode("=|=", $varvalue);
      if (isset($parts[0]) && !empty($parts[0])) {
        if (eregi("\\*\\*\\*", $parts[1])) {
          $parts[1] = explode("***", $parts[1]);
        }
        $variables[$parts[0]] = !is_array($parts[1]) ? (string) $parts[1] : $parts[1];
      }
    }
  }

  //$variables = unserialize($string);
  return $object ? (object) $variables : (array) $variables;
}