+/**
+ * @brief Update the gcontact entry for a given user id
+ *
+ * @param int $uid User ID
+ */
+function update_gcontact_for_user($uid) {
+ $r = q("SELECT `profile`.`locality`, `profile`.`region`, `profile`.`country-name`,
+ `profile`.`name`, `profile`.`about`, `profile`.`gender`,
+ `profile`.`pub_keywords`, `profile`.`dob`, `profile`.`photo`,
+ `profile`.`net-publish`, `user`.`nickname`, `user`.`hidewall`,
+ `contact`.`notify`, `contact`.`url`, `contact`.`addr`
+ FROM `profile`
+ INNER JOIN `user` ON `user`.`uid` = `profile`.`uid`
+ INNER JOIN `contact` ON `contact`.`uid` = `profile`.`uid`
+ WHERE `profile`.`uid` = %d AND `profile`.`is-default` AND `contact`.`self`",
+ intval($uid));
+
+ $location = formatted_location(array("locality" => $r[0]["locality"], "region" => $r[0]["region"],
+ "country-name" => $r[0]["country-name"]));
+
+ // The "addr" field was added in 3.4.3 so it can be empty for older users
+ if ($r[0]["addr"] != "")
+ $addr = $r[0]["nickname"].'@'.str_replace(array("http://", "https://"), "", App::get_baseurl());
+ else
+ $addr = $r[0]["addr"];
+
+ $gcontact = array("name" => $r[0]["name"], "location" => $location, "about" => $r[0]["about"],
+ "gender" => $r[0]["gender"], "keywords" => $r[0]["pub_keywords"],
+ "birthday" => $r[0]["dob"], "photo" => $r[0]["photo"],
+ "notify" => $r[0]["notify"], "url" => $r[0]["url"],
+ "hide" => ($r[0]["hidewall"] OR !$r[0]["net-publish"]),
+ "nick" => $r[0]["nickname"], "addr" => $addr,
+ "connect" => $addr, "server_url" => App::get_baseurl(),
+ "generation" => 1, "network" => NETWORK_DFRN);
+
+ update_gcontact($gcontact);
+}
+