Dotclear


Ignore:
Timestamp:
10/29/12 14:46:58 (13 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Add some methods to namespaces (settings) and workspaces (prefs), conservative way, partially fixes #794. Thanks zeiram for patches

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/core/class.dc.settings.php

    r301 r934  
    9292          return $this->namespaces[$ns]; 
    9393     } 
     94 
     95     /** 
     96     Rename a namespace. 
     97 
     98     @param    oldNs     <b>string</b>  Old namespace name 
     99     @param    newNs     <b>string</b>  New namespace name 
     100     @return   <b>boolean</b> 
     101     */ 
     102     public function renNamespace($oldNs,$newNs) 
     103     { 
     104          if (!array_key_exists($oldNs, $this->namespaces) || array_key_exists($newNs, $this->namespaces)) { 
     105               return false; 
     106          } 
     107 
     108          // Rename the namespace in the namespace array 
     109          $this->namespaces[$newNs] = $this->namespaces[$oldNs]; 
     110          unset($this->namespaces[$oldNs]); 
     111 
     112          // Rename the namespace in the database 
     113          $strReq = 'UPDATE '.$this->table. 
     114               " SET setting_ns = '".$this->con->escape($newNs)."' ". 
     115               " WHERE setting_ns = '".$this->con->escape($oldNs)."' "; 
     116          $this->con->execute($strReq); 
     117          return true; 
     118     } 
     119 
     120     /** 
     121     Delete a whole namespace with all settings pertaining to it. 
     122 
     123     @param    ns   <b>string</b>  Namespace name 
     124     @return   <b>boolean</b> 
     125     */ 
     126     public function delNamespace($ns) 
     127     { 
     128          if (!array_key_exists($ns, $this->namespaces)) { 
     129               return false; 
     130          } 
     131 
     132          // Remove the namespace from the namespace array 
     133          unset($this->namespaces[$ns]); 
     134 
     135          // Delete all settings from the namespace in the database 
     136          $strReq = 'DELETE FROM '.$this->table. 
     137               " WHERE setting_ns = '".$this->con->escape($ns)."' "; 
     138          $this->con->execute($strReq); 
     139          return true; 
     140     } 
    94141      
    95142     /** 
Note: See TracChangeset for help on using the changeset viewer.

Sites map