Modify

Opened 6 years ago

#1684 new Erweiterung

PayPal Plus Module: admin_access wiederherstellen

Reported by: Stefan May <stefan@…> Owned by:
Priority: niedrig Milestone:
Component: Module Version: 2.0.4.2
Keywords: Cc:
Blocked By: Blocking:

Description

Vorweg: Betrifft sicherlich nur sehr wenige Installationen. Aufgetreten beim Upgrade einer xtcommerce-Installation auf modified 2.0.4.2 mit aktuellem PayPal Plus Modul 1.27.

Voraussetzung: Fehlerhafter Eintrag in Tabelle "admin_access", Spalte "paypal_info" und/oder "paypal_module" enthalten Zahl "0" für "customers_id"=1 (Admin-Benutzer).

Ursache: Diese beiden Spalten werden beim Deinstallieren der PayPal-Module nicht gelöscht, dadurch auch bei Neuinstallation der Module nicht neu geschrieben.
Code aus PayPalPaymentBase.php in Funktionsdefinition remove():

      $admin_query = xtc_db_query("SELECT * 
                                     FROM ".TABLE_ADMIN_ACCESS."
                                    LIMIT 1");
      $admin = xtc_db_fetch_array($admin_query);
      foreach ($this->admin_access_array as $admin_access) {
        if ($admin_access != 'paypal_info' 
            && $admin_access != 'paypal_module' 
            && isset($admin[$admin_access])
            )
        {
          xtc_db_query("ALTER TABLE ".TABLE_ADMIN_ACCESS." DROP COLUMN `".$admin_access."`");
        }
      }

Die Funktionen install() und paypal_update() in der gleichen Datei erzeugen ausschließlich fehlende Spalten in Tabelle admin_access, ändern bestehende Spalten aber nicht.
Dadurch ist es ohne direktes Editieren der Datenbank nicht möglich, diese fehlerhaften Einträge zu korrigieren. Ein Aufruf der Benutzerberechtigungen im Admin-Interface (admin/accounting.php) erlaubt keine Änderungen für diesen Benutzer. In der Folge lassen sich die PayPal-Zahlungsmodule nicht konfigurieren.

Vorschlag:
In includes/external/paypal/classes/PayPalPaymentBase.php in "function install()" folgenden Codeblock (ab Zeile 470 in Modulversion 1.27)

    foreach ($this->admin_access_array as $admin_access) {
      if (!isset($admin[$admin_access])) {
        xtc_db_query("ALTER TABLE ".TABLE_ADMIN_ACCESS." ADD `".$admin_access."` INT(1) DEFAULT '0' NOT NULL");
        xtc_db_query("UPDATE ".TABLE_ADMIN_ACCESS." SET ".$admin_access." = '9' WHERE customers_id = 'groups' LIMIT 1");        
        xtc_db_query("UPDATE ".TABLE_ADMIN_ACCESS." SET ".$admin_access." = '1' WHERE customers_id = '1' LIMIT 1");        
        
        if (defined('RUN_MODE_ADMIN') && $_SESSION['customer_id'] > 1) {
          xtc_db_query("UPDATE ".TABLE_ADMIN_ACCESS." SET ".$admin_access." = '1' WHERE customers_id = '".$_SESSION['customer_id']."' LIMIT 1") ;
        }
      }
    }

ersetzen durch:

    foreach ($this->admin_access_array as $admin_access) {
      if (!isset($admin[$admin_access])) {
        xtc_db_query("ALTER TABLE ".TABLE_ADMIN_ACCESS." ADD `".$admin_access."` INT(1) DEFAULT '0' NOT NULL");
      }
      xtc_db_query("UPDATE ".TABLE_ADMIN_ACCESS." SET ".$admin_access." = '9' WHERE customers_id = 'groups' LIMIT 1");        
      xtc_db_query("UPDATE ".TABLE_ADMIN_ACCESS." SET ".$admin_access." = '1' WHERE customers_id = '1' LIMIT 1");        
      
      if (defined('RUN_MODE_ADMIN') && $_SESSION['customer_id'] > 1) {
        xtc_db_query("UPDATE ".TABLE_ADMIN_ACCESS." SET ".$admin_access." = '1' WHERE customers_id = '".$_SESSION['customer_id']."' LIMIT 1") ;
      }
    }

Alternativ in der gleichen Datei in "function paypal_update()" Codeblock (ab Zeile 648 in Modulversion 1.27)

    foreach ($this->admin_access_array as $admin_access) {
      if (!isset($admin[$admin_access])) {
        xtc_db_query("ALTER TABLE ".TABLE_ADMIN_ACCESS." ADD `".$admin_access."` INT(1) DEFAULT '0' NOT NULL");
        xtc_db_query("UPDATE ".TABLE_ADMIN_ACCESS." SET ".$admin_access." = '9' WHERE customers_id = 'groups' LIMIT 1");        
        xtc_db_query("UPDATE ".TABLE_ADMIN_ACCESS." SET ".$admin_access." = '1' WHERE customers_id = '1' LIMIT 1");        
        if (defined('RUN_MODE_ADMIN') && $_SESSION['customer_id'] > 1) {
          xtc_db_query("UPDATE ".TABLE_ADMIN_ACCESS." SET ".$admin_access." = '1' WHERE customers_id = '".$_SESSION['customer_id']."' LIMIT 1") ;
        }
      }
    }

ersetzen durch:

    foreach ($this->admin_access_array as $admin_access) {
      if (!isset($admin[$admin_access])) {
        xtc_db_query("ALTER TABLE ".TABLE_ADMIN_ACCESS." ADD `".$admin_access."` INT(1) DEFAULT '0' NOT NULL");
        }
      xtc_db_query("UPDATE ".TABLE_ADMIN_ACCESS." SET ".$admin_access." = '9' WHERE customers_id = 'groups' LIMIT 1");        
      xtc_db_query("UPDATE ".TABLE_ADMIN_ACCESS." SET ".$admin_access." = '1' WHERE customers_id = '1' LIMIT 1");        
      if (defined('RUN_MODE_ADMIN') && $_SESSION['customer_id'] > 1) {
        xtc_db_query("UPDATE ".TABLE_ADMIN_ACCESS." SET ".$admin_access." = '1' WHERE customers_id = '".$_SESSION['customer_id']."' LIMIT 1") ;
      }
    }

Dadurch würden die Admin-Berechtigungen immer neu gesetzt.

Attachments (0)

Change History (0)

Modify Ticket

Action
as new The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.