Пример #1
0
 public function install()
 {
     $result = true;
     // We need CURL to function correctly
     if (!$this->curlExists()) {
         $this->context->controller->errors[] = $this->l('Riskified require CURL to be installed and enabled.');
         $result = false;
     }
     if (!file_exists(dirname(__FILE__) . '/' . self::INSTALL_SQL_FILE)) {
         return false;
     } else {
         if (!($sql = Tools::file_get_contents(dirname(__FILE__) . '/' . self::INSTALL_SQL_FILE))) {
             return false;
         }
     }
     $sql = str_replace(array('PREFIX_', 'ENGINE_TYPE'), array(_DB_PREFIX_, _MYSQL_ENGINE_), $sql);
     $sql = preg_split("/;\\s*[\r\n]+/", trim($sql));
     foreach ($sql as $query) {
         if (!Db::getInstance()->execute(trim($query))) {
             return false;
         }
     }
     if (!parent::install() || !$this->registerHook('displayAdminOrder') || !$this->registerHook('displayBackOfficeHeader') || !$this->registerHook('displayBackOfficeTop') || !$this->registerHook('actionValidateOrder') || !$this->registerHook('header')) {
         $result = false;
     }
     RiskifiedLogger::insertLog(__METHOD__ . ' : ' . __LINE__, 'Riskified::install() = ' . $result);
     return $result;
 }