From d632d282cd000de420852404013dd2a4b4cc214c Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 25 Sep 2016 20:37:27 +0000 Subject: [PATCH] We are now having an account type and are publishing it --- boot.php | 9 +++--- database.sql | 4 ++- include/dbstructure.php | 2 ++ include/delivery.php | 2 +- include/dfrn.php | 8 +++-- include/notifier.php | 4 +-- mod/settings.php | 53 +++++++++++++++++++++++++--------- view/templates/field_radio.tpl | 2 -- view/templates/pagetypes.tpl | 25 +++++++++++----- 9 files changed, 77 insertions(+), 32 deletions(-) diff --git a/boot.php b/boot.php index fe16e01935..0ef450f3e2 100644 --- a/boot.php +++ b/boot.php @@ -182,13 +182,14 @@ define ( 'PAGE_PRVGROUP', 5 ); /** @}*/ /** - * @name page types + * @name account types * * @{ */ -define ( 'PAGE_TYPE_PERSON', 0 ); -define ( 'PAGE_TYPE_COMPANY', 1 ); -define ( 'PAGE_TYPE_COMMUNITY', 2 ); +define ( 'ACCOUNT_TYPE_PERSON', 0 ); +define ( 'ACCOUNT_TYPE_COMPANY', 1 ); +define ( 'ACCOUNT_TYPE_NEWS', 2 ); +define ( 'ACCOUNT_TYPE_COMMUNITY', 3 ); /** @}*/ /** diff --git a/database.sql b/database.sql index f621fdd2ef..ecd2be1529 100644 --- a/database.sql +++ b/database.sql @@ -1,6 +1,6 @@ -- ------------------------------------------ -- Friendica 3.5.1-dev (Asparagus) --- DB_UPDATE_VERSION 1202 +-- DB_UPDATE_VERSION 1203 -- ------------------------------------------ @@ -158,6 +158,7 @@ CREATE TABLE IF NOT EXISTS `contact` ( `writable` tinyint(1) NOT NULL DEFAULT 0, `forum` tinyint(1) NOT NULL DEFAULT 0, `prv` tinyint(1) NOT NULL DEFAULT 0, + `contact-type` int(11) unsigned NOT NULL DEFAULT 0, `hidden` tinyint(1) NOT NULL DEFAULT 0, `archive` tinyint(1) NOT NULL DEFAULT 0, `pending` tinyint(1) NOT NULL DEFAULT 1, @@ -1061,6 +1062,7 @@ CREATE TABLE IF NOT EXISTS `user` ( `cntunkmail` int(11) NOT NULL DEFAULT 10, `notify-flags` int(11) unsigned NOT NULL DEFAULT 65535, `page-flags` int(11) unsigned NOT NULL DEFAULT 0, + `account-type` int(11) unsigned NOT NULL DEFAULT 0, `prvnets` tinyint(1) NOT NULL DEFAULT 0, `pwdreset` varchar(255) NOT NULL DEFAULT '', `maxreq` int(11) NOT NULL DEFAULT 10, diff --git a/include/dbstructure.php b/include/dbstructure.php index 22df6cacac..411def5d0d 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -499,6 +499,7 @@ function db_definition() { "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), + "contact-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"), "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"), @@ -1402,6 +1403,7 @@ function db_definition() { "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"), "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"), "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"), + "account-type" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"), "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"), "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"), diff --git a/include/delivery.php b/include/delivery.php index fe33774382..7c0ba63a6b 100644 --- a/include/delivery.php +++ b/include/delivery.php @@ -178,7 +178,7 @@ function delivery_run(&$argv, &$argc){ $r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`, `user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`, - `user`.`page-flags`, `user`.`prvnets` + `user`.`page-flags`, `user`.`account-type`, `user`.`prvnets` FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid` WHERE `contact`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1", intval($uid) diff --git a/include/dfrn.php b/include/dfrn.php index cfeb8347b2..e9cfb228f6 100644 --- a/include/dfrn.php +++ b/include/dfrn.php @@ -98,9 +98,9 @@ class dfrn { $sql_extra = " AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' "; - $r = q("SELECT `contact`.*, `user`.`nickname`, `user`.`timezone`, `user`.`page-flags` + $r = q("SELECT `contact`.*, `user`.`nickname`, `user`.`timezone`, `user`.`page-flags`, `user`.`account-type` FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid` - WHERE `contact`.`self` = 1 AND `user`.`nickname` = '%s' LIMIT 1", + WHERE `contact`.`self` AND `user`.`nickname` = '%s' LIMIT 1", dbesc($owner_nick) ); @@ -440,9 +440,13 @@ class dfrn { xml::add_element($doc, $root, "link", "", $attributes); } + // For backward compatibility we keep this element if ($owner['page-flags'] == PAGE_COMMUNITY) xml::add_element($doc, $root, "dfrn:community", 1); + // The former element is replaced by this one + xml::add_element($doc, $root, "dfrn:account_type", $owner["account-type"]); + /// @todo We need a way to transmit the different page flags like "PAGE_PRVGROUP" xml::add_element($doc, $root, "updated", datetime_convert("UTC", "UTC", "now", ATOM_TIME)); diff --git a/include/notifier.php b/include/notifier.php index 0610a4e398..584555d4ac 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -134,7 +134,7 @@ function notifier_run(&$argv, &$argc){ } elseif($cmd === 'removeme') { $r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`, `user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`, - `user`.`page-flags`, `user`.`prvnets`, `user`.`guid` + `user`.`page-flags`, `user`.`prvnets`, `user`.`account-type`, `user`.`guid` FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid` WHERE `contact`.`uid` = %d AND `contact`.`self` LIMIT 1", intval($item_id)); @@ -204,7 +204,7 @@ function notifier_run(&$argv, &$argc){ $r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`, `user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`, - `user`.`page-flags`, `user`.`prvnets` + `user`.`page-flags`, `user`.`prvnets`, `user`.`account-type` FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid` WHERE `contact`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1", intval($uid) diff --git a/mod/settings.php b/mod/settings.php index 493a84064f..eb6c53e58d 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -420,6 +420,7 @@ function settings_post(&$a) { $publish = (((x($_POST,'profile_in_directory')) && (intval($_POST['profile_in_directory']) == 1)) ? 1: 0); $net_publish = (((x($_POST,'profile_in_netdirectory')) && (intval($_POST['profile_in_netdirectory']) == 1)) ? 1: 0); $old_visibility = (((x($_POST,'visibility')) && (intval($_POST['visibility']) == 1)) ? 1 : 0); + $account_type = (((x($_POST,'account-type')) && (intval($_POST['account-type']))) ? intval($_POST['account-type']) : 0); $page_flags = (((x($_POST,'page-flags')) && (intval($_POST['page-flags']))) ? intval($_POST['page-flags']) : 0); $blockwall = (((x($_POST,'blockwall')) && (intval($_POST['blockwall']) == 1)) ? 0: 1); // this setting is inverted! $blocktags = (((x($_POST,'blocktags')) && (intval($_POST['blocktags']) == 1)) ? 0: 1); // this setting is inverted! @@ -453,6 +454,16 @@ function settings_post(&$a) { if(x($_POST,'notify8')) $notify += intval($_POST['notify8']); + // Adjust the page flag if the account type doesn't fit to the page flag. + if (($account_type == ACCOUNT_TYPE_PERSON) AND !in_array($page_flags, array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE))) + $page_flags = PAGE_NORMAL; + elseif (($account_type == ACCOUNT_TYPE_COMPANY) AND !in_array($page_flags, array(PAGE_SOAPBOX))) + $page_flags = PAGE_SOAPBOX; + elseif (($account_type == ACCOUNT_TYPE_NEWS) AND !in_array($page_flags, array(PAGE_SOAPBOX))) + $page_flags = PAGE_SOAPBOX; + elseif (($account_type == ACCOUNT_TYPE_COMMUNITY) AND !in_array($page_flags, array(PAGE_COMMUNITY, PAGE_PRVGROUP))) + $page_flags = PAGE_COMMUNITY; + $email_changed = false; $err = ''; @@ -553,7 +564,7 @@ function settings_post(&$a) { $r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `openid` = '%s', `timezone` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', - `notify-flags` = %d, `page-flags` = %d, `default-location` = '%s', + `notify-flags` = %d, `page-flags` = %d, `account-type` = %d, `default-location` = '%s', `allow_location` = %d, `maxreq` = %d, `expire` = %d, `openidserver` = '%s', `def_gid` = %d, `blockwall` = %d, `hidewall` = %d, `blocktags` = %d, `unkmail` = %d, `cntunkmail` = %d, `language` = '%s' @@ -568,6 +579,7 @@ function settings_post(&$a) { dbesc($str_group_deny), intval($notify), intval($page_flags), + intval($account_type), dbesc($defloc), intval($allow_location), intval($maxreq), @@ -1065,19 +1077,34 @@ function settings_content(&$a) { if(! strlen($a->user['timezone'])) $timezone = date_default_timezone_get(); - $page_type = PAGE_TYPE_PERSON; - $pageset_tpl = get_markup_template('pagetypes.tpl'); $pagetype = replace_macros($pageset_tpl, array( - '$user' => t("User Types"), - '$company' => t("Company Types"), - '$community' => t("Community Types"), - '$page_type' => $page_type, - '$page_person' => PAGE_TYPE_PERSON, - '$page_company' => PAGE_TYPE_COMPANY, - '$page_forum' => PAGE_TYPE_COMMUNITY, - '$page_normal' => array('page-flags', t('Normal Account Page'), PAGE_NORMAL, + '$account_types'=> t("Account Types"), + '$user' => t("Personal Page Subtypes"), + '$community' => t("Community Forum Subtypes"), + '$account_type' => $a->user['account-type'], + '$type_person' => ACCOUNT_TYPE_PERSON, + '$type_company' => ACCOUNT_TYPE_COMPANY, + '$type_news' => ACCOUNT_TYPE_NEWS, + '$type_community' => ACCOUNT_TYPE_COMMUNITY, + '$account_person' => array('account-type', t('Personal Page'), ACCOUNT_TYPE_PERSON, + t('This account is a regular personal profile'), + ($a->user['account-type'] == ACCOUNT_TYPE_PERSON)), + + '$account_company' => array('account-type', t('Company Page'), ACCOUNT_TYPE_COMPANY, + t('This account is a company profile'), + ($a->user['account-type'] == ACCOUNT_TYPE_COMPANY)), + + '$account_news' => array('account-type', t('News Page'), ACCOUNT_TYPE_NEWS, + t('This account is a news account/reflector'), + ($a->user['account-type'] == ACCOUNT_TYPE_NEWS)), + + '$account_community' => array('account-type', t('Community Forum'), ACCOUNT_TYPE_COMMUNITY, + t('This account is a community forum where people can discuss with each other'), + ($a->user['account-type'] == ACCOUNT_TYPE_COMMUNITY)), + + '$page_normal' => array('page-flags', t('Normal Account Page'), PAGE_NORMAL, t('This account is a normal personal profile'), ($a->user['page-flags'] == PAGE_NORMAL)), @@ -1085,8 +1112,8 @@ function settings_content(&$a) { t('Automatically approve all connection/friend requests as read-only fans'), ($a->user['page-flags'] == PAGE_SOAPBOX)), - '$page_community' => array('page-flags', t('Community Forum/Celebrity Account'), PAGE_COMMUNITY, - t('Automatically approve all connection/friend requests as read-write fans'), + '$page_community' => array('page-flags', t('Public Forum'), PAGE_COMMUNITY, + t('Automatically approve all contact requests'), ($a->user['page-flags'] == PAGE_COMMUNITY)), '$page_freelove' => array('page-flags', t('Automatic Friend Page'), PAGE_FREELOVE, diff --git a/view/templates/field_radio.tpl b/view/templates/field_radio.tpl index ef8ec4f9a6..72228a1c20 100644 --- a/view/templates/field_radio.tpl +++ b/view/templates/field_radio.tpl @@ -1,5 +1,3 @@ - -
diff --git a/view/templates/pagetypes.tpl b/view/templates/pagetypes.tpl index cfbe409beb..ddb5f07b6b 100644 --- a/view/templates/pagetypes.tpl +++ b/view/templates/pagetypes.tpl @@ -1,15 +1,26 @@ -{{if $page_type == $page_person}} -

{{$user}}

+

{{$account_types}}

+{{include file="field_radio.tpl" field=$account_person}} +{{include file="field_radio.tpl" field=$account_company}} +{{include file="field_radio.tpl" field=$account_news}} +{{include file="field_radio.tpl" field=$account_community}} + +{{if $account_type == $type_person}} +
{{$user}}
{{include file="field_radio.tpl" field=$page_normal}} {{include file="field_radio.tpl" field=$page_soapbox}} {{include file="field_radio.tpl" field=$page_freelove}} {{/if}} -{{if $page_type == $page_company}} -

{{$company}}

- {{include file="field_radio.tpl" field=$page_soapbox}} + +{{if $account_type == $type_company}} + {{/if}} -{{if $page_type == $page_forum}} -

{{$community}}

+ +{{if $account_type == $type_news}} + +{{/if}} + +{{if $account_type == $type_community}} +
{{$community}}
{{include file="field_radio.tpl" field=$page_community}} {{include file="field_radio.tpl" field=$page_prvgroup}} {{/if}}