Changeset 5135

Show
Ignore:
Timestamp:
02/01/07 13:26:39 (2 years ago)
Author:
bergie
Message:

Midgard 1.8.2 compatibility

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/support/Role_Midgardelement/Midgardelement.php

    r4496 r5135  
    108108        } 
    109109         
    110         if ($this->config->get('midgard_sitegroup') != 'root') 
    111         { 
    112             // We have to dig up the init file to read the MidgardUsername and MidgardPassword properties 
    113             switch ($_MIDGARD['config']['prefix']) 
    114             { 
    115                 case '/usr': 
    116                 case '/usr/local': 
    117                     $midgard_path = '/etc/midgard'; 
     110        // We have to dig up the init file to read the MidgardUsername and MidgardPassword properties 
     111        switch ($_MIDGARD['config']['prefix']) 
     112        { 
     113            case '/usr': 
     114            case '/usr/local': 
     115                $midgard_path = '/etc/midgard'; 
     116                break; 
     117             
     118            default: 
     119                $midgard_path = "{$_MIDGARD['config']['prefix']}/etc/midgard"; 
     120                break; 
     121        } 
     122         
     123        $init_file_path =  "{$midgard_path}/conf.d/{$init_file}"; 
     124        if (!file_exists($init_file_path)) 
     125        { 
     126            PEAR::raiseError("Midgard configuration file \"{$init_file_path}\" not found.", mgd_errno(), PEAR_ERROR_DIE); 
     127            return false; 
     128        } 
     129        $midgard_username = null; 
     130        $midgard_password = null; 
     131         
     132        $lines = explode("\n", file_get_contents($init_file_path)); 
     133        foreach ($lines as $line) 
     134        { 
     135            if (substr($line, 0, 1) == '#') 
     136            { 
     137                // This is a comment line, skip 
     138                continue; 
     139            } 
     140         
     141            $parts = explode('=', $line); 
     142            if (count($parts) != 2) 
     143            { 
     144                // This is not valid config field, skip 
     145                continue; 
     146            } 
     147             
     148            switch ($parts[0]) 
     149            { 
     150                case 'MidgardUsername': 
     151                    $midgard_username = $parts[1]; 
    118152                    break; 
    119                  
    120                 default
    121                     $midgard_path = "{$_MIDGARD['config']['prefix']}/etc/midgard"
     153 
     154                case 'MidgardPassword'
     155                    $midgard_password = $parts[1]
    122156                    break; 
    123157            } 
    124              
    125             $init_file_path =  "{$midgard_path}/conf.d/{$init_file}"; 
    126             if (!file_exists($init_file_path)) 
    127             { 
    128                 PEAR::raiseError("Midgard configuration file \"{$init_file_path}\" not found.", mgd_errno(), PEAR_ERROR_DIE); 
    129                 return false; 
    130             } 
    131             $midgard_username = null; 
    132             $midgard_password = null; 
    133              
    134             $lines = explode("\n", file_get_contents($init_file_path)); 
    135             foreach ($lines as $line) 
    136             { 
    137                 if (substr($line, 0, 1) == '#') 
    138                 { 
    139                     // This is a comment line, skip 
    140                     continue; 
    141                 } 
    142              
    143                 $parts = explode('=', $line); 
    144                 if (count($parts) != 2) 
    145                 { 
    146                     // This is not valid config field, skip 
    147                     continue; 
    148                 } 
    149                  
    150                 switch ($parts[0]) 
    151                 { 
    152                     case 'MidgardUsername': 
    153                         $midgard_username = $parts[1]; 
    154                         break; 
    155  
    156                     case 'MidgardPassword': 
    157                         $midgard_password = $parts[1]; 
    158                         break; 
    159                 } 
    160             } 
    161              
    162             if (   is_null($midgard_username) 
    163                 || is_null($midgard_password)) 
    164             { 
    165                 PEAR::raiseError("Midgard configuration file \"{$init_file}\" did not contain MidgardUsername and MidgardPassword directives.", mgd_errno(), PEAR_ERROR_DIE); 
    166                 return false; 
    167             } 
    168              
    169             if (!mgd_auth_midgard($midgard_username, $midgard_password)) 
    170             { 
    171                 PEAR::raiseError("Failed to authenticate as Midgard user \"{$midgard_username}\" using credentials from configuration file \"{$init_file}\".", mgd_errno(), PEAR_ERROR_DIE); 
    172                 return false; 
    173             } 
    174              
    175             return true; 
    176         } 
     158        } 
     159         
     160        if (   is_null($midgard_username) 
     161            || is_null($midgard_password)) 
     162        { 
     163            PEAR::raiseError("Midgard configuration file \"{$init_file}\" did not contain MidgardUsername and MidgardPassword directives.", mgd_errno(), PEAR_ERROR_DIE); 
     164            return false; 
     165        } 
     166         
     167        if (!mgd_auth_midgard($midgard_username, $midgard_password)) 
     168        { 
     169            PEAR::raiseError("Failed to authenticate as Midgard user \"{$midgard_username}\" using credentials from configuration file \"{$init_file}\".", mgd_errno(), PEAR_ERROR_DIE); 
     170            return false; 
     171        } 
     172         
     173        return true; 
    177174    } 
    178175 
  • trunk/support/Role_Midgardelement/package.xml

    r4496 r5135  
    1919        <active>yes</active> 
    2020    </developer> 
    21     <date>2006-10-27</date> 
     21    <date>2007-02-01</date> 
    2222    <time>20:55:14</time> 
    2323    <version> 
    24         <release>1.1.2</release> 
     24        <release>1.1.3</release> 
    2525        <api>1.0.0</api> 
    2626    </version> 
     
    3131    <license uri="http://www.php.net/license/3_01.txt">PHP License</license> 
    3232    <notes> 
    33         Workaround for a Midgard 1.8 style multilang issue 
     33        Midgard 1.8.2 compatibility 
    3434    </notes> 
    3535    <contents>