X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FReport%2FForm.php;h=a6b4b9c4950b2614f47bd40ace87f88c0c5f3365;hb=46065582296a47d6c28887e8c939c57083f70476;hp=3b72580d73774d18a6589451aa0dd884327c3bc1;hpb=c9dcfd6d5d5d38c036786e90f9369c1ef4f726df;p=civicrm-core.git diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 3b72580d73..a6b4b9c495 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -3361,5 +3361,35 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a } } } + + /* 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(); + } + } }