This is the API documentation for concrete5 version 5.6 and earlier. View Current API Documentation
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 
<?php
defined('C5_EXECUTE') or die("Access Denied.");
class Concrete5_Controller_Dashboard_System_Environment_FileStorageLocations extends DashboardBaseController {

    var $helpers = array('form','concrete/interface','validation/token', 'concrete/file');
    
    public function view($updated=false) {
        $helper_file = Loader::helper('concrete/file');
        Loader::model('file_storage_location');
        $fsl = FileStorageLocation::getByID(FileStorageLocation::ALTERNATE_ID);
        if (is_object($fsl)) {
            $this->set('fsl', $fsl);
            $this->set('fslName', $fsl->getName());
            $this->set('fslDirectory', $fsl->getDirectory());
        }
    }
    

    public function storage_saved() {
        $this->set('message', t('File storage locations saved.'));
        $this->view();
    }

    public function storage_deleted() {
        $this->set('message', t('File storage location removed. Files using this location have been reset.'));
        $this->view();
    }

    public function save(){
        $helper_file = Loader::helper('concrete/file');
        $validation_token = Loader::helper('validation/token');
        Loader::model('file_storage_location');
        
        if (!$validation_token->validate("file_storage")) {
            $this->set('error', array($validation_token->getErrorMessage()));
            return;
        }

        if ($_POST['delete']) {

            $fsl = FileStorageLocation::getByID(FileStorageLocation::ALTERNATE_ID);
            if (is_object($fsl)) {
                $fsl->delete();
                $this->redirect('/dashboard/system/environment/file_storage_locations','storage_deleted');
            }

        } else {
            
            Config::save('DIR_FILES_UPLOADED', $this->post('DIR_FILES_UPLOADED'));

            if ($this->post('fslName') != '' && $this->post('fslDirectory') != '') {
                $fsl = FileStorageLocation::getByID(FileStorageLocation::ALTERNATE_ID);
                if (!is_object($fsl)) {
                    FileStorageLocation::add($this->post('fslName'), $this->post('fslDirectory'), FileStorageLocation::ALTERNATE_ID);
                } else {
                    $fsl->update($this->post('fslName'), $this->post('fslDirectory'));
                }           
            }

            $this->redirect('/dashboard/system/environment/file_storage_locations','storage_saved');
        }
    }
    
}