Skip to content

Commit

Permalink
The dataurl upload code is no longer used
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Oct 28, 2013
1 parent 62b322a commit 6e552fe
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 35 deletions.
2 changes: 1 addition & 1 deletion imp/lib/Ajax/Application/Handler/ComposeAttach.php
Expand Up @@ -55,7 +55,7 @@ public function addAttachment()

if ($imp_compose->canUploadAttachment()) {
try {
$atc_ob = $imp_compose->addAttachmentFromUpload($this->vars, 'file_upload');
$atc_ob = $imp_compose->addAttachmentFromUpload('file_upload');
$result->atc_id = $atc_ob->id;
$result->success = 1;

Expand Down
2 changes: 1 addition & 1 deletion imp/lib/Ajax/Application/Handler/Dynamic.php
Expand Up @@ -900,7 +900,7 @@ public function addAttachmentCkeditor()

if ($imp_compose->canUploadAttachment()) {
try {
$atc_ob = $imp_compose->addAttachmentFromUpload($this->vars, 'upload');
$atc_ob = $imp_compose->addAttachmentFromUpload('upload');
$atc_ob->related = true;

$data = array(
Expand Down
2 changes: 1 addition & 1 deletion imp/lib/Basic/Compose.php
Expand Up @@ -186,7 +186,7 @@ protected function _init()
if (isset($_FILES['upload_' . $i]) &&
strlen($_FILES['upload_' . $i]['name'])) {
try {
$atc_ob = $imp_compose->addAttachmentFromUpload($this->vars, 'upload_' . $i);
$atc_ob = $imp_compose->addAttachmentFromUpload('upload_' . $i);
if ($notify) {
$notification->push(sprintf(_("Added \"%s\" as an attachment."), $atc_ob->getPart()->getName()), 'horde.success');
}
Expand Down
50 changes: 19 additions & 31 deletions imp/lib/Compose.php
Expand Up @@ -2838,49 +2838,37 @@ public function addAttachmentFromPart($part)
/**
* Add attachment from uploaded (form) data.
*
* @param Horde_Variables $vars Variables object.
* @param string $field The form field name.
* @param string $field The form field name.
*
* @return IMP_Compose_Attachment Attachment object.
* @throws IMP_Compose_Exception
*/
public function addAttachmentFromUpload(Horde_Variables $vars, $field)
public function addAttachmentFromUpload($field)
{
global $browser;

if ($vars->get($field . '_dataurl')) {
$url_data = new Horde_Url_Data($vars->get($field));

$atc_file = Horde::getTempFile('impatt');
file_put_contents($atc_file, $url_data->data);

$bytes = strlen($url_data->data);
$filename = $vars->get($field . '_filename');
$type = $url_data->type;
} else {
try {
$browser->wasFileUploaded($field, _("attachment"));
} catch (Horde_Browser_Exception $e) {
throw new IMP_Compose_Exception($e);
}
try {
$browser->wasFileUploaded($field, _("attachment"));
} catch (Horde_Browser_Exception $e) {
throw new IMP_Compose_Exception($e);
}

$finfo = $_FILES[$field];
$finfo = $_FILES[$field];

$atc_file = $finfo['tmp_name'];
$atc_file = $finfo['tmp_name'];

$bytes = $finfo['size'];
$filename = Horde_Util::dispelMagicQuotes($finfo['name']);
$bytes = $finfo['size'];
$filename = Horde_Util::dispelMagicQuotes($finfo['name']);

switch (empty($finfo['type']) ? $finfo['type'] : '') {
case 'application/unknown':
case '':
$type = 'application/octet-stream';
break;
switch (empty($finfo['type']) ? $finfo['type'] : '') {
case 'application/unknown':
case '':
$type = 'application/octet-stream';
break;

default:
$type = $finfo['type'];
break;
}
default:
$type = $finfo['type'];
break;
}

return $this->_addAttachment(
Expand Down
2 changes: 1 addition & 1 deletion imp/lib/Minimal/Compose.php
Expand Up @@ -100,7 +100,7 @@ protected function _init()
isset($_FILES['upload_1']) &&
strlen($_FILES['upload_1']['name'])) {
try {
$atc_ob = $imp_compose->addAttachmentFromUpload($this->vars, 'upload_1');
$atc_ob = $imp_compose->addAttachmentFromUpload('upload_1');
if ($this->vars->a == _("Expand Names")) {
$notification->push(sprintf(_("Added \"%s\" as an attachment."), $atc_ob->getPart()->getName()), 'horde.success');
}
Expand Down

0 comments on commit 6e552fe

Please sign in to comment.