/** * Move files to plugin modules directory * @param string $code code for module * @param string $path path from what module will be moved * @return bool is success - true, else - false */ public static function moveFiles($code, $path) { if (!is_dir(GMP_MODULES_DIR . $code)) { if (mkdir(GMP_MODULES_DIR . $code)) { utilsGmp::copyDirectories($path, GMP_MODULES_DIR . $code); return true; } else { errorsGmp::push(__('Can not create module directory. Try to set permission to ' . GMP_MODULES_DIR . ' directory 755 or 777', GMP_LANG_CODE), errorsGmp::MOD_INSTALL); } } else { return true; } return false; }
/** * Move files to plugin modules directory * @param string $code code for module * @param string $path path from what module will be moved * @return bool is success - true, else - false */ public static function moveFiles($code, $path) { if (!is_dir(GMP_MODULES_DIR . $code)) { if (mkdir(GMP_MODULES_DIR . $code)) { utilsGmp::copyDirectories($path, GMP_MODULES_DIR . $code); return true; } else { errorsGmp::push(langGmp::_('Can not create module directory. Try to set permission to ' . GMP_MODULES_DIR . ' directory 755 or 777'), errorsGmp::MOD_INSTALL); } } else { return true; } //errorsGmp::push(langGmp::_(array('Directory', $code, 'already exists')), errorsGmp::MOD_INSTALL); return false; }
/** * Copy all files from one directory ($source) to another ($destination) * @param string $source path to source directory * @params string $destination path to destination directory */ public static function copyDirectories($source, $destination) { if (is_dir($source)) { @mkdir($destination); $directory = dir($source); while (FALSE !== ($readdirectory = $directory->read())) { if ($readdirectory == '.' || $readdirectory == '..') { continue; } $PathDir = $source . '/' . $readdirectory; if (is_dir($PathDir)) { utilsGmp::copyDirectories($PathDir, $destination . '/' . $readdirectory); continue; } copy($PathDir, $destination . '/' . $readdirectory); } $directory->close(); } else { copy($source, $destination); } }