dircopy($modulePath, $tmpPath . $module->name);
 $moduleTmpPath = "{$tmpPath}{$module->name}";
 chmod_R($moduleTmpPath, 0777);
 // Export write panels
 //check if arrary the write modules is empty
 if ($_POST["write_panels"] != NULL) {
     $write_panels = split(",", $_POST["write_panels"]);
     foreach ($write_panels as $panelID) {
         $writePanel = RCCWP_CustomWritePanel::Get($panelID);
         $exportedFilename = $moduleTmpPath . DIRECTORY_SEPARATOR . '_' . $writePanel->name . '.pnl';
         RCCWP_CustomWritePanel::Export($panelID, $exportedFilename);
     }
 }
 // Export duplicates and description
 $moduleInfoFilename = $moduleTmpPath . DIRECTORY_SEPARATOR . 'module_info.exp';
 $moduleInfo_exported_data['duplicates'] = RCCWP_ModuleDuplicate::GetCustomModulesDuplicates($moduleID);
 $moduleInfo_exported_data['moduleinfo'] = RCCWP_CustomWriteModule::Get($moduleID);
 $handle = fopen($moduleInfoFilename, "w");
 $result = @fwrite($handle, serialize($moduleInfo_exported_data));
 @fclose($handle);
 // -- Create zip file
 $zipFile = "{$tmpPath}{$module->name}.zip";
 chdir($moduleTmpPath . DIRECTORY_SEPARATOR);
 if (RCCWP_Application::CheckCompressionProgramZip()) {
     $command = "zip -r {$zipFile}  ./*";
 } else {
     _e('Cannot find zip program', $flutter_domain);
     return;
 }
 exec($command, $out, $err);
 // send file in header
    function View($param = 23)
    {
        global $flutter_domain;
        if (isset($_GET['custom-write-module-id']) && !empty($_GET['custom-write-module-id'])) {
            $customWriteModuleId = (int) $_GET['custom-write-module-id'];
        }
        if (isset($_POST['custom-write-module-id']) && !empty($_POST['custom-write-module-id'])) {
            $customWriteModuleId = (int) $_POST['custom-write-module-id'];
        }
        $customWriteModule = RCCWP_CustomWriteModule::Get($customWriteModuleId);
        ?>

		<div class="wrap">

		<h2><?php 
        _e('Custom Write Module Info', $flutter_domain);
        ?>
</h2>
		<h4><a href="?page=FlutterManageModules&view-modules=1"> « <?php 
        _e('Back to Custom Modules List', $flutter_domain);
        ?>
</a></h4>
		<form action="" method="post" id="view-write-module-form">
		
		<input type="hidden" name="custom-write-module-id" value="<?php 
        echo $customWriteModuleId;
        ?>
" />
			

  		<table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6">
  		<tbody>
  		<tr>
			<th scope="row" align="right"><?php 
        _e('Name', $flutter_domain);
        ?>
:</th>
			<td><?php 
        echo $customWriteModule->name;
        ?>
</td>
		</tr>
		<tr>
			<th scope="row" align="right"><?php 
        _e('Description', $flutter_domain);
        ?>
:</th>
			<td><?php 
        echo $customWriteModule->description;
        ?>
</td>
		</tr>
  		</tbody>
  		</table>
		  
		<script type="text/javascript" language="javascript">
			function confirmBeforeDelete()
			{
				return confirm("<?php 
        _e('Are you sure you want to delete this module? Please notice that all the template files of this module will be deleted too.', $flutter_domain);
        ?>
");							
			}
		</script>
		<p class="submit" >
			<input name="edit-custom-write-module" type="submit" id="edit-custom-write-module" value="<?php 
        _e('Edit Module', $flutter_domain);
        ?>
" />
			<input onclick="return confirmBeforeDelete();" name="delete-custom-write-module" type="submit" id="delete-custom-write-module" value="<?php 
        _e('Delete Module', $flutter_domain);
        ?>
" />
		</p>
		
		</form>
		
		<form action="" method="post" id="view-module-duplicates">
			<br /><br />
			<h3><?php 
        _e('Module Duplicates for Layout', $flutter_domain);
        ?>
</h3>
			<div class="tablenav"><div class="alignright">
				<input name="create-module-duplicate" type="submit" id="create-module-duplicate" value="<?php 
        _e('Create Duplicate', $flutter_domain);
        ?>
" class="button-secondary"  />
			</div></div>
			<br class="clear"/>

			<table cellpadding="3" cellspacing="3" width="100%" class="widefat">
			<thead>
			<tr>
				<th scope="col"><?php 
        _e('Name', $flutter_domain);
        ?>
</th>
				<th scope="col" colspan="2"><?php 
        _e('Action', $flutter_domain);
        ?>
</th>
			</tr>
			</thead>
			<tbody>
			<?php 
        $customWriteModuleDuplicates = RCCWP_ModuleDuplicate::GetCustomModulesDuplicates($customWriteModuleId);
        foreach ($customWriteModuleDuplicates as $customWriteModuleDuplicate) {
            $class = $class == '' ? 'alternate' : '';
            ?>
				<tr class="<?php 
            echo $class;
            ?>
">
					<td><?php 
            echo $customWriteModuleDuplicate->duplicate_name;
            ?>
</td>
					<td><a href="<?php 
            echo RCCWP_ManagementPage::GetModuleDuplicateEditUrl($customWriteModuleId, $customWriteModuleDuplicate->duplicate_id);
            ?>
" class="edit"><?php 
            _e('Rename', $flutter_domain);
            ?>
</a></td>
					<td><a href="<?php 
            echo RCCWP_ManagementPage::GetModuleDuplicateDeleteUrl($customWriteModuleId, $customWriteModuleDuplicate->duplicate_id);
            ?>
" class="delete"><?php 
            _e('Delete', $flutter_domain);
            ?>
</a></td>
				</tr>
			<?php 
        }
        ?>
			</tbody>
			</table>
		  
		</form>

		</div>
		
		<?php 
    }