/**
  * Export Module as a zip file.
  * @param Vtiger_Module Instance of module
  * @param Path Output directory path
  * @param String Zipfilename to use
  * @param Boolean True for sending the output as download
  */
 function export($languageCode, $todir = '', $zipfilename = '', $directDownload = false)
 {
     $this->__initExport($languageCode);
     // Call language export function
     $this->export_Language($languageCode);
     $this->__finishExport();
     // Export as Zip
     if ($zipfilename == '') {
         $zipfilename = "{$languageCode}-" . date('YmdHis') . ".zip";
     }
     $zipfilename = "{$this->_export_tmpdir}/{$zipfilename}";
     $zip = new Vtiger_Zip($zipfilename);
     // Add manifest file
     $zip->addFile($this->__getManifestFilePath(), "manifest.xml");
     // Copy module directory
     $zip->copyDirectoryFromDisk("languages/{$languageCode}", "modules");
     $zip->save();
     if ($todir) {
         copy($zipfilename, $todir);
     }
     if ($directDownload) {
         $zip->forceDownload($zipfilename);
         unlink($zipfilename);
     }
     $this->__cleanupExport();
 }
Exemplo n.º 2
0
function packen($filename, $wordtemplatedownloadpath, $temp_dir, $concontent, $stylecontent)
{
    //global $filename, $wordtemplatedownloadpath;
    //write a new content.xml
    $handle = fopen($wordtemplatedownloadpath . '/' . $temp_dir . '/content.xml', "w");
    fwrite($handle, $concontent);
    fclose($handle);
    //write a new styles.xml
    $handle2 = fopen($wordtemplatedownloadpath . '/' . $temp_dir . '/styles.xml', "w");
    fwrite($handle2, $stylecontent);
    fclose($handle2);
    include_once 'vtlib/Vtiger/Zip.php';
    $archive = new Vtiger_Zip($wordtemplatedownloadpath . '/' . $filename);
    //make a new archive (or .odt file)
    $archive->copyDirectoryFromDiskNoOffset($wordtemplatedownloadpath . $temp_dir);
    $archive->save();
}
Exemplo n.º 3
0
 /**
  * Export Module as a zip file.
  * @param Vtiger_Module Instance of module
  * @param Path Output directory path
  * @param String Zipfilename to use
  * @param Boolean True for sending the output as download
  */
 function export($moduleInstance, $todir = '', $zipfilename = '', $directDownload = false)
 {
     $module = $moduleInstance->name;
     $this->__initExport($module, $moduleInstance);
     // Call module export function
     $this->export_Module($moduleInstance);
     $this->__finishExport();
     // Export as Zip
     if ($zipfilename == '') {
         $zipfilename = "{$module}-" . date('YmdHis') . ".zip";
     }
     $zipfilename = "{$this->_export_tmpdir}/{$zipfilename}";
     $zip = new Vtiger_Zip($zipfilename);
     // Add manifest file
     $zip->addFile($this->__getManifestFilePath(), "manifest.xml");
     // Copy module directory
     $zip->copyDirectoryFromDisk("modules/{$module}");
     // Copy templates directory of the module (if any)
     if (is_dir("Smarty/templates/modules/{$module}")) {
         $zip->copyDirectoryFromDisk("Smarty/templates/modules/{$module}", "templates");
     }
     // Copy cron files of the module (if any)
     if (is_dir("cron/modules/{$module}")) {
         $zip->copyDirectoryFromDisk("cron/modules/{$module}", "cron");
     }
     $zip->save();
     if ($directDownload) {
         $zip->forceDownload($zipfilename);
         unlink($zipfilename);
     }
     $this->__cleanupExport();
 }
Exemplo n.º 4
0
 /**
  * Export Module as a zip file.
  * @param Vtiger_Module Instance of module
  * @param Path Output directory path
  * @param String Zipfilename to use
  * @param Boolean True for sending the output as download
  */
 function export($moduleInstance, $todir = '', $zipfilename = '', $directDownload = false)
 {
     $module = $moduleInstance->name;
     $this->__initExport($module, $moduleInstance);
     // Call module export function
     $this->export_Module($moduleInstance);
     $this->__finishExport();
     // Export as Zip
     // if($zipfilename == '') $zipfilename = "$module-" . date('YmdHis') . ".zip";
     $zipfilename = $moduleInstance->name . "_" . date('Y-m-d-Hi') . "_" . $moduleInstance->version . ".zip";
     $zipfilename = "{$this->_export_tmpdir}/{$zipfilename}";
     $zip = new Vtiger_Zip($zipfilename);
     // Add manifest file
     $zip->addFile($this->__getManifestFilePath(), "manifest.xml");
     // Copy module directory
     $zip->copyDirectoryFromDisk("modules/{$module}");
     // Copy Settings/module directory
     if (is_dir("modules/Settings/{$module}")) {
         $zip->copyDirectoryFromDisk("modules/Settings/{$module}", 'settings/');
     }
     // Copy cron files of the module (if any)
     if (is_dir("cron/modules/{$module}")) {
         $zip->copyDirectoryFromDisk("cron/modules/{$module}", "cron");
     }
     //Copy module templates files
     if (is_dir("layouts/vlayout/modules/{$module}")) {
         $zip->copyDirectoryFromDisk("layouts/vlayout/modules/{$module}", "templates");
     }
     //Copy Settings module templates files, if any
     if (is_dir("layouts/vlayout/modules/Settings/{$module}")) {
         $zip->copyDirectoryFromDisk("layouts/vlayout/modules/Settings/{$module}", "settings/templates");
     }
     //Copy language files
     $this->__copyLanguageFiles($zip, $module);
     //Copy image file
     if (file_exists("layouts/vlayout/skins/images/{$module}.png")) {
         $zip->copyFileFromDisk("layouts/vlayout/skins/images", "", "{$module}.png");
     }
     $zip->save();
     if ($todir) {
         copy($zipfilename, $todir);
     }
     if ($directDownload) {
         $zip->forceDownload($zipfilename);
         unlink($zipfilename);
     }
     $this->__cleanupExport();
 }
Exemplo n.º 5
0
 protected function createZipPackage($dirname, $o_module)
 {
     include_once 'vtlib/Vtiger/Zip.php';
     $module = $o_module->name;
     // Export as Zip
     $zipfilename = DIR_TEMP . $dirname . "/{$module}_" . date('Y-m-d') . "_{$o_module->version}.zip";
     $zip = new Vtiger_Zip($zipfilename);
     // Add manifest file
     $zip->addFile(DIR_TEMP . "{$dirname}/manifest.xml", "manifest.xml");
     $zip->copyDirectoryFromDisk(DIR_TEMP . "{$dirname}/modules", "modules");
     if (is_dir(DIR_TEMP . "{$dirname}/languages")) {
         $zip->copyDirectoryFromDisk(DIR_TEMP . "{$dirname}/languages", "languages");
     }
     if (is_dir(DIR_TEMP . "{$dirname}/templates")) {
         $zip->copyDirectoryFromDisk(DIR_TEMP . "{$dirname}/templates", "templates");
     }
     if (is_dir(DIR_TEMP . "{$dirname}/settings")) {
         $zip->copyDirectoryFromDisk(DIR_TEMP . "{$dirname}/settings", "settings");
     }
     if (is_dir(DIR_TEMP . "{$dirname}/cron")) {
         $zip->copyDirectoryFromDisk(DIR_TEMP . "{$dirname}/cron", "cron");
     }
     if (file_exists(DIR_TEMP . "{$dirname}/{$module}.png")) {
         $zip->addFile(DIR_TEMP . "{$dirname}/{$module}.png", "{$module}.png");
     }
     $zip->save();
     //$zip->forceDownload($zipfilename);
     //unlink($zipfilename);
     return $zipfilename;
 }
 /**
  * Export Module as a zip file.
  * @param Vtiger_Module Instance of module
  * @param Path Output directory path
  * @param String Zipfilename to use
  * @param Boolean True for sending the output as download
  */
 function export($moduleInstance, $todir = '', $zipfilename = '', $directDownload = false)
 {
     $module = $moduleInstance->name;
     $this->__initExport($module, $moduleInstance);
     // Call module export function
     $this->export_Module($moduleInstance);
     $this->__finishExport();
     // Export as Zip
     if ($zipfilename == '') {
         $zipfilename = "{$module}-" . date('YmdHis') . ".zip";
     }
     $zipfilename = "{$this->_export_tmpdir}/{$zipfilename}";
     $zip = new Vtiger_Zip($zipfilename);
     // Add manifest file
     $zip->addFile($this->__getManifestFilePath(), "manifest.xml");
     // Copy module directory
     $zip->copyDirectoryFromDisk("modules/{$module}");
     // Copy Settings/module directory
     if (is_dir("modules/Settings/{$module}")) {
         $zip->copyDirectoryFromDisk("modules/Settings/{$module}", 'settings/');
     }
     // Copy cron files of the module (if any)
     if (is_dir("cron/modules/{$module}")) {
         $zip->copyDirectoryFromDisk("cron/modules/{$module}", "cron");
     }
     //Copy module templates files
     if (is_dir("layouts/vlayout/modules/{$module}")) {
         $zip->copyDirectoryFromDisk("layouts/vlayout/modules/{$module}", "templates");
     }
     //Copy Settings module templates files, if any
     if (is_dir("layouts/vlayout/modules/Settings/{$module}")) {
         $zip->copyDirectoryFromDisk("layouts/vlayout/modules/Settings/{$module}", "settings/templates");
     }
     //Support to multiple layouts of module
     $layoutDirectories = glob('layouts' . '/*', GLOB_ONLYDIR);
     foreach ($layoutDirectories as $key => $layoutName) {
         $moduleLayout = $layoutName . "/modules/{$module}";
         if (is_dir($moduleLayout)) {
             $zip->copyDirectoryFromDisk($moduleLayout, $moduleLayout);
         }
         $settingsLayout = $layoutName . "/modules/Settings/{$module}";
         if (is_dir($settingsLayout)) {
             $zip->copyDirectoryFromDisk($settingsLayout, $settingsLayout);
         }
     }
     //Copy language files
     $this->__copyLanguageFiles($zip, $module);
     $zip->save();
     if ($todir) {
         copy($zipfilename, $todir);
     }
     if ($directDownload) {
         $zip->forceDownload($zipfilename);
         unlink($zipfilename);
     }
     $this->__cleanupExport();
 }
Exemplo n.º 7
0
global $adb;
$ids = vtlib_purify($_REQUEST['idstring']);
if (!empty($ids)) {
    // Export as Zip
    if ($todir == '') {
        $todir = 'cache';
    }
    if ($xmlfilename == '') {
        $xmlfilename = 'coreBOSUpdates.xml';
    }
    $xmlcfn = 'cache/' . $xmlfilename;
    if ($zipfilename == '') {
        $zipfilename = "cbupdates-" . date('YmdHis') . ".zip";
    }
    $zipfilename = "{$todir}/{$zipfilename}";
    $zip = new Vtiger_Zip($zipfilename);
    $sql = 'select * from vtiger_cbupdater
			inner join vtiger_crmentity on crmid=cbupdaterid
			where deleted=0 ';
    if ($ids != 'all') {
        $ids = str_replace(';', ',', $ids);
        $ids = trim($ids, ',');
        $sql .= " and cbupdaterid in ({$ids})";
    }
    $rs = $adb->query($sql);
    if ($rs and $adb->num_rows($rs) > 0) {
        $w = new XMLWriter();
        $w->openMemory();
        $w->setIndent(true);
        $w->startDocument('1.0', 'UTF-8');
        $w->startElement("updatesChangeLog");
Exemplo n.º 8
0
 static function buildLangPackage($languageCode, $languageName, $buildPath)
 {
     $fileName = $languageName . '.zip';
     if (is_file($buildPath . '/' . $fileName)) {
         unlink($buildPath . '/' . $fileName);
     }
     // first we check for the files
     if (!is_file("include/language/{$languageCode}.manifest.xml")) {
         // check for manifest
         throw new Exception("Manifest missing for language package {$languageName}");
     }
     // Export as Zip
     $zip = new Vtiger_Zip($buildPath . '/' . $fileName);
     // Add manifest file
     $zip->addFile("include/language/{$languageCode}.manifest.xml", 'manifest.xml');
     // Add calendar files
     $zip->copyFileFromDisk('jscalendar/', 'jscalendar/', 'calendar-setup.js');
     $zip->copyFileFromDisk('jscalendar/lang/', 'jscalendar/lang/', 'calendar-' . substr($languageCode, 0, 2) . '.js');
     //$zip->copyFileFromDisk('modules/Emails/language/','modules/Emails/language/','phpmailer.lang-'.$languageCode.'.php');
     // Copy module/include language files
     foreach (glob("{modules,include}/*/language/{$languageCode}.lang.{php,js}", GLOB_BRACE) as $langfile) {
         $fname = basename($langfile);
         $dname = dirname($langfile);
         $zip->copyFileFromDisk($dname, $dname, $fname);
     }
     $zip->copyFileFromDisk('include/language/', 'include/language/', $languageCode . '.lang.php');
     $zip->copyFileFromDisk('include/js/', 'include/js/', $languageCode . '.lang.js');
     $zip->save();
 }
Exemplo n.º 9
0
 static function languageFromFilesystem($languageCode, $languageName, $directDownload = false)
 {
     // first we check for the files
     $wehavefiles = file_exists("include/language/{$languageCode}.manifest.xml");
     // check for manifest
     if ($wehavefiles) {
         // Export as Zip
         if (file_exists('packages/optional/manifest.xml')) {
             @unlink('packages/optional/manifest.xml');
         }
         @copy("include/language/{$languageCode}.manifest.xml", 'packages/optional/manifest.xml');
         $mpkg = 'packages/optional/' . $languageName;
         $zipfilename = $mpkg . '.zip';
         if (file_exists($zipfilename)) {
             @unlink($zipfilename);
         }
         $zip = new Vtiger_Zip($zipfilename);
         // Add manifest file
         $zip->copyFileFromDisk('packages/optional/', '', 'manifest.xml');
         // Add calendar files
         $zip->copyFileFromDisk('jscalendar/', 'jscalendar/', 'calendar-setup.js');
         $zip->copyFileFromDisk('jscalendar/lang/', 'jscalendar/lang/', 'calendar-' . substr($languageCode, 0, 2) . '.js');
         // Copy module/include language files
         foreach (glob('{modules,include}/*/language/' . $languageCode . '.lang.{php,js}', GLOB_BRACE) as $langfile) {
             $fname = basename($langfile);
             $dname = dirname($langfile);
             $zip->copyFileFromDisk($dname, $dname, $fname);
         }
         $zip->copyFileFromDisk('include/language/', 'include/language/', $languageCode . '.lang.php');
         $zip->copyFileFromDisk('include/js/', 'include/js/', $languageCode . '.lang.js');
         $zip->save();
         if ($directDownload) {
             $zip->forceDownload($mpkg . '.zip');
         }
         @unlink('packages/optional/manifest.xml');
     } else {
         echo "ERROR: One or more files necessary to create package are missing";
     }
 }
Exemplo n.º 10
0
    if (!fopen($filepath . $saved_filename, 'r')) {
        if ($file_status == 1) {
            $dbQuery1 = 'update vtiger_notes set filestatus = 0 where notesid= ?';
            $result1 = $adb->pquery($dbQuery1, array($notesid));
            echo 'lost_integrity';
        } else {
            echo 'file_not_available';
        }
    } else {
        echo 'file_available';
    }
}
if (isset($_REQUEST['act']) && $_REQUEST['act'] == 'massDldCnt') {
    $all_files = vtlib_purify($_REQUEST['file_id']);
    $zipfilename = "cache/Documents" . $current_user->id . ".zip";
    $zip = new Vtiger_Zip($zipfilename);
    if (file_exists($zipfilename)) {
        @unlink($zipfilename);
    }
    $dec_files = json_decode($all_files, true);
    foreach ($dec_files as $folder_id => $files_id) {
        if ($files_id) {
            $folderQuery = $adb->pquery("SELECT foldername FROM vtiger_attachmentsfolder WHERE folderid = ?", array($folder_id));
            $folderName = $adb->query_result($folderQuery, 0, 'foldername');
            $files = explode(";", $files_id);
            foreach ($files as $file) {
                if ($file) {
                    $dbQuery = 'SELECT * FROM vtiger_attachments JOIN vtiger_seattachmentsrel ON vtiger_attachments.attachmentsid = vtiger_seattachmentsrel.attachmentsid WHERE crmid = ?';
                    $result = $adb->pquery($dbQuery, array($file)) or die('Could not get file list ');
                    if ($adb->num_rows($result) == 1) {
                        $pname = @$adb->query_result($result, 0, 'attachmentsid');