<?php
/*+*******************************************************************************
 * The content of this file is subject to the CRMTiger Pro license.
 * ("License"); You may not use this file except in compliance with the License
 * The Initial Developer of the Original Code is vTiger
 * The Modified Code of the Original Code owned by https://crmtiger.com/
 * Portions created by CRMTiger.com are Copyright(C) CRMTiger.com
 * All Rights Reserved.
  ***************************************************************************** */
class CTMobileSettings_SaveModuleIcons_Action extends Vtiger_Save_Action {

	public function process(Vtiger_Request $request) {
		global $root_directory;
		$IconModule = $request->get('IconModule');
		if(!empty($_FILES['moduleIcon']['name']) && !empty($IconModule)) {
			$destinationpath = $root_directory.'modules/CTMobile/MobileIcon/'.$IconModule.'.png';
			if(file_exists($destinationpath)){
				unlink($destinationpath);
			}
			$upload_status = move_uploaded_file($_FILES['moduleIcon']['tmp_name'],$destinationpath);
		}
		$reloadUrl = 'index.php?module=CTMobileSettings&parent=Settings&view=ModuleIcons';
		header('Location: ' . $reloadUrl);
	}
}
?>
