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.workspace.php

    r147 r934  
    263263          } 
    264264     } 
     265 
     266     /** 
     267     Rename an existing pref in a Workspace 
     268 
     269     @param    $oldId    <b>string</b>  Current pref name 
     270     @param    $newId    <b>string</b>  New pref name 
     271     @return   <b>boolean</b> 
     272     */ 
     273     public function rename($oldId,$newId) 
     274     { 
     275          if (!$this->ws) { 
     276               throw new Exception(__('No workspace specified')); 
     277          } 
     278           
     279          if (!array_key_exists($oldId,$this->prefs) || array_key_exists($newId,$this->prefs)) { 
     280               return false; 
     281          } 
     282 
     283          // Rename the pref in the prefs array 
     284          $this->prefs[$newId] = $this->prefs[$oldId]; 
     285          unset($this->prefs[$oldId]); 
     286 
     287          // Rename the pref in the database 
     288          $strReq = 'UPDATE '.$this->table. 
     289               " SET pref_id = '".$this->con->escape($newId)."' ". 
     290               " WHERE pref_ws = '".$this->con->escape($this->ws)."' ". 
     291               " AND pref_id = '".$this->con->escape($oldId)."' "; 
     292          $this->con->execute($strReq); 
     293          return true; 
     294     } 
    265295      
    266296     /** 
Note: See TracChangeset for help on using the changeset viewer.

Sites map