/** * @brief Processes delivery of profile. * * @see import_directory_profile() * @param array $sender an associative array * * \e string \b hash a xchan_hash * @param array $arr * @param array $deliveries (unused) */ function process_profile_delivery($sender, $arr, $deliveries) { logger('process_profile_delivery', LOGGER_DEBUG); $r = q("select xchan_addr from xchan where xchan_hash = '%s' limit 1", dbesc($sender['hash'])); if ($r) { import_directory_profile($sender['hash'], $arr, $r[0]['xchan_addr'], UPDATE_FLAGS_UPDATED, 0); } }
/** * @brief Push local channel updates to a local directory server. * * This is called from include/directory.php if a profile is to be pushed to the * directory and the local hub in this case is any kind of directory server. * * @param int $uid * @param boolean $force */ function local_dir_update($uid, $force) { logger('local_dir_update: uid: ' . $uid, LOGGER_DEBUG); $p = q("select channel.channel_hash, channel_address, channel_timezone, profile.* from profile left join channel on channel_id = uid where uid = %d and is_default = 1", intval($uid)); $profile = array(); $profile['encoding'] = 'zot'; if ($p) { $hash = $p[0]['channel_hash']; $profile['description'] = $p[0]['pdesc']; $profile['birthday'] = $p[0]['dob']; if ($age = age($p[0]['dob'], $p[0]['channel_timezone'], '')) { $profile['age'] = $age; } $profile['gender'] = $p[0]['gender']; $profile['marital'] = $p[0]['marital']; $profile['sexual'] = $p[0]['sexual']; $profile['locale'] = $p[0]['locality']; $profile['region'] = $p[0]['region']; $profile['postcode'] = $p[0]['postal_code']; $profile['country'] = $p[0]['country_name']; $profile['about'] = $p[0]['about']; $profile['homepage'] = $p[0]['homepage']; $profile['hometown'] = $p[0]['hometown']; if ($p[0]['keywords']) { $tags = array(); $k = explode(' ', $p[0]['keywords']); if ($k) { foreach ($k as $kk) { if (trim($kk)) { $tags[] = trim($kk); } } } if ($tags) { $profile['keywords'] = $tags; } } $hidden = 1 - intval($p[0]['publish']); logger('hidden: ' . $hidden); $r = q("select xchan_hidden from xchan where xchan_hash = '%s' limit 1", dbesc($p[0]['channel_hash'])); if (intval($r[0]['xchan_hidden']) != $hidden) { $r = q("update xchan set xchan_hidden = %d where xchan_hash = '%s'", intval($hidden), dbesc($p[0]['channel_hash'])); } $arr = array('channel_id' => $uid, 'hash' => $hash, 'profile' => $profile); call_hooks('local_dir_update', $arr); $address = $p[0]['channel_address'] . '@' . App::get_hostname(); if (perm_is_allowed($uid, '', 'view_profile')) { import_directory_profile($hash, $arr['profile'], $address, 0); } else { // they may have made it private $r = q("delete from xprof where xprof_hash = '%s'", dbesc($hash)); $r = q("delete from xtag where xtag_hash = '%s'", dbesc($hash)); } } $ud_hash = random_string() . '@' . App::get_hostname(); update_modtime($hash, $ud_hash, $p[0]['channel_address'] . '@' . App::get_hostname(), $force ? UPDATE_FLAGS_FORCED : UPDATE_FLAGS_UPDATED); }