コード例 #1
0
 function test_canUpgrade()
 {
     $oPkgMgr = new OX_PluginManager();
     $oPkgMgr->uninstallPackage($this->packageName);
     // put the version 1 package in place
     $this->_switchFiles(1);
     // third param indicates whether pkg mgr is expecting an upgrade
     // this time it expects to install
     $this->assertTrue($oPkgMgr->_checkPackageContents($this->packageName . '.xml', $this->aUpload['tmp_name'], false));
     $this->assertEqual($oPkgMgr->aParse['plugins'][1]['version'], '0.0.1');
     // need to have version 1 installed
     $this->assertTrue($oPkgMgr->installPackage($this->aUpload));
     // Test 1 : package definition has same version than installation
     $aPlugin = $oPkgMgr->aParse['plugins'][1];
     $oUpgrader = new OX_Plugin_UpgradeComponentGroup($aPlugin, $oPkgMgr);
     $this->assertFalse($oUpgrader->canUpgrade());
     $this->assertEqual($oUpgrader->existing_installation_status, OA_STATUS_PLUGIN_CURRENT_VERSION);
     // Test 2 : package definition has lower version than installation
     $aPlugin['version'] = '0.0.0';
     $oUpgrader = new OX_Plugin_UpgradeComponentGroup($aPlugin, $oPkgMgr);
     $this->assertFalse($oUpgrader->canUpgrade());
     $this->assertEqual($oUpgrader->existing_installation_status, OA_STATUS_PLUGIN_VERSION_FAILED);
     // Test 3 : package definition has higher version than installation
     $aPlugin['version'] = '0.0.2';
     $oUpgrader = new OX_Plugin_UpgradeComponentGroup($aPlugin, $oPkgMgr);
     $this->assertTrue($oUpgrader->canUpgrade());
     $this->assertEqual($oUpgrader->existing_installation_status, OA_STATUS_PLUGIN_CAN_UPGRADE);
     // leave the version 1 package installed for next test (upgrade)
 }
コード例 #2
0
ファイル: install-plugin.php プロジェクト: villos/tree_admin
function installPlugin($pluginName)
{
    $aErrors = array();
    $aResult = array('name' => $pluginName, 'status' => '', 'errors' => &$aErrors);
    // make sure this is a legitimate bundled plugin request
    if ($aPlugin = getPlugin($pluginName)) {
        require_once MAX_PATH . '/lib/OA.php';
        //OA::logMem('start deliveryLog/installPlugin');
        require_once LIB_PATH . '/Plugin/PluginManager.php';
        $oPluginManager = new OX_PluginManager();
        if (!array_key_exists($aPlugin['name'], $GLOBALS['_MAX']['CONF']['plugins'])) {
            $filename = $aPlugin['name'] . '.' . $aPlugin['ext'];
            $filepath = $aPlugin['path'] . $filename;
            // TODO: refactor for remote paths?
            $oPluginManager->installPackage(array('tmp_name' => $filepath, 'name' => $filename));
            if ($oPluginManager->countErrors()) {
                $aResult['status'] = 'Failed';
                foreach ($oPluginManager->aErrors as $errmsg) {
                    $aErrors[] = $errmsg;
                }
            } else {
                $aResult['status'] = 'OK';
            }
        } else {
            $aResult['status'] = 'Already Installed';
            $aErrors[] = 'Could not be installed because previous installation (whole or partial) was found';
        }
        unset($oPluginManager);
        //OA::logMem('stop deliveryLog/installPlugin');
    } else {
        $aResult['status'] = 'Invalid';
        $aErrors[] = 'Not a valid default plugin';
    }
    return $aResult;
}
コード例 #3
0
ファイル: plugin-index.php プロジェクト: villos/tree_admin
// Required files
require_once MAX_PATH . '/www/admin/config.php';
require_once LIB_PATH . '/Plugin/PluginManager.php';
require_once LIB_PATH . '/Plugin/ComponentGroupManager.php';
// Security check
OA_Permission::enforceAccount(OA_ACCOUNT_ADMIN);
$oPluginManager = new OX_PluginManager();
$oComponentGroupManager = new OX_Plugin_ComponentGroupManager();
$action = $_REQUEST['action'];
$plugin = $_REQUEST['package'];
$group = $_REQUEST['group'];
$parent = $_REQUEST['parent'];
//install
if (array_key_exists('install', $_POST)) {
    if (array_key_exists('filename', $_FILES)) {
        $oPluginManager->installPackage($_FILES['filename']);
    }
} else {
    if (array_key_exists('import', $_POST)) {
        if (array_key_exists('filename', $_FILES)) {
            $oPluginManager->installPackageCodeOnly($_FILES['filename']);
        }
    } else {
        if (array_key_exists('getupgrade', $_POST)) {
            $downloadurl = $_POST['downloadurl'];
            $aFile['error'] = 0;
            $aFile['type'] = 'application/zip';
            $aFile['name'] = basename($downloadurl);
            $aFile['tmp_name'] = MAX_PATH . '/var/' . $aFile['name'];
            file_put_contents($aFile['tmp_name'], file_get_contents($downloadurl));
            if (file_exists($aFile['tmp_name'])) {
コード例 #4
0
 function test_getPackageDiagnostics()
 {
     $oPkgMgr = new OX_PluginManager();
     $file = MAX_PATH . $this->testpathData . 'zipDiagnosticTest/testPluginPackage.zip';
     unset($GLOBALS['_MAX']['CONF']['plugins']['testPluginPackage']);
     unset($GLOBALS['_MAX']['CONF']['pluginGroupComponents']['testPlugin001']);
     //install
     $this->assertTrue($oPkgMgr->installPackage(array('tmp_name' => $file, 'name' => 'testPluginPackage.zip')));
     if (count($oPkgMgr->aErrors)) {
         foreach ($oPkgMgr->aErrors as $error) {
             $this->fail($error);
         }
     }
     $aResultGood = $oPkgMgr->getPackageDiagnostics('testPluginPackage');
     $this->assertFalse($aResultGood['plugin']['error']);
     unlink(MAX_PATH . $oPkgMgr->pathPluginsAdmin . 'testPlugin001/' . 'testPlugin-common.php');
     $oPkgMgr->_unregisterSettings('testPlugin001', false);
     unset($GLOBALS['_MAX']['CONF']['testPlugin001']);
     unset($GLOBALS['_MAX']['CONF']['testPlugin001']['setting1']);
     $oPkgMgr->_unregisterPluginVersion('testPlugin001');
     $oPkgMgr->_unregisterSchemaVersion('testPlugin001');
     $oPkgMgr->_unregisterPreferences('testPlugin001', $aResultGood['groups'][0]['install']['config']['preferences']);
     $oPkgMgr->_dropTables('testPlugin', $aResultGood['groups'][0]['install']['database']['mdb2schema']);
     $aResultBad = $oPkgMgr->getPackageDiagnostics('testPluginPackage');
     $this->assertTrue($aResultBad['groups'][1]['error']);
     //uninstall
     $this->assertTrue($oPkgMgr->uninstallPackage('testPluginPackage'));
     TestEnv::restoreConfig();
 }