Skip to content

Commit

Permalink
[#98] dropped CiviCRM 4.6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
abugey committed Nov 15, 2022
1 parent 1c33e1e commit 0c3be7e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 48 deletions.
2 changes: 1 addition & 1 deletion CRM/Xcm/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ public function getCurrentUserID($fallback_id = 2) {
}

// check via API key, i.e. when coming through REST-API
$api_key = CRM_Utils_Request::retrieve('api_key', 'String', $store, FALSE, NULL, 'REQUEST');
$api_key = CRM_Utils_Request::retrieve('api_key', 'String', NULL, FALSE, NULL, 'REQUEST');
if (!$api_key || strtolower($api_key) == 'null') {
return $fallback_id; // nothing we can do
}
Expand Down
49 changes: 2 additions & 47 deletions CRM/Xcm/Form/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ class CRM_Xcm_Form_Import extends CRM_Core_Form {
public function buildQuickForm() {
$config = CRM_Core_Config::singleton();

$uploadFileSize = self::formatUnitSize(
$uploadFileSize = CRM_Utils_Number::formatUnitSize(
$config->maxFileSize . 'm',
TRUE
);
// Fetch uploadFileSize from php_ini when $config->maxFileSize is set to
// "no limit".
if (empty($uploadFileSize)) {
$uploadFileSize = self::formatUnitSize(
$uploadFileSize = CRM_Utils_Number::formatUnitSize(
ini_get('upload_max_filesize'),
TRUE
);
Expand Down Expand Up @@ -223,49 +223,4 @@ public function getRenderableElementNames() {
return $elementNames;
}

/**
* Copied from CiviCRM 4.7+
*
* @param string $size
* @param bool $checkForPostMax
*
* @return int
*/
public static function formatUnitSize($size, $checkForPostMax = FALSE) {
// if the method exists in CiviCRM -> use that!
if (method_exists('CRM_Utils_Number', 'formatUnitSize')) {
return CRM_Utils_Number::formatUnitSize($size, $checkForPostMax);
}

// doesn't exist -> we're probably on CiviCRM 4.6
if ($size) {
$last = strtolower($size{strlen($size) - 1});
$size = (int) $size;
switch ($last) {
// The 'G' modifier is available since PHP 5.1.0

case 'g':
$size *= 1024;
case 'm':
$size *= 1024;
case 'k':
$size *= 1024;
}

if ($checkForPostMax) {
$maxImportFileSize = self::formatUnitSize(ini_get('upload_max_filesize'));
$postMaxSize = self::formatUnitSize(ini_get('post_max_size'));
if ($maxImportFileSize > $postMaxSize && $postMaxSize == $size) {
CRM_Core_Session::setStatus(ts("Note: Upload max filesize ('upload_max_filesize') should not exceed Post max size ('post_max_size') as defined in PHP.ini, please check with your system administrator."), ts("Warning"), "alert");
}
// respect php.ini upload_max_filesize
if ($size > $maxImportFileSize && $size !== $postMaxSize) {
$size = $maxImportFileSize;
CRM_Core_Session::setStatus(ts("Note: Please verify your configuration for Maximum File Size (in MB) <a href='%1'>Administrator >> System Settings >> Misc</a>. It should support 'upload_max_size' as defined in PHP.ini.Please check with your system administrator.", array(1 => CRM_Utils_System::url('civicrm/admin/setting/misc', 'reset=1'))), ts("Warning"), "alert");
}
}
return $size;
}
}

}

0 comments on commit 0c3be7e

Please sign in to comment.