]> git.mxchange.org Git - friendica.git/commitdiff
The account type is now read and displayed
authorMichael Vogel <ike@pirati.ca>
Sat, 1 Oct 2016 20:03:27 +0000 (20:03 +0000)
committerMichael Vogel <ike@pirati.ca>
Sat, 1 Oct 2016 20:03:27 +0000 (20:03 +0000)
16 files changed:
include/Contact.php
include/dfrn.php
include/identity.php
mod/allfriends.php
mod/cal.php
mod/common.php
mod/contacts.php
mod/directory.php
mod/dirfind.php
mod/hovercard.php
mod/match.php
mod/network.php
mod/photos.php
mod/suggest.php
mod/videos.php
mod/viewcontacts.php

index 004d3aa2870fbbf22e6cba883416977485e3cf88..f1e8bbe6d629ceb9728d74fa923ccad31ea7e414 100644 (file)
@@ -208,22 +208,22 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) {
                $uid = local_user();
 
        // Fetch contact data from the contact table for the given user
-       $r = q("SELECT `id`, `id` AS `cid`, 0 AS `gid`, 0 AS `zid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`,
-                       `xmpp`, `keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `bd` AS `birthday`, `self`
+       $r = q("SELECT `id`, `id` AS `cid`, 0 AS `gid`, 0 AS `zid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
+                       `keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, `self`
                FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d",
                        dbesc(normalise_link($url)), intval($uid));
 
        // Fetch the data from the contact table with "uid=0" (which is filled automatically)
        if (!$r)
-               $r = q("SELECT `id`, 0 AS `cid`, `id` AS `zid`, 0 AS `gid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`,
-                               `xmpp`, `keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `bd` AS `birthday`, 0 AS `self`
+               $r = q("SELECT `id`, 0 AS `cid`, `id` AS `zid`, 0 AS `gid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
+                       `keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, 0 AS `self`
                        FROM `contact` WHERE `nurl` = '%s' AND `uid` = 0",
                                dbesc(normalise_link($url)));
 
        // Fetch the data from the gcontact table
        if (!$r)
-               $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`, `keywords`, `gender`, `photo`, `photo` AS `thumb`, `photo` AS `micro`, `community` AS `forum`, 0 AS `prv`, `community`, `birthday`, 0 AS `self`
+               $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`,
+                       `keywords`, `gender`, `photo`, `photo` AS `thumb`, `photo` AS `micro`, `community` AS `forum`, 0 AS `prv`, `community`, 0 AS `contact-type`, `birthday`, 0 AS `self`
                        FROM `gcontact` WHERE `nurl` = '%s'",
                                dbesc(normalise_link($url)));
 
@@ -683,4 +683,43 @@ function formatted_location($profile) {
 
        return $location;
 }
+
+/**
+ * @brief Returns the account type name
+ *
+ * The function be called with either the profile or the contct array
+ *
+ * @param array $contact contact or profile array
+ */
+function account_type($contact) {
+
+       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']))
+               || (isset($contact['prv']) && intval($contact['prv']))
+               || (isset($contact['community']) && intval($contact['community'])))
+               $type = ACCOUNT_TYPE_COMMUNITY;
+       else
+               $type = ACCOUNT_TYPE_PERSON;
+
+       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;
+               }
+
+       return $account_type;
+}
 ?>
index e9cfb228f65f7b8781bdc23cbe283fdf88e04e36..c5d00e8a6730e8f2e8404d71891485e4b17df474 100644 (file)
@@ -2492,7 +2492,19 @@ class dfrn {
 
                logger("Import DFRN message for user ".$importer["uid"]." from contact ".$importer["id"], LOGGER_DEBUG);
 
-               // is it a public forum? Private forums aren't supported by now with this method
+               // The account type is new since 3.5.1
+               if ($xpath->query("/atom:feed/dfrn:account_type")->length > 0) {
+                       $accounttype = intval($xpath->evaluate("/atom:feed/dfrn:account_type/text()", $context)->item(0)->nodeValue);
+
+                       if ($accounttype != $importer["contact-type"])
+                               q("UPDATE `contact` SET `contact-type` = %d WHERE `id` = %d",
+                                       intval($accounttype),
+                                       intval($importer["id"])
+                               );
+               }
+
+               // is it a public forum? Private forums aren't supported with this method
+               // This is deprecated since 3.5.1
                $forum = intval($xpath->evaluate("/atom:feed/dfrn:community/text()", $context)->item(0)->nodeValue);
 
                if ($forum != $importer["forum"])
index def50a98fc560316632d1814a972bbc74bd35682..b3dbea8fc6ab860974fdf06f58e13919d04ac31a 100644 (file)
@@ -310,15 +310,8 @@ function profile_sidebar($profile, $block = 0) {
                );
        }
 
-       // check if profile is a forum
-       if((intval($profile['page-flags']) == PAGE_COMMUNITY)
-                       || (intval($profile['page-flags']) == PAGE_PRVGROUP)
-                       || (isset($profile['forum']) && intval($profile['forum']))
-                       || (isset($profile['prv']) && intval($profile['prv']))
-                       || (isset($profile['community']) && intval($profile['community'])))
-               $account_type = t('Forum');
-       else
-               $account_type = "";
+       // Fetch the account type
+       $account_type = account_type($profile);
 
        if((x($profile,'address') == 1)
                        || (x($profile,'location') == 1)
index 498b9d7dbf1cf62b0b61eff85aec17e8575ace5b..03f78e696e2c4946a112dc2aeecd694472e049e8 100644 (file)
@@ -76,7 +76,7 @@ function allfriends_content(&$a) {
                        'details'       => $contact_details['location'],
                        'tags'          => $contact_details['keywords'],
                        'about'         => $contact_details['about'],
-                       'account_type'  => (($contact_details['community']) ? t('Forum') : ''),
+                       'account_type'  => account_type($contact_details),
                        'network'       => network_to_name($contact_details['network'], $contact_details['url']),
                        'photo_menu'    => $photo_menu,
                        'conntxt'       => t('Connect'),
index ab20617257160722047ef9906022add163986165..78907da06a190380bb4339dfb23d74c5360d4cd2 100644 (file)
@@ -40,10 +40,7 @@ function cal_init(&$a) {
 
                $profile = get_profiledata_by_nick($nick, $a->profile_uid);
 
-               if((intval($profile['page-flags']) == PAGE_COMMUNITY) || (intval($profile['page-flags']) == PAGE_PRVGROUP))
-                       $account_type = t('Forum');
-               else
-                       $account_type = "";
+               $account_type = account_type($profile);
 
                $tpl = get_markup_template("vcard-widget.tpl");
 
index 9b2c69f6d70c4955b12daaa6cca20ddf9e49f7de..063eafe67b90d3a1925f6571abb7325e9351c8e8 100644 (file)
@@ -120,7 +120,7 @@ function common_content(&$a) {
                        'details'       => $contact_details['location'],
                        'tags'          => $contact_details['keywords'],
                        'about'         => $contact_details['about'],
-                       'account_type'  => (($contact_details['community']) ? t('Forum') : ''),
+                       'account_type'  => account_type($contact_details),
                        'network'       => network_to_name($contact_details['network'], $contact_details['url']),
                        'photo_menu'    => $photo_menu,
                        'id'            => ++$id,
index be8135f5cbc4cb1ad722eb8ba4c85df16db9aede..410cced8e66092326ce9c82a436372e7cf04ca96 100644 (file)
@@ -38,7 +38,7 @@ function contacts_init(&$a) {
 
                        if (($a->data['contact']['network'] != "") AND ($a->data['contact']['network'] != NETWORK_DFRN)) {
                                $networkname = format_network_name($a->data['contact']['network'],$a->data['contact']['url']);
-                       } else 
+                       } else
                                $networkname = '';
 
                        $vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"),array(
@@ -48,7 +48,7 @@ function contacts_init(&$a) {
                                '$addr' => (($a->data['contact']['addr'] != "") ? ($a->data['contact']['addr']) : ""),
                                '$network_name' => $networkname,
                                '$network' => t('Network:'),
-                               'account_type' => (($a->data['contact']['forum'] || $a->data['contact']['prv']) ? t('Forum') : '')
+                               '$account_type' => account_type($a->data['contact'])
                        ));
                        $finpeople_widget = '';
                        $follow_widget = '';
@@ -623,7 +623,7 @@ function contacts_content(&$a) {
                        '$url' => $url,
                        '$profileurllabel' => t('Profile URL'),
                        '$profileurl' => $contact['url'],
-                       'account_type' => (($contact['forum'] || $contact['prv']) ? t('Forum') : ''),
+                       '$account_type' => account_type($contact),
                        '$location' => bbcode($contact["location"]),
                        '$location_label' => t("Location:"),
                        '$xmpp' => bbcode($contact["xmpp"]),
@@ -910,8 +910,6 @@ function contact_posts($a, $contact_id) {
 
 function _contact_detail_for_template($rr){
 
-       $community = '';
-
        switch($rr['rel']) {
                case CONTACT_IS_FRIEND:
                        $dir_icon = 'images/lrarrow.gif';
@@ -937,11 +935,6 @@ function _contact_detail_for_template($rr){
                $sparkle = '';
        }
 
-       //test if contact is a forum page
-       if (isset($rr['forum']) OR isset($rr['prv']))
-                               $community = ($rr['forum'] OR $rr['prv']);
-
-
        return array(
                'img_hover' => sprintf( t('Visit %s\'s profile [%s]'),$rr['name'],$rr['url']),
                'edit_hover' => t('Edit contact'),
@@ -952,7 +945,7 @@ function _contact_detail_for_template($rr){
                'thumb' => proxy_url($rr['thumb'], false, PROXY_SIZE_THUMB),
                'name' => htmlentities($rr['name']),
                'username' => htmlentities($rr['name']),
-               'account_type' => ($community ? t('Forum') : ''),
+               'account_type' => account_type($rr),
                'sparkle' => $sparkle,
                'itemurl' => (($rr['addr'] != "") ? $rr['addr'] : $rr['url']),
                'url' => $url,
index a6a9cb8ab24356f4ef017c7ed3e01b9e0414e75c..06aeec622fffb5d0af21d163b12edeb8f6c6bae3 100644 (file)
@@ -99,7 +99,6 @@ function directory_content(&$a) {
 
                foreach($r as $rr) {
 
-                       $community = '';
                        $itemurl= '';
 
                        $itemurl = (($rr['addr'] != "") ? $rr['addr'] : $rr['profile_url']);
@@ -128,13 +127,6 @@ function directory_content(&$a) {
 //                     if(strlen($rr['gender']))
 //                             $details .= '<br />' . t('Gender: ') . $rr['gender'];
 
-
-                       // show if account is a community account
-                       /// @TODO The other page types should be also respected, but first we need a good 
-                       /// translatiion and systemwide consistency for displaying the page type
-                       if((intval($rr['page-flags']) == PAGE_COMMUNITY) OR (intval($rr['page-flags']) == PAGE_PRVGROUP))
-                               $community = true;
-
                        $profile = $rr;
 
                        if((x($profile,'address') == 1)
@@ -171,7 +163,7 @@ function directory_content(&$a) {
                                'img_hover' => $rr['name'],
                                'name' => $rr['name'],
                                'details' => $details,
-                               'account_type' => ($community ? t('Forum') : ''),
+                               'account_type' => account_type($rr),
                                'profile' => $profile,
                                'location' => $location_e,
                                'tags' => $rr['pub_keywords'],
index 52e16175543abb5e92b0afbb2cff6ffb5cf0d264..215731978cfe6adeab59cb72e5a5da557c3ad9da 100644 (file)
@@ -220,7 +220,7 @@ function dirfind_content(&$a, $prefix = "") {
                                        'details'       => $contact_details['location'],
                                        'tags'          => $contact_details['keywords'],
                                        'about'         => $contact_details['about'],
-                                       'account_type'  => (($contact_details['community']) ? t('Forum') : ''),
+                                       'account_type'  => account_type($contact_details),
                                        'network' => network_to_name($jj->network, $jj->url),
                                        'id' => ++$id,
                                );
index 9bd91f0d5a062ba28244c64240e5eee353d4d2e6..65b75b32112df4ab9954fd40664d040d54b4b004 100644 (file)
@@ -77,10 +77,9 @@ function hovercard_content() {
 //             'server_url' => $contact["server_url"],
                'bd' => (($contact["birthday"] == "0000-00-00") ? "" : $contact["birthday"]),
 //             'generation' => $contact["generation"],
-               'account_type' => ($contact['community'] ? t("Forum") : ""),
+               'account_type' => account_type($contact),
                'actions' => $actions,
        );
-
        if($datatype == "html") {
                $t = get_markup_template("hovercard.tpl");
 
index 8341911577be4311375e31b5432bcc503b69e542..33e07c91ce40fbcf9614d0aca83040756c49c8b0 100644 (file)
@@ -81,7 +81,7 @@ function match_content(&$a) {
                                                'details'       => $contact_details['location'],
                                                'tags'          => $contact_details['keywords'],
                                                'about'         => $contact_details['about'],
-                                               'account_type'  => (($contact_details['community']) ? t('Forum') : ''),
+                                               'account_type'  => account_type($contact_details),
                                                'thumb' => proxy_url($jj->photo, false, PROXY_SIZE_THUMB),
                                                'inttxt' => ' ' . t('is interested in:'),
                                                'conntxt' => t('Connect'),
index 6ebedbcae8ff27f9ce63516080dacee98508cadf..f4af489db9af8cd369301e48001600f6d7c69434 100644 (file)
@@ -502,7 +502,7 @@ function network_content(&$a, $update = 0) {
        }
        elseif($cid) {
 
-               $r = q("SELECT `id`,`name`,`network`,`writable`,`nurl`, `forum`, `prv`, `addr`, `thumb`, `location` FROM `contact` WHERE `id` = %d
+               $r = q("SELECT `id`,`name`,`network`,`writable`,`nurl`, `forum`, `prv`, `contact-type`, `addr`, `thumb`, `location` FROM `contact` WHERE `id` = %d
                                AND `blocked` = 0 AND `pending` = 0 LIMIT 1",
                        intval($cid)
                );
@@ -514,10 +514,11 @@ function network_content(&$a, $update = 0) {
                                'name' => htmlentities($r[0]['name']),
                                'itemurl' => (($r[0]['addr']) ? ($r[0]['addr']) : ($r[0]['nurl'])),
                                'thumb' => proxy_url($r[0]['thumb'], false, PROXY_SIZE_THUMB),
-                               'account_type' => (($r[0]['forum']) || ($r[0]['prv']) ? t('Forum') : ''),
                                'details' => $r[0]['location'],
                        );
 
+                       $entries[0]["account_type"] = account_type($r[0]);
+
                        $o = replace_macros(get_markup_template("viewcontact_template.tpl"),array(
                                'contacts' => $entries,
                                'id' => 'network',
index a191dcf0712562cd5222233024f8b20d9d2be7dc..741181b2e9fa4628e1f65cbaf01859f2cd646d93 100644 (file)
@@ -38,10 +38,7 @@ function photos_init(&$a) {
 
                $profile = get_profiledata_by_nick($nick, $a->profile_uid);
 
-               if((intval($profile['page-flags']) == PAGE_COMMUNITY) || (intval($profile['page-flags']) == PAGE_PRVGROUP))
-                       $account_type = t('Forum');
-               else
-                       $account_type = "";
+               $account_type = account_type($profile);
 
                $tpl = get_markup_template("vcard-widget.tpl");
 
index 00033b2d246feba8b84f961dc4edf4a8587844aa..4399450eccf2a1330882886d10e9923bc820e383 100644 (file)
@@ -95,7 +95,7 @@ function suggest_content(&$a) {
                        'details'       => $contact_details['location'],
                        'tags'          => $contact_details['keywords'],
                        'about'         => $contact_details['about'],
-                       'account_type'  => (($contact_details['community']) ? t('Forum') : ''),
+                       'account_type'  => account_type($contact_details),
                        'ignlnk' => $ignlnk,
                        'ignid' => $rr['id'],
                        'conntxt' => t('Connect'),
@@ -113,7 +113,6 @@ function suggest_content(&$a) {
        $o .= replace_macros($tpl,array(
                '$title' => t('Friend Suggestions'),
                '$contacts' => $entries,
-               
        ));
 
        return $o;
index e5a0887bb9f3a2e6e22c1ade3fe262977d94886f..fb742eb015f355e1d2965091ffe7641a1a8ef1c8 100644 (file)
@@ -33,10 +33,7 @@ function videos_init(&$a) {
 
                $profile = get_profiledata_by_nick($nick, $a->profile_uid);
 
-               if((intval($profile['page-flags']) == PAGE_COMMUNITY) || (intval($profile['page-flags']) == PAGE_PRVGROUP))
-                       $account_type = t('Forum');
-               else
-                       $account_type = "";
+               $account_type = account_type($profile);
 
                $tpl = get_markup_template("vcard-widget.tpl");
 
index 2eae8fec8e41813cdf3e21d19e80c584d6a71d40..19dd8b7f95184a1f7b2ccef5f254748222eba355 100644 (file)
@@ -102,7 +102,7 @@ function viewcontacts_content(&$a) {
                        'details'       => $contact_details['location'],
                        'tags'          => $contact_details['keywords'],
                        'about'         => $contact_details['about'],
-                       'account_type'  => (($contact_details['community']) ? t('Forum') : ''),
+                       'account_type'  => account_type($contact_details),
                        'url' => $url,
                        'sparkle' => '',
                        'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),