Esempio n. 1
0
 public function submit()
 {
     if ($this->validateAction()) {
         $post = $this->request->request->all();
         $fsl = FileStorageLocation::getByID($post['fslID']);
         if (is_object($fsl)) {
             $fIDs = $post['fID'];
             if (is_array($fIDs)) {
                 foreach ($fIDs as $fID) {
                     $f = File::getByID($fID);
                     if (is_object($f)) {
                         $fp = new Permissions($f);
                         if ($fp->canEditFilePermissions()) {
                             try {
                                 $f->setFileStorageLocation($fsl);
                             } catch (\Exception $e) {
                                 $json = new \Concrete\Core\Application\EditResponse();
                                 $err = \Core::make('error');
                                 $err->add($e->getMessage());
                                 $json->setError($err);
                                 $json->outputJSON();
                             }
                         }
                     }
                 }
             }
         } else {
             $json = new \Concrete\Core\Application\EditResponse();
             $err = \Core::make('error');
             $err->add(t('Please select valid file storage location.'));
             $json->setError($err);
             $json->outputJSON();
         }
         $response = new EditResponse();
         $response->setFiles($this->files);
         $response->setMessage(t('File storage locations updated successfully.'));
         $response->outputJSON();
     }
 }
Esempio n. 2
0
 public function delete()
 {
     $request = \Request::getInstance();
     if (!Loader::helper('validation/token')->validate('delete')) {
         $this->error->add(Loader::helper('validation/token')->getErrorMessage());
     }
     $fsl = FileStorageLocation::getByID($request->request->get('fslID'));
     if (!is_object($fsl)) {
         $this->error->add(t('Invalid file storage location object.'));
     }
     if ($fsl->isDefault()) {
         $this->error->add(t('You may not delete the default file storage location.'));
     }
     if (!$this->error->has()) {
         $fsl->delete();
         $this->redirect('/dashboard/system/files/storage', 'storage_location_deleted');
     }
     $this->edit($request->request->get('fslID'));
 }
Esempio n. 3
0
$form = Loader::helper('form');
$r = new FileEditResponse();
$r->setFile($f);
if ($_POST['task'] == 'set_password') {
    if (!$token->validate('set_password_' . $fileID)) {
        die(t('Invalid CSRF Token.'));
    }
    $f->setPassword($_POST['fPassword']);
    $r->setMessage(t('File password saved successfully.'));
    $r->outputJSON();
}
if ($_POST['task'] == 'set_location') {
    if (!$token->validate('set_location_' . $fileID)) {
        die(t('Invalid CSRF Token.'));
    }
    $fsl = FileStorageLocation::getByID($_POST['fslID']);
    if (is_object($fsl)) {
        try {
            $f->setFileStorageLocation($fsl);
        } catch (\Exception $e) {
            $json = new \Concrete\Core\Application\EditResponse();
            $err = Core::make('error');
            $err->add($e->getMessage());
            $json->setError($err);
            $json->outputJSON();
        }
    }
    $r->setMessage(t('File storage location saved successfully.'));
    $r->outputJSON();
}
?>
 public function testGetByDefault()
 {
     $this->getStorageLocation();
     $type = Type::getByHandle('local');
     $configuration = $type->getConfigurationObject();
     StorageLocation::add($configuration, 'Other Storage');
     $location = StorageLocation::getDefault();
     $this->assertInstanceOf('\\Concrete\\Core\\File\\StorageLocation\\StorageLocation', $location);
     $this->assertEquals(true, $location->isDefault());
     $this->assertEquals('Default', $location->getName());
     $alternate = StorageLocation::getByID(2);
     $this->assertInstanceOf('\\Concrete\\Core\\File\\StorageLocation\\StorageLocation', $alternate);
     $this->assertEquals(false, $alternate->isDefault());
     $this->assertEquals('Other Storage', $alternate->getName());
 }