includes/plugins.php
changeset 808 97cd1a3229d0
parent 801 eb8b23f11744
child 812 68060328e9c6
equal deleted inserted replaced
807:34e8bf0f25e1 808:97cd1a3229d0
   555     
   555     
   556     // load up the installer schema
   556     // load up the installer schema
   557     $schema = $this->parse_plugin_blocks( ENANO_ROOT . '/plugins/' . $filename, 'install' );
   557     $schema = $this->parse_plugin_blocks( ENANO_ROOT . '/plugins/' . $filename, 'install' );
   558     
   558     
   559     $sql = array();
   559     $sql = array();
       
   560     global $dbdriver;
   560     if ( !empty($schema) )
   561     if ( !empty($schema) )
   561     {
   562     {
       
   563       // Decide which schema to use
       
   564       $use_schema = false;
       
   565       foreach ( $schema as $current_schema )
       
   566       {
       
   567         if ( isset($current_schema['dbms']) && $current_schema['dbms'] === $dbdriver )
       
   568         {
       
   569           $use_schema =& $current_schema['value'];
       
   570           break;
       
   571         }
       
   572       }
       
   573       if ( !$use_schema )
       
   574       {
       
   575         if ( !isset($schema[0]['dbms']) )
       
   576         {
       
   577           $use_schema =& $schema[0]['value'];
       
   578         }
       
   579         else
       
   580         {
       
   581           $return = array(
       
   582             'mode' => 'error',
       
   583             'error' => $lang->get('acppl_err_dmbs_not_supported', array('dbdriver' => $db->dbms_name))
       
   584           );
       
   585           break;
       
   586         }
       
   587       }
   562       // parse SQL
   588       // parse SQL
   563       $parser = new SQL_Parser($schema[0]['value'], true);
   589       $parser = new SQL_Parser($use_schema, true);
   564       $parser->assign_vars(array(
   590       $parser->assign_vars(array(
   565         'TABLE_PREFIX' => table_prefix
   591         'TABLE_PREFIX' => table_prefix
   566         ));
   592         ));
   567       $sql = $parser->parse();
   593       $sql = $parser->parse();
   568     }
   594     }
   638   
   664   
   639   function uninstall_plugin($filename, $plugin_list = null)
   665   function uninstall_plugin($filename, $plugin_list = null)
   640   {
   666   {
   641     global $db, $session, $paths, $template, $plugins; // Common objects
   667     global $db, $session, $paths, $template, $plugins; // Common objects
   642     global $lang;
   668     global $lang;
       
   669     global $cache;
   643     
   670     
   644     if ( defined('ENANO_DEMO_MODE') )
   671     if ( defined('ENANO_DEMO_MODE') )
   645     {
   672     {
   646       return array(
   673       return array(
   647           'mode' => 'error',
   674           'mode' => 'error',
   681     
   708     
   682     // load up the installer schema
   709     // load up the installer schema
   683     $schema = $this->parse_plugin_blocks( ENANO_ROOT . '/plugins/' . $filename, 'uninstall' );
   710     $schema = $this->parse_plugin_blocks( ENANO_ROOT . '/plugins/' . $filename, 'uninstall' );
   684     
   711     
   685     $sql = array();
   712     $sql = array();
       
   713     global $dbdriver;
   686     if ( !empty($schema) )
   714     if ( !empty($schema) )
   687     {
   715     {
       
   716       // Decide which schema to use
       
   717       $use_schema = false;
       
   718       foreach ( $schema as $current_schema )
       
   719       {
       
   720         if ( isset($current_schema['dbms']) && $current_schema['dbms'] === $dbdriver )
       
   721         {
       
   722           $use_schema =& $current_schema['value'];
       
   723           break;
       
   724         }
       
   725       }
       
   726       if ( !$use_schema )
       
   727       {
       
   728         if ( !isset($schema[0]['dbms']) )
       
   729         {
       
   730           $use_schema =& $schema[0]['value'];
       
   731         }
       
   732         else
       
   733         {
       
   734           $return = array(
       
   735             'mode' => 'error',
       
   736             'error' => $lang->get('acppl_err_dmbs_not_supported', array('dbdriver' => $db->dbms_name))
       
   737           );
       
   738           break;
       
   739         }
       
   740       }
   688       // parse SQL
   741       // parse SQL
   689       $parser = new SQL_Parser($schema[0]['value'], true);
   742       $parser = new SQL_Parser($use_schema, true);
   690       $parser->assign_vars(array(
   743       $parser->assign_vars(array(
   691         'TABLE_PREFIX' => table_prefix
   744         'TABLE_PREFIX' => table_prefix
   692         ));
   745         ));
   693       $sql = $parser->parse();
   746       $sql = $parser->parse();
   694     }
   747     }