1
1
Fork 0

We are now having an account type and are publishing it

This commit is contained in:
Michael Vogel 2016-09-25 20:37:27 +00:00
parent 196eb6009f
commit d632d282cd
9 changed files with 77 additions and 32 deletions

View file

@ -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 );
/** @}*/
/**

View 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,

View 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"),

View 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)

View 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));

View 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)

View 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,

View 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'>

View 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 $page_type == $page_forum}}
<h4>{{$community}}</h4>
{{if $account_type == $type_news}}
<input type='hidden' name='page-flags' value='1'>
{{/if}}
{{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}}