]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
added quota back
authorCash Costello <cash.costello@gmail.com>
Sat, 14 Jul 2012 19:50:06 +0000 (15:50 -0400)
committerCash Costello <cash.costello@gmail.com>
Sat, 14 Jul 2012 19:50:06 +0000 (15:50 -0400)
classes/TidypicsImage.php
languages/en.php
lib/upload.php
pages/photos/image/upload.php
views/default/forms/photos/admin/settings.php
views/default/forms/photos/admin/settings/main.php
views/default/forms/photos/ajax_upload.php
views/default/forms/photos/basic_upload.php
views/default/photos/sidebar.php
views/default/photos/sidebar/quota.php [new file with mode: 0644]

index 672a0df203a647b24a0e6d8ba4e171298d5a1eaa..5a8d42ccc3d3d04a4b4dab2339c49b806cce3108 100644 (file)
@@ -217,11 +217,15 @@ class TidypicsImage extends ElggFile {
                }
 
                $owner = $this->getOwnerEntity();
-               $owner->image_repo_size = (int)$owner->image_repo_size + $size;
+               $owner->image_repo_size = (int)$owner->image_repo_size + $this->size();
 
                return true;
        }
 
+       /**
+        * Need to restore sanity to this function
+        * @param type $data
+        */
        protected function checkUploadErrors($data) {
                // check for upload errors
                if ($data['error']) {
index 0fe3996f1bd9f5bd66389902c277d5dfa52aff6b..007dc57854d738cb4d377aafa58de80e086e5828 100644 (file)
@@ -71,7 +71,7 @@ $english = array(
                        'tidypics:settings:uploader' => "Use Flash uploader",
                        'tidypics:settings:grp_perm_override' => "Allow group members full access to group albums",
                        'tidypics:settings:maxfilesize' => "Maximum image size in megabytes (MB):",
-                       'tidypics:settings:quota' => "User/Group Quota (MB) - 0 equals no quota",
+                       'tidypics:settings:quota' => "User Quota (MB) - 0 equals no quota",
                        'tidypics:settings:watermark' => "Enter text to appear in the watermark",
                        'tidypics:settings:im_path' => "Enter the path to your ImageMagick commands",
                        'tidypics:settings:img_river_view' => "How many entries in activity river for each batch of uploaded images",
@@ -153,12 +153,13 @@ $english = array(
                        'album:tags' => "Tags",
                        'album:cover' => "Make image album cover?",
                        'album:cover_link' => 'Set cover image',
+                       'tidypics:title:quota' => 'Quota',
                        'tidypics:quota' => "Quota usage:",
                        'tidypics:uploader:choose' => "Choose photos",
                        'tidypics:uploader:upload' => "Upload photos",
                        'tidypics:uploader:describe' => "Describe photos",
                        'tidypics:uploader:filedesc' => 'Image files (jpeg, png, gif)',
-                       'tidypics:uploader:instructs' => 'There are three easy steps for adding photos to your album using this uploader: choosing, uploading, and describing them. If you do not have Flash, there is also a <a href="%s">basic uploader</a> available.',
+                       'tidypics:uploader:instructs' => 'There are three easy steps for adding photos to your album using this uploader: choosing, uploading, and describing them. There is a %s MB maximum per photo. If you do not have Flash, there is also a <a href="%s">basic uploader</a> available.',
                        'tidypics:uploader:basic' => 'You can upload up to 10 photos at a time (%s MB maximum per photo)',
                        'tidypics:sort:instruct' => 'Sort the album photos by dragging and dropping the images. Then click the save button.',
                        'tidypics:sort:no_images' => 'No images found to sort. Upload images using the link above.',
index 0b034517c495c5e3c7bc4ff22d809c00d20d3f40..a83323f16fe579afb31155fefe83f0fb236eec88 100644 (file)
@@ -111,9 +111,9 @@ function tp_upload_check_quota($image_size, $owner_guid) {
                // no quota
                return true;
        }
-       
-       $image_repo_size_md = get_metadata_byname($owner_guid, "image_repo_size");
-       $image_repo_size = (int)$image_repo_size_md->value;
+
+       $owner = get_entity($owner_guid);
+       $image_repo_size_md = (int)$owner->image_repo_size;
        
        return ($image_repo_size + $image_size) < $quota;
 }
\ No newline at end of file
index 3d3e67b58f6513421468a73929ffb329cdf06db3..425d5689ad426db23461e656d82b5b594439fda6 100644 (file)
@@ -52,6 +52,7 @@ $body = elgg_view_layout('content', array(
        'content' => $content,
        'title' => $title,
        'filter' => '',
+       'sidebar' => elgg_view('photos/sidebar', array('page' => 'upload')),
 ));
 
 echo elgg_view_page($title, $body);
index 7e9c17ac251636f266ab4fabd2e8121abbe522a8..403203f69ce5b410a3fc2b565bd1134d8faf9aff 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * Tidypics admin settings form body
  *
- * @todo watermark, quota, remove original image, group only upload not delete
+ * @todo remove original image, group only upload not delete
  */
 
 $plugin = elgg_get_plugin_from_id('tidypics');
@@ -24,15 +24,3 @@ $content = elgg_view('forms/photos/admin/settings/thumbnails', array('plugin' =>
 echo elgg_view_module('inline', $title, $content);
 
 echo elgg_view('input/submit', array('value' => elgg_echo("save")));
-
-return true;
-
-
-// Quota Size
-$quota = $plugin->quota;
-if (!$quota) {
-       $quota = 0;
-}
-$form_body .= "<p>" . elgg_echo('tidypics:settings:quota') . "<br />";
-$form_body .= elgg_view("input/text",array('internalname' => 'params[quota]', 'value' => $quota)) . "</p>";
-
index 352a9c5a15defef61582c0f10ba242039d500d70..c99b9d68840e1221cda506bbc427525b729297de 100644 (file)
@@ -34,3 +34,15 @@ echo elgg_view("input/text", array(
        'value' => $plugin->watermark_text,
 ));
 echo '</div>';
+
+// Quota Size
+$quota = $plugin->quota;
+if (!$quota) {
+       $quota = 0;
+}
+echo '<div>' . elgg_echo('tidypics:settings:quota');
+echo elgg_view('input/text', array(
+       'name' => 'params[quota]',
+       'value' => $quota,
+));
+echo '</div>';
index be25d628eec4fb45af8459301820e7629271211a..3ab578a38ff046f2ebd678a02e2ecd47880c9d72 100644 (file)
@@ -17,26 +17,13 @@ if (!$maxfilesize) {
        $maxfilesize = 5;
 }
 
-$quota = elgg_get_plugin_setting('quota', 'tidypics');
-if ($quota) {
-       $image_repo_size_md = get_metadata_byname($album->container_guid, "image_repo_size");
-       $image_repo_size = (int)$image_repo_size_md->value;
-       $image_repo_size = $image_repo_size / 1024 / 1024;
-       $quote_percentage = round(100 * ($image_repo_size / $quota));
-       // for small quotas, so one decimal place
-       if ($quota < 10) {
-               $image_repo_size = sprintf('%.1f', $image_repo_size);
-       } else {
-               $image_repo_size = round($image_repo_size);
-       }
-       if ($image_repo_size > $quota) {
-               $image_repo_size = $quota;
-       }
-}
-
 ?>
 
-<p><?php echo elgg_echo('tidypics:uploader:instructs', array($basic_uploader_url)); ?></p>
+<p>
+<?php
+       echo elgg_echo('tidypics:uploader:instructs', array($maxfilesize, $basic_uploader_url));
+?>
+</p>
 
 <ul id="tidypics-uploader-steps">
        <li class="mbm">
index e4535814ba66f3c2da65970023dfb8b27904e870..ba849d1b4867eacbc0a19ba6984cad34fec58b89 100644 (file)
@@ -15,33 +15,6 @@ $album = $vars['entity'];
 $access_id = $album->access_id;
 
 $maxfilesize = (float) elgg_get_plugin_setting('maxfilesize', 'tidypics');
-$quota = elgg_get_plugin_setting('quota', 'tidypics');
-/*
-if ($quota) {
-       $image_repo_size_md = get_metadata_byname($album->container_guid, "image_repo_size");
-       $image_repo_size = (int)$image_repo_size_md->value;
-       $image_repo_size = $image_repo_size / 1024 / 1024;
-       $quote_percentage = round(100 * ($image_repo_size / $quota));
-       // for small quotas, so one decimal place
-       if ($quota < 10) {
-               $image_repo_size = sprintf('%.1f', $image_repo_size);
-       } else {
-               $image_repo_size = round($image_repo_size);
-       }
-       if ($image_repo_size > $quota) {
-               $image_repo_size = $quota;
-       }
-}
-               <?php
-               if ($quota) {
-                       ?>
-               <i><?php echo elgg_echo("tidypics:quota") . ' ' . $image_repo_size . '/' . $quota . " MB ({$quote_percentage}%)"; ?></i><br />
-                       <?php
-               }
-               ?>
-
- *
-*/
 
 $instructions = elgg_echo("tidypics:uploader:upload");
 $max = elgg_echo('tidypics:uploader:basic', array($maxfilesize));
index 4c0feb72c4fef31e108157a8b6fb0dadb5adc3eb..fd5202691e3f4f643247898b25e5aa8dfcf17cb2 100644 (file)
@@ -10,3 +10,9 @@ if ($image && $page == 'view') {
                echo elgg_view('photos/sidebar/exif', $vars);
        }
 }
+
+if ($page == 'upload') {
+       if (elgg_get_plugin_setting('quota', 'tidypics')) {
+               echo elgg_view('photos/sidebar/quota', $vars);
+       }
+}
\ No newline at end of file
diff --git a/views/default/photos/sidebar/quota.php b/views/default/photos/sidebar/quota.php
new file mode 100644 (file)
index 0000000..16b7885
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+/**
+ * User quota
+ */
+
+$user = elgg_get_logged_in_user_entity();
+
+
+$quota = elgg_get_plugin_setting('quota', 'tidypics');
+if ($quota) {
+       $image_repo_size = (int)$user->image_repo_size;
+       $image_repo_size = $image_repo_size / 1024 / 1024;
+       $quote_percentage = round(100 * ($image_repo_size / $quota));
+       // for small quotas, so one decimal place
+       if ($quota < 10) {
+               $image_repo_size = sprintf('%.1f', $image_repo_size);
+       } else {
+               $image_repo_size = round($image_repo_size);
+       }
+       if ($image_repo_size > $quota) {
+               $image_repo_size = $quota;
+       }
+
+       $title = elgg_echo('tidypics:title:quota');
+       $body = elgg_echo("tidypics:quota") . ' ' . $image_repo_size . '/' . $quota . " MB ({$quote_percentage}%)";
+       echo elgg_view_module('aside', $title, $body);
+}