Author: david
Date: Fri Sep 23 16:05:44 2011
New Revision: 9809

Log:
Remove upload code

Modified:
   trunk/apps/qubit/modules/digitalobject/actions/editAction.class.php

Modified: trunk/apps/qubit/modules/digitalobject/actions/editAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/actions/editAction.class.php Fri Sep 
23 15:56:52 2011        (r9808)
+++ trunk/apps/qubit/modules/digitalobject/actions/editAction.class.php Fri Sep 
23 16:05:44 2011        (r9809)
@@ -125,86 +125,28 @@
     $this->form = new sfForm;
     $this->form->getValidatorSchema()->setOption('allow_extra_fields', true);
 
-    $this->resource = new QubitDigitalObject;
+    $this->resource = $this->getRoute()->resource;
 
-    $this->informationObject = new QubitInformationObject;
-
-    // If digital object already exists (template: edit)
-    if (isset($this->getRoute()->resource))
+    // Check that resource exists
+    if (!isset($this->resource))
     {
-      $this->resource = $this->getRoute()->resource;
-
-      $this->informationObject = $this->resource->informationObject;
-
-      // Check user authorization
-      if (!QubitAcl::check($this->informationObject, 'update'))
-      {
-        QubitAcl::forwardUnauthorized();
-      }
-
-      // Get representations
-      $this->representations = array(
-        QubitTerm::REFERENCE_ID => 
$this->resource->getChildByUsageId(QubitTerm::REFERENCE_ID),
-        QubitTerm::THUMBNAIL_ID => 
$this->resource->getChildByUsageId(QubitTerm::THUMBNAIL_ID));
-
-      $this->addFormFields();
+      $this->forward404();
     }
 
-    // Upload a new digital object (template: uploadForm)
-    else
-    {
-      $this->informationObject = 
QubitInformationObject::getById($request->informationObject);
-
-      // Check that object exists and that it is not the root
-      if (!isset($this->informationObject) || 
!isset($this->informationObject->parent))
-      {
-        $this->forward404();
-      }
-
-      // Check if already exists a digital object
-      if (null !== $digitalObject = 
$this->informationObject->getDigitalObject())
-      {
-        $this->redirect(array($digitalObject, 'module' => 'digitalobject', 
'action' => 'edit'));
-      }
-
-      // Check user authorization
-      if (!QubitAcl::check($this->informationObject, 'update'))
-      {
-        QubitAcl::forwardUnauthorized();
-      }
-
-      // Check repository file upload limit
-      $repo = $this->informationObject->getRepository(array('inherit' => 
true));
-      if (null !== $repo
-        && $repo->uploadLimit != -1
-        && $repo->getDiskUsage(array('units' => 'G')) >= 
floatval($repo->uploadLimit))
-      {
-        $this->redirect(array($repo, 'module' => 'repository', 'action' => 
'uploadLimitExceeded'));
-      }
+    $this->informationObject = $this->resource->informationObject;
 
-      // Single upload
-      if (0 < count($request->getFiles()))
-      {
-        $this->form->setValidator('file', new sfValidatorFile);
-      }
-
-      $this->form->setWidget('file', new sfWidgetFormInputFile);
-
-      // URL
-      if (isset($request->url) && 'http://' != $request->url)
-      {
-        $this->form->setValidator('url', new sfValidatorUrl);
-      }
-
-      $this->form->setDefault('url', 'http://');
-      $this->form->setWidget('url', new sfWidgetFormInput);
+    // Check user authorization
+    if (!QubitAcl::check($this->informationObject, 'update'))
+    {
+      QubitAcl::forwardUnauthorized();
+    }
 
-      $this->form->setValidator('informationObject', new sfValidatorInteger);
-      $this->form->setWidget('informationObject', new sfWidgetFormInputHidden);
-      $this->form->setDefault('informationObject', 
$this->informationObject->id);
+    // Get representations
+    $this->representations = array(
+      QubitTerm::REFERENCE_ID => 
$this->resource->getChildByUsageId(QubitTerm::REFERENCE_ID),
+      QubitTerm::THUMBNAIL_ID => 
$this->resource->getChildByUsageId(QubitTerm::THUMBNAIL_ID));
 
-      $this->setTemplate('uploadForm');
-    }
+    $this->addFormFields();
 
     // Process forms
     if ($request->isMethod('post'))
@@ -212,46 +154,13 @@
       $this->form->bind($request->getPostParameters(), $request->getFiles());
       if ($this->form->isValid())
       {
-        if (null !== $this->form->getValue('file') || null !== 
$this->form->getValue('url'))
-        {
-          // Process single-upload form
-          $this->processUploadForm();
-        }
-        else
-        {
-          // Process update form
-          $this->processUpdateForm();
-        }
-      }
-    }
-  }
+        $this->processForm();
 
-  /**
-   * Upload the asset selected by user and create a digital object with 
appropriate
-   * representations.
-   *
-   * @return DigitalObjectEditAction this action
-   */
-  public function processUploadForm()
-  {
-    if (null !== $this->form->getValue('file'))
-    {
-      $name = $this->form->getValue('file')->getOriginalName();
-      $content = 
file_get_contents($this->form->getValue('file')->getTempName());
+        $this->resource->save();
 
-      $this->resource->assets[] = new QubitAsset($name, $content);
-      $this->resource->usageId = QubitTerm::MASTER_ID;
-    }
-    else if (null !== $this->form->getValue('url'))
-    {
-      $this->resource->importFromURI($this->form->getValue('url'));
+        $this->redirect(array($this->informationObject, 'module' => 
'informationobject'));
+      }
     }
-
-    $this->informationObject->digitalObjects[] = $this->resource;
-
-    $this->informationObject->save();
-
-    $this->redirect(array($this->informationObject, 'module' => 
'informationobject'));
   }
 
   /**
@@ -259,7 +168,7 @@
    *
    * @return DigitalObjectEditAction this action
    */
-  public function processUpdateForm()
+  public function processForm()
   {
     // Set property 'displayAsCompound'
     
$this->resource->setDisplayAsCompoundObject($this->form->getValue('displayAsCompound'));
@@ -331,9 +240,5 @@
     {
       $this->resource->createThumbnail();
     }
-
-    $this->resource->save();
-
-    $this->redirect(array($this->informationObject, 'module' => 
'informationobject'));
   }
 }

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to