Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Thomas Willingham
2013-07-03 16:10:58 +01:00
21 changed files with 302 additions and 214 deletions

View File

@@ -43,7 +43,7 @@ require_once('include/taxonomy.php');
define ( 'RED_PLATFORM', 'Red Matrix' );
define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R');
define ( 'ZOT_REVISION', 1 );
define ( 'DB_UPDATE_VERSION', 1048 );
define ( 'DB_UPDATE_VERSION', 1049 );
define ( 'EOL', '<br />' . "\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
@@ -1419,7 +1419,7 @@ function get_max_import_size() {
* Function : profile_load
* @parameter App $a
* @parameter string $nickname
* @parameter int $profile
* @parameter string $profile
*
* Summary: Loads a profile into the page sidebar.
* The function requires a writeable copy of the main App structure, and the nickname
@@ -1436,7 +1436,9 @@ function get_max_import_size() {
*/
function profile_load(&$a, $nickname, $profile = 0) {
function profile_load(&$a, $nickname, $profile = '') {
logger('profile_load: ' . $profile);
$user = q("select channel_id from channel where channel_address = '%s' limit 1",
dbesc($nickname)
@@ -1460,30 +1462,29 @@ function profile_load(&$a, $nickname, $profile = 0) {
return;
}
$r = q("SELECT abook_profile FROM abook WHERE abook_xchan = '%s' limit 1",
dbesc($observer['xchan_hash'])
);
if($r)
$profile = $r[0]['abook_profile'];
if(! $profile) {
$r = q("SELECT abook_profile FROM abook WHERE abook_xchan = '%s' and abook_channel = '%d' limit 1",
dbesc($observer['xchan_hash']),
intval($user[0]['channel_id'])
);
if($r)
$profile = $r[0]['abook_profile'];
}
$r = null;
if($profile) {
$profile_int = intval($profile);
$r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , channel.* FROM `profile`
LEFT JOIN channel ON `profile`.`uid` = channel.channel_id
WHERE channel.channel_address = '%s' AND `profile`.`id` = %d LIMIT 1",
$r = q("SELECT profile.uid AS profile_uid, profile.*, channel.* FROM profile
LEFT JOIN channel ON profile.uid = channel.channel_id
WHERE channel.channel_address = '%s' AND profile.profile_guid = '%s' LIMIT 1",
dbesc($nickname),
intval($profile_int)
dbesc($profile)
);
}
if(! ($r && count($r))) {
$r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `channel`.* FROM `profile`
LEFT JOIN `channel` ON `profile`.`uid` = channel.channel_id
WHERE channel.channel_address = '%s' AND `profile`.`is_default` = 1 LIMIT 1",
if(! $r) {
$r = q("SELECT profile.uid AS profile_uid, profile.*, channel.* FROM profile
LEFT JOIN channel ON profile.uid = channel.channel_id
WHERE channel.channel_address = '%s' AND profile.is_default = 1 LIMIT 1",
dbesc($nickname)
);
}