Esempio n. 1
0
 function activate($sTemplate)
 {
     $aTemplate = BxDolModuleQuery::getInstance()->getModuleByName($sTemplate);
     if (empty($aTemplate) || !is_array($aTemplate)) {
         return array('code' => 1, 'message' => _t('_adm_err_operation_failed'));
     }
     $aTemplates = array();
     $iTemplates = $this->oDb->getTemplatesBy(array('type' => 'active'), $aTemplates);
     if ($iTemplates == 1 && $aTemplates[0]['name'] == $sTemplate) {
         return array('code' => 1, 'message' => _t('_adm_dsg_err_last_active'));
     }
     $sTemplateDefault = getParam('template');
     if ($aTemplate['uri'] == $sTemplateDefault) {
         return array('code' => 2, 'message' => _t('_adm_dsg_err_deactivate_default'));
     }
     $oInstallerUtils = BxDolStudioInstallerUtils::getInstance();
     $aResult = (int) $aTemplate['enabled'] == 0 ? $oInstallerUtils->perform($aTemplate['path'], 'enable') : $oInstallerUtils->perform($aTemplate['path'], 'disable');
     if ($aResult['code'] != 0) {
         return $aResult;
     }
     $oTemplate = BxDolStudioTemplate::getInstance();
     $aResult = array('code' => 0, 'message' => _t('_adm_scs_operation_done'));
     if ((int) $aTemplate['enabled'] == 0) {
         $aResult['content'] = $oTemplate->parseHtmlByName('page_content_2_col.html', array('page_menu_code' => $this->getPageMenu(), 'page_main_code' => $this->getPageCode()));
     } else {
         $aResult['content'] = "";
     }
     return $aResult;
 }
Esempio n. 2
0
 function processActions()
 {
     if (($sAction = bx_get($this->sParamPrefix . '_action')) !== false) {
         $sAction = bx_process_input($sAction);
         $aResult = array('code' => 1, 'message' => _t('_adm_' . $this->sLangPrefix . '_err_cannot_process_action'));
         switch ($sAction) {
             case 'uninstall':
                 $sPageName = bx_process_input(bx_get($this->sParamPrefix . '_page_name'));
                 if (empty($sPageName)) {
                     break;
                 }
                 bx_import('BxDolModuleQuery');
                 $aModule = BxDolModuleQuery::getInstance()->getModuleByName($sPageName);
                 if (empty($aModule) || !is_array($aModule)) {
                     break;
                 }
                 if (($iWidgetId = (int) bx_get($this->sParamPrefix . '_widget_id')) != 0 && (int) bx_get($this->sParamPrefix . '_confirmed') != 1) {
                     $aResult['message'] = $this->getPopupConfirm($iWidgetId, $aModule);
                     break;
                 }
                 bx_import('BxDolStudioInstallerUtils');
                 $aResult = BxDolStudioInstallerUtils::getInstance()->perform($aModule['path'], 'uninstall');
                 if (!empty($aResult['message'])) {
                     $aResult['message'] = $this->getPopupResult($aResult['message']);
                 }
                 break;
         }
         if (!empty($aResult['message'])) {
             bx_import('BxTemplStudioFunctions');
             $aResult['message'] = BxTemplStudioFunctions::getInstance()->transBox('', $aResult['message']);
         }
         echo json_encode($aResult);
         exit;
     }
 }
Esempio n. 3
0
 /**
  * Check all pending for uninstallation modules and uninstall them if no pending for deletion files are found
  */
 public static function checkModulesPendingUninstall()
 {
     bx_import('BxDolModuleQuery');
     $a = BxDolModuleQuery::getInstance()->getModules();
     foreach ($a as $aModule) {
         // after we make sure that all pending for deletion files are deleted
         if (!$aModule['pending_uninstall'] || BxDolStorage::isQueuedFilesForDeletion($aModule['name'])) {
             continue;
         }
         // remove pending uninstall flag
         self::setModulePendingUninstall($aModule['uri'], false);
         // perform uninstallation
         bx_import('BxDolStudioInstallerUtils');
         $aResult = BxDolStudioInstallerUtils::getInstance()->perform($aModule['path'], 'uninstall');
         // send email nofitication
         $aTemplateKeys = array('Module' => $aModule['title'], 'Result' => _t('_Success'), 'Message' => '');
         if ($aResult['code'] > 0) {
             $aTemplateKeys['Result'] = _t('_Failed');
             $aTemplateKeys['Message'] = $aResult['message'];
         }
         bx_import('BxDolEmailTemplates');
         $aMessage = BxDolEmailTemplates::getInstance()->parseTemplate('t_DelayedModuleUninstall', $aTemplateKeys);
         sendMail(getParam('site_email'), $aMessage['Subject'], $aMessage['Body'], 0, array(), BX_EMAIL_SYSTEM);
     }
 }
Esempio n. 4
0
 /**
  * Static method to get an instance of a module's class.
  *
  * @param $sName module name.
  */
 public static function getInstance($sName)
 {
     if (empty($sName)) {
         return null;
     }
     bx_import('BxDolModuleQuery');
     $aModule = BxDolModuleQuery::getInstance()->getModuleByName($sName);
     if (empty($aModule) || !is_array($aModule)) {
         return null;
     }
     $sClassName = $aModule['class_prefix'] . 'Module';
     if ('system' != $sName) {
         if (isset($GLOBALS['bxDolClasses'][$sClassName])) {
             return $GLOBALS['bxDolClasses'][$sClassName];
         }
         $sClassPath = BX_DIRECTORY_PATH_MODULES . $aModule['path'] . '/classes/' . $sClassName . '.php';
         if (!file_exists($sClassPath)) {
             return null;
         }
         require_once $sClassPath;
         $GLOBALS['bxDolClasses'][$sClassName] = new $sClassName($aModule);
         return $GLOBALS['bxDolClasses'][$sClassName];
     } else {
         $sClassName = 'BxTemplServices';
         return bx_instance($sClassName, array($aModule));
     }
 }
Esempio n. 5
0
 function isEnabled($aWidget)
 {
     $aModule = BxDolModuleQuery::getInstance()->getModuleByName($aWidget['module']);
     if (empty($aModule) || !is_array($aModule)) {
         return true;
     }
     return (int) $aModule['enabled'] == 1;
 }
Esempio n. 6
0
 /**
  * Constructor
  */
 public function __construct($oConfig)
 {
     parent::__construct();
     if (is_a($oConfig, 'BxDolModuleConfig')) {
         $this->_sPrefix = $oConfig->getDbPrefix();
     } else {
         trigger_error('It is impossible to create BxDolModuleDb class instance without prefix: ' . get_class($this), E_USER_ERROR);
     }
 }
Esempio n. 7
0
 protected function getIcon(&$aWidget)
 {
     $oTemplate = BxDolStudioTemplate::getInstance();
     $sUrl = $oTemplate->getIconUrl($aWidget['icon']);
     if (empty($sUrl)) {
         $aModule = BxDolModuleQuery::getInstance()->getModuleByName($aWidget['module']);
         $sUrl = BxDolStudioUtils::getIconDefault($aModule['type']);
     }
     return $sUrl;
 }
Esempio n. 8
0
 /**
  * Perform serice call
  * @param $mixed module name or module id
  * @param $sMethod service method name in format 'method_name', corresponding class metod is serviceMethodName
  * @param $aParams params to pass to service method
  * @param $sClass class to search for service method, by default it is main module class
  * @return service call result
  */
 public static function call($mixed, $sMethod, $aParams = array(), $sClass = 'Module')
 {
     $oDb = BxDolModuleQuery::getInstance();
     $aModule = array();
     if (is_string($mixed)) {
         $aModule = $oDb->getModuleByName($mixed);
     } else {
         $aModule = $oDb->getModuleById($mixed);
     }
     return empty($aModule) ? '' : BxDolRequest::processAsService($aModule, $sMethod, $aParams, $sClass);
 }
Esempio n. 9
0
 public static function getObjectInstance($sModule = "", $sPage = "", $bInit = true)
 {
     $oModuleDb = BxDolModuleQuery::getInstance();
     $sClass = 'BxTemplStudioModule';
     if ($sModule != '' && $oModuleDb->isModuleByName($sModule)) {
         $aModule = $oModuleDb->getModuleByName($sModule);
         if (file_exists(BX_DIRECTORY_PATH_MODULES . $aModule['path'] . 'classes/' . $aModule['class_prefix'] . 'StudioPage.php')) {
             bx_import('StudioPage', $aModule);
             $sClass = $aModule['class_prefix'] . 'StudioPage';
         }
     }
     $oObject = new $sClass($sModule, $sPage);
     if ($bInit) {
         $oObject->init();
     }
     return $oObject;
 }
Esempio n. 10
0
 public function prepare()
 {
     $iUmaskSave = umask(0);
     bx_import('BxDolStudioInstallerUtils');
     $oInstallerUtils = BxDolStudioInstallerUtils::getInstance();
     $aUpdated = array();
     while (true) {
         $aUpdates = $oInstallerUtils->checkUpdates();
         foreach ($aUpdates as $aUpdate) {
             $mixedResult = $oInstallerUtils->downloadUpdatePublic($aUpdate['name']);
             if ($mixedResult !== true) {
                 $this->setError($mixedResult);
                 break;
             }
         }
         if ($this->getError()) {
             break;
         }
         $aUpdates = $oInstallerUtils->getUpdates();
         foreach ($aUpdates as $aUpdate) {
             $aResult = BxDolStudioInstallerUtils::getInstance()->perform($aUpdate['dir'], 'update');
             if ((int) $aResult['code'] != 0) {
                 $this->setError($aResult['message']);
                 break;
             } else {
                 $aUpdated[$aUpdate['module_name']] = $aUpdate['version_to'];
             }
         }
         break;
     }
     umask($iUmaskSave);
     if (!empty($aUpdated)) {
         bx_import('BxDolModuleQuery');
         $oModuleQuery = BxDolModuleQuery::getInstance();
         $sUpdated = '';
         foreach ($aUpdated as $sModule => $sVersion) {
             $aModule = $oModuleQuery->getModuleByName($sModule);
             $sUpdated .= _t('_sys_et_txt_body_upgraded_module', $aModule['title'], $sVersion);
         }
         sendMailTemplateSystem('t_UpgradeModulesSuccess', array('conclusion' => $sUpdated));
     }
     return $this->getError() ? false : true;
 }
Esempio n. 11
0
 public function actionResetHash($sType)
 {
     $oDb = bx_instance('BxDolStudioInstallerQuery');
     $sResult = '';
     switch ($sType) {
         case 'system':
             $oHasher = bx_instance('BxDolInstallerHasher');
             $oDb->deleteModuleTrackFiles(BX_SYSTEM_MODULE_ID);
             $sResult = _t('_bx_dev_hash_' . ($oHasher->hashSystemFiles() ? 'msg' : 'err') . '_reset_hash_system');
             break;
         case 'modules':
             bx_import('BxDolInstallerUtils');
             bx_import('BxDolModuleQuery');
             $aModules = BxDolModuleQuery::getInstance()->getModules();
             $aTmplVarsModules = array();
             foreach ($aModules as $aModule) {
                 if ($aModule['name'] == 'system') {
                     continue;
                 }
                 $aConfig = BxDolInstallerUtils::getModuleConfig($aModule);
                 $sPathInstaller = BX_DIRECTORY_PATH_MODULES . $aModule['path'] . 'install/installer.php';
                 if (empty($aConfig) || !file_exists($sPathInstaller)) {
                     continue;
                 }
                 require_once $sPathInstaller;
                 $sClassName = $aConfig['class_prefix'] . 'Installer';
                 $oInstaller = new $sClassName($aConfig);
                 $oDb->deleteModuleTrackFiles($aModule['id']);
                 $aFiles = array();
                 $oInstaller->hashFiles(BX_DIRECTORY_PATH_ROOT . 'modules/' . $aModule['path'], $aFiles);
                 foreach ($aFiles as $aFile) {
                     $oDb->insertModuleTrack($aModule['id'], $aFile);
                 }
                 $aTmplVarsModules[] = array('module' => $aModule['title'], 'files' => count($aFiles));
             }
             $sResult = $this->_oTemplate->parseHtmlByName('hash_modules.html', array('bx_repeat:modules' => $aTmplVarsModules));
             break;
     }
     echo $sResult;
     exit;
 }
Esempio n. 12
0
 /**
  * Process menu triggers.
  * Menu triggers allow to automatically add menu items to modules with no different if dependant module was install before or after the module menu item belongs to.
  * For example module "Notes" adds menu items to all profiles modules (Persons, Organizations, etc)
  * with no difference if persons module was installed before or after "Notes" module was installed.
  * @param $sMenuTriggerName trigger name to process, usually specified in module installer class - @see BxBaseModGeneralInstaller
  * @return always true, always success
  */
 public static function processMenuTrigger($sMenuTriggerName)
 {
     // get list of active modules
     $aModules = BxDolModuleQuery::getInstance()->getModulesBy(array('type' => 'modules', 'active' => 1));
     // get list of menu triggers
     $aMenuItems = BxDolMenuQuery::getMenuTriggers($sMenuTriggerName);
     // check each menu item trigger for all modules
     foreach ($aMenuItems as $aMenuItem) {
         foreach ($aModules as $aModule) {
             if (!BxDolRequest::serviceExists($aModule['name'], 'get_menu_set_name_for_menu_trigger')) {
                 continue;
             }
             if (!($sMenuSet = BxDolService::call($aModule['name'], 'get_menu_set_name_for_menu_trigger', array($sMenuTriggerName)))) {
                 continue;
             }
             $aMenuItem['set_name'] = $sMenuSet;
             BxDolMenuQuery::addMenuItemToSet($aMenuItem);
         }
     }
     return true;
 }
 protected function _restoreLanguageByModule($aLanguage, $sPath, $mixedModule)
 {
     $oXmlParser = BxDolXmlParser::getInstance();
     $aModule = $mixedModule;
     if (!is_array($mixedModule)) {
         $sMethod = is_string($mixedModule) && !is_numeric($mixedModule) ? 'getModuleByUri' : 'getModuleById';
         $aModule = BxDolModuleQuery::getInstance()->{$sMethod}($mixedModule);
     }
     if (empty($aModule) || !is_array($aModule) || !$aModule['uri'] || !$aModule['lang_category']) {
         return true;
     }
     $sPath = $sPath . $aModule['uri'] . '.xml';
     if (!file_exists($sPath) && isset($aModule['path'])) {
         $sPath = BX_DIRECTORY_PATH_MODULES . $aModule['path'] . 'install/langs/' . $aLanguage['name'] . '.xml';
         if (!file_exists($sPath)) {
             return true;
         }
     }
     $aLanguageInfo = $this->readLanguage($sPath);
     if (empty($aLanguageInfo['name']) || empty($aLanguageInfo['strings']) || $aLanguageInfo['name'] != $aLanguage['name']) {
         return false;
     }
     $aCategory = array();
     $this->oDb->getCategoriesBy(array('type' => 'by_name', 'value' => $aModule['lang_category']), $aCategory, false);
     $iCategoryId = 0;
     if (empty($aCategory) || !is_array($aCategory)) {
         $iCategoryId = $this->addLanguageCategory($aModule['lang_category']);
         if (empty($iCategoryId)) {
             return false;
         }
     } else {
         $iCategoryId = $aCategory['id'];
     }
     $bDeleteStringsByKey = !$this->oDb->deleteStringsBy(array('type' => 'by_cat_and_lang', 'category_id' => $iCategoryId, 'language_id' => $aLanguage['id']));
     $bResult = true;
     foreach ($aLanguageInfo['strings'] as $sKey => $sValue) {
         if ($sKey != '') {
             if ($bDeleteStringsByKey) {
                 $this->oDb->deleteStringsBy(array('type' => 'by_key_and_lang', 'key' => $sKey, 'language_id' => $aLanguage['id']));
             }
             $bResult &= $this->addLanguageString($sKey, $sValue, $aLanguage['id'], $iCategoryId, false) > 0;
         }
     }
     return $bResult;
 }
 public function downloadUpdatePublic($sModuleName)
 {
     bx_import('BxDolModuleQuery');
     $aModule = BxDolModuleQuery::getInstance()->getModuleByName($sModuleName);
     bx_import('BxDolStudioJson');
     $aItem = BxDolStudioJson::getInstance()->load(BX_DOL_UNITY_URL_MARKET . 'json_download_update', array('product' => base64_encode(serialize(array('name' => $aModule['name'], 'version' => $aModule['version'], 'hash' => $aModule['hash']))), 'domain' => BX_DOL_URL_ROOT, 'user' => (int) getParam('sys_oauth_user')));
     return $this->downloadFile($aItem);
 }
Esempio n. 15
0
<?php

/**
 * @package     Dolphin Core
 * @copyright   Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
 * @license     CC-BY - http://creativecommons.org/licenses/by/3.0/
 */
require_once "./../inc/header.inc.php";
$GLOBALS['aRequest'] = explode('/', $_GET['r']);
$sName = bx_process_input(array_shift($GLOBALS['aRequest']));
bx_import('BxDolModuleQuery');
$GLOBALS['aModule'] = BxDolModuleQuery::getInstance()->getModuleByUri($sName);
if (empty($GLOBALS['aModule'])) {
    require_once BX_DIRECTORY_PATH_INC . "design.inc.php";
    BxDolRequest::moduleNotFound($sName);
}
include BX_DIRECTORY_PATH_MODULES . $GLOBALS['aModule']['path'] . 'request.php';
Esempio n. 16
0
 public function serviceGetBlockSpace($bDynamic = false)
 {
     $bInclideScriptSpace = false;
     //Use dynamic loading by default if this setting is enabled.
     $sJsObject = $this->getPageJsObject();
     $aChartData = array();
     if (!$bDynamic) {
         $aItems = array(array('label' => '_adm_dbd_txt_su_database', 'value' => $this->getDbSize()));
         if ($bInclideScriptSpace) {
             $iSizeDiskTotal = $this->getFolderSize(BX_DIRECTORY_PATH_ROOT);
             $iSizeDiskMedia = $this->getFolderSize(BX_DIRECTORY_STORAGE);
             $aItems[] = array('label' => '_adm_dbd_txt_su_system', 'value' => $iSizeDiskTotal - $iSizeDiskMedia);
         }
         bx_import('BxDolModuleQuery');
         $aModules = BxDolModuleQuery::getInstance()->getModulesBy(array('type' => 'all'));
         foreach ($aModules as $aModule) {
             $sName = $aModule['name'];
             $sTitle = $aModule['title'];
             if ($aModule['name'] == 'system') {
                 $sName = 'sys';
                 $sTitle = _t('_adm_dbd_txt_su_system_media');
             }
             $aItems[] = array('label' => $sTitle, 'value' => (int) $this->oDb->getModuleStorageSize($sName));
         }
         $iSizeTotal = 0;
         $aChartData = array();
         foreach ($aItems as $sColor => $aItem) {
             $iSizeTotal += $aItem['value'];
             $aChartData[] = array(bx_js_string(strip_tags(_t($aItem['label'])), BX_ESCAPE_STR_APOS), array('v' => $aItem['value'], 'f' => bx_js_string(_t_format_size($aItem['value']))));
         }
     }
     $sContent = BxDolStudioTemplate::getInstance()->parseHtmlByName('dbd_space.html', array('bx_if:show_content' => array('condition' => !$bDynamic, 'content' => array('js_object' => $sJsObject, 'chart_data' => json_encode($aChartData))), 'bx_if:show_loader' => array('condition' => $bDynamic, 'content' => array('js_object' => $sJsObject))));
     return array('content' => $sContent);
 }
Esempio n. 17
0
 public static function getModules($bShowCustom = true, $bShowSystem = true)
 {
     $aResult = array();
     if ($bShowSystem) {
         $aResult[BX_DOL_STUDIO_MODULE_SYSTEM] = self::getModuleTitle(BX_DOL_STUDIO_MODULE_SYSTEM);
     }
     if ($bShowCustom) {
         $aResult[BX_DOL_STUDIO_MODULE_CUSTOM] = self::getModuleTitle(BX_DOL_STUDIO_MODULE_CUSTOM);
     }
     bx_import('BxDolModuleQuery');
     $aModules = BxDolModuleQuery::getInstance()->getModulesBy(array('type' => 'modules', 'active' => 1));
     foreach ($aModules as $aModule) {
         $aResult[$aModule['name']] = $aModule['title'];
     }
     return $aResult;
 }
Esempio n. 18
0
 /**
  * Check whether code is associated with active template.
  *
  * @param string  $sCode      template's unique URI.
  * @param boolean $bSetCookie save code in COOKIE or not.
  */
 protected function _checkCode($sCode, $bSetCookie)
 {
     if (empty($sCode) || !preg_match('/^[A-Za-z0-9_-]+$/', $sCode)) {
         return;
     }
     bx_import('BxDolModuleQuery');
     $aModule = BxDolModuleQuery::getInstance()->getModuleByUri($sCode);
     if (empty($aModule) || !is_array($aModule) || (int) $aModule['enabled'] != 1 || !file_exists($this->_sRootPath . 'modules/' . $aModule['path'] . 'data/template/')) {
         return;
     }
     bx_import('BxDolModuleConfig');
     $oConfig = new BxDolModuleConfig($aModule);
     $this->_sCode = $oConfig->getUri();
     $this->_sSubPath = $oConfig->getDirectory();
     if (!$bSetCookie || bx_get('preview')) {
         return;
     }
     $aUrl = parse_url(BX_DOL_URL_ROOT);
     $sPath = isset($aUrl['path']) && !empty($aUrl['path']) ? $aUrl['path'] : '/';
     setcookie($this->_sCodeKey, $this->_sCode, time() + 60 * 60 * 24 * 365, $sPath);
 }
Esempio n. 19
0
 protected static function _methodExists($mixedModule, $sMethodType, $sMethodName, $sClass = "Module")
 {
     $aModule = $mixedModule;
     if (is_string($mixedModule)) {
         bx_import('BxDolModuleQuery');
         $aModule = BxDolModuleQuery::getInstance()->getModuleByName($mixedModule);
     }
     if (!$aModule) {
         return false;
     }
     $sClass = $aModule['class_prefix'] . $sClass;
     if (($oModule = BxDolRequest::_require($aModule, $sClass)) === false) {
         return false;
     }
     $sMethod = $sMethodType . bx_gen_method_name($sMethodName);
     return method_exists($oModule, $sMethod);
 }
 private function getInstalledInfo()
 {
     bx_import('BxDolModuleQuery');
     $aModules = BxDolModuleQuery::getInstance()->getModules();
     $aInstalledInfo = array();
     foreach ($aModules as $aModule) {
         $aInstalledInfo[$aModule['path']] = $aModule;
     }
     return $aInstalledInfo;
 }
 protected function _getManageAccountUrl($sFilter = '')
 {
     $sModuleAccounts = 'bx_accounts';
     if (!BxDolModuleQuery::getInstance()->isEnabledByName($sModuleAccounts)) {
         return '';
     }
     $sTypeUpc = strtoupper($this->_sManageType);
     $oModuleAccounts = BxDolModule::getInstance($sModuleAccounts);
     if (!$oModuleAccounts || empty($oModuleAccounts->_oConfig->CNF['URL_MANAGE_' . $sTypeUpc])) {
         return '';
     }
     $sLink = $oModuleAccounts->_oConfig->CNF['URL_MANAGE_' . $sTypeUpc];
     $sLink = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink($sLink);
     if (!empty($sFilter)) {
         $sLink = bx_append_url_params($sLink, array('filter' => $sFilter));
     }
     return $sLink;
 }
Esempio n. 22
0
 protected function actionBlockCreate()
 {
     $sJsObject = $this->getPageJsObject();
     $oTemplate = BxDolStudioTemplate::getInstance();
     $sSelected = BX_DOL_STUDIO_BP_SKELETONS;
     $aForm = array('form_attrs' => array('id' => 'adm-bp-block-create', 'action' => sprintf($this->sPageUrl, $this->sType, $this->sPage) . '&bp_action=' . $this->sActionBlockCreate, 'method' => 'post'), 'params' => array('db' => array('table' => 'sys_pages_blocks', 'key' => 'id', 'uri' => '', 'uri_title' => '', 'submit_name' => 'do_submit')), 'inputs' => array('blocks' => array('type' => 'custom', 'name' => 'blocks', 'content' => '', 'db' => array('pass' => 'Int'))));
     $aMenu = array(BX_DOL_STUDIO_BP_SKELETONS => array('name' => BX_DOL_STUDIO_BP_SKELETONS, 'icon' => 'qrcode', 'title' => '_sys_block_types_skeletons', 'selected' => $sSelected == BX_DOL_STUDIO_BP_SKELETONS), BX_DOL_STUDIO_MODULE_SYSTEM => array('name' => BX_DOL_STUDIO_MODULE_SYSTEM, 'icon' => 'cog', 'title' => '_sys_block_types_system', 'selected' => $sSelected == BX_DOL_STUDIO_MODULE_SYSTEM), BX_DOL_STUDIO_MODULE_CUSTOM => array('name' => BX_DOL_STUDIO_MODULE_CUSTOM, 'icon' => 'wrench', 'title' => '_sys_block_types_custom', 'selected' => $sSelected == BX_DOL_STUDIO_MODULE_CUSTOM));
     bx_import('BxDolModuleQuery');
     $aModules = BxDolModuleQuery::getInstance()->getModulesBy(array('type' => 'modules'));
     $aModulesWithBlocks = $this->oDb->getModulesWithCopyableBlocks();
     foreach ($aModules as $aModule) {
         $sName = $aModule['name'];
         if (!in_array($sName, $aModulesWithBlocks)) {
             continue;
         }
         if (!empty($aMenu[$sName])) {
             $aMenu[$sName] = array_merge($aMenu[$sName], $aModule);
         } else {
             $aMenu[$sName] = $aModule;
         }
         if (empty($aMenu[$sName]['icon'])) {
             $aMenu[$sName]['icon'] = BxDolStudioUtils::getModuleIcon($aModule, 'menu', false);
         }
     }
     foreach ($aMenu as $sKey => $aItem) {
         $aMenu[$sKey]['onclick'] = $sJsObject . '.onChangeModule(\'' . $aItem['name'] . '\', this);';
     }
     bx_import('BxTemplStudioMenu');
     $oMenu = new BxTemplStudioMenu(array('template' => 'menu_side.html', 'menu_items' => $aMenu));
     $aTmplParams = array('menu' => $oMenu->getCode(), 'html_block_lists_id' => $this->aHtmlIds['block_lists_id'], 'blocks' => $this->getBlockList($sSelected));
     $aForm['inputs']['blocks']['content'] = $oTemplate->parseHtmlByName('bp_add_block_form.html', $aTmplParams);
     $oForm = new BxTemplStudioFormView($aForm);
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         $aIds = $oForm->getCleanValue('blocks');
         $aBlocks = array();
         $this->oDb->getBlocks(array('type' => 'by_ids', 'value' => $aIds), $aBlocks, false);
         bx_import('BxDolStudioLanguagesUtils');
         $oLanguage = BxDolStudioLanguagesUtils::getInstance();
         bx_import('BxDolStorage');
         $oStorege = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
         $bResult = true;
         foreach ($aBlocks as $aBlock) {
             $sTitleKey = $this->getSystemName($aBlock['title'] . '_' . time());
             $sTitleValue = _t($aBlock['title']);
             unset($aBlock['id']);
             $aBlock['object'] = $this->sPage;
             $aBlock['cell_id'] = 1;
             $aBlock['module'] = $this->getBlockModule($aBlock);
             $aBlock['title'] = $sTitleKey;
             $aBlock['copyable'] = 0;
             $aBlock['deletable'] = 1;
             //--- Process Lang copy
             $sContentKey = $sContentValue = "";
             if ($aBlock['type'] == BX_DOL_STUDIO_BP_BLOCK_LANG && $aBlock['content'] != '') {
                 $sContentKey = $this->getSystemName($aBlock['content'] . '_' . time());
                 $sContentValue = _t($aBlock['content']);
                 $aBlock['content'] = $sContentKey;
                 $oLanguage->addLanguageString($sContentKey, $sContentValue);
             }
             //--- Process Image copy
             $iImageId = $sImageAlign = "";
             if ($aBlock['type'] == BX_DOL_STUDIO_BP_BLOCK_IMAGE && $aBlock['content'] != '') {
                 list($iImageId, $sImageAlign) = explode($this->sParamsDivider, $aBlock['content']);
                 $aBlock['content'] = "";
                 if (is_numeric($iImageId) && (int) $iImageId != 0 && ($iImageId = $oStorege->storeFileFromStorage(array('id' => $iImageId))) !== false) {
                     $aBlock['content'] = implode($this->sParamsDivider, array($iImageId, $sImageAlign));
                 }
             }
             if (!$this->oDb->insertBlock($aBlock)) {
                 if ($sContentKey != "") {
                     $oLanguage->deleteLanguageString($sContentKey);
                 }
                 if ($iImageId != "") {
                     $oStorege->deleteFile((int) $iImageId, 0);
                 }
                 $bResult = false;
                 break;
             }
             $oLanguage->addLanguageString($sTitleKey, $sTitleValue);
         }
         if ($bResult) {
             return array('eval' => $sJsObject . '.onCreateBlock(oData)');
         } else {
             return array('msg' => _t('_adm_bp_err_block_added'));
         }
     }
     bx_import('BxTemplStudioFunctions');
     $sContent = BxTemplStudioFunctions::getInstance()->popupBox($this->aHtmlIds['create_block_popup_id'], _t('_adm_bp_txt_new_block_popup'), $oTemplate->parseHtmlByName('bp_add_block.html', array('action' => 'create', 'form_id' => $aForm['form_attrs']['id'], 'form' => $oForm->getCode(true))));
     return array('popup' => $sContent);
 }
Esempio n. 23
0
 protected function _getProfilesModules()
 {
     $aRet = array();
     bx_import('BxDolModuleQuery');
     $aModules = BxDolModuleQuery::getInstance()->getModulesBy(array('type' => 'modules', 'active' => 1));
     foreach ($aModules as $aModule) {
         $oModule = BxDolModule::getInstance($aModule['name']);
         if ($oModule instanceof iBxDolProfileService) {
             $aRet[] = $aModule;
         }
     }
     return $aRet;
 }
 private function emailNotifyModulesUpgrade($sResult, $aData)
 {
     $oModuleQuery = BxDolModuleQuery::getInstance();
     $sConclusion = '';
     if (!empty($aData)) {
         foreach ($aData as $sModule => $sMessage) {
             $aModule = $oModuleQuery->getModuleByName($sModule);
             $sConclusion .= _t('_sys_et_txt_body_modules_upgrade_' . $sResult, $aModule['title'], $sMessage);
         }
     }
     sendMailTemplateSystem('t_UpgradeModules' . ucfirst($sResult), array('conclusion' => $sConclusion));
 }
Esempio n. 25
0
 function checkTemplate($sVal)
 {
     return strlen($sVal) > 0 && BxDolModuleQuery::getInstance()->isEnabled($sVal);
 }
Esempio n. 26
0
 function __construct()
 {
     parent::__construct();
 }
Esempio n. 27
0
 /**
  * Process page triggers.
  * Page triggers allow to automatically add page blocks to modules with no different if dependant module was install before or after the module page block belongs to.
  * For example module "Notes" adds page blocks to all profiles modules (Persons, Organizations, etc)
  * with no difference if persons module was installed before or after "Notes" module was installed.
  * @param $sPageTriggerName trigger name to process, usually specified in module installer class - @see BxBaseModGeneralInstaller
  * @return always true, always success
  */
 public static function processPageTrigger($sPageTriggerName)
 {
     // get list of active modules
     $aModules = BxDolModuleQuery::getInstance()->getModulesBy(array('type' => 'modules', 'active' => 1));
     // get list of page block triggers
     $aPageBlocks = BxDolPageQuery::getPageTriggers($sPageTriggerName);
     // check each page block trigger for all modules
     foreach ($aPageBlocks as $aPageBlock) {
         foreach ($aModules as $aModule) {
             if (!BxDolRequest::serviceExists($aModule['name'], 'get_page_object_for_page_trigger')) {
                 continue;
             }
             $sPageObject = BxDolService::call($aModule['name'], 'get_page_object_for_page_trigger', array($sPageTriggerName));
             if (!$sPageObject) {
                 continue;
             }
             $aPageBlock['object'] = $sPageObject;
             BxDolPageQuery::addPageBlockToPage($aPageBlock);
         }
     }
     return true;
 }