Changeset 2185

Show
Ignore:
Timestamp:
07/15/08 20:31:00 (5 months ago)
Author:
ringmaster
Message:

If Habari fails to create the "files" directory or verify that the Simple File Silo can write files to it, don't allow the plugin to activate in addition to producing the error. Fixes #425, provided by arthus.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/htdocs/system/plugins/simplefilesilo/simplefilesilo.plugin.php

    r2137 r2185  
    4141        $this->root= $user_path . 'files'; //Options::get('simple_file_root'); 
    4242        $this->url= Site::get_url('user', true) . 'files';  //Options::get('simple_file_url'); 
    43         /* Check for the existence of the files directory */ 
     43         
     44        if (! $this->check_files()) { 
     45            Session::error( "Web server does not have permission to create 'files' directory for SimpleFile Media Silo." ); 
     46            Plugins::deactivate_plugin(__FILE__); //Deactivate plugin 
     47            Utils::redirect(); //Refresh page � unfortunately, if not done so then results don't appear 
     48        } 
     49    } 
     50     
     51    /** 
     52     * Checks if files directory is usable 
     53     */ 
     54    private function check_files() { 
     55        $user_path= HABARI_PATH . '/' . Site::get_path('user', true); 
     56        $this->root= $user_path . 'files'; //Options::get('simple_file_root'); 
     57        $this->url= Site::get_url('user', true) . 'files';  //Options::get('simple_file_url'); 
     58         
    4459        if ( ! is_dir( $this->root ) ) { 
    4560            if ( is_writable( $user_path ) ) { 
    4661                mkdir( $this->root, 0766 ); 
    4762            } else { 
    48                 Session::error( "Web server does not have permission to create 'files' directory for SimpleFile Media Silo." ); 
    49             } 
    50         } 
    51  
    52     } 
    53  
     63                return false; 
     64            } 
     65        } 
     66         
     67        return true; 
     68    } 
     69     
    5470    /** 
    5571     * Return basic information about this silo