aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2016-10-17 22:09:41 -0700
committerzotlabs <mike@macgirvin.com>2016-10-17 22:09:41 -0700
commit17091bd38c4e4e5d8b1812dd1d9efeffe0046d02 (patch)
tree74a4d72846767c58d26b113b14de3da4dd0fb0c0
parent437aa168d136db2c782ed2b366e411721f5f605c (diff)
downloadvolse-hubzilla-17091bd38c4e4e5d8b1812dd1d9efeffe0046d02.tar.gz
volse-hubzilla-17091bd38c4e4e5d8b1812dd1d9efeffe0046d02.tar.bz2
volse-hubzilla-17091bd38c4e4e5d8b1812dd1d9efeffe0046d02.zip
add get_photo hook to go along with get_profile_photo hook. This allows a plugin to over-ride the permissions for cover photos or insert a different photo in place of that requested
-rw-r--r--Zotlabs/Lib/Enotify.php3
-rw-r--r--Zotlabs/Module/Photo.php23
-rw-r--r--doc/hook/get_photo.bb14
-rw-r--r--doc/hooklist.bb3
4 files changed, 29 insertions, 14 deletions
diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php
index 9b4117b9c..ffe2f0950 100644
--- a/Zotlabs/Lib/Enotify.php
+++ b/Zotlabs/Lib/Enotify.php
@@ -78,15 +78,12 @@ class Enotify {
$sender_email = get_config('system','from_email');
if(! $sender_email)
$sender_email = 'Administrator' . '@' . \App::get_hostname();
-
$sender_name = get_config('system','from_email_name');
if(! $sender_name)
$sender_name = \Zotlabs\Lib\System::get_site_name();
-
-
$additional_mail_header = "";
if(array_key_exists('item', $params)) {
diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php
index 1134f4275..256a51e71 100644
--- a/Zotlabs/Module/Photo.php
+++ b/Zotlabs/Module/Photo.php
@@ -127,17 +127,7 @@ class Photo extends \Zotlabs\Web\Controller {
}
}
- // If using resolution 1, make sure it exists before proceeding:
- if($resolution == 1) {
- $r = q("SELECT uid FROM photo WHERE resource_id = '%s' AND imgscale = %d LIMIT 1",
- dbesc($photo),
- intval($resolution)
- );
- if(! $r) {
- $resolution = 2;
- }
- }
-
+
$r = q("SELECT uid FROM photo WHERE resource_id = '%s' AND imgscale = %d LIMIT 1",
dbesc($photo),
intval($resolution)
@@ -166,6 +156,14 @@ class Photo extends \Zotlabs\Web\Controller {
intval($resolution)
);
+ $d = [ 'imgscale' => $resolution, 'resource_id' => $photo, 'photo' => $r, 'allowed' => $allowed ];
+ call_hooks('get_photo',$d);
+
+ $resolution = $d['imgscale'];
+ $photo = $d['resource_id'];
+ $r = $d['photo'];
+ $allowed = $d['allowed'];
+
if($r && $allowed) {
$data = dbunescbin($r[0]['content']);
$mimetype = $r[0]['mimetype'];
@@ -200,6 +198,9 @@ class Photo extends \Zotlabs\Web\Controller {
}
}
+
+
+
if(! isset($data)) {
if(isset($resolution)) {
switch($resolution) {
diff --git a/doc/hook/get_photo.bb b/doc/hook/get_photo.bb
new file mode 100644
index 000000000..eaf3beffb
--- /dev/null
+++ b/doc/hook/get_photo.bb
@@ -0,0 +1,14 @@
+[h2]get_photo[/h2]
+
+Called when fetching the content of photos (except for profile photos) in mod_photo.
+
+
+Hook arguments:
+
+'imgscale' => integer resolution requested
+'resource_id' => resource_id of requested photo
+'photo' => array of matching photo table rows after querying for the photo
+'allowed' => whether or not access to this resource is allowed
+
+
+
diff --git a/doc/hooklist.bb b/doc/hooklist.bb
index e67f791ae..5226e7de6 100644
--- a/doc/hooklist.bb
+++ b/doc/hooklist.bb
@@ -239,6 +239,9 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
[zrl=[baseurl]/help/hook/get_features]get_features[/zrl]
Called when get_features() is called
+[zrl=[baseurl]/help/hook/get_photo]get_photo[/zrl]
+ Called when photo content (except for profile photos) is fetched in mod_photo
+
[zrl=[baseurl]/help/hook/get_profile_photo]get_profile_photo[/zrl]
Called when local profile photo content is fetched in mod_photo