/** * utf8_recursive_encode * * This function walks through an Array and recursively calls utf8_encode on the * values of each of the elements. * * @param $data Array of data to encode * @return utf8 encoded Array data */ function utf8_recursive_encode($data) { $result = array(); foreach ($data as $key => $val) { if (is_array($val)) { $result[$key] = utf8_recursive_encode($val); } else { $result[$key] = utf8_encode($val); } } return $result; }
} else { $GLOBALS['log']->debug("*** ERROR: tried to delete an email for an account for which {$current_user->full_name} is not the owner!"); echo "NOOP: error see log"; } } else { echo "error: missing credentials"; } break; case "getSingleMessage": $GLOBALS['log']->debug("********** EMAIL 2.0 - Asynchronous - at: getSingleMessage"); if (isset($_REQUEST['uid']) && !empty($_REQUEST['uid']) && isset($_REQUEST['ieId']) && !empty($_REQUEST['ieId'])) { $out = $email->et->getSingleMessage($ie); //Bug: //echo $json->encode($out); //header("Content-Type: application/json; charset=UTF-8"); echo $json->encode(utf8_recursive_encode($out)); } else { echo "error: no UID"; } break; case "getSingleMessageFromSugar": $GLOBALS['log']->debug("********** EMAIL 2.0 - Asynchronous - at: getSingleMessageFromSugar"); if (isset($_REQUEST['uid']) && !empty($_REQUEST['uid'])) { $email->retrieve($_REQUEST['uid']); //$email->description_html = from_html($email->description_html); $ie->email = $email; if ($email->status == 'draft' || $email->type == 'draft') { // forcing an editview since we are looking at a draft message global $current_user; $ret = $ie->email->et->displayComposeEmail($email); $ret = $ie->email->et->getDraftAttachments($ret, $ie);