Author: david
Date: Tue Sep  6 12:09:24 2011
New Revision: 9670

Log:
Check and handle upload limit exceeded condition for repository. Refs issue 
#2023

Added:
   
trunk/apps/qubit/modules/repository/actions/uploadLimitExceededAction.class.php 
  (contents, props changed)
   trunk/apps/qubit/modules/repository/templates/uploadLimitExceededSuccess.php 
  (contents, props changed)
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 Tue Sep 
 6 12:07:10 2011        (r9669)
+++ trunk/apps/qubit/modules/digitalobject/actions/editAction.class.php Tue Sep 
 6 12:09:24 2011        (r9670)
@@ -173,6 +173,15 @@
         QubitAcl::forwardUnauthorized();
       }
 
+      // Check repository file upload limit
+      var_dump($this->informationObject->getRepository(array('inherit' => 
true))->id);
+      if (null !== ($repo = 
$this->informationObject->getRepository(array('inherit' => true))))
+        && $repo->uploadLimit != -1
+        && $repo->getDiskUsage() >= $repo->uploadLimit)
+      {
+        $this->redirect(array($repo, 'module' => 'repository', 'action' => 
'uploadLimitExceeded'));
+      }
+
       // Single upload
       if (0 < count($request->getFiles()))
       {

Added: 
trunk/apps/qubit/modules/repository/actions/uploadLimitExceededAction.class.php
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ 
trunk/apps/qubit/modules/repository/actions/uploadLimitExceededAction.class.php 
    Tue Sep  6 12:09:24 2011        (r9670)
@@ -0,0 +1,39 @@
+<?php
+
+/*
+ * This file is part of Qubit Toolkit.
+ *
+ * Qubit Toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Qubit Toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Qubit Toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * Display warning when repository upload limit is exceeded
+ *
+ * @package    qubit
+ * @subpackage repository
+ * @author     david juhasz <[email protected]>
+ * @version    SVN: $Id$
+ */
+class RepositoryUploadLimitExceededAction extends sfAction
+{
+  public function execute($request)
+  {
+    $this->resource = null;
+
+    if (isset($this->getRoute()->resource))
+    {
+      $this->resource = $this->getRoute()->resource;
+    }
+  }
+}

Added: 
trunk/apps/qubit/modules/repository/templates/uploadLimitExceededSuccess.php
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ 
trunk/apps/qubit/modules/repository/templates/uploadLimitExceededSuccess.php    
    Tue Sep  6 12:09:24 2011        (r9670)
@@ -0,0 +1,32 @@
+<h1><?php echo __('Upload limit exceeded') ?></h1>
+
+<div class="messages error">
+  <?php echo __('The upload limit of %1% GB for <a href="%2%">%3%</a> has been 
exceeded (%4% GB currently used)', array(
+    '%1%' => $resource->uploadLimit,
+    '%2%' => url_for(array($resource, 'module' => 'repository')),
+    '%3%' => $resource->__toString(),
+    '%4%' => $resource->getDiskUsage(array('units' => 'G')))) ?>
+</div>
+
+<div>
+  <?php echo __('To upload a new digital object') ?>
+  <ul>
+    <li><?php echo __('Email your system administrator &lt;<a 
href="mailto:%1%";>%1%</a>&gt; and request a larger upload limit', array('%1%' 
=> sfConfig::get('app_adminstrator_email'))) ?></li>
+    <li><?php echo __('Delete <a href="%1%">existing digital objects</a> to 
reduce disk usage', array('%1%' => url_for(array(null, 'module' => 'search', 
'query' => '+repositorySlug:'.$resource->slug.' +digitalObject:true')))) ?></li>
+  </ul>
+</div>
+
+
+  <div class="actions section">
+
+    <h2 class="element-invisible"><?php echo __('Actions') ?></h2>
+
+    <div class="content">
+      <ul class="clearfix links">
+        <li><a href="#" onClick="history.back(); return false;"><?php echo 
__('Back') ?></a></li>
+      </ul>
+    </div>
+
+  </div>
+
+</form>

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