function defaultData() { $oManager = new OX_Plugin_ComponentGroupManager(); if (!array_key_exists('testPlugin', $GLOBALS['_MAX']['CONF']['pluginGroupComponents'])) { $oManager->disableComponentGroup('testPlugin'); } $this->oManager->enableComponentGroup('testPlugin'); $oTestPluginTable = OA_Dal::factoryDO('testplugin_table'); if (!$oTestPluginTable) { OA::debug('Failed to instantiate DataObject for testplugin_table'); return false; } $oTestPluginTable->myplugin_desc = 'Hello World'; $aSettings[0]['data'] = $oTestPluginTable->insert(); $aSettings[0]['section'] = 'myPlugin'; $aSettings[0]['key'] = 'english'; $oTestPluginTable->myplugin_desc = 'Hola Mundo'; $aSettings[1]['data'] = $oTestPluginTable->insert(); $aSettings[1]['section'] = 'myPlugin'; $aSettings[1]['key'] = 'spanish'; $oTestPluginTable->myplugin_desc = 'Look Simon, you\'re just making it up now'; $aSettings[2]['data'] = $oTestPluginTable->insert(); $aSettings[2]['section'] = 'myPlugin'; $aSettings[2]['key'] = 'russian'; $oManager->_registerSettings($aSettings); $oManager->disableComponentGroup('testPlugin'); return true; }
/** * Returns the instance of menu. Subsequent calls return the same object. * * @return OA_Admin_Menu */ function &singleton() { $accountType = OA_Permission::getAccountType(); if (isset($GLOBALS['_MAX']['MENU_OBJECT'][$accountType])) { $oMenu =& $GLOBALS['_MAX']['MENU_OBJECT'][$accountType]; } elseif ($GLOBALS['_MAX']['CONF']['debug']['production'] != 0 && ($oMenu = OA_Admin_Menu::_loadFromCache($accountType))) { $GLOBALS['_MAX']['MENU_OBJECT'][$accountType] =& $oMenu; } else { $oMenu = new OA_Admin_Menu(); if (empty($oMenu->aAllSections)) { include_once MAX_PATH . '/lib/OA/Admin/Menu/config.php'; $oMenu = _buildNavigation(OA_Permission::getAccountType()); } require_once LIB_PATH . '/Plugin/ComponentGroupManager.php'; $oPluginManager = new OX_Plugin_ComponentGroupManager(); $oPluginManager->mergeMenu($oMenu, $accountType); $GLOBALS['_MAX']['MENU_OBJECT'][$accountType] =& $oMenu; $oMenu->_saveToCache($accountType); } // Filter against user-account-preferences... return $oMenu; }
function execute($aParams = array()) { $oManager = new OX_Plugin_ComponentGroupManager(); $oManager->_logMessage('testPluginPackage 0.0.2 : ' . get_class($this)); return true; }
| You should have received a copy of the GNU General Public License | | along with this program; if not, write to the Free Software | | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | +---------------------------------------------------------------------------+ $Id: plugin-index.php 37157 2009-05-28 12:31:10Z andrew.hill $ */ // Require the initialisation file require_once '../../init.php'; // 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 {
/** * use the parent method to parse the package xml * * @param boolean $input_file * @param boolean $classname * @return boolean */ public function parseXML($input_file, $classname = 'OX_ParserPlugin') { return parent::parseXML($input_file, $classname); }
function test_getComponentGroupSettingsArray() { $oManager = new OX_Plugin_ComponentGroupManager(); $GLOBALS['_MAX']['CONF']['test'] = array('foo' => 1, 'bar' => 0); $aComponentGroups = $oManager->getComponentGroupSettingsArray('test'); $this->assertIsA($aComponentGroups, 'array'); $this->assertEqual(count($aComponentGroups), 2); $this->assertEqual($aComponentGroups['foo'], 1); $this->assertEqual($aComponentGroups['bar'], 0); unset($GLOBALS['_MAX']['CONF']['test']); $aComponentGroups = $oManager->getComponentGroupSettingsArray('test'); $this->assertIsA($aComponentGroups, 'array'); $this->assertEqual(count($aComponentGroups), 0); }
// Required files require_once MAX_PATH . '/lib/OA/Admin/Option.php'; require_once MAX_PATH . '/lib/OA/Preferences.php'; require_once MAX_PATH . '/lib/max/Plugin/Translation.php'; require_once MAX_PATH . '/www/admin/config.php'; require_once LIB_PATH . '/Plugin/ComponentGroupManager.php'; // Security check OA_Permission::enforceAccount(OA_ACCOUNT_ADMIN, OA_ACCOUNT_MANAGER, OA_ACCOUNT_ADVERTISER, OA_ACCOUNT_TRAFFICKER); phpAds_registerGlobal('group'); // Load the account's preferences, with additional information, into a specially named array $GLOBALS['_MAX']['PREF_EXTRA'] = OA_Preferences::loadPreferences(true, true); // Create a new option object for displaying the setting's page's HTML form $oOptions = new OA_Admin_Option('preferences'); // Prepare an array for storing error messages $aErrormessage = array(); $oComponentGroupManager = new OX_Plugin_ComponentGroupManager(); $aGroup = $oComponentGroupManager->_getComponentGroupConfiguration($group); $enabled = $GLOBALS['_MAX']['CONF']['pluginGroupComponents'][$group]; $disabled = !$enabled && OA_Permission::getAccountType() != OA_ACCOUNT_ADMIN; // If the settings page is a submission, deal with the form data if (isset($_POST['submitok']) && $_POST['submitok'] == 'true') { // Prepare an array of the HTML elements to process, and which // of the preferences are checkboxes $aElements = array(); foreach ($aGroup['preferences'] as $k => $v) { $aElements[] = $group . '_' . $v['name']; // Register the HTML element value MAX_commonRegisterGlobalsArray(array($group . '_' . $v['name'])); } $aCheckboxes = array(); // Validation
function test_DependencyArray() { $oPluginManager = new OX_Plugin_ComponentGroupManager(); $oPluginManager->pathPackages = $this->testpathPackages; $aConf = array('testPlugin' => 1, 'testDepends' => 0); $GLOBALS['_MAX']['CONF']['pluginGroupComponents'] = $aConf; $oPluginManager->_registerPluginVersion('testPlugin', '0.0.1'); $oPluginManager->_registerPluginVersion('testDepends', '0.0.1-test'); $aDepends = $oPluginManager->_buildDependencyArray(); $this->assertIsA($aDepends, 'array'); $this->assertEqual(count($aDepends), 2); $this->assertEqual($aDepends['testPlugin']['isDependedOnBy'][0], 'testDepends'); $this->assertEqual($aDepends['testDepends']['dependsOn']['testPlugin'], '0.0.1'); $this->assertTrue($oPluginManager->_saveDependencyArray($aDepends)); $aDepends = $oPluginManager->_loadDependencyArray(); $this->assertIsA($aDepends, 'array'); $this->assertEqual(count($aDepends), 2); $this->assertTrue($oPluginManager->_hasDependencies('testPlugin')); $this->assertFalse($oPluginManager->_hasDependencies('testDepends')); $this->assertEqual($aDepends['testPlugin']['isDependedOnBy'][0], 'testDepends'); $this->assertEqual($aDepends['testDepends']['dependsOn']['testPlugin'], '0.0.1'); $GLOBALS['_MAX']['CONF']['pluginGroupComponents'] = array(); $aDepends = $oPluginManager->_buildDependencyArray(); $this->assertIsA($aDepends, 'array'); $this->assertEqual(count($aDepends), 0); $this->assertTrue($oPluginManager->_saveDependencyArray($aDepends)); $aDepends = $oPluginManager->_loadDependencyArray(); $this->assertIsA($aDepends, 'array'); $this->assertEqual(count($aDepends), 0); $oPluginManager->_clearDependencyCache(); $oPluginManager->_unregisterPluginVersion('testPlugin'); $oPluginManager->_unregisterPluginVersion('testDepends'); unset($GLOBALS['_MAX']['CONF']['pluginGroupComponents']); }
OA_Permission::enforceAccount(OA_ACCOUNT_ADMIN); // Create a new option object for displaying the setting's page's HTML form $oOptions = new OA_Admin_Option('preferences'); // Prepare an array for storing error messages $aErrormessage = array(); $pattern = '/[^a-zA-Z0-9\\._-]/'; $plugin = preg_replace($pattern, '', $_REQUEST['parent']); $group = preg_replace($pattern, '', $_REQUEST['group']); $parent = preg_replace($pattern, '', $_REQUEST['parent']); if ($plugin) { $backURL = "plugin-index.php?action=info&package={$plugin}"; } else { $backURL = "plugin-index.php?selection=plugins"; } // get the settings for this plugin $oManager = new OX_Plugin_ComponentGroupManager(); $aConfig = $oManager->_getComponentGroupConfiguration($group); // If the settings page is a submission, deal with the form data if (isset($_POST['submitok']) && $_POST['submitok'] == 'true') { // Prepare an array of the HTML elements to process, and the // location to save the values in the settings configuration // file $aElements = array(); foreach ($aConfig['preferences'] as $k => $v) { $aElements[] = $group . '_' . $v['key']; // Register the HTML element value MAX_commonRegisterGlobalsArray(array($group . '_' . $v['key'])); } $aCheckboxes = array(); $valid = true; $validationFile = MAX_PATH . $GLOBALS['_MAX']['CONF']['pluginPaths']['packages'] . $group . '/processPreferences.php';
/** * caches hooks for enabled plugins only * indexed by group name * * @return boolean */ function cachePreferenceOptions() { $oComponentGroupManager = new OX_Plugin_ComponentGroupManager(); $aComponentGroups = $GLOBALS['_MAX']['CONF']['pluginGroupComponents'] ? $GLOBALS['_MAX']['CONF']['pluginGroupComponents'] : array(); $aOptions = array(); foreach ($aComponentGroups as $name => $enabled) { if ($enabled || OA_Permission::getAccountType() == OA_ACCOUNT_ADMIN) { $aConfig[$name] = $oComponentGroupManager->_getComponentGroupConfiguration($name); if (count($aConfig[$name]['preferences'])) { $aOptions[$name] = array('name' => $name, 'text' => $aConfig[$name]['option'] ? $aConfig[$name]['option'] : $name, 'value' => 'account-preferences-plugin.php?group=' . $name, 'perm' => array(OA_ACCOUNT_ADMIN, OA_ACCOUNT_MANAGER, OA_ACCOUNT_ADVERTISER, OA_ACCOUNT_TRAFFICKER)); } } } $oCache = $oComponentGroupManager->_getOA_Cache('Plugins', 'PrefOptions'); $oCache->setFileNameProtection(false); return $oCache->save($aOptions); }
// Security check OA_Permission::enforceAccount(OA_ACCOUNT_ADMIN); // Create a new option object for displaying the setting's page's HTML form $oOptions = new OA_Admin_Option('settings'); // Prepare an array for storing error messages $aErrormessage = array(); $pattern = '/[^a-zA-Z0-9\\._-]/'; $group = preg_replace($pattern, '', $_REQUEST['group']); $plugin = preg_replace($pattern, '', $_REQUEST['plugin']); if ($plugin) { $backURL = "plugin-index.php?action=info&package={$plugin}"; } else { $backURL = "plugin-index.php?selection=plugins"; } // get the settings for this plugin $oManager = new OX_Plugin_ComponentGroupManager(); $aComponentSettings = $oManager->getComponentGroupSettings($group, true); // If the settings page is a submission, deal with the form data if (isset($_POST['submitok']) && $_POST['submitok'] == 'true') { // Prepare an array of the HTML elements to process, and the // location to save the values in the settings configuration // file $aElements = array(); foreach ($aComponentSettings as $k => $v) { if (0 == strcmp($v['type'], 'checkbox')) { $aItemSettings = array($group => $v['key'], 'bool' => 'true'); } else { $aItemSettings = array($group => $v['key']); } $aElements += array($group . '_' . $v['key'] => $aItemSettings); // Register the HTML element value