]> git.mxchange.org Git - friendica.git/commitdiff
We are now having an account type and are publishing it
authorMichael Vogel <ike@pirati.ca>
Sun, 25 Sep 2016 20:37:27 +0000 (20:37 +0000)
committerMichael Vogel <ike@pirati.ca>
Sun, 25 Sep 2016 20:37:27 +0000 (20:37 +0000)
boot.php
database.sql
include/dbstructure.php
include/delivery.php
include/dfrn.php
include/notifier.php
mod/settings.php
view/templates/field_radio.tpl
view/templates/pagetypes.tpl

index fe16e0193505e5464a208866b2f5a484c216a92e..0ef450f3e2afb951728d79342e449b0e89f57847 100644 (file)
--- 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 );
 /** @}*/
 
 /**
index f621fdd2ef0e2e3739daba5da45a413e661a991b..ecd2be1529f4e29b963f1fb47355a9d07738b08b 100644 (file)
@@ -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,
index 22df6cacac9ab943a23bfd50fc733287e6a244b5..411def5d0d942ef7924736f437e96825f21cf749 100644 (file)
@@ -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"),
index fe337743820dcb85940262fefdb4abe099c4d530..7c0ba63a6b41b9649cf30e925df64cf089e6ccd8 100644 (file)
@@ -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)
index cfeb8347b2400c977f9712dafcadb96d77bdb0a9..e9cfb228f65f7b8781bdc23cbe283fdf88e04e36 100644 (file)
@@ -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));
index 0610a4e398df5a9baba95ba58e4e9df7a6927b03..584555d4ac40989f31c95b928b31f3e55563df35 100644 (file)
@@ -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)
index 493a84064f77d39bfc34908bb8e0906cc0d08883..eb6c53e58dfc885dbd5e84e2629bfeb8be360788 100644 (file)
@@ -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,
index ef8ec4f9a6372e7c13ea191703e7ccf2e40b1776..72228a1c209f73ae7a35efa0918c7bdbb7730c9b 100644 (file)
@@ -1,5 +1,3 @@
-
-       
        <div class='field radio'>
                <label for='id_{{$field.0}}_{{$field.2}}'>{{$field.1}}</label>
                <input type="radio" name='{{$field.0}}' id='id_{{$field.0}}_{{$field.2}}' value="{{$field.2|escape:'html'}}" {{if $field.4}}checked="true"{{/if}} aria-describedby={{$field.0}}_tip'>
index cfbe409beb9a68f7e68345c132491e5f739cb46e..ddb5f07b6b9dae976fcf8af0ed78799284c33678 100644 (file)
@@ -1,15 +1,26 @@
-{{if $page_type == $page_person}}
-<h4>{{$user}}</h4>
+<h4>{{$account_types}}</h4>
+{{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}}
+       <h5>{{$user}}</h5>
        {{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}}
-<h4>{{$company}}</h4>
-       {{include file="field_radio.tpl" field=$page_soapbox}}
+
+{{if $account_type == $type_company}}
+       <input type='hidden' name='page-flags' value='1'>
+{{/if}}
+
+{{if $account_type == $type_news}}
+       <input type='hidden' name='page-flags' value='1'>
 {{/if}}
-{{if $page_type == $page_forum}}
-<h4>{{$community}}</h4>
+
+{{if $account_type == $type_community}}
+       <h5>{{$community}}</h5>
        {{include file="field_radio.tpl" field=$page_community}}
        {{include file="field_radio.tpl" field=$page_prvgroup}}
 {{/if}}