Author: david
Date: Fri Sep 23 14:51:25 2011
New Revision: 9805

Log:
Test if information object is linked to a repository. Fixes issue 2087.

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

Modified: trunk/apps/qubit/modules/digitalobject/actions/uploadAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/actions/uploadAction.class.php       
Fri Sep 23 14:47:33 2011        (r9804)
+++ trunk/apps/qubit/modules/digitalobject/actions/uploadAction.class.php       
Fri Sep 23 14:51:25 2011        (r9805)
@@ -21,6 +21,12 @@
 {
   public function execute($request)
   {
+    ProjectConfiguration::getActive()->loadHelpers('Qubit');
+
+    $uploadLimt = 0;
+    $uploadFiles = array();
+    $warning = null;
+
     $this->informationObject = 
QubitInformationObject::getById($request->informationObjectId);
 
     if (!isset($this->informationObject))
@@ -36,17 +42,15 @@
 
     $repo = $this->informationObject->getRepository(array('inherit' => true));
 
-    $uploadLimit = $repo->uploadLimit;
-    if (0 < $uploadLimit)
+    if (isset($repo))
     {
-      $uploadLimit *= pow(10,9); // Convert to bytes
+      $uploadLimit = $repo->uploadLimit;
+      if (0 < $uploadLimit)
+      {
+        $uploadLimit *= pow(10,9); // Convert to bytes
+      }
     }
 
-    ProjectConfiguration::getActive()->loadHelpers('Qubit');
-
-    $uploadFiles = array();
-    $warning = null;
-
     // Create tmp dir, if it doesn't exist already
     $tmpDir = sfConfig::get('sf_upload_dir').'/tmp';
     if (!file_exists($tmpDir))
@@ -57,7 +61,7 @@
 
     foreach ($_FILES as $file)
     {
-      if (0 <= $uploadLimit && $uploadLimit < $repo->getDiskUsage() + 
$file['size'])
+      if (null != $repo && 0 <= $uploadLimit && $uploadLimit < 
$repo->getDiskUsage() + $file['size'])
       {
         $uploadFiles = array('error' => $this->context->i18n->__(
           '%1% upload limit of %2% GB exceeded for %3%', array(

-- 
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