}
}
}
+
+ /* function used for showing charts on print screen */
+ static function uploadChartImage() {
+ // upload strictly for '.png' images
+ $name = CRM_Utils_Request::retrieve('name', 'String', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET');
+ if (preg_match('/\.png$/', trim($name))) {
+ //
+ // POST data is usually string data, but we are passing a RAW .png
+ // so PHP is a bit confused and $_POST is empty. But it has saved
+ // the raw bits into $HTTP_RAW_POST_DATA
+ //
+ $httpRawPostData = $GLOBALS['HTTP_RAW_POST_DATA'];
+
+ // prepare the directory
+ $config = CRM_Core_Config::singleton();
+ $defaultPath = str_replace('/persist/contribute/' , '/persist/', $config->imageUploadDir) . '/openFlashChart/';
+ if (!file_exists($defaultPath)) {
+ mkdir($defaultPath, 0777, TRUE);
+ }
+
+ // full path to the saved image including filename
+ $destination = $defaultPath . basename($name);
+
+ //write and save
+ $jfh = fopen($destination, 'w') or die("can't open file");
+ fwrite($jfh, $httpRawPostData);
+ fclose($jfh);
+ CRM_Utils_System::civiExit();
+ }
+ }
}