-
Notifications
You must be signed in to change notification settings - Fork 460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding support to keep original Filename of Attachment and open more flexibility #645
base: master
Are you sure you want to change the base?
Conversation
Adding support for "original" Filename. $mailbox->setAttachmentsFilenameMode(Mailbox::ATTACH_FILE_NAMERANDOM); # filename by random (old way) $mailbox->setAttachmentsFilenameMode(Mailbox::ATTACH_FILE_NAMEORIGINAL); # filename by email
@fglueck can you please resolve the conflicts? |
@fglueck friendly reminder :) |
Can you please also squash your commits at the end, so that it's only one? It would be also cool, when the commit message would be Thank you! :) |
sorry I miss the button "Squash and merge". Is it possible that you must first "allow" this? |
I have unfortunately no permissions to change any settings of this project. But you can usually rebase and squash locally and force push the changes, don't you? Ok, if it's not possible, I also can squash and merge it through the buttons here. :) |
Wouldn't it be a bit more beautiful and more human readable, when there would be some more underscores in the constant names? Like this? public const ATTACH_FILE_NAME_RANDOM = 1; // Filename is unique (random)
public const ATTACH_FILE_NAME_ORIGINAL = 2; // Filename is Attachment-Filename
public const ATTACH_FILE_NAME_ITTERATED = 3; // Filename is Attachment-Filename but if allready exists it will be extend by Number (#nr) |
Your right, I change the names and add itterated filename. |
Perfect, I've already seen it. There are some more reviews (see above). :) |
You meen the "squash" ? I never do this before... so I can try to do this... |
No, I mean these pending reviews in the code. |
Adding support for "original" Filename. $mailbox->setAttachmentsFilenameMode(Mailbox::ATTACH_FILE_NAME_RANDOM); # filename by random (old way) $mailbox->setAttachmentsFilenameMode(Mailbox::ATTACH_FILE_NAME_ORIGINAL); # filename by email
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, forgot to publish my review. 😞
src/PhpImap/Mailbox.php
Outdated
public const ATTACH_FILE_NAMERANDOM = 1; // Filename is unique (random) | ||
public const ATTACH_FILE_NAMEORIGINAL = 2; // Filename is Attachment-Filename | ||
/** @var int */ | ||
protected $attachmentsFilenameMode = self::ATTACH_FILE_NAMERANDOM; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protected $attachmentsFilenameMode = self::ATTACH_FILE_NAMERANDOM; | |
protected $attachmentsFilenameMode = self::ATTACH_FILE_NAMERANDOM; | |
|
||
public const ATTACH_FILE_NAMERANDOM = 1; // Filename is unique (random) | ||
public const ATTACH_FILE_NAMEORIGINAL = 2; // Filename is Attachment-Filename | ||
/** @var int */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** @var int */ | |
/** @var int */ |
src/PhpImap/Mailbox.php
Outdated
/** | ||
* Set $this->setAttachmentsRandomFilename param. | ||
* | ||
* @param int $random ATTACH_FILE_NAMERANDOM, ATTACH_FILE_NAMEORIGINAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable in the comment should match the actual parameter variable.
* @param int $random ATTACH_FILE_NAMERANDOM, ATTACH_FILE_NAMEORIGINAL | |
* @param int $mode ATTACH_FILE_NAMERANDOM, ATTACH_FILE_NAMEORIGINAL |
public function setAttachmentsFilenameMode(int $mode) : Mailbox | ||
{ | ||
$this->attachmentsFilenameMode = $mode; | ||
return $this; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need this return here? Wouldn't be a void
function enough?
*/ | ||
public function setAttachmentsFilenameMode(int $mode) : Mailbox | ||
{ | ||
$this->attachmentsFilenameMode = $mode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I miss a check here, which ensures, that only supported modes can be set. Something like this:
$this->attachmentsFilenameMode = $mode; | |
if (!defined($mode)) | |
{ | |
throw new UnexpectedValueException("The defined mode '$mode' is not supported. Supported modes: ATTACH_FILE_NAMERANDOM, ATTACH_FILE_NAMEORIGINAL"); | |
} | |
$this->attachmentsFilenameMode = $mode; |
Note: I haven't tested this code.
can be extend with settings like "OVERWRITE_EXISTING _FILES" or like "GENERATE_FILENAME_IF_FILE_EXISTS"...