Beispiel #1
0
include_once MODULE_PATH . "/system/lib/ModuleLoader.php";
$moduleName = $argv[1];
$version = isset($argv[2]) ? $argv[2] : 'latest';
if ($moduleName != "all" && $moduleName != "") {
    $moduleArr = array($moduleName);
} else {
    $moduleArr = glob(MODULE_PATH . "/*");
    for ($i = 0; $i < count($moduleArr); $i++) {
        $moduleArr[$i] = basename($moduleArr[$i]);
    }
}
foreach ($moduleArr as $moduleName) {
    $loader = new ModuleLoader($moduleName);
    echo "Start upgrading {$moduleName} module ..." . PHP_EOL;
    echo "--------------------------------------------------------" . PHP_EOL;
    $loader->upgradeModule();
    echo $loader->errors . "" . PHP_EOL;
    // load the module again
    echo PHP_EOL . "Reload module ..." . PHP_EOL;
    $loader->loadModule($installSql);
    echo $loader->errors . "" . PHP_EOL;
    // give predefined users access to actions
    echo "Give admin to access all actions of module '{$moduleName}'" . PHP_EOL;
    //giveActionAccess("module='$moduleName'", 1);	// admin to access all actions
    echo "--------------------------------------------------------" . PHP_EOL;
    echo "End loading {$moduleName} module" . PHP_EOL;
}
// give predefined users access to actions
function giveActionAccess($where, $role_id)
{
    $db = BizSystem::dbConnection();
 public function installPackage($cpkFilePath)
 {
     $package = $this->_installPackage;
     $uri = $this->_repoUri;
     $this->setInstallInfo($package, array("state" => "Install", "log" => "Installing ..."));
     //trigger remote log action
     $operator = Openbiz::$app->getProfile()->getProfileName(Openbiz::$app->getUserProfile("Id"), 'short');
     $app_id = $package['app_id'];
     $release_id = $package['Id'];
     $this->recordInstallLog($uri, $app_id, $release_id, SITE_URL, $operator);
     $tmpFolder = OPENBIZ_APP_FILE_PATH . DIRECTORY_SEPARATOR . "tmpfiles" . DIRECTORY_SEPARATOR;
     $toFolder = $tmpFolder . time();
     try {
         $this->_unpack($cpkFilePath, $toFolder);
     } catch (Exception $e) {
         throw new Exception("ERROR in unpack {$cpkFilePath}. " . $e->getMessage());
     }
     $this->pkg_log("Unpack. {$cpkFilePath} is unpacked to {$toFolder}\n");
     // copy files to target folder from the tmp folder
     $this->_filecopy($toFolder);
     if (strtolower($package['type']) == 'module' || strtolower($package['type']) == 'application') {
         // invoke module upgrade command
         foreach ($this->_installModules as $moduleName) {
             $this->pkg_log("invoke module upgrade command\n");
             $loader = new ModuleLoader($moduleName);
             $loader->debug = 0;
             $this->pkg_log("Start upgrading {$moduleName} module ..." . PHP_EOL);
             $this->pkg_log("--------------------------------------------------------" . PHP_EOL);
             $result = $loader->upgradeModule(true);
             $this->pkg_log($loader->errors . "" . PHP_EOL);
             $this->pkg_log($loader->logs . "" . PHP_EOL);
             if ($result == false) {
                 throw new Exception("Error in install package. " . $loader->errors);
             }
             // load the module again
             $this->pkg_log("Reload module ..." . PHP_EOL);
             $loader->loadModule($installSql);
             $this->pkg_log($loader->errors . "" . PHP_EOL);
         }
     }
     $time = date('Y-m-d H:i:s');
     //reload current profile
     Openbiz::getService(ACL_SERVICE)->clearACLCache();
     $this->setInstallInfo($package, array("time" => $time, "version" => $package['version'], "state" => "OK", "log" => "Completed"));
 }