aboutsummaryrefslogtreecommitdiffstats
path: root/mod/profile_photo.php
diff options
context:
space:
mode:
authorsirius <sirius83@gmx.de>2014-04-16 00:40:01 +0200
committersirius <sirius83@gmx.de>2014-04-16 00:40:01 +0200
commitb0dc9f13edcbb705e1aa7d0af33bf0351f4d81f4 (patch)
tree32b053e3f2c95740e316e898d6a2e15688aa4d02 /mod/profile_photo.php
parent8b8feea12f886a22f7eb66456be7828b7aef455e (diff)
parentefe80bb8e98b32b95d1380633e9ffd834fa82511 (diff)
downloadvolse-hubzilla-b0dc9f13edcbb705e1aa7d0af33bf0351f4d81f4.tar.gz
volse-hubzilla-b0dc9f13edcbb705e1aa7d0af33bf0351f4d81f4.tar.bz2
volse-hubzilla-b0dc9f13edcbb705e1aa7d0af33bf0351f4d81f4.zip
Merging in conflict
Diffstat (limited to 'mod/profile_photo.php')
-rw-r--r--mod/profile_photo.php28
1 files changed, 19 insertions, 9 deletions
diff --git a/mod/profile_photo.php b/mod/profile_photo.php
index 2cf7a8abf..ef0a31673 100644
--- a/mod/profile_photo.php
+++ b/mod/profile_photo.php
@@ -1,20 +1,30 @@
<?php
+/* @file profile_photo.php
+ @brief Module-file with functions for handling of profile-photos
+
+*/
+
require_once('include/photo/photo_driver.php');
+/* @brief Function for sync'ing permissions of profile-photos and their profile
+*
+* @param $profileid The id number of the profile to sync
+* @return void
+*/
+
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)) {
- if(x($profileid)) {
+ $r = q("SELECT photo, profile_guid, id, is_default FROM profile WHERE profile.id = %d LIMIT 1", intval($profileid));
+ $profile = $r[0];
+ if(x($profile['id']) && x($profile['photo']) && intval($profile['is_default']) != 1) { //Only set perms when query suceeded and when we are not on the default profile
+ preg_match("@\w*(?=-\d*$)@i", $profile['photo'], $resource_id);
+ $resource_id = $resource_id[0];
- $r1 = q("SELECT abook.abook_xchan FROM abook WHERE abook_profile = %d ", intval($profile['id']));
+ $r1 = q("SELECT abook.abook_xchan FROM abook WHERE abook_profile = %d ", intval($profile['id'])); //Should not be needed in future. Catches old int-profile-ids.
$r2 = q("SELECT abook.abook_xchan FROM abook WHERE abook_profile = '%s'", dbesc($profile['profile_guid']));
foreach ($r1 as $entry) {
$allowcid .= "<" . $entry['abook_xchan'] . ">";
@@ -23,7 +33,7 @@ function profile_photo_set_profile_perms($profileid) {
$allowcid .= "<" . $entry['abook_xchan'] . ">";
}
if(x($allowcid)) {
- q("UPDATE `photo` SET allow_cid = '%s' WHERE resource_id = '%s'",dbesc($allowcid),dbesc($resource_id));
+ q("UPDATE `photo` SET allow_cid = '%s' WHERE resource_id = '%s' AND uid = %d",dbesc($allowcid),dbesc($resource_id),intval($profile['id']));
}
}
}