modules/MailIntegration/actions/Import.php
<?php
/**
* Import action file.
*
* @package Action
*
* @copyright YetiForce S.A.
* @license YetiForce Public License 6.5 (licenses/LicenseEN.txt or yetiforce.com)
* @author Mariusz Krzaczkowski <m.krzaczkowski@yetiforce.com>
*/
/**
* Import action class.
*/
class MailIntegration_Import_Action extends \App\Controller\Action
{
/** {@inheritdoc} */
public function checkPermission(App\Request $request)
{
if (!Users_Privileges_Model::getCurrentUserPrivilegesModel()->hasModulePermission($request->getModule())) {
throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);
}
if (!\App\Privilege::isPermitted('OSSMailView', 'CreateView')) {
throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);
}
}
/** {@inheritdoc} */
public function process(App\Request $request)
{
$mail = App\Mail\Message::getScannerByEngine($request->getByType('source'));
$mail->initFromRequest($request);
$mail->process();
$response = new Vtiger_Response();
$response->setResult($mail->processData);
$response->emit();
}
}