public function testReadOnlyCdnShouldProhibitRemoval() { $this->_helper->injectConfigValues(array('cdn' => array('readonly' => true))); $exception = null; try { $filename = 'wefoiejwoiejfeiowjfeowijfoewijf.txt'; $file = new Garp_File(Garp_File::TYPE_DOCUMENTS); $file->clearContext(); $file->remove($filename); } catch (Exception $e) { $exception = $e->getMessage(); } $this->assertEquals(Garp_File::EXCEPTION_CDN_READONLY, $exception); }
/** * Import content from various formats. * This action has two states; * - first a datafile is uploaded. The user is presented with a mapping interface * where they have to map columns in the datafile to columns in the database. * - then this URL is called again with the selected mapping, and the columns are * mapped and inserted into the database. * * @return Void */ public function importAction() { $memLim = ini_get('memory_limit'); ini_set('memory_limit', '2G'); set_time_limit(0); // No time limit Zend_Registry::set('CMS', true); $params = new Garp_Util_Configuration($this->getRequest()->getParams()); $params->obligate('datafile')->obligate('model')->setDefault('firstRow', 0)->setDefault('ignoreErrors', false); $importer = Garp_Content_Import_Factory::getImporter($params['datafile']); $success = false; if (isset($params['mapping'])) { $mapping = Zend_Json::decode($params['mapping']); $className = Garp_Content_Api::modelAliasToClass($params['model']); $model = new $className(); $response = array(); try { $success = !!$importer->save($model, $mapping, array('firstRow' => $params['firstRow'], 'ignoreErrors' => $params['ignoreErrors'])); } catch (Exception $e) { $response['message'] = $e->getMessage(); } if ($success) { // cleanup input file $gf = new Garp_File(); $gf->remove($params['datafile']); } $response['success'] = $success; $this->view->response = $response; } else { $std = new stdClass(); $std->success = true; $std->data = $importer->getSampleData(); $this->view->response = $std; } ini_set('memory_limit', $memLim); $this->_helper->layout->setLayout('json'); $this->renderScript('content/call.phtml'); }