added php download of membershipments
This commit is contained in:
56
vendor/webklex/php-imap/examples/custom_attachment_mask.php
vendored
Normal file
56
vendor/webklex/php-imap/examples/custom_attachment_mask.php
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/*
|
||||
* File: custom_message_mask.php
|
||||
* Category: Example
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 14.03.19 18:47
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
class CustomAttachmentMask extends \Webklex\PHPIMAP\Support\Masks\AttachmentMask {
|
||||
|
||||
/**
|
||||
* New custom method which can be called through a mask
|
||||
* @return string
|
||||
*/
|
||||
public function token(){
|
||||
return implode('-', [$this->id, $this->getMessage()->getUid(), $this->name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom attachment saving method
|
||||
* @return bool
|
||||
*/
|
||||
public function custom_save() {
|
||||
$path = "foo".DIRECTORY_SEPARATOR."bar".DIRECTORY_SEPARATOR;
|
||||
$filename = $this->token();
|
||||
|
||||
return file_put_contents($path.$filename, $this->getContent()) !== false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** @var \Webklex\PHPIMAP\Client $client */
|
||||
$cm = new \Webklex\PHPIMAP\ClientManager('path/to/config/imap.php');
|
||||
$client = $cm->account('default');
|
||||
$client->connect();
|
||||
$client->setDefaultAttachmentMask(CustomAttachmentMask::class);
|
||||
|
||||
/** @var \Webklex\PHPIMAP\Folder $folder */
|
||||
$folder = $client->getFolder('INBOX');
|
||||
|
||||
/** @var \Webklex\PHPIMAP\Message $message */
|
||||
$message = $folder->query()->limit(1)->get()->first();
|
||||
|
||||
/** @var \Webklex\PHPIMAP\Attachment $attachment */
|
||||
$attachment = $message->getAttachments()->first();
|
||||
|
||||
/** @var CustomAttachmentMask $masked_attachment */
|
||||
$masked_attachment = $attachment->mask();
|
||||
|
||||
echo 'Token for uid ['.$masked_attachment->getMessage()->getUid().']: '.$masked_attachment->token();
|
||||
|
||||
$masked_attachment->custom_save();
|
||||
50
vendor/webklex/php-imap/examples/custom_message_mask.php
vendored
Normal file
50
vendor/webklex/php-imap/examples/custom_message_mask.php
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/*
|
||||
* File: custom_message_mask.php
|
||||
* Category: Example
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 14.03.19 18:47
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
class CustomMessageMask extends \Webklex\PHPIMAP\Support\Masks\MessageMask {
|
||||
|
||||
/**
|
||||
* New custom method which can be called through a mask
|
||||
* @return string
|
||||
*/
|
||||
public function token(){
|
||||
return implode('-', [$this->message_id, $this->uid, $this->message_no]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get number of message attachments
|
||||
* @return integer
|
||||
*/
|
||||
public function getAttachmentCount() {
|
||||
return $this->getAttachments()->count();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** @var \Webklex\PHPIMAP\Client $client */
|
||||
$cm = new \Webklex\PHPIMAP\ClientManager('path/to/config/imap.php');
|
||||
$client = $cm->account('default');
|
||||
$client->connect();
|
||||
|
||||
/** @var \Webklex\PHPIMAP\Folder $folder */
|
||||
$folder = $client->getFolder('INBOX');
|
||||
|
||||
/** @var \Webklex\PHPIMAP\Message $message */
|
||||
$message = $folder->query()->limit(1)->get()->first();
|
||||
|
||||
/** @var CustomMessageMask $masked_message */
|
||||
$masked_message = $message->mask(CustomMessageMask::class);
|
||||
|
||||
echo 'Token for uid ['.$masked_message->uid.']: '.$masked_message->token().' @atms:'.$masked_message->getAttachmentCount();
|
||||
|
||||
$masked_message->setFlag('seen');
|
||||
|
||||
42
vendor/webklex/php-imap/examples/folder_structure.blade.php
vendored
Normal file
42
vendor/webklex/php-imap/examples/folder_structure.blade.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/*
|
||||
* File: folder_structure.blade.php
|
||||
* Category: View
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 15.09.18 19:53
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
/**
|
||||
* @var \Webklex\PHPIMAP\Support\FolderCollection $paginator
|
||||
* @var \Webklex\PHPIMAP\Folder $folder
|
||||
*/
|
||||
|
||||
?>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Folder</th>
|
||||
<th>Unread messages</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if($paginator->count() > 0): ?>
|
||||
<?php foreach($paginator as $folder): ?>
|
||||
<tr>
|
||||
<td><?php echo $folder->name; ?></td>
|
||||
<td><?php echo $folder->search()->unseen()->setFetchBody(false)->count(); ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<td colspan="4">No folders found</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php echo $paginator->links(); ?>
|
||||
46
vendor/webklex/php-imap/examples/message_table.blade.php
vendored
Normal file
46
vendor/webklex/php-imap/examples/message_table.blade.php
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/*
|
||||
* File: message_table.blade.php
|
||||
* Category: View
|
||||
* Author: M.Goldenbaum
|
||||
* Created: 15.09.18 19:53
|
||||
* Updated: -
|
||||
*
|
||||
* Description:
|
||||
* -
|
||||
*/
|
||||
|
||||
/**
|
||||
* @var \Webklex\PHPIMAP\Support\FolderCollection $paginator
|
||||
* @var \Webklex\PHPIMAP\Message $message
|
||||
*/
|
||||
|
||||
?>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>UID</th>
|
||||
<th>Subject</th>
|
||||
<th>From</th>
|
||||
<th>Attachments</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if($paginator->count() > 0): ?>
|
||||
<?php foreach($paginator as $message): ?>
|
||||
<tr>
|
||||
<td><?php echo $message->getUid(); ?></td>
|
||||
<td><?php echo $message->getSubject(); ?></td>
|
||||
<td><?php echo $message->getFrom()[0]->mail; ?></td>
|
||||
<td><?php echo $message->getAttachments()->count() > 0 ? 'yes' : 'no'; ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<td colspan="4">No messages found</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php echo $paginator->links(); ?>
|
||||
Reference in New Issue
Block a user