4 // Included here for completeness, but this is a very dangerous operation.
5 // It is the caller's responsibility to confirm the requestor's intent and
6 // authorisation to do this.
8 function user_remove($uid) {
12 logger('Removing user: ' . $uid);
14 $r = q("select * from user where uid = %d limit 1", intval($uid));
16 call_hooks('remove_user',$r[0]);
18 // save username (actually the nickname as it is guaranteed
19 // unique), so it cannot be re-registered in the future.
21 q("insert into userd ( username ) values ( '%s' )",
25 /// @todo Should be done in a background job since this likely will run into a time out
26 // don't delete yet, will be done later when contacts have deleted my stuff
27 // q("DELETE FROM `contact` WHERE `uid` = %d", intval($uid));
28 q("DELETE FROM `gcign` WHERE `uid` = %d", intval($uid));
29 q("DELETE FROM `group` WHERE `uid` = %d", intval($uid));
30 q("DELETE FROM `group_member` WHERE `uid` = %d", intval($uid));
31 q("DELETE FROM `intro` WHERE `uid` = %d", intval($uid));
32 q("DELETE FROM `event` WHERE `uid` = %d", intval($uid));
33 q("DELETE FROM `item` WHERE `uid` = %d", intval($uid));
34 q("DELETE FROM `item_id` WHERE `uid` = %d", intval($uid));
35 q("DELETE FROM `mail` WHERE `uid` = %d", intval($uid));
36 q("DELETE FROM `mailacct` WHERE `uid` = %d", intval($uid));
37 q("DELETE FROM `manage` WHERE `uid` = %d", intval($uid));
38 q("DELETE FROM `notify` WHERE `uid` = %d", intval($uid));
39 q("DELETE FROM `photo` WHERE `uid` = %d", intval($uid));
40 q("DELETE FROM `attach` WHERE `uid` = %d", intval($uid));
41 q("DELETE FROM `profile` WHERE `uid` = %d", intval($uid));
42 q("DELETE FROM `profile_check` WHERE `uid` = %d", intval($uid));
43 q("DELETE FROM `pconfig` WHERE `uid` = %d", intval($uid));
44 q("DELETE FROM `search` WHERE `uid` = %d", intval($uid));
45 q("DELETE FROM `spam` WHERE `uid` = %d", intval($uid));
46 // don't delete yet, will be done later when contacts have deleted my stuff
47 // q("DELETE FROM `user` WHERE `uid` = %d", intval($uid));
48 q("UPDATE `user` SET `account_removed` = 1, `account_expires_on` = UTC_TIMESTAMP() WHERE `uid` = %d", intval($uid));
49 proc_run(PRIORITY_HIGH, "include/notifier.php", "removeme", $uid);
51 // Send an update to the directory
52 proc_run(PRIORITY_LOW, "include/directory.php", $r[0]['url']);
54 if($uid == local_user()) {
55 unset($_SESSION['authenticated']);
56 unset($_SESSION['uid']);
57 goaway($a->get_baseurl());
62 function contact_remove($id) {
64 $r = q("select uid from contact where id = %d limit 1",
67 if((! dbm::is_result($r)) || (! intval($r[0]['uid'])))
70 $archive = get_pconfig($r[0]['uid'], 'system','archive_removed_contacts');
72 q("update contact set `archive` = 1, `network` = 'none', `writable` = 0 where id = %d",
78 q("DELETE FROM `contact` WHERE `id` = %d", intval($id));
80 // Delete the rest in the background
81 proc_run(PRIORITY_LOW, 'include/remove_contact.php', $id);
85 // sends an unfriend message. Does not remove the contact
87 function terminate_friendship($user,$self,$contact) {
92 require_once('include/datetime.php');
94 if($contact['network'] === NETWORK_OSTATUS) {
96 require_once('include/ostatus.php');
98 // create an unfollow slap
100 $item['verb'] = NAMESPACE_OSTATUS."/unfollow";
101 $item['follow'] = $contact["url"];
102 $slap = ostatus::salmon($item, $user);
104 if((x($contact,'notify')) && (strlen($contact['notify']))) {
105 require_once('include/salmon.php');
106 slapper($user,$contact['notify'],$slap);
109 elseif($contact['network'] === NETWORK_DIASPORA) {
110 require_once('include/diaspora.php');
111 diaspora::send_unshare($user,$contact);
113 elseif($contact['network'] === NETWORK_DFRN) {
114 require_once('include/dfrn.php');
115 dfrn::deliver($user,$contact,'placeholder', 1);
121 // Contact has refused to recognise us as a friend. We will start a countdown.
122 // If they still don't recognise us in 32 days, the relationship is over,
123 // and we won't waste any more time trying to communicate with them.
124 // This provides for the possibility that their database is temporarily messed
125 // up or some other transient event and that there's a possibility we could recover from it.
127 function mark_for_death($contact) {
129 if($contact['archive'])
132 if($contact['term-date'] == '0000-00-00 00:00:00') {
133 q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d",
134 dbesc(datetime_convert()),
135 intval($contact['id'])
138 if ($contact['url'] != '') {
139 q("UPDATE `contact` SET `term-date` = '%s'
140 WHERE `nurl` = '%s' AND `term-date` <= '1000-00-00'",
141 dbesc(datetime_convert()),
142 dbesc(normalise_link($contact['url']))
148 /// We really should send a notification to the owner after 2-3 weeks
149 /// so they won't be surprised when the contact vanishes and can take
150 /// remedial action if this was a serious mistake or glitch
153 /// Check for contact vitality via probing
155 $expiry = $contact['term-date'] . ' + 32 days ';
156 if(datetime_convert() > datetime_convert('UTC','UTC',$expiry)) {
158 // relationship is really truly dead.
159 // archive them rather than delete
160 // though if the owner tries to unarchive them we'll start the whole process over again
162 q("UPDATE `contact` SET `archive` = 1 WHERE `id` = %d",
163 intval($contact['id'])
166 if ($contact['url'] != '') {
167 q("UPDATE `contact` SET `archive` = 1 WHERE `nurl` = '%s'",
168 dbesc(normalise_link($contact['url']))
176 function unmark_for_death($contact) {
178 $r = q("SELECT `term-date` FROM `contact` WHERE `id` = %d AND `term-date` > '%s'",
179 intval($contact['id']),
180 dbesc('1000-00-00 00:00:00')
183 // We don't need to update, we never marked this contact as dead
184 if (!dbm::is_result($r)) {
188 // It's a miracle. Our dead contact has inexplicably come back to life.
189 q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d",
190 dbesc('0000-00-00 00:00:00'),
191 intval($contact['id'])
194 if ($contact['url'] != '') {
195 q("UPDATE `contact` SET `term-date` = '%s' WHERE `nurl` = '%s'",
196 dbesc('0000-00-00 00:00:00'),
197 dbesc(normalise_link($contact['url']))
203 * @brief Get contact data for a given profile link
205 * The function looks at several places (contact table and gcontact table) for the contact
206 * It caches its result for the same script execution to prevent duplicate calls
208 * @param string $url The profile link
209 * @param int $uid User id
210 * @param array $default If not data was found take this data as default value
212 * @return array Contact data
214 function get_contact_details_by_url($url, $uid = -1, $default = array()) {
215 static $cache = array();
221 if (isset($cache[$url][$uid])) {
222 return $cache[$url][$uid];
225 // Fetch contact data from the contact table for the given user
226 $r = q("SELECT `id`, `id` AS `cid`, 0 AS `gid`, 0 AS `zid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
227 `keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, `self`
228 FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d",
229 dbesc(normalise_link($url)), intval($uid));
231 // Fetch the data from the contact table with "uid=0" (which is filled automatically)
233 $r = q("SELECT `id`, 0 AS `cid`, `id` AS `zid`, 0 AS `gid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
234 `keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, 0 AS `self`
235 FROM `contact` WHERE `nurl` = '%s' AND `uid` = 0",
236 dbesc(normalise_link($url)));
238 // Fetch the data from the gcontact table
240 $r = q("SELECT 0 AS `id`, 0 AS `cid`, `id` AS `gid`, 0 AS `zid`, 0 AS `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, '' AS `xmpp`,
241 `keywords`, `gender`, `photo`, `photo` AS `thumb`, `photo` AS `micro`, `community` AS `forum`, 0 AS `prv`, `community`, `contact-type`, `birthday`, 0 AS `self`
242 FROM `gcontact` WHERE `nurl` = '%s'",
243 dbesc(normalise_link($url)));
245 if (dbm::is_result($r)) {
246 // If there is more than one entry we filter out the connector networks
248 foreach ($r AS $id => $result) {
249 if ($result["network"] == NETWORK_STATUSNET) {
255 $profile = array_shift($r);
257 // "bd" always contains the upcoming birthday of a contact.
258 // "birthday" might contain the birthday including the year of birth.
259 if ($profile["birthday"] != "0000-00-00") {
260 $bd_timestamp = strtotime($profile["birthday"]);
261 $month = date("m", $bd_timestamp);
262 $day = date("d", $bd_timestamp);
264 $current_timestamp = time();
265 $current_year = date("Y", $current_timestamp);
266 $current_month = date("m", $current_timestamp);
267 $current_day = date("d", $current_timestamp);
269 $profile["bd"] = $current_year."-".$month."-".$day;
270 $current = $current_year."-".$current_month."-".$current_day;
272 if ($profile["bd"] < $current) {
273 $profile["bd"] = (++$current_year)."-".$month."-".$day;
276 $profile["bd"] = "0000-00-00";
282 if (($profile["photo"] == "") AND isset($default["photo"])) {
283 $profile["photo"] = $default["photo"];
286 if (($profile["name"] == "") AND isset($default["name"])) {
287 $profile["name"] = $default["name"];
290 if (($profile["network"] == "") AND isset($default["network"])) {
291 $profile["network"] = $default["network"];
294 if (($profile["thumb"] == "") AND isset($profile["photo"])) {
295 $profile["thumb"] = $profile["photo"];
298 if (($profile["micro"] == "") AND isset($profile["thumb"])) {
299 $profile["micro"] = $profile["thumb"];
302 if ((($profile["addr"] == "") OR ($profile["name"] == "")) AND ($profile["gid"] != 0) AND
303 in_array($profile["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) {
304 proc_run(PRIORITY_LOW, "include/update_gcontact.php", $profile["gid"]);
307 // Show contact details of Diaspora contacts only if connected
308 if (($profile["cid"] == 0) AND ($profile["network"] == NETWORK_DIASPORA)) {
309 $profile["location"] = "";
310 $profile["about"] = "";
311 $profile["gender"] = "";
312 $profile["birthday"] = "0000-00-00";
315 $cache[$url][$uid] = $profile;
320 if (! function_exists('contact_photo_menu')) {
321 function contact_photo_menu($contact, $uid = 0)
330 $contact_drop_link = '';
337 if ($contact['uid'] != $uid) {
339 $profile_link = zrl($contact['url']);
340 $menu = Array('profile' => array(t('View Profile'), $profile_link, true));
345 $r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `network` = '%s' AND `uid` = %d",
346 dbesc($contact['nurl']), dbesc($contact['network']), intval($uid));
348 return contact_photo_menu($r[0], $uid);
350 $profile_link = zrl($contact['url']);
351 $connlnk = 'follow/?url='.$contact['url'];
353 'profile' => array(t('View Profile'), $profile_link, true),
354 'follow' => array(t('Connect/Follow'), $connlnk, true)
362 if ($contact['network'] === NETWORK_DFRN) {
364 $profile_link = $a->get_baseurl() . '/redir/' . $contact['id'];
366 $profile_link = $contact['url'];
369 if ($profile_link === 'mailbox') {
374 $status_link = $profile_link . '?url=status';
375 $photos_link = $profile_link . '?url=photos';
376 $profile_link = $profile_link . '?url=profile';
379 if (in_array($contact['network'], array(NETWORK_DFRN, NETWORK_DIASPORA))) {
380 $pm_url = $a->get_baseurl() . '/message/new/' . $contact['id'];
383 if ($contact['network'] == NETWORK_DFRN) {
384 $poke_link = $a->get_baseurl() . '/poke/?f=&c=' . $contact['id'];
387 $contact_url = $a->get_baseurl() . '/contacts/' . $contact['id'];
389 $posts_link = $a->get_baseurl() . '/contacts/' . $contact['id'] . '/posts';
390 $contact_drop_link = $a->get_baseurl() . '/contacts/' . $contact['id'] . '/drop?confirm=1';
394 * "name" => [ "Label", "link", (bool)Should the link opened in a new tab? ]
397 'status' => array(t("View Status"), $status_link, true),
398 'profile' => array(t("View Profile"), $profile_link, true),
399 'photos' => array(t("View Photos"), $photos_link, true),
400 'network' => array(t("Network Posts"), $posts_link, false),
401 'edit' => array(t("View Contact"), $contact_url, false),
402 'drop' => array(t("Drop Contact"), $contact_drop_link, false),
403 'pm' => array(t("Send PM"), $pm_url, false),
404 'poke' => array(t("Poke"), $poke_link, false),
408 $args = array('contact' => $contact, 'menu' => &$menu);
410 call_hooks('contact_photo_menu', $args);
412 $menucondensed = array();
414 foreach ($menu AS $menuname => $menuitem) {
415 if ($menuitem[1] != '') {
416 $menucondensed[$menuname] = $menuitem;
420 return $menucondensed;
424 function random_profile() {
425 $r = q("SELECT `url` FROM `gcontact` WHERE `network` = '%s'
426 AND `last_contact` >= `last_failure`
427 AND `updated` > UTC_TIMESTAMP - INTERVAL 1 MONTH
428 ORDER BY rand() LIMIT 1",
429 dbesc(NETWORK_DFRN));
431 if (dbm::is_result($r))
432 return dirname($r[0]['url']);
437 function contacts_not_grouped($uid,$start = 0,$count = 0) {
440 $r = q("select count(*) as total from contact where uid = %d and self = 0 and id not in (select distinct(`contact-id`) from group_member where uid = %d) ",
450 $r = q("select * from contact where uid = %d and self = 0 and id not in (select distinct(`contact-id`) from group_member where uid = %d) and blocked = 0 and pending = 0 limit %d, %d",
461 * @brief Fetch the contact id for a given url and user
463 * @param string $url Contact URL
464 * @param integer $uid The user id for the contact
465 * @param boolean $no_update Don't update the contact
467 * @return integer Contact ID
469 function get_contact($url, $uid = 0, $no_update = false) {
470 require_once("include/Scrape.php");
472 logger("Get contact data for url ".$url." and user ".$uid." - ".App::callstack(), LOGGER_DEBUG);;
477 // is it an address in the format user@server.tld?
478 /// @todo use gcontact and/or the addr field for a lookup
479 if (!strstr($url, "http") OR strstr($url, "@")) {
480 $data = probe_url($url);
486 $contact = q("SELECT `id`, `avatar-date` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d ORDER BY `id` LIMIT 2",
487 dbesc(normalise_link($url)),
491 $contact = q("SELECT `id`, `avatar-date` FROM `contact` WHERE `alias` IN ('%s', '%s') AND `uid` = %d ORDER BY `id` LIMIT 1",
493 dbesc(normalise_link($url)),
497 $contactid = $contact[0]["id"];
499 // Update the contact every 7 days
500 $update_photo = ($contact[0]['avatar-date'] < datetime_convert('','','now -7 days'));
501 //$update_photo = ($contact[0]['avatar-date'] < datetime_convert('','','now -12 hours'));
503 if (!$update_photo OR $no_update) {
510 $data = probe_url($url);
512 // Does this address belongs to a valid network?
513 if (!in_array($data["network"], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA))) {
517 // Get data from the gcontact table
518 $r = q("SELECT `name`, `nick`, `url`, `photo`, `addr`, `alias`, `network` FROM `gcontact` WHERE `nurl` = '%s'",
519 dbesc(normalise_link($url)));
528 if ($contactid == 0) {
529 q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
530 `name`, `nick`, `photo`, `network`, `pubkey`, `rel`, `priority`,
531 `batch`, `request`, `confirm`, `poco`, `name-date`, `uri-date`,
532 `writable`, `blocked`, `readonly`, `pending`)
533 VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', 1, 0, 0, 0)",
535 dbesc(datetime_convert()),
537 dbesc(normalise_link($data["url"])),
538 dbesc($data["addr"]),
539 dbesc($data["alias"]),
540 dbesc($data["notify"]),
541 dbesc($data["poll"]),
542 dbesc($data["name"]),
543 dbesc($data["nick"]),
544 dbesc($data["photo"]),
545 dbesc($data["network"]),
546 dbesc($data["pubkey"]),
547 intval(CONTACT_IS_SHARING),
548 intval($data["priority"]),
549 dbesc($data["batch"]),
550 dbesc($data["request"]),
551 dbesc($data["confirm"]),
552 dbesc($data["poco"]),
553 dbesc(datetime_convert()),
554 dbesc(datetime_convert())
557 $contact = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d ORDER BY `id` LIMIT 2",
558 dbesc(normalise_link($data["url"])),
563 $contactid = $contact[0]["id"];
565 // Update the newly created contact from data in the gcontact table
566 $r = q("SELECT `location`, `about`, `keywords`, `gender` FROM `gcontact` WHERE `nurl` = '%s'",
567 dbesc(normalise_link($data["url"])));
569 logger("Update contact ".$data["url"]);
570 q("UPDATE `contact` SET `location` = '%s', `about` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `id` = %d",
571 dbesc($r["location"]), dbesc($r["about"]), dbesc($r["keywords"]),
572 dbesc($r["gender"]), intval($contactid));
576 if ((count($contact) > 1) AND ($uid == 0) AND ($contactid != 0) AND ($url != ""))
577 q("DELETE FROM `contact` WHERE `nurl` = '%s' AND `id` != %d",
578 dbesc(normalise_link($url)),
581 require_once("Photo.php");
583 update_contact_avatar($data["photo"],$uid,$contactid);
585 $r = q("SELECT `addr`, `alias`, `name`, `nick` FROM `contact` WHERE `id` = %d", intval($contactid));
587 // This condition should always be true
588 if (!dbm::is_result($r))
591 // Only update if there had something been changed
592 if (($data["addr"] != $r[0]["addr"]) OR
593 ($data["alias"] != $r[0]["alias"]) OR
594 ($data["name"] != $r[0]["name"]) OR
595 ($data["nick"] != $r[0]["nick"]))
596 q("UPDATE `contact` SET `addr` = '%s', `alias` = '%s', `name` = '%s', `nick` = '%s',
597 `name-date` = '%s', `uri-date` = '%s' WHERE `id` = %d",
598 dbesc($data["addr"]),
599 dbesc($data["alias"]),
600 dbesc($data["name"]),
601 dbesc($data["nick"]),
602 dbesc(datetime_convert()),
603 dbesc(datetime_convert()),
611 * @brief Returns posts from a given gcontact
613 * @param App $a argv application class
614 * @param int $gcontact_id Global contact
616 * @return string posts in HTML
618 function posts_from_gcontact($a, $gcontact_id) {
620 require_once('include/conversation.php');
622 // There are no posts with "uid = 0" with connector networks
623 // This speeds up the query a lot
624 $r = q("SELECT `network` FROM `gcontact` WHERE `id` = %d", dbesc($gcontact_id));
625 if (in_array($r[0]["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, "")))
626 $sql = "(`item`.`uid` = 0 OR (`item`.`uid` = %d AND `item`.`private`))";
628 $sql = "`item`.`uid` = %d";
630 if(get_config('system', 'old_pager')) {
631 $r = q("SELECT COUNT(*) AS `total` FROM `item`
632 WHERE `gcontact-id` = %d and $sql",
633 intval($gcontact_id),
634 intval(local_user()));
636 $a->set_pager_total($r[0]['total']);
639 $r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
640 `author-name` AS `name`, `owner-avatar` AS `photo`,
641 `owner-link` AS `url`, `owner-avatar` AS `thumb`
642 FROM `item` FORCE INDEX (`gcontactid_uid_created`)
643 WHERE `gcontact-id` = %d AND $sql AND
644 NOT `deleted` AND NOT `moderated` AND `visible`
645 ORDER BY `item`.`created` DESC LIMIT %d, %d",
646 intval($gcontact_id),
647 intval(local_user()),
648 intval($a->pager['start']),
649 intval($a->pager['itemspage'])
652 $o = conversation($a,$r,'community',false);
654 if(!get_config('system', 'old_pager')) {
655 $o .= alt_pager($a,count($r));
663 * @brief Returns posts from a given contact url
665 * @param App $a argv application class
666 * @param string $contact_url Contact URL
668 * @return string posts in HTML
670 function posts_from_contact_url($a, $contact_url) {
672 require_once('include/conversation.php');
674 // There are no posts with "uid = 0" with connector networks
675 // This speeds up the query a lot
676 $r = q("SELECT `network`, `id` AS `author-id` FROM `contact`
677 WHERE `contact`.`nurl` = '%s' AND `contact`.`uid` = 0",
678 dbesc(normalise_link($contact_url)));
679 if (in_array($r[0]["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""))) {
680 $sql = "(`item`.`uid` = 0 OR (`item`.`uid` = %d AND `item`.`private`))";
682 $sql = "`item`.`uid` = %d";
685 $author_id = intval($r[0]["author-id"]);
687 if (get_config('system', 'old_pager')) {
688 $r = q("SELECT COUNT(*) AS `total` FROM `item`
689 WHERE `author-id` = %d and $sql",
691 intval(local_user()));
693 $a->set_pager_total($r[0]['total']);
696 $r = q(item_query()." AND `item`.`author-id` = %d AND ".$sql.
697 " ORDER BY `item`.`created` DESC LIMIT %d, %d",
699 intval(local_user()),
700 intval($a->pager['start']),
701 intval($a->pager['itemspage'])
704 $o = conversation($a,$r,'community',false);
706 if (!get_config('system', 'old_pager')) {
707 $o .= alt_pager($a,count($r));
716 * @brief Returns a formatted location string from the given profile array
718 * @param array $profile Profile array (Generated from the "profile" table)
720 * @return string Location string
722 function formatted_location($profile) {
725 if($profile['locality'])
726 $location .= $profile['locality'];
728 if($profile['region'] AND ($profile['locality'] != $profile['region'])) {
732 $location .= $profile['region'];
735 if($profile['country-name']) {
739 $location .= $profile['country-name'];
746 * @brief Returns the account type name
748 * The function can be called with either the user or the contact array
750 * @param array $contact contact or user array
752 function account_type($contact) {
754 // There are several fields that indicate that the contact or user is a forum
755 // "page-flags" is a field in the user table,
756 // "forum" and "prv" are used in the contact table. They stand for PAGE_COMMUNITY and PAGE_PRVGROUP.
757 // "community" is used in the gcontact table and is true if the contact is PAGE_COMMUNITY or PAGE_PRVGROUP.
758 if((isset($contact['page-flags']) && (intval($contact['page-flags']) == PAGE_COMMUNITY))
759 || (isset($contact['page-flags']) && (intval($contact['page-flags']) == PAGE_PRVGROUP))
760 || (isset($contact['forum']) && intval($contact['forum']))
761 || (isset($contact['prv']) && intval($contact['prv']))
762 || (isset($contact['community']) && intval($contact['community'])))
763 $type = ACCOUNT_TYPE_COMMUNITY;
765 $type = ACCOUNT_TYPE_PERSON;
767 // The "contact-type" (contact table) and "account-type" (user table) are more general then the chaos from above.
768 if (isset($contact["contact-type"]))
769 $type = $contact["contact-type"];
770 if (isset($contact["account-type"]))
771 $type = $contact["account-type"];
774 case ACCOUNT_TYPE_ORGANISATION:
775 $account_type = t("Organisation");
777 case ACCOUNT_TYPE_NEWS:
778 $account_type = t('News');
780 case ACCOUNT_TYPE_COMMUNITY:
781 $account_type = t("Forum");
788 return $account_type;