diff options
author | sirius <sirius83@gmx.de> | 2014-04-14 00:45:24 +0200 |
---|---|---|
committer | sirius <sirius83@gmx.de> | 2014-04-14 00:45:24 +0200 |
commit | 8b8feea12f886a22f7eb66456be7828b7aef455e (patch) | |
tree | 4aa3563cf2f68e06b539bff4521bd7b00b42db2e /mod/profile_photo.php | |
parent | 153cc599a3ffe406200462f3cc7a597c34e8fcf7 (diff) | |
download | volse-hubzilla-8b8feea12f886a22f7eb66456be7828b7aef455e.tar.gz volse-hubzilla-8b8feea12f886a22f7eb66456be7828b7aef455e.tar.bz2 volse-hubzilla-8b8feea12f886a22f7eb66456be7828b7aef455e.zip |
Added hackish support for permissions-sync between profile and profile-pictures
Diffstat (limited to 'mod/profile_photo.php')
-rw-r--r-- | mod/profile_photo.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/mod/profile_photo.php b/mod/profile_photo.php index 876e3a931..2cf7a8abf 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -2,6 +2,34 @@ require_once('include/photo/photo_driver.php'); +function profile_photo_set_profile_perms($profileid) { + + $allowcid = ''; + $r = q("SELECT photo, profile_guid, id FROM profile WHERE profile.id = %d LIMIT 1", intval($profileid)); + $profile = $r[0]; + + if(x($profile['photo'])) { + preg_match("@\w*(?=-\d*$)@i", $profile['photo'], $resource_id); + $resource_id = $resource_id[0]; + + if(x($profileid)) { + + $r1 = q("SELECT abook.abook_xchan FROM abook WHERE abook_profile = %d ", intval($profile['id'])); + $r2 = q("SELECT abook.abook_xchan FROM abook WHERE abook_profile = '%s'", dbesc($profile['profile_guid'])); + foreach ($r1 as $entry) { + $allowcid .= "<" . $entry['abook_xchan'] . ">"; + } + foreach ($r2 as $entry) { + $allowcid .= "<" . $entry['abook_xchan'] . ">"; + } + if(x($allowcid)) { + q("UPDATE `photo` SET allow_cid = '%s' WHERE resource_id = '%s'",dbesc($allowcid),dbesc($resource_id)); + } + } + } + return; +} + function profile_photo_init(&$a) { if(! local_user()) { @@ -142,6 +170,11 @@ function profile_photo_post(&$a) { // Update directory in background proc_run('php',"include/directory.php",$channel['channel_id']); + + // Now copy profile-permissions to pictures, to prevent privacyleaks by automatically created folder 'Profile Pictures' + + profile_photo_set_profile_perms($_REQUEST['profile']); + } else notice( t('Unable to process image') . EOL); |