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

    r147 r934  
    9898      
    9999     /** 
     100     Rename a workspace. 
     101 
     102     @param    oldWs     <b>string</b>  Old workspace name 
     103     @param    newws     <b>string</b>  New workspace name 
     104     @return   <b>boolean</b> 
     105     */ 
     106     public function renWorkspace($oldNs,$newNs) 
     107     { 
     108          if (!array_key_exists($oldWs, $this->workspaces) || array_key_exists($newWs, $this->workspaces)) { 
     109               return false; 
     110          } 
     111 
     112          // Rename the workspace in the workspace array 
     113          $this->workspaces[$newWs] = $this->workspaces[$oldWs]; 
     114          unset($this->workspaces[$oldWs]); 
     115 
     116          // Rename the workspace in the database 
     117          $strReq = 'UPDATE '.$this->table. 
     118               " SET pref_ws = '".$this->con->escape($newWs)."' ". 
     119               " WHERE pref_ws = '".$this->con->escape($oldWs)."' "; 
     120          $this->con->execute($strReq); 
     121          return true; 
     122     } 
     123 
     124     /** 
     125     Delete a whole workspace with all preferences pertaining to it. 
     126 
     127     @param    ws   <b>string</b>  Workspace name 
     128     @return   <b>boolean</b> 
     129     */ 
     130     public function delWorkspace($ws) 
     131     { 
     132          if (!array_key_exists($ws, $this->workspaces)) { 
     133               return false; 
     134          } 
     135 
     136          // Remove the workspace from the workspace array 
     137          unset($this->workspaces[$ws]); 
     138 
     139          // Delete all preferences from the workspace in the database 
     140          $strReq = 'DELETE FROM '.$this->table. 
     141               " WHERE pref_ws = '".$this->con->escape($ws)."' "; 
     142          $this->con->execute($strReq); 
     143          return true; 
     144     } 
     145      
     146     /** 
    100147     Returns full workspace with all prefs pertaining to it. 
    101148      
Note: See TracChangeset for help on using the changeset viewer.

Sites map