Exemplo n.º 1
0
 private function loadModule($module)
 {
     $loader = new ModuleLoader();
     if (!$loader->isModuleExists($module)) {
         throw new Exception("{$module} not found");
     }
     return $loader->loadModule($module);
 }
Exemplo n.º 2
0
 /**
  * load module from the modules/$module/ directory
  *
  * @return void
  */
 public function loadModule($module)
 {
     $loader = new ModuleLoader($module);
     $loader->debug = false;
     if (!$loader->loadModule()) {
         $this->m_Errors[] = nl2br($this->GetMessage("MODULE_LOAD_ERROR") . "\n" . $loader->errors . "\n" . $loader->logs);
     } else {
         $this->m_Notices[] = $this->GetMessage("MODULE_LOAD_COMPLETE");
         //." ".$loader->logs;
     }
     $this->rerender();
 }
Exemplo n.º 3
0
 /**
  * load module from the modules/$module/ directory
  *
  * @return void
  */
 public function loadModule($module)
 {
     $loader = new ModuleLoader($module);
     $loader->debug = false;
     if (!$loader->loadModule()) {
         $this->errors[] = nl2br($this->GetMessage("MODULE_LOAD_ERROR") . "\n" . $loader->errors . "\n" . $loader->logs);
     } else {
         $this->notices[] = $this->GetMessage("MODULE_LOAD_COMPLETE", $module);
         //." ".$loader->logs;
     }
     $roles = Openbiz::$app->getUserProfile("roles");
     $role_id = $roles[0];
     $this->giveActionAccess($module, $role_id);
     //reload current profile
     Openbiz::getService(ACL_SERVICE)->clearACLCache();
     $this->rerender();
 }
Exemplo n.º 4
0
function loadModules()
{
    include_once Openbiz::$app->getModulePath() . "/system/lib/ModuleLoader.php";
    $modules = array('system', 'menu', 'help', 'contact', 'cronjob');
    foreach (glob(Openbiz::$app->getModulePath() . DIRECTORY_SEPARATOR . "*") as $dir) {
        $modName = str_replace(Openbiz::$app->getModulePath() . DIRECTORY_SEPARATOR, "", $dir);
        if (!in_array($modName, $modules)) {
            array_push($modules, $modName);
        }
    }
    $logs = "";
    // find all modules
    foreach ($modules as $mod) {
        $logs .= "Loading Module: {$mod}\n";
        $loader = new ModuleLoader($mod);
        $loader->debug = 0;
        $loader->loadModule(true);
        $logs .= $loader->logs;
        $logs .= $loader->errors;
        $logs .= "\n";
    }
    giveActionAccess("", 1);
    // admin to access all actions
    //giveActionAccess("module='user'", 2);
    file_put_contents(OPENBIZ_APP_FILE_PATH . '/install.log', $logs);
    echo "SUCCESS. Modules are loaded in Cubi. ###\n" . $logs;
}
Exemplo n.º 5
0
<?php

header('Content-Type:text/plain; charset=UTF-8');
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED & ~E_WARNING);
define('MEDIA_FOLDER', 'media/');
include 'ClassLoader.php';
ClassLoader::loadAll();
// POST FILTERING
foreach ($_POST as $key => $value) {
    $value = strip_tags($value);
    $_POST[$key] = $value;
}
if (!empty($_POST)) {
    if (isset($_POST['action'])) {
        ModuleLoader::loadModule($_POST['action']);
    }
} else {
    sleep(1);
    echo 'SERVER UP AND RUNNING';
}
Exemplo n.º 6
0
    $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();
    try {
        if (empty($where)) {
            $sql = "SELECT * FROM acl_action";
        } else {
Exemplo n.º 7
0
if (!$db) {
    echo "Please create a CubiInstall database in cubi/Config.xml." . PHP_EOL;
}
$modules = array('system', 'menu');
foreach (glob(Openbiz::$app->getModulePath() . DIRECTORY_SEPARATOR . "*") as $dir) {
    $modName = str_replace(Openbiz::$app->getModulePath() . DIRECTORY_SEPARATOR, "", $dir);
    if ($modName != "system" && $modName != "menu") {
        array_push($modules, $modName);
    }
}
// find all modules
foreach ($modules as $mod) {
    echo PHP_EOL . "---------------------------------------------------" . PHP_EOL;
    echo "> Start loading '{$mod}' module ..." . PHP_EOL;
    $loader = new ModuleLoader($mod, $cubiInstallDb);
    $loader->loadModule(true);
    echo "> End loading '{$mod}' module" . PHP_EOL;
}
echo PHP_EOL . "---------------------------------------------------" . PHP_EOL;
// give predefined users access to actions
echo "> Give admin to access all actions " . PHP_EOL;
giveActionAccess("", 1);
// admin to access all actions
echo "> Give member access to user related actions " . PHP_EOL;
giveActionAccess("module='user'", 2);
// member access to user related actions
echo PHP_EOL . "---------------------------------------------------" . PHP_EOL;
echo "Cubi install database is created successfully!" . PHP_EOL;
// give predefined users access to actions
function giveActionAccess($where, $role_id)
{
Exemplo n.º 8
0
 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"));
 }
Exemplo n.º 9
0
function fillDB()
{
    include_once MODULE_PATH . "/system/lib/ModuleLoader.php";
    replaceDbConfig();
    $modules = array('system', 'menu');
    foreach (glob(MODULE_PATH . DIRECTORY_SEPARATOR . "*") as $dir) {
        $modName = str_replace(MODULE_PATH . DIRECTORY_SEPARATOR, "", $dir);
        if ($modName != "system" && $modName != "menu") {
            array_push($modules, $modName);
        }
    }
    // find all modules
    foreach ($modules as $mod) {
        $loader = new ModuleLoader($mod);
        $loader->debug = 0;
        $loader->loadModule(true);
    }
    // admin to access all actions
    giveActionAccess("", 1);
    // sipadmin to access siremis user profile and sip admin pages
    giveActionAccess("module='user' OR module='ser'", 2);
    // sipuser to access siremis user profile and sip user pages
    giveActionAccess("module='user' OR module='sipuser'", 3);
    return true;
}