Assembla home | Assembla project page
 
Show
Ignore:
Timestamp:
07/04/08 02:17:44 (3 months ago)
Author:
Slynderdale
Message:

Fixed a bug in Set that adds quotes about the value that gets set to the INI value.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Phergie/Plugin/Set.php

    r223 r260  
    3434            if (preg_match('#^(' . str_replace('.', '\\.', $var) . '\s*= *)(.*)$#im', $contents, $m)) { 
    3535                $contents = preg_replace('#^' . str_replace('.', '\\.', $var) . '\s*=.*$#im', $var . ' = ' . str_replace('$', '\\$', $this->makeIniValue($value, $m[2], $append)), $contents); 
    36                 $this->setIni($var, $this->parseIniValue($this->makeIniValue($value, $m[2], $append))); 
    37                 $this->doNotice($user, 'Updated Setting: ' . $var . ' = ' . $this->getIni($var)); 
     36                $this->setIni($var, $this->parseIniValue($this->makeIniValue($value, $m[2], $append, true))); 
     37                $this->doNotice($user, 'Updated Setting: ' . $var . ' = ' . $this->makeIniValue($this->getIni($var))); 
    3838            // Insert it if not set 
    3939            } else { 
    4040                $contents .= PHP_EOL . $var . ' = ' . $this->makeIniValue($value); 
    4141                $this->setIni($var, $this->parseIniValue($value)); 
    42                 $this->doNotice($user, 'Inserted Setting: ' . $var . ' = ' . $this->getIni($var)); 
     42                $this->doNotice($user, 'Inserted Setting: ' . $var . ' = ' . $this->makeIniValue($this->getIni($var))); 
    4343            } 
    4444            // Save ini file 
     
    5656        $user = $this->event->getNick(); 
    5757        if ($this->fromAdmin(true)) { 
    58             $this->doPrivmsg($this->event->getSource(), $var . ' = ' . $this->getIni($var)); 
     58            $this->doNotice($user, $var . ' = ' . $this->makeIniValue($this->getIni($var))); 
    5959        } else { 
    6060            $this->doNotice($user, 'You do not have permission to get any settings.'); 
     
    6565     * Builds a ini value 
    6666     */ 
    67     protected function makeIniValue($new, $old = "", $append = false
     67    protected function makeIniValue($new, $old = "", $append = false, $noquotes = false
    6868    { 
    6969        $new = trim($new, "\" '"); 
     
    7171 
    7272        if ($append && !empty($old)) { 
    73             return '"' . $old . ', ' . $new . '"'
     73            return ($noquotes?'':'"') . $old . ', ' . $new . ($noquotes?'':'"')
    7474        } 
    7575 
     
    8181            return (strtolower($new) != 'null' ? $new : ''); 
    8282        } else { 
    83             return '"' . $new . '"'
     83            return ($noquotes?'':'"') . $new . ($noquotes?'':'"')
    8484        } 
    8585    }