]> git.mxchange.org Git - friendica.git/blobdiff - include/Contact.php
Fix Issue #2816 - MySQL version typo
[friendica.git] / include / Contact.php
index f1e8bbe6d629ceb9728d74fa923ccad31ea7e414..458f56ce524c1c3bfa87d8409de79a0e4234381c 100644 (file)
@@ -687,12 +687,16 @@ function formatted_location($profile) {
 /**
  * @brief Returns the account type name
  *
- * The function be called with either the profile or the contct array
+ * The function can be called with either the user or the contact array
  *
- * @param array $contact contact or profile array
+ * @param array $contact contact or user array
  */
 function account_type($contact) {
 
+       // There are several fields that indicate that the contact or user is a forum
+       // "page-flags" is a field in the user table,
+       // "forum" and "prv" are used in the contact table. They stand for PAGE_COMMUNITY and PAGE_PRVGROUP.
+       // "community" is used in the gcontact table and is true if the contact is PAGE_COMMUNITY or PAGE_PRVGROUP.
        if((isset($contact['page-flags']) && (intval($contact['page-flags']) == PAGE_COMMUNITY))
                || (isset($contact['page-flags']) && (intval($contact['page-flags']) == PAGE_PRVGROUP))
                || (isset($contact['forum']) && intval($contact['forum']))
@@ -702,23 +706,26 @@ function account_type($contact) {
        else
                $type = ACCOUNT_TYPE_PERSON;
 
+       // The "contact-type" (contact table) and "account-type" (user table) are more general then the chaos from above.
        if (isset($contact["contact-type"]))
                $type = $contact["contact-type"];
        if (isset($contact["account-type"]))
                $type = $contact["account-type"];
 
-       if ($type != 0)
-               switch($type) {
-                       case ACCOUNT_TYPE_ORGANISATION:
-                               $account_type = t("Organisation");
-                                break;
-                       case ACCOUNT_TYPE_NEWS:
-                               $account_type = t('News');
-                               break;
-                       case ACCOUNT_TYPE_COMMUNITY:
-                               $account_type = t("Forum");
-                               break;
-               }
+       switch($type) {
+               case ACCOUNT_TYPE_ORGANISATION:
+                       $account_type = t("Organisation");
+                       break;
+               case ACCOUNT_TYPE_NEWS:
+                       $account_type = t('News');
+                       break;
+               case ACCOUNT_TYPE_COMMUNITY:
+                       $account_type = t("Forum");
+                       break;
+               default:
+                       $account_type = "";
+                       break;
+       }
 
        return $account_type;
 }