Changeset 13968

Show
Ignore:
Timestamp:
12/18/07 15:50:47 (10 months ago)
Author:
flack
Message:

export all writable snippetdirs in the current sitegroup, not just sitegroup-config

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/midcom.helper.filesync/exporter/snippet.php

    r13886 r13968  
    1616{ 
    1717    var $root_dir = ''; 
    18      
     18 
    1919    function midcom_helper_filesync_exporter_snippet() 
    2020    { 
    2121        parent::midcom_helper_filesync_exporter(); 
    22          
     22 
    2323        $this->root_dir = midcom_helper_filesync_interface::prepare_dir('snippets'); 
    2424    } 
    25      
     25 
    2626    function read_snippetdir($snippetdir, $path) 
    2727    { 
     
    3131            mkdir($snippetdir_path); 
    3232        } 
    33          
     33 
    3434        $snippet_qb = midcom_baseclasses_database_snippet::new_query_builder(); 
    3535        $snippet_qb->add_constraint('up', '=', $snippetdir->id); 
     
    3737        foreach ($snippets as $snippet) 
    3838        { 
    39             // TODO: Multilang support?      
     39            // TODO: Multilang support? 
    4040            file_put_contents("{$snippetdir_path}/{$snippet->name}.php", $snippet->code); 
    41              
     41 
    4242            if (!empty($snippet->doc)) 
    4343            { 
     
    4545            } 
    4646        } 
    47          
     47 
    4848        $dir_qb = midcom_baseclasses_database_snippetdir::new_query_builder(); 
    4949        $dir_qb->add_constraint('up', '=', $snippetdir->id); 
     
    5454        } 
    5555    } 
    56      
    57     function read_root($snippetpath) 
    58     { 
    59         $snippetdir = new midcom_baseclasses_database_snippetdir(); 
    60         $snippetdir->get_by_path($snippetpath); 
    61         if (!$snippetdir->guid) 
    62         { 
    63             return null; 
    64         } 
    65          
    66         $this->read_snippetdir($snippetdir, $this->root_dir); 
    67     } 
    68   
     56 
    6957    function export() 
    7058    { 
    71         $this->read_root($GLOBALS['midcom_config']['midcom_sgconfig_basedir']); 
     59      $qb = midcom_baseclasses_database_snippetdir::new_query_builder(); 
     60      $qb->add_constraint('up', '=', 0); 
     61      $qb->add_constraint('sitegroup', '=', $_MIDCOM->midgard->sitegroup); 
     62      $rootdirs = $qb->execute(); 
     63      foreach ($rootdirs as $rootdir) 
     64      { 
     65          if ($_MIDCOM->auth->can_do('midgard:update', $rootdir)) 
     66          { 
     67              $this->read_snippetdir($rootdir, $this->root_dir); 
     68          } 
     69      } 
    7270    } 
     71 
    7372} 
    7473?>