modules/OSSMailView/actions/Relation.php
<?php
/**
* Relation action class.
*
* @copyright YetiForce S.A.
* @license YetiForce Public License 6.5 (licenses/LicenseEN.txt or yetiforce.com)
* @author Mariusz Krzaczkowski <m.krzaczkowski@yetiforce.com>
*/
class OSSMailView_Relation_Action extends \App\Controller\Action
{
/**
* Function to check permission.
*
* @param \App\Request $request
*
* @throws \App\Exceptions\NoPermitted
* @throws \App\Exceptions\NoPermittedToRecord
*/
public function checkPermission(App\Request $request)
{
$moduleName = $request->getModule();
$userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
if (!$userPrivilegesModel->hasModulePermission($moduleName)) {
throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);
}
if (!\App\Privilege::isPermitted($moduleName, 'ReloadRelationRecord')) {
throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);
}
if (!\App\Privilege::isPermitted($request->getByType('moduleName'), 'DetailView', $request->getInteger('record'))) {
throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);
}
}
public function process(App\Request $request)
{
$moduleName = $request->getModule();
$recordModel = Vtiger_Record_Model::getCleanInstance($moduleName);
$recordModel->setReloadRelationRecord($request->getByType('moduleName'), $request->getInteger('record'));
$response = new Vtiger_Response();
$response->setResult(\App\Language::translate('LBL_SET_RELOAD_RELATIONS', $moduleName));
$response->emit();
}
}