Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/units/helpers/upload_helper.php
Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Line(s) | |||||
} | } | ||||
/** @var FileHelper $file_helper */ | /** @var FileHelper $file_helper */ | ||||
$file_helper = $this->Application->recallObject('FileHelper'); | $file_helper = $this->Application->recallObject('FileHelper'); | ||||
$filename = $file_helper->ensureUniqueFilename($tmp_path, $filename); | $filename = $file_helper->ensureUniqueFilename($tmp_path, $filename); | ||||
$storage_format = $this->getStorageFormat($this->Application->GetVar('field'), $event); | $storage_format = $this->getStorageFormat($this->Application->GetVar('field'), $event); | ||||
if ( $storage_format ) { | if ( $storage_format ) { | ||||
/** @var ImageHelper $image_helper */ | |||||
$image_helper = $this->Application->recallObject('ImageHelper'); | $image_helper = $this->Application->recallObject('ImageHelper'); | ||||
/* @var $image_helper ImageHelper */ | |||||
$this->moveUploadedFile($value['tmp_name'] . '.jpg'); // add extension, so ResizeImage can work | $this->moveUploadedFile($value['tmp_name'] . '.jpg'); // add extension, so ResizeImage can work | ||||
$url = $image_helper->ResizeImage($value['tmp_name'] . '.jpg', $storage_format); | $url = $image_helper->ResizeImage($value['tmp_name'] . '.jpg', $storage_format); | ||||
$tmp_name = preg_replace('/^' . preg_quote($this->Application->BaseURL(), '/') . '/', '/', $url); | $tmp_name = preg_replace('/^' . preg_quote($this->Application->BaseURL(), '/') . '/', '/', $url); | ||||
rename($tmp_name, $tmp_path . $filename); | rename($tmp_name, $tmp_path . $filename); | ||||
} | } | ||||
else { | else { | ||||
$this->moveUploadedFile($tmp_path . $filename); | $this->moveUploadedFile($tmp_path . $filename); | ||||
Show All 36 Lines | |||||
// Flash uploader does NOT send correct cookies, so we need to make our own check | // Flash uploader does NOT send correct cookies, so we need to make our own check | ||||
$cookie_name = 'adm_' . $this->Application->ConfigValue('SessionCookieName'); | $cookie_name = 'adm_' . $this->Application->ConfigValue('SessionCookieName'); | ||||
$this->Application->HttpQuery->Cookie['cookies_on'] = 1; | $this->Application->HttpQuery->Cookie['cookies_on'] = 1; | ||||
$this->Application->HttpQuery->Cookie[$cookie_name] = $this->Application->GetVar('flashsid'); | $this->Application->HttpQuery->Cookie[$cookie_name] = $this->Application->GetVar('flashsid'); | ||||
// this prevents session from auto-expiring when KeepSessionOnBrowserClose & FireFox is used | // this prevents session from auto-expiring when KeepSessionOnBrowserClose & FireFox is used | ||||
$this->Application->HttpQuery->Cookie[$cookie_name . '_live'] = $this->Application->GetVar('flashsid'); | $this->Application->HttpQuery->Cookie[$cookie_name . '_live'] = $this->Application->GetVar('flashsid'); | ||||
/** @var Session $admin_session */ | |||||
$admin_session = $this->Application->recallObject('Session.admin'); | $admin_session = $this->Application->recallObject('Session.admin'); | ||||
/* @var $admin_session Session */ | |||||
if ( $admin_session->RecallVar('user_id') == USER_ROOT ) { | if ( $admin_session->RecallVar('user_id') == USER_ROOT ) { | ||||
return true; | return true; | ||||
} | } | ||||
// copy some data from given session to current session | // copy some data from given session to current session | ||||
$backup_user_id = $this->Application->RecallVar('user_id'); | $backup_user_id = $this->Application->RecallVar('user_id'); | ||||
$this->Application->StoreVar('user_id', $admin_session->RecallVar('user_id')); | $this->Application->StoreVar('user_id', $admin_session->RecallVar('user_id')); | ||||
▲ Show 20 Lines • Show All 124 Lines • ▼ Show 20 Line(s) | |||||
* | * | ||||
* @param kEvent $event Event. | * @param kEvent $event Event. | ||||
* @param string $field Field. | * @param string $field Field. | ||||
* | * | ||||
* @return kDBItem | * @return kDBItem | ||||
*/ | */ | ||||
public function prepareUploadedFile(kEvent $event, $field) | public function prepareUploadedFile(kEvent $event, $field) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(Array ('skip_autoload' => true)); | $object = $event->getObject(Array ('skip_autoload' => true)); | ||||
/* @var $object kDBItem */ | |||||
$filename = $this->getSafeFilename(); | $filename = $this->getSafeFilename(); | ||||
if ( !$filename ) { | if ( !$filename ) { | ||||
$object->SetDBField($field, ''); | $object->SetDBField($field, ''); | ||||
return $object; | return $object; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |