aboutsummaryrefslogtreecommitdiffstats
path: root/mod/photos.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/photos.php')
-rw-r--r--mod/photos.php45
1 files changed, 42 insertions, 3 deletions
diff --git a/mod/photos.php b/mod/photos.php
index d96bc135e..624f0bdca 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -38,8 +38,10 @@ function photos_init(&$a) {
$o .= '<div class="fn">' . $a->data['user']['username'] . '</div>';
$o .= '<div id="profile-photo-wrapper"><img class="photo" style="width: 175px; height: 175px;" src="' . $a->get_cached_avatar_image($a->get_baseurl() . '/photo/profile/' . $a->data['user']['uid'] . '.jpg') . '" alt="' . $a->data['user']['username'] . '" /></div>';
$o .= '</div>';
-
- if(! intval($a->data['user']['hidewall'])) {
+
+ $albums_visible = ((intval($a->data['user']['hidewall']) && (! local_user()) && (! remote_user())) ? false : true);
+
+ if($albums_visible) {
$o .= '<div id="side-bar-photos-albums" class="widget">';
$o .= '<h3>' . '<a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '">' . t('Photo Albums') . '</a></h3>';
@@ -709,6 +711,24 @@ function photos_post(&$a) {
logger('mod/photos.php: photos_post(): loading the contents of ' . $src , LOGGER_DEBUG);
$imagedata = @file_get_contents($src);
+
+
+
+ $r = q("select sum(octet_length(data)) as total from photo where uid = %d and scale = 0 and album != 'Contact Photos' ",
+ intval($a->data['user']['uid'])
+ );
+
+ $limit = service_class_fetch($a->data['user']['uid'],'photo_upload_limit');
+
+ if(($limit !== false) && (($r[0]['total'] + strlen($imagedata)) > $limit)) {
+ notice( upgrade_message() . EOL );
+ @unlink($src);
+ $foo = 0;
+ call_hooks('photo_post_end',$foo);
+ killme();
+ }
+
+
$ph = new Photo($imagedata, $type);
if(! $ph->is_valid()) {
@@ -723,6 +743,12 @@ function photos_post(&$a) {
$ph->orient($src);
@unlink($src);
+ $max_length = get_config('system','max_image_length');
+ if(! $max_length)
+ $max_length = MAX_IMAGE_LENGTH;
+ if($max_length > 0)
+ $ph->scaleImage($max_length);
+
$width = $ph->getWidth();
$height = $ph->getHeight();
@@ -966,12 +992,25 @@ function photos_content(&$a) {
<input type="submit" name="submit" value="' . t('Submit') . '" id="photos-upload-submit" /> </div>';
-
+ $r = q("select sum(octet_length(data)) as total from photo where uid = %d and scale = 0 and album != 'Contact Photos' ",
+ intval($a->data['user']['uid'])
+ );
+
+
+ $limit = service_class_fetch($a->data['user']['uid'],'photo_upload_limit');
+ if($limit !== false) {
+ $usage_message = sprintf( t("You have used %1$.2f Mbytes of %2$.2f Mbytes photo storage."), $r[0]['total'] / 1024000, $limit / 1024000 );
+ }
+ else {
+ $usage_message = sprintf( t('You have used %1$.2f Mbytes of photo storage.'), $r[0]['total'] / 1024000 );
+ }
+
$tpl = get_markup_template('photos_upload.tpl');
$o .= replace_macros($tpl,array(
'$pagename' => t('Upload Photos'),
'$sessid' => session_id(),
+ '$usage' => $usage_message,
'$nickname' => $a->data['user']['nickname'],
'$newalbum' => t('New album name: '),
'$existalbumtext' => t('or existing album name: '),