public static function add($moduleName)
 {
     $con = Application::getDbConnection();
     $con->queryExecute("INSERT INTO b_module(ID) VALUES('" . $con->getSqlHelper()->forSql($moduleName) . "')");
     self::$installedModules = array();
     $cacheManager = Application::getInstance()->getManagedCache();
     $cacheManager->clean("b_module");
 }
Example #2
0
 public function __construct()
 {
     $this->_configMain = Registry::get('main', 'config');
     $this->_lang = Lang::lang();
     $this->_db = Application::getDbConnection();
     $this->_config = Config::factory(Config::File_Array, $this->_configMain['configs'] . 'designer.php');
     $this->_session = Store_Session::getInstance('Designer');
     $this->_storage = Designer_Storage::getInstance($this->_config->get('storage'), $this->_config);
 }
Example #3
0
 protected function getCookieDomain()
 {
     static $bCache = false;
     static $cache = false;
     if ($bCache) {
         return $cache;
     }
     $context = Application::getInstance()->getContext();
     $server = $context->getServer();
     $cacheFlags = \Bitrix\Main\Config\Configuration::getValue("cache_flags");
     $cacheTtl = isset($cacheFlags["site_domain"]) ? $cacheFlags["site_domain"] : 0;
     if ($cacheTtl === false) {
         $connection = Application::getDbConnection();
         $sqlHelper = $connection->getSqlHelper();
         $sql = "SELECT DOMAIN " . "FROM b_lang_domain " . "WHERE '" . $sqlHelper->forSql('.' . $server->getHttpHost()) . "' like " . $sqlHelper->getConcatFunction("'%.'", "DOMAIN") . " " . "ORDER BY " . $sqlHelper->getLengthFunction("DOMAIN") . " ";
         $recordset = $connection->query($sql);
         if ($record = $recordset->fetch()) {
             $cache = $record['DOMAIN'];
         }
     } else {
         $managedCache = Application::getInstance()->getManagedCache();
         if ($managedCache->read($cacheTtl, "b_lang_domain", "b_lang_domain")) {
             $arLangDomain = $managedCache->get("b_lang_domain");
         } else {
             $arLangDomain = array("DOMAIN" => array(), "LID" => array());
             $connection = Application::getDbConnection();
             $sqlHelper = $connection->getSqlHelper();
             $recordset = $connection->query("SELECT * " . "FROM b_lang_domain " . "ORDER BY " . $sqlHelper->getLengthFunction("DOMAIN"));
             while ($record = $recordset->fetch()) {
                 $arLangDomain["DOMAIN"][] = $record;
                 $arLangDomain["LID"][$record["LID"]][] = $record;
             }
             $managedCache->set("b_lang_domain", $arLangDomain);
         }
         foreach ($arLangDomain["DOMAIN"] as $domain) {
             if (strcasecmp(substr('.' . $server->getHttpHost(), -(strlen($domain['DOMAIN']) + 1)), "." . $domain['DOMAIN']) == 0) {
                 $cache = $domain['DOMAIN'];
                 break;
             }
         }
     }
     $bCache = true;
     return $cache;
 }
 private function loadEventHandlers()
 {
     $cache = Application::getInstance()->getManagedCache();
     if ($cache->read(3600, self::$cacheKey)) {
         $arEvents = $cache->get(self::$cacheKey);
     } else {
         $arEvents = array();
         $con = Application::getDbConnection();
         $rs = $con->query("\n\t\t\t\tSELECT *\n\t\t\t\tFROM b_module_to_module m2m\n\t\t\t\t\tINNER JOIN b_module m ON (m2m.TO_MODULE_ID = m.ID)\n\t\t\t\tORDER BY SORT\n\t\t\t");
         while ($ar = $rs->fetch()) {
             $ar['TO_NAME'] = $this->formatEventName(array("MODULE_ID" => $ar["TO_MODULE_ID"], "CLASS" => $ar["TO_CLASS"], "METHOD" => $ar["TO_METHOD"]));
             $ar["~FROM_MODULE_ID"] = strtoupper($ar["FROM_MODULE_ID"]);
             $ar["~MESSAGE_ID"] = strtoupper($ar["MESSAGE_ID"]);
             if (strlen($ar["TO_METHOD_ARG"]) > 0) {
                 $ar["TO_METHOD_ARG"] = unserialize($ar["TO_METHOD_ARG"]);
             } else {
                 $ar["TO_METHOD_ARG"] = array();
             }
             $arEvents[] = $ar;
         }
         $cache->set(self::$cacheKey, $arEvents);
     }
     if (!is_array($arEvents)) {
         $arEvents = array();
     }
     $handlers = $this->handlers;
     foreach ($arEvents as $ar) {
         $this->handlers[$ar["~FROM_MODULE_ID"]][$ar["~MESSAGE_ID"]][] = array("SORT" => $ar["SORT"], "MODULE_ID" => $ar["TO_MODULE_ID"], "PATH" => $ar["TO_PATH"], "CLASS" => $ar["TO_CLASS"], "METHOD" => $ar["TO_METHOD"], "METHOD_ARG" => $ar["TO_METHOD_ARG"], "VERSION" => $ar["VERSION"], "NAME" => $ar["TO_NAME"]);
     }
     // need to re-sort because of AddEventHandler() calls
     $funcSort = create_function('$a, $b', 'if ($a["SORT"] == $b["SORT"]) return 0; return ($a["SORT"] < $b["SORT"]) ? -1 : 1;');
     foreach (array_keys($handlers) as $moduleId) {
         foreach (array_keys($handlers[$moduleId]) as $event) {
             uasort($this->handlers[$moduleId][$event], $funcSort);
         }
     }
     $this->isHandlersLoaded = true;
 }
Example #5
0
 public function testAction()
 {
     Application::getDbConnection()->getProfiler()->setEnabled(false);
     $this->_tManager->launch(Bgtask_Manager::LAUNCHER_JSON, 'Task_Test', array());
 }
Example #6
0
 /**
  * Request server db state
  * Start background task
  */
 public function viewDbsyncAction()
 {
     $serverId = Request::post('server_id', 'pagecode', '');
     if (!strlen($serverId)) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $list = $this->_serversConfig->get('list');
     if (!isset($list[$serverId])) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     Application::getDbConnection()->getProfiler()->setEnabled(false);
     $bgStorage = new Bgtask_Storage_Orm(Model::factory('Bgtask'), Model::factory('Bgtask_Signal'));
     $logger = new Bgtask_Log_File($this->_configMain['task_log_path'] . 'syncdb_' . $serverId . '_' . date('d_m_Y__H_i_s'));
     $tm = Bgtask_Manager::getInstance();
     $tm->setStorage($bgStorage);
     $tm->setLogger($logger);
     $cfg = $list[$serverId];
     $cfg['id'] = $serverId;
     $tm->launch(Bgtask_Manager::LAUNCHER_JSON, 'Task_Deploy_Dbsync', $cfg);
 }