public function import($aVals, $bMissingOnly = false) { $iProductId = Admincp_Service_Product_Product::instance()->getId($aVals['product']); if (!$iProductId) { $iProductId = 1; } $aCache = array(); if ($bMissingOnly) { $aRows = $this->database()->select('file_name')->from($this->_sTable)->execute('getRows', array('free_result' => true)); foreach ($aRows as $aRow) { $aCache[$aRow['file_name']] = $aRow['file_name']; } } $aSql = array(); $aVals = isset($aVals['cron'][0]) ? $aVals['cron'] : array($aVals['cron']); foreach ($aVals as $aVal) { if ($bMissingOnly && in_array($aVal['file_name'], $aCache)) { continue; } $aSql[] = array($aVal['file_name'], $aVal['type_id'], $aVal['every'], $iProductId, 1); } if ($aSql) { $this->database()->multiInsert($this->_sTable, array('file_name', 'type_id', 'every', 'product_id', 'is_active'), $aSql); } return true; }
/** * Controller */ public function process() { if (Phpfox::getParam('core.phpfox_is_hosted')) { $this->url()->send('admincp'); } $bIsEdit = false; if (($iId = $this->request()->getInt('id')) && ($aComponent = Phpfox::getService('admincp.component')->getForEdit($iId))) { $bIsEdit = true; $this->template()->assign(array('aForms' => $aComponent)); } $aValidation = array('product_id' => Phpfox::getPhrase('admincp.select_product'), 'component' => Phpfox::getPhrase('admincp.specify_component'), 'is_active' => Phpfox::getPhrase('admincp.select_component_active'), 'type' => Phpfox::getPhrase('admincp.select_component_type')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); if ($aVals = $this->request()->getArray('val')) { if ($oValid->isValid($aVals)) { if ($bIsEdit) { if (Phpfox::getService('admincp.component.process')->update($iId, $aVals)) { $this->url()->send('admincp.component.add', array('id' => $iId), Phpfox::getPhrase('admincp.component_successfully_updated')); } } else { if (Phpfox::getService('admincp.component.process')->add($aVals)) { $this->url()->send('admincp.component', null, Phpfox::getPhrase('admincp.component_successfully_added')); } } } } $this->template()->setTitle($bIsEdit ? Phpfox::getPhrase('admincp.editing_component') : Phpfox::getPhrase('admincp.add_component'))->setBreadcrumb(Phpfox::getPhrase('admincp.manage_components'), $this->url()->makeUrl('admincp.component'))->setBreadCrumb($bIsEdit ? Phpfox::getPhrase('admincp.editing_component') : Phpfox::getPhrase('admincp.add_component'), null, true)->assign(array('aProducts' => Admincp_Service_Product_Product::instance()->get(), 'aModules' => Phpfox::getService('admincp.module')->getModules(), 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'bIsEdit' => $bIsEdit)); }
public function import($aVals, $bMissingOnly = false) { $iProductId = Admincp_Service_Product_Product::instance()->getId($aVals['product']); if (!is_array($aVals)) { return false; } $aCache = array(); if ($bMissingOnly) { $aRows = $this->database()->select('call_name')->from(Phpfox::getT('plugin_hook'))->execute('getRows', array('free_result' => true)); foreach ($aRows as $aRow) { $aCache[md5($aRow['call_name'])] = $aRow['call_name']; } } $aSql = array(); $aVals = isset($aVals['hook'][0]) ? $aVals['hook'] : array($aVals['hook']); foreach ($aVals as $aVal) { if ($bMissingOnly && isset($aCache[md5($aVal['call_name'])])) { continue; } $iModuleId = Phpfox_Module::instance()->getModuleId($aVal['module']); $aSql[] = array($aVal['hook_type'], $iModuleId, $iProductId, $aVal['call_name'], $aVal['added'], $aVal['version_id']); } if ($aSql) { $this->database()->multiInsert(Phpfox::getT('plugin_hook'), array('hook_type', 'module_id', 'product_id', 'call_name', 'added', 'version_id'), $aSql); } return true; }
public function import($aVals, $bMissingOnly = false) { $iProductId = Admincp_Service_Product_Product::instance()->getId($aVals['product']); if (!$iProductId) { $iProductId = 1; } if ($bMissingOnly) { $aCache = array(); $aRows = $this->database()->select('var_name')->from($this->_sTable)->execute('getRows', array('free_result' => true)); foreach ($aRows as $aRow) { $aCache[$aRow['var_name']] = $aRow['var_name']; } $aSql = array(); foreach ($aVals['name'] as $aValue) { if (in_array($aValue['value'], $aCache)) { continue; } $aSql[] = array($iProductId, $aValue['version_id'], $aValue['value']); } if ($aSql) { $this->database()->multiInsert($this->_sTable, array('product_id', 'version_id', 'var_name'), $aSql); } } else { $aSql = array(); foreach ($aVals['name'] as $aValue) { $aSql[] = array($iProductId, $aValue['version_id'], $aValue['value']); } $this->database()->multiInsert($this->_sTable, array('product_id', 'version_id', 'var_name'), $aSql); } return true; }
/** * Controller */ public function process() { Phpfox::getUserParam('language.can_manage_lang_packs', true); $bNoJsValidation = $this->getParam('bNoJsValidation'); $aModules = Phpfox::getService('admincp.module')->getModules(); $aLanguages = Phpfox::getService('language')->get(); if ($sPhrase = $this->getParam('sVar')) { $aParts = explode('.', $sPhrase); $sPhrase = $aParts[1]; } /* $aValidation = array( 'var_name' => array( 'def' => 'required', 'title' => Phpfox::getPhrase('language.select_varname') ) ); */ $aValidation = array(); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_phrase_form', 'aParams' => $aValidation)); if ($aVals = $this->request()->getArray('val')) { if (empty($aVals['var_name']) && isset($aVals['text']['en'])) { $aVals['var_name'] = $aVals['text']['en']; } if (empty($aVals['var_name'])) { Phpfox_Error::set('Provide a var name.'); } // Check that all the fields are valid if ($oValid->isValid($aVals)) { // Check to make sure the phrase has not already been added if ($sIsPhrase = Phpfox::getService('language.phrase')->isPhrase($aVals)) { Phpfox_Error::set(Phpfox::getPhrase('language.phrase_already_created', array('phrase' => $sIsPhrase)) . ' - ' . Phpfox::getPhrase($sIsPhrase)); $sCachePhrase = $sIsPhrase; } else { $sVarName = Phpfox::getService('language.phrase.process')->prepare($aVals['var_name']); if (isset($aVals['module'])) { $aParts = explode('|', $aVals['module']); $sVarName = $aParts[1] . '.' . $sVarName; } $sCached = Phpfox::getPhrase('language.phrase_added', array('phrase' => $sVarName)); // Add the new phrase $sPhrase = Phpfox::getService('language.phrase.process')->add($aVals); // Verify if we have a return URL, if we do send them there instead if ($sReturn = $this->request()->get('return')) { $this->url()->forward($sReturn, $sCached); } else { Phpfox::getLib('session')->set('cache_new_phrase', $sVarName); // Phrase added lets send them back to the same page with a message that the phrase was added $this->url()->send('admincp.language.phrase.add', array('last-module' => $aParts[1]), $sCached); } } } } if (!isset($sCachePhrase) && ($sCachePhrase = Phpfox::getLib('session')->get('cache_new_phrase'))) { Phpfox::getLib('session')->remove('cache_new_phrase'); } // Assign needed vars to the template $this->template()->assign(array('aProducts' => Admincp_Service_Product_Product::instance()->get(), 'aModules' => $aModules, 'aLanguages' => $aLanguages, 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $bNoJsValidation ? 'return true;' : $oValid->getJsForm(), 'sReturn' => ($sReturn = $this->request()->get('return')) ? $sReturn : $this->getParam('sReturnUrl'), 'sVar' => $sPhrase, 'sCachePhrase' => isset($sCachePhrase) ? $sCachePhrase : '', 'sLastModuleId' => $this->request()->get('last-module')))->setBreadCrumb(Phpfox::getPhrase('language.add_phrase'), $this->url()->current(), true)->setTitle(Phpfox::getPhrase('language.add_phrase')); ($sPlugin = Phpfox_Plugin::get('language.component_controller_admincp_phrase_add_process')) ? eval($sPlugin) : false; }
/** * Controller */ public function process() { $aValidExt = array('xml', 'zip', 'tar.gz'); $oArchiveExport = Phpfox::getLib('archive.export')->set($aValidExt); $oArchiveImport = Phpfox::getLib('archive.import')->set($aValidExt); // Run the export routine if ($iExportId = $this->request()->get('export')) { if ($sXml = Phpfox::getService('admincp.setting')->export($iExportId)) { $oArchiveExport->download($this->request()->get('file_extension'), 'phpfox_setting.xml', $sXml); } } // Run the import routine if ($aFile = $this->request()->get('import')) { if ($sXmlData = $oArchiveImport->process($aFile)) { $aParams = Phpfox::getLib('xml.parser')->parse($sXmlData); // Import the settings if ($iImported = Phpfox::getService('admincp.setting.process')->import($aParams, true)) { // Settings imported, mention how many settings were imported. $this->url()->send('admincp', array('setting', 'file'), Phpfox::getPhrase('admincp.setting_imported', array('total' => $iImported))); } else { if (is_numeric($iImported)) { // Nothing new to import Phpfox_Error::set(Phpfox::getPhrase('admincp.nothing_new_import')); } } } } // Assign needed vars to the template $this->template()->assign(array('aProducts' => Admincp_Service_Product_Product::instance()->get(), 'aArchives' => $oArchiveExport->getSupported(), 'sSupported' => $oArchiveImport->getSupported()))->setBreadCrumb(Phpfox::getPhrase('admincp.import_export_settings'))->setTitle(Phpfox::getPhrase('admincp.import_export_settings')); ($sPlugin = Phpfox_Plugin::get('admincp.component_controller_setting_file_process')) ? eval($sPlugin) : false; }
/** * Controller */ public function process() { if (Phpfox::getParam('core.phpfox_is_hosted')) { $this->url()->send('admincp'); } $bIsEdit = false; if ($iEditId = $this->request()->get('id')) { $aProduct = Admincp_Service_Product_Product::instance()->getForEdit($iEditId); if (isset($aProduct['product_id'])) { $bIsEdit = true; $this->template()->assign(array('aForms' => $aProduct, 'aDependencies' => Admincp_Service_Product_Product::instance()->getDependencies($aProduct['product_id']), 'aInstalls' => Admincp_Service_Product_Product::instance()->getInstalls($aProduct['product_id']))); } } $aValidation = array('product_id' => Phpfox::getPhrase('admincp.add_a_product_id'), 'title' => Phpfox::getPhrase('admincp.add_a_product_title')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); if ($aVals = $this->request()->getArray('val')) { $oAdmincpProductProcess = Phpfox::getService('admincp.product.process'); if (isset($aVals['dependency'])) { if (isset($aVals['dependency']['delete'])) { foreach ($aVals['dependency']['delete'] as $iDeleteId) { $bDeleted = $oAdmincpProductProcess->deleteDependency($iDeleteId); } } if (isset($aVals['dependency']['update'])) { foreach ($aVals['dependency']['update'] as $iDependencyId => $aDependency) { $oAdmincpProductProcess->updateDependency($iDependencyId, $aDependency); } } $bAdded = $oAdmincpProductProcess->addDependency($aVals['dependency']); $this->url()->send('admincp', array('product', 'add', 'id' => $aVals['dependency']['product_id']), Phpfox::getPhrase('admincp.product_dependency_updated')); } elseif (isset($aVals['install'])) { if (isset($aVals['install']['delete'])) { foreach ($aVals['install']['delete'] as $iDeleteId) { $bDeleted = $oAdmincpProductProcess->deleteInstall($iDeleteId); } } if (isset($aVals['install']['update'])) { foreach ($aVals['install']['update'] as $iInstallId => $aInstallUpdate) { $oAdmincpProductProcess->updateInstall($iInstallId, $aInstallUpdate); } } $bAdded = $oAdmincpProductProcess->addInstall($aVals['install']); $this->url()->send('admincp', array('product', 'add', 'id' => $aVals['install']['product_id']), Phpfox::getPhrase('admincp.product_install_uninstall_updated')); } else { if ($oValid->isValid($aVals)) { if ($bIsEdit) { if (Phpfox::getService('admincp.product.process')->update($aProduct['product_id'], $aVals)) { $this->url()->send('admincp', array('product', 'add', 'id' => $aProduct['product_id']), Phpfox::getPhrase('admincp.product_successfully_updated')); } } else { if ($sName = Phpfox::getService('admincp.product.process')->add($aVals)) { $this->url()->send('admincp', array('product'), Phpfox::getPhrase('admincp.product_successfully_created')); } } } } } $this->template()->setTitle($bIsEdit ? Phpfox::getPhrase('admincp.editing_product') . ': ' . $aProduct['title'] : Phpfox::getPhrase('admincp.create_new_product'))->setBreadcrumb(Phpfox::getPhrase('admincp.products'), $this->url()->makeUrl('admincp.product'))->setBreadCrumb($bIsEdit ? Phpfox::getPhrase('admincp.editing_product') . ': ' . $aProduct['title'] : Phpfox::getPhrase('admincp.create_new_product'), $this->url()->current(), true)->assign(array('sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'bIsEdit' => $bIsEdit)); }
/** * Controller */ public function process() { if (Phpfox::getParam('core.phpfox_is_hosted')) { $this->url()->send('admincp'); } $bIsEdit = false; if (($iEditId = $this->request()->get('id')) || ($iEditId = $this->request()->get('module_id'))) { Phpfox::getUserParam('admincp.can_manage_modules', true); $aRow = Phpfox::getService('admincp.module')->getForEdit($iEditId); $bIsEdit = true; if ($aRow['is_menu'] && !empty($aRow['menu'])) { $aMenus = unserialize($aRow['menu']); $aSubs = array(); foreach ($aMenus as $sPhrase => $aMenu) { $aParts = explode('.', $sPhrase); $aSubs[] = array('phrase' => Phpfox::getService('language.phrase')->getStaticPhrase($sPhrase), 'link' => implode('.', $aMenu['url']), 'var_name' => $aParts[1]); } $aRow['menu'] = $aSubs; } $this->template()->assign(array('aForms' => $aRow)); } else { Phpfox::getUserParam('admincp.can_add_new_modules', true); } $aValidation = array('module_id' => Phpfox::getPhrase('admincp.select_name_for_your_module')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); if ($aVals = $this->request()->getArray('val')) { if ($oValid->isValid($aVals)) { if ($bIsEdit) { if (Phpfox::getService('admincp.module.process')->update($aRow['module_id'], $aVals)) { $this->url()->send('admincp', array('module', 'add', 'id' => $aRow['module_id']), Phpfox::getPhrase('admincp.module_successfully_updated')); } } else { if (Phpfox_Module::instance()->isModule($aVals['module_id'])) { Phpfox_Error::set(Phpfox::getPhrase('admincp.module_name_already_used')); } else { if ($sName = Phpfox::getService('admincp.module.process')->add($aVals)) { $this->url()->send('admincp', array('module'), Phpfox::getPhrase('admincp.module_successfully_created_redirect')); } } } } } $aVals = $this->request()->getArray('val'); $aMenus = array(); if (isset($aVals['menu']) || isset($aRow['menu'])) { $aSubMenus = $bIsEdit ? $aRow['menu'] : $aVals['menu']; if (is_array($aSubMenus) && count($aSubMenus)) { foreach ($aSubMenus as $iKey => $aMenu) { if (empty($aMenu['phrase'])) { continue; } $aMenus[$iKey] = $aMenu; } } } $this->template()->setBreadCrumb($bIsEdit ? 'Editing Module: ' . $aRow['module_id'] : Phpfox::getPhrase('admincp.create_module'), $this->url()->current(), true)->setTitle($bIsEdit ? 'Editing Module: ' . $aRow['module_id'] : Phpfox::getPhrase('admincp.create_module'))->assign(array('aProducts' => Admincp_Service_Product_Product::instance()->get(), 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'aLanguages' => $bIsEdit ? Phpfox::getService('language')->getWithPhrase($aRow['phrase_var_name']) : Phpfox::getService('language')->get(), 'sDir' => PHPFOX_DIR_MODULE, 'aMenus' => $aMenus, 'iMenus' => $bIsEdit && count($aRow['menu']) ? count($aRow['menu']) - 1 : (isset($aVals['menu']) ? count($aVals['menu']) - 1 : 3), 'sPhpfoxDs' => PHPFOX_DS, 'bIsEdit' => $bIsEdit)); ($sPlugin = Phpfox_Plugin::get('admincp.component_controller_module_add_process')) ? eval($sPlugin) : false; }
/** * Controller */ public function process() { $bIsEdit = false; $oSession = Phpfox::getLib('session'); $aValidation = array('product_id' => Phpfox::getPhrase('page.select_product'), 'title' => Phpfox::getPhrase('page.missing_title'), 'title_url' => Phpfox::getPhrase('page.missing_url_title'), 'is_active' => Phpfox::getPhrase('page.specify_page_active'), 'text' => Phpfox::getPhrase('page.page_missing_data')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); if (($iPageId = $this->request()->getInt('id')) || ($iPageId = $this->request()->getInt('page_id'))) { Phpfox::getUserParam('page.can_manage_custom_pages', true); $aPage = Phpfox::getService('page')->getForEdit($iPageId); if (isset($aPage['page_id'])) { $bIsEdit = true; // $aPage['attachment'] = (Phpfox::isModule('attachment') ? Phpfox::getService('attachment')->getForItemEdit($aPage['page_id'], 'page', Phpfox::getUserId()) : ''); if (Phpfox::isModule('tag')) { $aTags = Tag_Service_Tag::instance()->getTagsById('page', $aPage['page_id']); if (isset($aTags[$aPage['page_id']])) { $aPage['tag_list'] = ''; foreach ($aTags[$aPage['page_id']] as $aTag) { $aPage['tag_list'] .= ' ' . $aTag['tag_text'] . ','; } $aPage['tag_list'] = trim(trim($aPage['tag_list'], ',')); } } $this->template()->assign(array('aForms' => $aPage, 'aAccess' => empty($aPage['disallow_access']) ? null : unserialize($aPage['disallow_access']))); } } if ($aVals = $this->request()->getArray('val')) { Phpfox::getLib('parse.input')->allowTitle(Phpfox::getLib('parse.input')->cleanTitle($aVals['title_url']), Phpfox::getPhrase('page.invalid_title')); if ($oValid->isValid($aVals)) { if ($bIsEdit) { $sMessage = Phpfox::getPhrase('page.page_successfully_updated'); $sReturn = Phpfox::getService('page.process')->update($aPage['page_id'], $aVals, $aPage['user_id']); $aUrl = null; } else { $sMessage = Phpfox::getPhrase('page.successfully_added'); $sReturn = Phpfox::getService('page.process')->add($aVals); $aUrl = null; } if ($sReturn) { return ['redirect' => $this->url()->makeUrl($sReturn, null, $sMessage)]; } } else { $aError = Phpfox_Error::get(); $sError = ''; if (is_array($aError)) { $sError = implode(' ', $aError); } else { $sError = $aError; } return ['error' => $sError]; } } $this->template()->setSectionTitle('<a href="' . $this->url()->makeUrl('admincp.page') . '">Custom Pages</a>')->setTitle(Phpfox::getPhrase('page.add_new_page'))->setBreadCrumb(Phpfox::getPhrase('page.add_new_page'))->assign(array('aProducts' => Admincp_Service_Product_Product::instance()->get(), 'aUserGroups' => Phpfox::getService('user.group')->get(), 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'bIsEdit' => $bIsEdit, 'aModules' => Phpfox_Module::instance()->getModules(), 'bFormIsPosted' => count($aVals) ? true : false))->setEditor()->setHeader(array('jquery/plugin/jquery.highlightFade.js' => 'static_script', 'switch_menu.js' => 'static_script', '<script type="text/javascript">var Attachment = {sCategory: "page", iItemId: "' . (isset($aPage['page_id']) ? $aPage['page_id'] : '') . '"};</script>')); }
/** * Controller */ public function process() { Phpfox::getUserParam('language.can_manage_lang_packs', true); $aValidExt = array('xml', 'zip', 'tar.gz'); $oArchiveExport = Phpfox::getLib('archive.export')->set($aValidExt); $oArchiveImport = Phpfox::getLib('archive.import')->set($aValidExt); // Run the export routine if ($aVals = $this->request()->getArray('val')) { if ($sXml = Phpfox::getService('language')->export($aVals['language_id'], $aVals['product_id'])) { $oArchiveExport->download($aVals['file_extension'], 'phpfox_language.xml', $sXml); } } // Run the import routine if ($this->request()->get('import')) { $aFile = $this->request()->get('file'); /* if (empty($aFile['name']) && $this->request()->get('download')) { $sXmlData = PhpFox::send(array( 'cmd' => 'import-language-package', 'name' => $this->request()->get('download') )); } */ if (isset($sXmlData) || ($sXmlData = $oArchiveImport->process($aFile))) { $aParams = Phpfox::getLib('xml.parser')->parse($sXmlData); // Import the settings if ($iImported = Phpfox::getService('language.process')->import($aParams, $this->request()->get('missing_phrases') ? true : false)) { // Settings imported, mention how many settings were imported. $this->url()->send('admincp', array('language', 'file'), Phpfox::getPhrase('language.language_package_successfully_imported')); } } } /* $oCache = Phpfox::getLib('cache'); $sCacheId = $oCache->set('phpfox_language_packages'); if (!($sData = $oCache->get($sCacheId, 300))) { $sData = PhpFox::send(array( 'cmd' => 'get-language-packages' )); $oCache->save($sCacheId, $sData); } $aImports = Phpfox::getLib('xml.parser')->parse($sData); */ $aImports = array(); // Assign needed vars to the template $this->template()->assign(array('aProducts' => Admincp_Service_Product_Product::instance()->get(), 'aLanguages' => Phpfox::getService('language')->get(), 'aArchives' => $oArchiveExport->getSupported(), 'sSupported' => $oArchiveImport->getSupported(), 'aImports' => isset($aImports['language']) ? $aImports['language'] : array()))->setBreadCrumb(Phpfox::getPhrase('language.import_export'))->setTitle(Phpfox::getPhrase('language.import_export')); ($sPlugin = Phpfox_Plugin::get('language.component_controller_admincp_file_process')) ? eval($sPlugin) : false; }
/** * Controller */ public function process() { if (Phpfox::getParam('core.phpfox_is_hosted')) { $this->url()->send('admincp'); } $bIsEdit = false; $aValidation = array('product_id' => Phpfox::getPhrase('admincp.select_product'), 'hook_type' => Phpfox::getPhrase('admincp.select_what_type_of_a_hook_this_is')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); if ($aVals = $this->request()->getArray('val')) { if (Phpfox::getService('admincp.plugin.process')->addHook($aVals)) { $this->url()->send('admincp.plugin.hook.add', null, Phpfox::getPhrase('admincp.hook_successfully_added')); } } $this->template()->setTitle(Phpfox::getPhrase('admincp.add_hook'))->setBreadCrumb(Phpfox::getPhrase('admincp.add_hook'))->assign(array('aProducts' => Admincp_Service_Product_Product::instance()->get(), 'aModules' => Phpfox::getService('admincp.module')->getModules(), 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'bIsEdit' => $bIsEdit, 'aHookTypes' => array('library', 'service', 'component', 'template'))); }
/** * Controller */ public function process() { Phpfox::getUserParam('admincp.can_add_new_block', true); $bIsEdit = false; if (($iEditId = $this->request()->getInt('id')) || ($iEditId = $this->request()->getInt('block_id'))) { $aRow = Admincp_Service_Block_Block::instance()->getForEdit($iEditId); $bIsEdit = true; $this->template()->assign(array('aForms' => $aRow, 'aAccess' => empty($aRow['disallow_access']) ? null : unserialize($aRow['disallow_access']))); } $aValidation = array('product_id' => Phpfox::getPhrase('admincp.select_product'), 'location' => Phpfox::getPhrase('admincp.select_block_placement'), 'is_active' => Phpfox::getPhrase('admincp.specify_block_active')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); if ($aVals = $this->request()->getArray('val')) { if ($oValid->isValid($aVals)) { if ($bIsEdit) { $sMessage = Phpfox::getPhrase('admincp.successfully_updated'); $aUrl = array('block', 'add', 'id' => $aRow['block_id']); Phpfox::getService('admincp.block.process')->update($aRow['block_id'], $aVals); } else { $sMessage = Phpfox::getPhrase('admincp.block_successfully_added'); $aUrl = array('block'); Phpfox::getService('admincp.block.process')->add($aVals); } $this->url()->send('admincp', $aUrl, $sMessage); } } if (Phpfox::getParam('core.enabled_edit_area')) { $this->template()->setHeader(array('editarea/edit_area_full.js' => 'static_script', '<script type="text/javascript"> editAreaLoader.init({ id: "source_code" ,start_highlight: true ,allow_resize: "both" ,allow_toggle: false ,word_wrap: false ,language: "en" ,syntax: "php" }); </script>')); } $aStyles = Theme_Service_Style_Style::instance()->getStyles(); if ($bIsEdit) { foreach ($aStyles as $iKey => $aStyle) { if (isset($aRow['style_id']) && isset($aRow['style_id'][$aStyle['style_id']])) { $aStyles[$iKey]['block_is_selected'] = $aRow['style_id'][$aStyle['style_id']]; } } } $this->template()->assign(array('aProducts' => Admincp_Service_Product_Product::instance()->get(), 'aControllers' => Phpfox::getService('admincp.component')->get(true), 'aComponents' => Phpfox::getService('admincp.component')->get(), 'aUserGroups' => Phpfox::getService('user.group')->get(), 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'bIsEdit' => $bIsEdit, 'aStyles' => $aStyles))->setTitle(Phpfox::getPhrase('admincp.block_manager'))->setBreadcrumb(Phpfox::getPhrase('admincp.block_manager'), $this->url()->makeUrl('admincp.block'))->setBreadcrumb($bIsEdit ? Phpfox::getPhrase('admincp.editing') . ': ' . (empty($aRow['m_connection']) ? Phpfox::getPhrase('admincp.site_wide') : $aRow['m_connection']) . (empty($aRow['component']) ? '' : '::' . rtrim(str_replace('|', '::', $aRow['component']), '::')) . (empty($aRow['title']) ? '' : ' (' . Phpfox_Locale::instance()->convert($aRow['title']) . ')') : Phpfox::getPhrase('admincp.add_new_block'), $this->url()->makeUrl('admincp.block.add'), true)->setTitle(Phpfox::getPhrase('admincp.add_new_block')); }
/** * Controller */ public function process() { Phpfox::getUserParam('user.can_add_user_group_setting', true); $aGroups = Phpfox::getService('user.group')->get('user_group.is_special = 1'); $aForms = array(); if (($iSetting = $this->request()->getInt('id')) && ($aForms = Phpfox::getService('user.group.setting')->getSetting($iSetting)) && isset($aForms['setting_id'])) { foreach ($aGroups as $iKey => $aGroup) { if ($aGroup['user_group_id'] == '1') { $aGroups[$iKey]['value'] = $aForms['default_admin']; } elseif ($aGroup['user_group_id'] == '3') { $aGroups[$iKey]['value'] = $aForms['default_guest']; } elseif ($aGroup['user_group_id'] == '4') { $aGroups[$iKey]['value'] = $aForms['default_staff']; } else { $aGroups[$iKey]['value'] = $aForms['default_user']; } } } if (!$this->request()->getInt('id')) { $this->url()->send('admincp'); } $aValidation = array('name' => Phpfox::getPhrase('user.select_varname')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation)); if ($aVals = $this->request()->getArray('val')) { // Check that all the fields are valid if ($oValid->isValid($aVals)) { if (isset($aForms['setting_id'])) { if (Phpfox::getService('user.group.setting.process')->updateSetting(array_merge($aVals, array('setting_id' => $aForms['setting_id'])))) { $this->url()->send('admincp', array('user', 'group', 'add', 'id' => $this->request()->getInt('gid'), '#setting' . $aForms['setting_id']), Phpfox::getPhrase('user.setting_successfully_updated')); } } else { if (Phpfox::getService('user.group.setting.process')->addSetting($aVals)) { $this->url()->send('admincp', array('user', 'group', 'setting'), Phpfox::getPhrase('user.setting_successfully_added')); } } } } if ($sCacheSetting = Phpfox::getLib('session')->get('cache_new_user_setting')) { Phpfox::getLib('session')->remove('cache_new_user_setting'); } if (isset($aForms['name'])) { Phpfox_Database::instance()->select('language_phrase.text, ')->leftJoin(Phpfox::getT('language_phrase'), 'language_phrase', "language_phrase.language_id = l.language_id AND language_phrase.var_name = 'user_setting_{$aForms['name']}'"); } $aLanguages = Phpfox::getService('language')->get(); $this->template()->setBreadcrumb(Phpfox::getPhrase('user.user_groups'), $this->url()->makeUrl('admincp.user.group'))->setBreadcrumb(Phpfox::getPhrase('user.manage_user_groups'), $this->url()->makeUrl('admincp.user.group'))->setBreadcrumb(Phpfox::getPhrase('user.add_user_group_setting'), null, true)->setTitle(Phpfox::getPhrase('user.add_user_group_setting'))->assign(array('aProducts' => Admincp_Service_Product_Product::instance()->get(), 'aModules' => Phpfox::getService('admincp.module')->getModules(), 'aLanguages' => $aLanguages, 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'aTypes' => array('boolean', 'integer', 'string', 'array'), 'aUserGroups' => $aGroups, 'sCacheSetting' => $sCacheSetting, 'aForms' => $aForms, 'iGroupId' => $this->request()->getInt('gid'))); ($sPlugin = Phpfox_Plugin::get('user.component_controller_admincp_group_setting_process')) ? eval($sPlugin) : false; }
/** * Controller */ public function process() { if (Phpfox::getParam('core.phpfox_is_hosted')) { $this->url()->send('admincp'); } $aValidation = array('var_name' => Phpfox::getPhrase('admincp.add_a_title_for_the_group'), 'info' => Phpfox::getPhrase('admincp.add_information_regarding_group')); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_setting_form', 'aParams' => $aValidation)); if ($aVals = $this->request()->getArray('val')) { if ($oValid->isValid($aVals)) { if ($sVarName = Phpfox::getService('admincp.setting.group.process')->add($aVals)) { $this->url()->send('admincp.setting.group.add', null, Phpfox::getPhrase('admincp.added') . ': ' . $sVarName); } } } $this->template()->setBreadCrumb(Phpfox::getPhrase('admincp.add_setting_group'))->setTitle(Phpfox::getPhrase('admincp.add_setting_group'))->assign(array('aProducts' => Admincp_Service_Product_Product::instance()->get(), 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'aModules' => Phpfox_Module::instance()->getModules())); ($sPlugin = Phpfox_Plugin::get('admincp.component_controller_setting_group_add_process')) ? eval($sPlugin) : false; }
/** * Controller */ public function process() { if ($aVals = $this->request()->getArray('val')) { if (Phpfox::getService('admincp.product.process')->updateActive($aVals)) { $this->url()->send('admincp.product', null, Phpfox::getPhrase('admincp.product_s_updated')); } } if ($sPlugin = Phpfox_Plugin::get('admincp.component_controller_product_index_3')) { eval($sPlugin); if (isset($mReturnFromPlugin)) { return $mReturnFromPlugin; } } if ($sDeleteProduct = $this->request()->get('delete')) { if (Phpfox::getService('admincp.product.process')->delete($sDeleteProduct)) { $this->url()->send('admincp.product', null, Phpfox::getPhrase('admincp.product_successfully_deleted')); } } if ($sUpgrade = $this->request()->get('upgrade')) { if ($sPlugin = Phpfox_Plugin::get('admincp.component_controller_product_index_1')) { eval($sPlugin); if (isset($mReturnFromPlugin)) { return $mReturnFromPlugin; } } if (Phpfox::getService('admincp.product.process')->upgrade($sUpgrade)) { Phpfox_Plugin::set(); if ($sPlugin = Phpfox_Plugin::get('admincp.component_controller_product_index_2')) { eval($sPlugin); if (isset($mReturnFromPlugin)) { return $mReturnFromPlugin; } } $this->url()->send('admincp.product', null, Phpfox::getPhrase('admincp.product_successfully_upgraded')); } } $aProducts = Admincp_Service_Product_Product::instance()->get(false); foreach ($aProducts as $iKey => $aProduct) { if ($aProduct['product_id'] == 'phpfox' || $aProduct['product_id'] == 'phpfox_installer') { unset($aProducts[$iKey]); } } $this->template()->setTitle(Phpfox::getPhrase('admincp.manage_products'))->setBreadcrumb(Phpfox::getPhrase('admincp.manage_products'))->assign(array('aProducts' => $aProducts)); }
/** * Controller */ public function process() { $oAdmincpMenu = Admincp_Service_Menu_Menu::instance(); $bIsEdit = false; $bIsPage = false; if (Phpfox::isModule('page') && ($sPage = $this->request()->get('page'))) { $aPage = Phpfox::getService('page')->getPage($sPage, true); if (isset($aPage['page_id'])) { $bIsPage = true; $this->template()->assign(array('aPage' => $aPage, 'sModuleValue' => $aPage['module_id'] ? $aPage['module_id'] . '|' . $aPage['module_id'] : 'page|page', 'aAccess' => empty($aPage['disallow_access']) ? null : unserialize($aPage['disallow_access']))); } } if (($iEditId = $this->request()->getInt('id')) || ($iEditId = $this->request()->getInt('menu_id'))) { $aRow = $oAdmincpMenu->getForEdit($iEditId); $aLanguages = Phpfox::getService('language')->getWithPhrase($aRow['var_name']); $bIsEdit = true; $aTypes = Admincp_Service_Menu_Menu::instance()->getTypes(); if (!in_array($aRow['m_connection'], $aTypes)) { $aRow['m_connection'] = $aRow['m_connection']; } $this->template()->assign(array('aForms' => $aRow, 'aAccess' => empty($aRow['disallow_access']) ? null : unserialize($aRow['disallow_access']))); } else { $aLanguages = Phpfox::getService('language')->get(); } if ($aVals = $this->request()->getArray('val')) { if ($bIsEdit) { $sMessage = Phpfox::getPhrase('admincp.menu_successfully_updated'); Admincp_Service_Menu_Process::instance()->update($aRow['menu_id'], $aVals); } else { $sMessage = Phpfox::getPhrase('admincp.menu_successfully_added'); Admincp_Service_Menu_Process::instance()->add($aVals); } if (isset($aVals['is_page'])) { $this->url()->send($aVals['url_value'], null, Phpfox::getPhrase('admincp.page_menu_successfully_added')); } if ($bIsEdit) { $this->url()->send('admincp.menu', null, $sMessage); } else { $this->url()->send('admincp.menu', null, $sMessage); } } $this->template()->assign(array('aProducts' => Admincp_Service_Product_Product::instance()->get(), 'aModules' => Phpfox::getService('admincp.module')->getModules(), 'aParents' => Admincp_Service_Menu_Menu::instance()->get(array('menu.parent_id = 0 AND menu.m_connection IN(\'main\', \'main_right\')'), false), 'aControllers' => Phpfox::getService('admincp.component')->get(true), 'aPages' => Phpfox::getService('page')->getCache(), 'aLanguages' => $aLanguages, 'aUserGroups' => Phpfox::getService('user.group')->get(), 'aTypes' => $oAdmincpMenu->getTypes(), 'bIsEdit' => $bIsEdit, 'bIsPage' => $bIsPage))->setBreadcrumb(Phpfox::getPhrase('admincp.add_new_menu'), $this->url()->makeUrl('current'), true)->setTitle(Phpfox::getPhrase('admincp.add_new_menu')); }
/** * Controller * @todo Complete the update routine... */ public function process() { if (Phpfox::getParam('core.phpfox_is_hosted')) { $this->url()->send('admincp'); } Phpfox::getUserParam('core.can_add_new_setting', true); $bEdit = false; if ($iId = $this->request()->getInt('id')) { $aSetting = Phpfox::getService('admincp.setting')->getForEdit($iId); if (is_array($aSetting) && isset($aSetting['setting_id'])) { $bEdit = true; $this->url()->send('admincp.setting'); $this->template()->assign(array('aForms' => $aSetting)); } } $aValidation = array('var_name' => array('def' => 'required', 'title' => Phpfox::getPhrase('admincp.add_variable_name')), 'title' => array('def' => 'required', 'title' => Phpfox::getPhrase('admincp.add_title_for_setting')), 'info' => array('def' => 'required', 'title' => Phpfox::getPhrase('admincp.add_information_regarding_setting'))); $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_setting_form', 'aParams' => $aValidation)); if ($aVals = $this->request()->getArray('val')) { if ($oValid->isValid($aVals)) { if ($bEdit) { exit('Updating...'); } else { if ($sSetting = Phpfox::getService('admincp.setting')->isSetting($aVals['var_name'])) { Phpfox_Error::set(Phpfox::getPhrase('admincp.already_in_use') . ': ' . $sSetting); } else { if ($sSetting = Phpfox::getService('admincp.setting.process')->add($aVals)) { $this->url()->send('admincp', array('setting', 'add'), Phpfox::getPhrase('admincp.added') . ': ' . $sSetting); } } } } } $aGroups = Phpfox::getService('admincp.setting.group')->getGroups(); foreach ($aGroups as $iKey => $aGroup) { if (!isset($aGroup['var_name'])) { unset($aGroups[$iKey]); continue; } } $this->template()->assign(array('aProducts' => Admincp_Service_Product_Product::instance()->get(), 'aGroups' => $aGroups, 'aModules' => Phpfox_Module::instance()->getModules(), 'sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'bEdit' => $bEdit))->setBreadCrumb(Phpfox::getPhrase('admincp.add_setting'))->setTitle(Phpfox::getPhrase('admincp.add_setting')); ($sPlugin = Phpfox_Plugin::get('admincp.component_controller_setting_add_process')) ? eval($sPlugin) : false; }
/** * Controller */ public function process() { $iId = $this->request()->getInt('id'); $aTheme = Theme_Service_Theme::instance()->getTheme($iId); if (Phpfox::getParam('core.enabled_edit_area')) { $this->template()->setHeader(array('editarea/edit_area_full.js' => 'static_script', '<script type="text/javascript"> editAreaLoader.init({ id: "js_template_content" ,start_highlight: true ,allow_resize: "both" ,allow_toggle: false ,word_wrap: false ,language: "en" ,syntax: "html" ,plugins: "phpfox" }); </script>')); } $this->template()->setTitle(Phpfox::getPhrase('theme.themes'))->setTitle(Phpfox::getPhrase('theme.templates'))->setTitle($aTheme['name'])->setBreadcrumb(Phpfox::getPhrase('theme.themes'), $this->url()->makeUrl('admincp.theme'))->setBreadcrumb($aTheme['name'], $this->url()->makeUrl('admincp.theme'))->setBreadcrumb(Phpfox::getPhrase('theme.templates'), null, true)->setHeader('cache', array('template.js' => 'module_theme', 'template.css' => 'style_css', 'jquery/plugin/jquery.scrollTo.js' => 'static_script', 'jquery/plugin/jquery.highlightFade.js' => 'static_script'))->assign(array('aTemplates' => Phpfox::getService('theme.template')->get($aTheme['folder']), 'aTheme' => $aTheme, 'aProducts' => Admincp_Service_Product_Product::instance()->get())); }
public function process() { $Apps = new Core\App(); if ($token = $this->request()->get('m9token')) { $response = (new Core\Home(PHPFOX_LICENSE_ID, PHPFOX_LICENSE_KEY))->token(['token' => $token]); if ($response->token) { $file = PHPFOX_DIR_SETTINGS . 'license.sett.php'; $content = file_get_contents($file); $content = preg_replace('!define\\(\'PHPFOX_LICENSE_ID\', \'(.*?)\'\\);!s', 'define(\'PHPFOX_LICENSE_ID\', \'techie_' . $this->request()->get('m9id') . '\');', $content); $content = preg_replace('!define\\(\'PHPFOX_LICENSE_KEY\', \'(.*?)\'\\);!s', 'define(\'PHPFOX_LICENSE_KEY\', \'techie_' . $this->request()->get('m9key') . '\');', $content); file_put_contents($file, $content); $this->template()->assign('vendorCreated', true); } } if (defined('PHPFOX_IS_TECHIE') && PHPFOX_IS_TECHIE) { $this->template()->setActionMenu(['New App' => ['url' => $this->url()->makeUrl('admincp/app/add'), 'class' => 'popup']]); } $this->template()->setSectionTitle('Apps'); $this->template()->assign(['apps' => $Apps->all('__remove_core'), 'aNewProducts' => Admincp_Service_Product_Product::instance()->getNewProductsForInstall()]); }
/** * Controller */ public function process() { $this->_setMenuName('admincp.theme'); $aStyle = Theme_Service_Style_Style::instance()->getStyle($this->request()->getInt('id')); if (!isset($aStyle['theme_id'])) { return Phpfox_Error::display(Phpfox::getPhrase('theme.not_a_valid_style')); } if (Phpfox::getParam('core.enabled_edit_area')) { $this->template()->setHeader(array('editarea/edit_area_full.js' => 'static_script', '<script type="text/javascript"> editAreaLoader.init({ id: "js_template_content" ,start_highlight: true ,allow_resize: "both" ,allow_toggle: false ,word_wrap: false ,language: "en" ,syntax: "css" ,plugins: "phpfox" }); </script>')); } $this->template()->setTitle(Phpfox::getPhrase('theme.edit_css'))->setBreadcrumb(Phpfox::getPhrase('theme.themes'), $this->url()->makeUrl('admincp.theme'))->setBreadcrumb($aStyle['theme_name'], $this->url()->makeUrl('admincp.theme'))->setBreadcrumb(Phpfox::getPhrase('theme.styles'), $this->url()->makeUrl('admincp.theme.style', array('id' => $aStyle['theme_id'])))->setBreadcrumb($aStyle['name'], $this->url()->makeUrl('admincp.theme.style', array('id' => $aStyle['theme_id'])))->setBreadcrumb(Phpfox::getPhrase('theme.edit_css'), null, true)->setHeader(array('template.css' => 'style_css', 'style.js' => 'module_theme'))->assign(array('aFiles' => Theme_Service_Style_Style::instance()->getFiles($aStyle['theme_folder'], $aStyle['folder'], $aStyle['style_id']), 'aStyle' => $aStyle, 'aProducts' => Admincp_Service_Product_Product::instance()->get(), 'aCustomDataContent' => defined('PHPFOX_IS_HOSTED_SCRIPT') ? Theme_Service_Style_Style::instance()->getStyleContent($aStyle['style_id']) : '')); }
public function import($aVals, $bMissingOnly = false) { $iProductId = Admincp_Service_Product_Product::instance()->getId($aVals['product']); $aCache = array(); if ($bMissingOnly) { $aRows = $this->database()->select('m_connection, component')->from($this->_sTable)->execute('getRows', array('free_result' => true)); foreach ($aRows as $aRow) { $aCache[md5($aRow['m_connection'] . $aRow['component'])] = $aRow['component']; } } $aSql = array(); $aVals = isset($aVals['block'][0]) ? $aVals['block'] : array($aVals['block']); foreach ($aVals as $aVal) { if ($bMissingOnly && isset($aCache[md5($aVal['m_connection'] . $aVal['component'])])) { continue; } $iModuleId = Phpfox_Module::instance()->getModuleId($aVal['module']); $aSql[] = array($aVal['type_id'], $aVal['m_connection'], $iModuleId, $iProductId, $aVal['component'], $aVal['location'], 1, $aVal['ordering']); } if ($aSql) { $this->database()->multiInsert($this->_sTable, array('type_id', 'm_connection', 'module_id', 'product_id', 'component', 'location', 'is_active', 'ordering'), $aSql); } return true; }
public function import($aVals, $bMissingOnly = false) { $iProductId = Admincp_Service_Product_Product::instance()->getId($aVals['product']); $aCache = array(); if ($bMissingOnly) { $aRows = $this->database()->select('var_name')->from($this->_sTable)->execute('getRows', array('free_result' => true)); foreach ($aRows as $aRow) { $aCache[$aRow['var_name']] = $aRow['var_name']; } } $aSql = array(); $aVals = isset($aVals['menu'][0]) ? $aVals['menu'] : array($aVals['menu']); foreach ($aVals as $aVal) { if ($bMissingOnly && in_array($aVal['var_name'], $aCache)) { continue; } $iModuleId = Phpfox_Module::instance()->getModuleId($aVal['module']); $aSql[] = array($aVal['parent_id'], $aVal['m_connection'], $iModuleId, $iProductId, $aVal['var_name'], 1, $aVal['ordering'], $aVal['url_value'], empty($aVal['disallow_access']) ? null : $aVal['disallow_access'], $aVal['version_id']); } if ($aSql) { $this->database()->multiInsert($this->_sTable, array('parent_id', 'm_connection', 'module_id', 'product_id', 'var_name', 'is_active', 'ordering', 'url_value', 'disallow_access', 'version_id'), $aSql); } return true; }
/** * Controller */ public function process() { $this->template()->assign(array('aProducts' => Admincp_Service_Product_Product::instance()->get(), 'bUseClass' => $this->getParam('class'), 'bProductIsRequired' => $this->getParam('product_form_required', true))); }
/** * Build and cache all the plug-ins for future use. * */ public static function set() { $aPlugins = array(); $oCache = Phpfox::getLib('cache'); $iCacheId = $oCache->set(array('plugin', 'plugin')); if (Phpfox::getParam('core.cache_plugins') && !(self::$_aPlugins = $oCache->get($iCacheId)) || !Phpfox::getParam('core.cache_plugins')) { $oDb = Phpfox_Database::instance(); $aRows = $oDb->select('p.call_name, p.php_code')->from(Phpfox::getT('plugin'), 'p')->join(Phpfox::getT('product'), 'product', 'p.product_id = product.product_id AND product.is_active = 1')->join(Phpfox::getT('plugin_hook'), 'ph', 'ph.call_name = p.call_name AND ph.is_active = 1')->join(Phpfox::getT('module'), 'm', 'm.module_id = p.module_id AND m.is_active = 1')->where('p.is_active = 1')->order('p.ordering ASC')->execute('getRows'); $oDb->freeResult(); foreach ($aRows as $aRow) { $aRow['call_name'] = strtolower($aRow['call_name']); if (isset($aPlugins[$aRow['call_name']])) { $aPlugins[$aRow['call_name']] .= self::_cleanPhp($aRow['php_code']) . " "; } else { $aPlugins[$aRow['call_name']] = self::_cleanPhp($aRow['php_code']) . " "; } } foreach ((new Core\App())->all() as $app) { $dir = $app->path . 'hooks/'; if (is_dir($dir)) { foreach (scandir($dir) as $file) { if (substr($file, -4) == '.php') { $code = self::_cleanPhp(file_get_contents($dir . $file)); $name = substr_replace($file, '', -4); if (isset($aPlugins[$name])) { $aPlugins[$name] .= $code . " "; } else { $aPlugins[$name] = $code . " "; } } } } } $aModules = Phpfox_Module::instance()->getModules(); foreach ($aModules as $sModule => $iModuleId) { if (is_dir(PHPFOX_DIR_MODULE . $sModule . PHPFOX_DS . PHPFOX_DIR_MODULE_PLUGIN . PHPFOX_DS)) { if (!Phpfox::isModule($sModule)) { continue; } $rHooks = opendir(PHPFOX_DIR_MODULE . $sModule . PHPFOX_DS . PHPFOX_DIR_MODULE_PLUGIN . PHPFOX_DS); while (($sHook = readdir($rHooks)) !== false) { if (substr($sHook, -4) != '.php') { continue; } $sHookContent = self::_cleanPhp(file_get_contents(PHPFOX_DIR_MODULE . $sModule . PHPFOX_DS . PHPFOX_DIR_MODULE_PLUGIN . PHPFOX_DS . $sHook)); $sHookVarName = substr_replace($sHook, '', -4); if (isset($aPlugins[$sHookVarName])) { $aPlugins[$sHookVarName] .= $sHookContent . " "; } else { $aPlugins[$sHookVarName] = $sHookContent . " "; } } closedir($rHooks); } } $hPlugin = opendir(PHPFOX_DIR_PLUGIN); while ($sProduct = readdir($hPlugin)) { if ($sProduct == '.' || $sProduct == '..') { continue; } if (is_dir(PHPFOX_DIR_PLUGIN . $sProduct)) { if (!Admincp_Service_Product_Product::instance()->isProduct($sProduct)) { continue; } $hProduct = opendir(PHPFOX_DIR_PLUGIN . $sProduct); while ($sHook = readdir($hProduct)) { if (substr($sHook, -4) != '.php') { continue; } $sHookContent = self::_cleanPhp(file_get_contents(PHPFOX_DIR_PLUGIN . $sProduct . PHPFOX_DS . $sHook)); $sHookVarName = substr_replace($sHook, '', -4); if (isset($aPlugins[$sHookVarName])) { $aPlugins[$sHookVarName] .= $sHookContent . " "; } else { $aPlugins[$sHookVarName] = $sHookContent . " "; } } closedir($hProduct); } } foreach (array_keys($aPlugins) as $sKey) { self::$_aPlugins[$sKey] = $sKey; $iPluginCacheId = $oCache->set(array('plugin', 'plugin_data_' . $sKey)); if (Phpfox::getParam('core.cache_plugins') && !$oCache->get($iPluginCacheId) || !Phpfox::getParam('core.cache_plugins')) { $oCache->save($iPluginCacheId, $aPlugins[$sKey]); } $oCache->close($iPluginCacheId); } $oCache->save($iCacheId, self::$_aPlugins); } }
public function export($sProductId, $sModuleId = null) { $oXmlBuilder = Phpfox::getLib('xml.builder'); $iTotal = 0; $aWhere = array(); $aCache = array(); $aWhere[] = "p.product_id = '" . $sProductId . "'"; if ($sModuleId !== null) { $aWhere[] = " AND p.module_id = '" . $sModuleId . "'"; } $aRows = $this->database()->select('p.*')->from(Phpfox::getT('plugin'), 'p')->leftJoin(Phpfox::getT('product'), 'product', 'product.product_id = p.product_id')->leftJoin(Phpfox::getT('module'), 'm', "m.module_id = p.module_id")->where($aWhere)->execute('getRows'); foreach ($aRows as $aRow) { $iTotal++; } $hDir = opendir(PHPFOX_DIR_PLUGIN); while ($sDir = readdir($hDir)) { if ($sProductId != $sDir) { continue; } if (!Admincp_Service_Product_Product::instance()->isProduct($sDir)) { continue; } $hPluginDir = opendir(PHPFOX_DIR_PLUGIN . $sDir); while ($sPlugin = readdir($hPluginDir)) { if (substr($sPlugin, -4) != '.php') { continue; } $aParts = explode('.', $sPlugin); if (!isset($aParts[1])) { continue; } if ($sModuleId !== null && $sModuleId != $aParts[0]) { continue; } if (!Phpfox::isModule($aParts[0])) { continue; } if ($sModuleId !== null && $sModuleId != $aParts[0]) { continue; } $iTotal++; } closedir($hPluginDir); } closedir($hDir); if (!$iTotal) { return false; } $oXmlBuilder->addGroup('plugins'); foreach ($aRows as $aRow) { $oXmlBuilder->addTag('plugin', $aRow['php_code'], array('module_id' => $aRow['module_id'], 'product_id' => $sProductId, 'call_name' => $aRow['call_name'], 'title' => $aRow['title'])); } $hDir = opendir(PHPFOX_DIR_PLUGIN); while ($sDir = readdir($hDir)) { if ($sProductId != $sDir) { continue; } if (!Admincp_Service_Product_Product::instance()->isProduct($sDir)) { continue; } $hPluginDir = opendir(PHPFOX_DIR_PLUGIN . $sDir); while ($sPlugin = readdir($hPluginDir)) { if (substr($sPlugin, -4) != '.php') { continue; } $aParts = explode('.', $sPlugin); if (!isset($aParts[1])) { continue; } if ($sModuleId !== null && $sModuleId != $aParts[0]) { continue; } if (!Phpfox::isModule($aParts[0])) { continue; } if ($sModuleId !== null && $sModuleId != $aParts[0]) { continue; } $iTotal++; $sCode = file_get_contents(PHPFOX_DIR_PLUGIN . $sDir . PHPFOX_DS . $sPlugin); $sCallName = substr_replace($sPlugin, '', -4); $oXmlBuilder->addTag('plugin', $sCode, array('module_id' => $aParts[0], 'product_id' => $sProductId, 'call_name' => $sCallName, 'title' => $sCallName)); } closedir($hPluginDir); } closedir($hDir); $oXmlBuilder->closeGroup(); return true; }
public function import($aVals, $bMissingOnly = false) { $oSetting = Phpfox::getLib('setting'); if (!isset($aVals['product'])) { return Phpfox_Error::set(Phpfox::getPhrase('admincp.unable_import_settings')); } if (!isset($aVals['setting'])) { return Phpfox_Error::set(Phpfox::getPhrase('admincp.unable_import_settings')); } $iProductId = Admincp_Service_Product_Product::instance()->getId($aVals['product']); if (!$iProductId) { $iProductId = 1; } /* $aRows = $this->database()->select('group_id, var_name') ->from(Phpfox::getT('setting_group')) ->execute('getRows', array( 'free_result' => true )); $aGroups = array(); foreach ($aRows as $aRow) { $aGroups[$aRow['var_name']] = $aRow['group_id']; } */ if ($bMissingOnly) { $aCache = array(); $aRows = $this->database()->select('var_name')->from($this->_sTable)->execute('getRows', array('free_result' => true)); foreach ($aRows as $aRow) { $aCache[$aRow['var_name']] = $aRow['var_name']; } $aSql = array(); foreach ($aVals['setting'] as $aSetting) { if (!in_array($aSetting['var_name'], $aCache)) { $iModuleId = Phpfox_Module::instance()->getModuleId($aSetting['module']); $aSql[] = array(empty($aSetting['group']) ? null : $aSetting['group'], $iModuleId, $iProductId, $aValue['is_hidden'], $aSetting['version_id'], $aSetting['type'], $aSetting['var_name'], $aSetting['phrase_var_name'], $aSetting['value'], $aSetting['value'], $aSetting['ordering']); } } if ($aSql) { $this->database()->multiInsert($this->_sTable, array('group_id', 'module_id', 'product_id', 'is_hidden', 'version_id', 'type', 'var_name', 'phrase_var_name', 'value_actual', 'value_default', 'ordering'), $aSql); } } else { $aSql = array(); foreach ($aVals['setting'] as $aValue) { $iModuleId = (int) Phpfox_Module::instance()->getModuleId($aValue['module']); $aSql[] = array(empty($aSetting['group']) ? null : $aSetting['group'], $iModuleId, $iProductId, $aValue['is_hidden'], $aValue['version_id'], $aValue['type'], $aValue['var_name'], $aValue['phrase_var_name'], $aValue['value'], $aValue['value'], $aValue['ordering']); } $this->database()->multiInsert($this->_sTable, array('group_id', 'module_id', 'product_id', 'is_hidden', 'version_id', 'type', 'var_name', 'phrase_var_name', 'value_actual', 'value_default', 'ordering'), $aSql); } return count($aSql); }
public function import($aVals, $bMissingOnly = false) { $iProductId = Admincp_Service_Product_Product::instance()->getId($aVals['product']); if (!$iProductId) { $iProductId = 1; } if ($bMissingOnly) { $aCache = array(); $aRows = $this->database()->select('name')->from($this->_sTable)->execute('getRows', array('free_result' => true)); foreach ($aRows as $aRow) { $aCache[] = $aRow['name']; } $aSql = array(); foreach ($aVals['setting'] as $aVal) { if (!in_array($aVal['value'], $aCache)) { $iModuleId = Phpfox_Module::instance()->getModuleId($aVal['module']); $aSql[] = array($iModuleId, $iProductId, $aVal['value'], $aVal['type'], $aVal['admin'], $aVal['user'], $aVal['guest'], $aVal['staff'], $aVal['ordering']); } } if ($aSql) { $this->database()->multiInsert($this->_sTable, array('module_id', 'product_id', 'name', 'type', 'default_admin', 'default_user', 'default_guest', 'default_staff', 'ordering'), $aSql); $this->cache()->remove('user_group_setting', 'substr'); } } else { $aSql = array(); foreach ($aVals['setting'] as $aVal) { $iModuleId = (int) Phpfox_Module::instance()->getModuleId($aVal['module']); $aSql[] = array($iModuleId, $iProductId, $aVal['value'], $aVal['type'], $aVal['admin'], $aVal['user'], $aVal['guest'], $aVal['staff'], $aVal['ordering']); } $this->database()->multiInsert($this->_sTable, array('module_id', 'product_id', 'name', 'type', 'default_admin', 'default_user', 'default_guest', 'default_staff', 'ordering'), $aSql); } return true; }
/** * Controller */ public function process() { Phpfox::isUser(true); Phpfox::getUserParam('admincp.has_admin_access', true); if (Phpfox::getParam('core.admincp_http_auth')) { $aAuthUsers = Phpfox::getParam('core.admincp_http_auth_users'); if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']) && isset($aAuthUsers[Phpfox::getUserId()]) && ($_SERVER['PHP_AUTH_USER'] == $aAuthUsers[Phpfox::getUserId()]['name'] && $_SERVER['PHP_AUTH_PW'] == $aAuthUsers[Phpfox::getUserId()]['password'])) { } else { header("WWW-Authenticate: Basic realm=\"AdminCP\""); header("HTTP/1.0 401 Unauthorized"); exit("NO DICE!"); } } if (Phpfox::getParam('admincp.admin_cp') != $this->request()->get('req1')) { return Phpfox_Module::instance()->setController('error.404'); } if (!Phpfox::getService('user.auth')->isActiveAdminSession()) { return Phpfox_Module::instance()->setController('admincp.login'); } if ($this->request()->get('upgraded')) { Phpfox::getLib('cache')->remove(); Phpfox::getLib('template.cache')->remove(); $this->url()->send('admincp'); } $this->_sModule = ($sReq2 = $this->request()->get('req2')) ? strtolower($sReq2) : Phpfox::getParam('admincp.admin_cp'); if ($this->_sModule == 'logout') { $this->_sController = $this->_sModule; $this->_sModule = 'admincp'; } else { $this->_sController = ($sReq3 = $this->request()->get('req3')) ? $sReq3 : $this->_sController; } if ($sReq4 = $this->request()->get('req4')) { $sReq4 = str_replace(' ', '', strtolower(str_replace('-', ' ', $sReq4))); } $sReq5 = $this->request()->get('req5'); $bPass = false; if (file_exists(PHPFOX_DIR_MODULE . $this->_sModule . PHPFOX_DS . PHPFOX_DIR_MODULE_COMPONENT . PHPFOX_DS . 'controller' . PHPFOX_DS . 'admincp' . PHPFOX_DS . $this->_sController . '.class.php')) { $this->_sController = 'admincp.' . $this->_sController; $bPass = true; } if (!$bPass && $sReq5 && file_exists(PHPFOX_DIR_MODULE . $this->_sModule . PHPFOX_DS . PHPFOX_DIR_MODULE_COMPONENT . PHPFOX_DS . 'controller' . PHPFOX_DS . 'admincp' . PHPFOX_DS . $this->_sController . PHPFOX_DS . $sReq4 . PHPFOX_DS . $sReq5 . '.class.php')) { $this->_sController = 'admincp.' . $this->_sController . '.' . $sReq4 . '.' . $sReq5; $bPass = true; } if (!$bPass && $sReq4 && file_exists(PHPFOX_DIR_MODULE . $this->_sModule . PHPFOX_DS . PHPFOX_DIR_MODULE_COMPONENT . PHPFOX_DS . 'controller' . PHPFOX_DS . 'admincp' . PHPFOX_DS . $this->_sController . PHPFOX_DS . $sReq4 . '.class.php')) { $this->_sController = 'admincp.' . $this->_sController . '.' . $sReq4; $bPass = true; } if (!$bPass && file_exists(PHPFOX_DIR_MODULE . $this->_sModule . PHPFOX_DS . PHPFOX_DIR_MODULE_COMPONENT . PHPFOX_DS . 'controller' . PHPFOX_DS . 'admincp' . PHPFOX_DS . $this->_sController . PHPFOX_DS . $this->_sController . '.class.php')) { $this->_sController = 'admincp.' . $this->_sController . '.' . $this->_sController; $bPass = true; } if (!$bPass && $sReq4 && file_exists(PHPFOX_DIR_MODULE . $this->_sModule . PHPFOX_DS . PHPFOX_DIR_MODULE_COMPONENT . PHPFOX_DS . 'controller' . PHPFOX_DS . 'admincp' . PHPFOX_DS . $this->_sController . PHPFOX_DS . $sReq4 . '.class.php')) { $this->_sController = 'admincp.' . $this->_sController . '.' . $sReq4; $bPass = true; } if (!$bPass && $sReq4 && file_exists(PHPFOX_DIR_MODULE . $this->_sModule . PHPFOX_DS . PHPFOX_DIR_MODULE_COMPONENT . PHPFOX_DS . 'controller' . PHPFOX_DS . 'admincp' . PHPFOX_DS . $this->_sController . PHPFOX_DS . $sReq4 . PHPFOX_DS . 'index.class.php')) { $this->_sController = 'admincp.' . $this->_sController . '.' . $sReq4 . '.index'; $bPass = true; } if (!$bPass && file_exists(PHPFOX_DIR_MODULE . $this->_sModule . PHPFOX_DS . PHPFOX_DIR_MODULE_COMPONENT . PHPFOX_DS . 'controller' . PHPFOX_DS . 'admincp' . PHPFOX_DS . $this->_sController . PHPFOX_DS . 'index.class.php')) { $this->_sController = 'admincp.' . $this->_sController . '.index'; $bPass = true; } if (!$bPass && file_exists(PHPFOX_DIR_MODULE . 'admincp' . PHPFOX_DS . PHPFOX_DIR_MODULE_COMPONENT . PHPFOX_DS . 'controller' . PHPFOX_DS . $this->_sModule . PHPFOX_DS . $this->_sController . '.class.php')) { $this->_sController = $this->_sModule . '.' . $this->_sController; $this->_sModule = 'admincp'; $bPass = true; } if (!$bPass && $sReq4 && file_exists(PHPFOX_DIR_MODULE . 'admincp' . PHPFOX_DS . PHPFOX_DIR_MODULE_COMPONENT . PHPFOX_DS . 'controller' . PHPFOX_DS . $this->_sModule . PHPFOX_DS . $this->_sController . PHPFOX_DS . $sReq4 . '.class.php')) { $this->_sController = $this->_sModule . '.' . $this->_sController . '.' . $sReq4; $this->_sModule = 'admincp'; $bPass = true; } if (!$bPass && Phpfox::getParam('admincp.admin_cp') != 'admincp' && file_exists(PHPFOX_DIR_MODULE . $this->_sModule . PHPFOX_DS . PHPFOX_DIR_MODULE_COMPONENT . PHPFOX_DS . 'controller' . PHPFOX_DS . $this->_sController . '.class.php')) { $bPass = true; } $bForceIndex = false; if (!$bPass && Phpfox::isModule($this->request()->segment('req2'))) { $this->_sModule = 'admincp'; $this->_sController = 'app.index'; $bForceIndex = true; $bPass = true; } // Get the menu we will used to display all the "Modules" // $aModules = Phpfox::getService('admincp.module')->getAdminMenu(); // Create AdminCP menu $aMenus = array('admincp.users' => array('admincp.browse_members' => 'admincp.user.browse', 'admincp.user_group_manager' => array('admincp.manage_user_groups' => 'admincp.user.group', 'admincp.create_user_group' => 'admincp.user.group.add', 'admincp.add_user_group_setting' => 'admincp.user.group.setting'), 'admincp.user_cancellation_options' => array('admincp.user_cancellation_options_add' => 'admincp.user.cancellations.add', 'admincp.user_cancellation_options_manage' => 'admincp.user.cancellations.manage', 'admincp.user_cancellations_feedback' => 'admincp.user.cancellations.feedback'), 'user.promotions' => array('user.manage_promotions' => 'admincp.user.promotion', 'user.add_promotion' => 'admincp.user.promotion.add'), 'admincp.inactive_members' => 'admincp.user.inactivereminder')); $aMenus = ['<i class="fa fa-dashboard"></i>Dashboard' => 'admincp', '<i class="fa fa-cubes"></i>Apps' => 'admincp.apps', '<i class="fa fa-paint-brush"></i>Themes' => 'admincp.theme', 'Members', '<i class="fa fa-search"></i>Search' => 'admincp.user.browse', '<i class="fa fa-users"></i>User Groups' => 'admincp.user.group', '<i class="fa fa-diamond"></i>Promotions' => 'admincp.user.promotion', '<i class="fa fa-th-list"></i>Custom Fields' => 'admincp.custom', 'Site', '<i class="fa fa-file-text-o"></i>Pages' => 'admincp.page', '<i class="fa fa-bars"></i>Menus' => 'admincp.menu', '<i class="fa fa-th"></i>Blocks' => 'admincp.block', '<i class="fa fa-language"></i>Phrases' => 'admincp.language.phrase', 'Tools', 'Settings' => ['Countries' => 'admincp.core.country', 'Currencies' => 'admincp.core.currency', 'Attachments' => 'admincp.attachment', 'Payment Gateways' => 'admincp.api.gateway', 'Language' => 'admincp.language', 'Short URLs' => 'admincp.setting.url', 'User', 'Settings' => $this->url()->makeUrl('admincp.setting.edit', ['module-id' => 'user']), 'Registration' => $this->url()->makeUrl('admincp.setting.edit', ['group-id' => 'registration']), 'Relationship Statues' => 'admincp.custom.relationships', 'Cancellation Options' => 'admincp.user.cancellations.manage', 'Subscription Packages' => 'admincp.subscribe', 'E-Gifts' => 'admincp.egift.categories', 'Anti-SPAM Questions' => 'admincp.user.spam'], '<i class="fa fa-th-large"></i>Modules' => 'admincp.product', '<i class="fa fa-bullhorn"></i>Announcements' => 'admincp.announcement', '<i class="fa fa-newspaper-o"></i>Newsletter' => 'admincp.newsletter.manage', '<i class="fa fa-info"></i>Status' => array(Phpfox::getPhrase('core.site_statistics') => 'admincp.core.stat', Phpfox::getPhrase('core.admincp_menu_system_overview') => 'admincp.core.system', Phpfox::getPhrase('admincp.inactive_members') => 'admincp.user.inactivereminder'), '<i class="fa fa-server"></i>Maintenance' => array(Phpfox::getPhrase('admincp.menu_cache_manager') => 'admincp.maintain.cache', Phpfox::getPhrase('admincp.admincp_menu_reparser') => 'admincp.maintain.reparser', Phpfox::getPhrase('admincp.remove_duplicates') => 'admincp.maintain.duplicate', Phpfox::getPhrase('admincp.counters') => 'admincp.maintain.counter', Phpfox::getPhrase('admincp.check_modified_files') => 'admincp.checksum.modified', Phpfox::getPhrase('admincp.check_unknown_files') => 'admincp.checksum.unknown', Phpfox::getPhrase('admincp.find_missing_settings') => 'admincp.setting.missing', 'Toggle Modules' => $this->url()->makeUrl('admincp.module', ['view' => 'all'])), '<i class="fa fa-ban"></i>Ban Filters' => array(Phpfox::getPhrase('ban.ban_filter_username') => 'admincp.ban.username', Phpfox::getPhrase('ban.ban_filter_email') => 'admincp.ban.email', Phpfox::getPhrase('ban.ban_filter_display_name') => 'admincp.ban.display', Phpfox::getPhrase('ban.ban_filter_ip') => 'admincp.ban.ip', Phpfox::getPhrase('ban.ban_filter_word') => 'admincp.ban.word')]; /* $aThemes = []; foreach (Theme_Service_Theme::instance()->get() as $aTheme) { $aThemes[$aTheme['name']] = $this->url()->makeUrl('admincp.theme.manage', ['id' => $aTheme['theme_id']]); } */ // d($aThemes); exit; list($aGroups, $aModules, $aProductGroups) = Phpfox::getService('admincp.setting.group')->get(); $aCache = $aGroups; $aGroups = []; // $aGroups[] = 'Site & Server'; foreach ($aCache as $key => $value) { $n = $key; switch ($value['group_id']) { case 'cookie': $n = 'Browser Cookies'; break; case 'site_offline_online': $n = 'Toggle Site'; break; case 'general': $n = 'Site Settings'; break; case 'mail': $n = 'Mail Server'; break; case 'spam': $n = 'Spam Assistance'; break; case 'registration': continue 2; break; } // unset($aGroups[$key]); $aGroups[$n] = $value; } ksort($aGroups); // d($aGroups); exit; $aApps = []; /* $aProducts = Admincp_Service_Product_Product::instance()->getNewProductsForInstall(); if (count($aProducts)) { foreach ($aProducts as $aProduct) { $aApps[$aProduct['title']] = [ 'highlight' => true, 'message' => 'Install', 'url' => $this->url()->makeUrl('admincp.product.install', ['id' => $aProduct['product_id']]) ]; } } */ /* $aSkip = ['apps', 'user', 'track', 'tinymce', 'theme', 'tag', 'subscribe', 'share', 'search', 'rss', 'request', 'report', 'rate', 'profile', 'privacy', 'page', 'notification', 'mobile', 'log', 'link', 'like', 'language', 'input', 'admincp', 'api', 'apps', 'attachment', 'ban', 'comment', 'contact', 'core', 'custom', 'emoticon', 'error', 'favorite', 'help', 'im']; foreach (Phpfox_Module::instance()->getModules() as $sModule) { if (in_array($sModule, $aSkip)) { continue; } // $aApps[$sModule] = $this->url()->makeUrl('admincp.app', ['id' => $sModule]); $aApps[$sModule] = $this->url()->makeUrl('admincp.' . $sModule); } */ $aSettings = []; foreach ($aGroups as $sGroupName => $aGroupValues) { $aSettings[$sGroupName] = $this->url()->makeUrl('admincp.setting.edit', ['group-id' => $aGroupValues['group_id']]); // $aMenus['Settings'][$sGroupName] = '#'; } // d($aSettings); exit; $aCache = $aMenus; $aMenus = []; foreach ($aCache as $sKey => $mValue) { /* if ($mValue == '#modules') { $aMenus[$sKey] = $aApps; continue; } else if ($mValue == '#themes') { $aMenus[$sKey] = $aThemes; continue; } */ /* if (is_string($mValue) && $mValue === 'Tools') { // d($mValue); $aMenus[$sKey] = 'Modules'; foreach ((new Core\App())->all('__core') as $Core) { $icon = ''; $name = $Core->name; $id = str_replace('__module_', '', $Core->id); switch ($id) { case 'ad': $icon = 'money'; break; case 'blog': $icon = 'file'; break; } if (!empty($icon)) { $icon = '<i class="fa fa-' . $icon . '"></i>'; } $aMenus[$icon . $Core->name] = $this->url()->makeUrl('admincp.app', ['id' => $Core->id]); } $sKey++; } */ if ($sKey === 'Settings') { $sKey = '<i class="fa fa-cog"></i>Settings'; /* $aMerge = []; foreach ($mValue as $sSubKey => $sSubValue) { if (strpos($sSubValue, '.')) { $aMerge[Phpfox::getPhrase($sSubKey)] = $sSubValue; } else { $aMerge[] = $sSubValue; } } $mValue = array_merge($aSettings, $aMerge); */ $moduleSettings = []; foreach ((new Core\App())->all('__core') as $Core) { $name = $Core->name; $id = str_replace('__module_', '', $Core->id); $url = $this->url()->makeUrl('admincp.app', ['id' => $Core->id]); $goSettings = false; $goIndex = false; switch ($id) { case 'ad': $name = 'Ad Campaigns'; break; case 'blog': $name = 'Blog Categories & Settings'; break; case 'contact': $name = '"Contact Us" Form'; break; /* case 'user': $goSettings = true; $name = 'User'; break; */ /* case 'user': $goSettings = true; $name = 'User'; break; */ case 'feed': $goSettings = true; $this->template()->setSectionTitle('Activity Feed'); break; case 'forum': $name = 'Forums'; $goIndex = true; break; case 'mail': $name = 'Private Messages'; break; case 'event': case 'photo': case 'marketplace': case 'music': case 'pages': $goIndex = true; break; } if ($goSettings) { $url = $this->url()->makeUrl('admincp.setting.edit', ['module-id' => $id]); } else { if ($goIndex) { $url = $this->url()->makeUrl('admincp.' . $id); } } $moduleSettings[$name] = $url; } $mValue = array_merge($aSettings, $mValue, ['Modules'], $moduleSettings); } $aMenus[$sKey] = $mValue; if (is_string($mValue) && $mValue == 'admincp.theme' && PHPFOX_IS_TECHIE) { $aMenus['<i class="fa fa-sheqel"></i>Techie'] = ['Products' => 'admincp.product', 'Modules' => 'admincp.module', 'Plugins' => 'admincp.plugin', 'Components' => 'admincp.component']; } } ($sPlugin = Phpfox_Plugin::get('admincp.component_controller_index_process_menu')) ? eval($sPlugin) : false; $aUser = Phpfox::getUserBy(); // $aUser['full_name'] = substr($aUser['full_name'], 0, Phpfox::getParam('user.maximum_length_for_full_name')); $sSectionTitle = ''; $app = $this->request()->get('req2'); $bForceIndex = true; if ($app == 'app') { $app = str_replace('__module_', '', $this->request()->get('id')); $bForceIndex = false; } $is_settings = false; if ($this->url()->getUrl() == 'admincp/setting/edit') { $app = $this->request()->get('module-id'); $is_settings = true; } $aSkipModules = ['api', 'comment', 'feed', 'apps', 'announcement', 'ban', 'facebook', 'user', 'core', 'custom', 'admincp', 'page', 'language', 'attachment', 'theme']; $searchSettings = Admincp_Service_Setting_Setting::instance()->getForSearch($aSkipModules); $this->template()->setHeader('<script>var admincpSettings = ' . json_encode($searchSettings) . ';</script>'); if ($is_settings && in_array($app, $aSkipModules) && $app != 'user' && $app != 'feed') { $this->url()->send('admincp'); } if ($app && Phpfox::isModule($app) && !in_array($app, $aSkipModules)) { $app = Phpfox_Module::instance()->get($app); $name = Phpfox_Locale::instance()->translate($app['module_id'], 'module'); $sSectionTitle = $name; $menu = unserialize($app['menu']); $menus = []; $current = $this->url()->getUrl(); $infoActive = false; if ($this->request()->get('req2') == 'app') { $infoActive = true; } if (Admincp_Service_Setting_Setting::instance()->moduleHasSettings($app['module_id'])) { $menus['Settings'] = ['is_active' => $is_settings, 'url' => $this->url()->makeUrl('admincp.setting.edit', ['module-id' => $app['module_id']])]; } if (is_array($menu) && count($menu)) { foreach ($menu as $key => $value) { $is_active = false; $url = 'admincp.' . implode('.', $value['url']); if ($current == str_replace('.', '/', $url)) { $is_active = true; if ($infoActive) { $menus['Info']['is_active'] = false; } } $menus[Phpfox::getPhrase($key)] = ['url' => $url, 'is_active' => $is_active]; } } $this->template()->assign(['aSectionAppMenus' => $menus, 'ActiveApp' => (new Core\App())->get('__module_' . $app['module_id'])]); } $this->template()->assign(array('sSectionTitle' => $sSectionTitle, 'aModulesMenu' => $aModules, 'aAdminMenus' => $aMenus, 'aUserDetails' => $aUser, 'sPhpfoxVersion' => PhpFox::getVersion(), 'sSiteTitle' => Phpfox::getParam('core.site_title')))->setHeader(array('menu.css' => 'style_css', 'menu.js' => 'style_script', 'admin.js' => 'static_script', 'jquery/plugin/jquery.mosaicflow.min.js' => 'static_script'))->setTitle(Phpfox::getPhrase('admincp.admin_cp')); if (in_array($app, ['plugin', 'module', 'component'])) { $this->template()->setSectionTitle('Techie: ' . ucwords($app)); $this->template()->setActionMenu(['New ' . ucwords($app) => ['url' => $this->url()->makeUrl('admincp.' . $app . '.add'), 'class' => 'popup']]); } if ($bPass) { Phpfox_Module::instance()->setController($this->_sModule . '.' . $this->_sController); $sMenuController = str_replace(array('.index', '.phrase'), '', 'admincp.' . ($this->_sModule != 'admincp' ? $this->_sModule . '.' . str_replace('admincp.', '', $this->_sController) : $this->_sController)); $aCachedSubMenus = array(); $sActiveSideBar = ''; if ($sMenuController == 'admincp.setting.edit') { $sMenuController = 'admincp.setting'; } if ($this->_getMenuName() !== null) { $sMenuController = $this->_getMenuName(); } /* foreach ($aMenus as $sKey => $aSubMenus) { if (is_array($aSubMenus)) { foreach ($aSubMenus as $sSubkey => $mSubMenus) { if (is_array($mSubMenus)) { foreach ($mSubMenus as $sSubkey2 => $mSubMenus2) { if ($sMenuController == $mSubMenus2) { $sActiveSideBar = $sSubkey; foreach ($aSubMenus as $sSubkey3 => $mSubMenus3) { if (is_array($mSubMenus3)) { $aCachedSubMenus[$sSubkey3] = $mSubMenus3; } else { $aCachedSubMenus[$sKey][$sSubkey3] = $mSubMenus3; } } } } } else { if ($sMenuController == $mSubMenus) { $sActiveSideBar = $sKey; foreach ($aSubMenus as $sSubkey3 => $mSubMenus3) { if (is_array($mSubMenus3)) { $aCachedSubMenus[$sSubkey3] = $mSubMenus3; } else { $aCachedSubMenus[$sKey][$sSubkey3] = $mSubMenus3; } } } } } } } $bIsModuleConnection = false; if (!$aCachedSubMenus) { $bIsModuleConnection = true; $sActiveSideBar = $this->_sModule; foreach ($aModules as $aModule) { if (!isset($aModule['module_id'])) { continue; } if (!$aModule['is_menu']) { continue; } if (!is_array($aModule['menu'])) { continue; } foreach ($aModule['menu'] as $sPhrase => $aLink) { $aCachedSubMenus[$aModule['module_id']][$sPhrase] = 'admincp.' . str_replace('/', '.', $aLink['url']); } } } */ $this->template()->assign(array('aCachedSubMenus' => $aCachedSubMenus, 'sActiveSideBar' => $sActiveSideBar, 'bIsModuleConnection' => false, 'sMenuController' => $sMenuController, 'aActiveMenus' => false && isset($aCachedSubMenus[$sActiveSideBar]) ? $aCachedSubMenus[$sActiveSideBar] : array())); } else { if ($this->_sModule != Phpfox::getParam('admincp.admin_cp')) { Phpfox_Module::instance()->setController('error.404'); } else { Phpfox::getService('admincp')->check(); /* define('PHPFOX_CAN_MOVE_BLOCKS', true); $this->template()->setHeader('cache', array( 'sort.js' => 'module_theme', 'design.js' => 'module_theme', 'jquery/ui.js' => 'static_script', ) ) ->setHeader(array( '<script type="text/javascript">function designOnUpdate() { $Core.design.updateSorting(); }</script>', '<script type="text/javascript">$Core.design.init({type_id: \'admincp\'});</script>' ) ); Phpfox_Module::instance()->setCacheBlockData(array( 'table' => 'admincp_dashboard', 'field' => 'user_id', 'item_id' => Phpfox::getUserId(), 'controller' => 'admincp.index' ) ); */ $this->template()->setBreadcrumb(Phpfox::getPhrase('admincp.dashboard'))->setTitle(Phpfox::getPhrase('admincp.dashboard'))->assign(array('bIsModuleConnection' => false, 'bIsDashboard' => true, 'aNewProducts' => Admincp_Service_Product_Product::instance()->getNewProductsForInstall())); } } }
/** * Controller */ public function process() { if (Phpfox::getParam('core.phpfox_is_hosted')) { $this->url()->send('admincp'); } $oArchiveExport = Phpfox::getLib('archive.export')->set(array('zip')); $oArchiveImport = Phpfox::getLib('archive.import')->set(array('zip')); if ($this->request()->get('req4') == 'process') { $aData = unserialize(base64_decode($this->request()->get('step'))); if ($mReturn = Phpfox::getService('admincp.module.process')->processInstall($this->request()->get('id'), $aData, $this->request()->get('overwrite'))) { if (is_array($mReturn)) { $this->url()->send('admincp', array('product', 'file', 'process', 'overwrite' => $this->request()->get('overwrite'), 'id' => $this->request()->get('id'), 'step' => base64_encode(serialize($mReturn)))); } else { Phpfox_Module::instance()->_cacheModules(); Phpfox_Plugin::set(); if ($sPlugin = Phpfox_Plugin::get('admincp.component_controller_product_file_1')) { eval($sPlugin); if (isset($mReturnFromPlugin)) { return $mReturnFromPlugin; } } if ($this->request()->get('overwrite')) { if ($sPlugin = Phpfox_Plugin::get('admincp.component_controller_product_file_2')) { eval($sPlugin); if (isset($mReturnFromPlugin)) { return $mReturnFromPlugin; } } $this->url()->send('admincp', array('product'), Phpfox::getPhrase('admincp.product_successfully_installed')); } else { if ($sPlugin = Phpfox_Plugin::get('admincp.component_controller_product_file_3')) { eval($sPlugin); if (isset($mReturnFromPlugin)) { return $mReturnFromPlugin; } } $this->url()->send('admincp', array('product'), Phpfox::getPhrase('admincp.product_successfully_installed')); } } } } // Run the export routine if ($sExportId = $this->request()->get('export')) { if ($mData = Admincp_Service_Product_Product::instance()->export($sExportId)) { $oArchiveExport->download('phpfox-product-' . $mData['name'], 'zip', $mData['folder']); } } if ($sProduct = $this->request()->get('install')) { // Import the settings if ($aInstall = Phpfox::getService('admincp.product.process')->import($sProduct, $this->request()->get('overwrite'))) { $this->url()->send('admincp', array('product', 'file', 'process', 'overwrite' => $this->request()->get('overwrite'), 'id' => $aInstall['product_id'], 'step' => base64_encode(serialize($aInstall['files'])))); } } // Run the import routine // if (isset($_FILES['import']) && ($aFile = $_FILES['import'])) /* if ($this->request()->get('import')) { if (preg_match('/^phpfox-product-(.*?)\.zip$/i', $aFile['name'], $aMatches)) { if ($aFiles = $oArchiveImport->process($aFile)) { $sFolderName = $aMatches[1]; if (preg_match('/^(.*)-(.*?)$/i', $aMatches[1])) { $aParts = explode('-', $aMatches[1]); $sFolderName = $aParts[0]; } // Import the settings if (($aInstall = Phpfox::getService('admincp.product.process')->import($sFolderName, $this->request()->get('overwrite')))) { $this->url()->send('admincp', array('product', 'file', 'process', 'overwrite' => $this->request()->get('overwrite'), 'id' => $aInstall['product_id'], 'step' => base64_encode(serialize($aInstall['files'])))); } } } else { Phpfox_Error::set('Not a valid product to import.'); } } */ $aProducts = Admincp_Service_Product_Product::instance()->get(); foreach ($aProducts as $iKey => $aProduct) { if ($aProduct['product_id'] == 'phpfox' || $aProduct['product_id'] == 'phpfox_installer') { unset($aProducts[$iKey]); } } // Assign needed vars to the template $this->template()->setTitle(Phpfox::getPhrase('admincp.import_products'))->setBreadcrumb(Phpfox::getPhrase('admincp.products'), $this->url()->makeUrl('admincp.product'))->setBreadCrumb(Phpfox::getPhrase('admincp.import_products'), null, true)->assign(array('aArchives' => $oArchiveExport->getSupported(), 'sSupported' => $oArchiveImport->getSupported(), 'sFtpEditLink' => $this->url()->makeUrl('admincp.setting.edit', array('group-id' => 'ftp')), 'aNewProducts' => Admincp_Service_Product_Product::instance()->getNewProductsForInstall())); }