"Company" is now "Organisation" and there is an auto update

This commit is contained in:
Michael Vogel 2016-09-26 19:35:01 +00:00
parent d632d282cd
commit 2f06e9360f
4 changed files with 27 additions and 15 deletions

View file

@ -187,7 +187,7 @@ define ( 'PAGE_PRVGROUP', 5 );
* @{ * @{
*/ */
define ( 'ACCOUNT_TYPE_PERSON', 0 ); define ( 'ACCOUNT_TYPE_PERSON', 0 );
define ( 'ACCOUNT_TYPE_COMPANY', 1 ); define ( 'ACCOUNT_TYPE_ORGANISATION',1 );
define ( 'ACCOUNT_TYPE_NEWS', 2 ); define ( 'ACCOUNT_TYPE_NEWS', 2 );
define ( 'ACCOUNT_TYPE_COMMUNITY', 3 ); define ( 'ACCOUNT_TYPE_COMMUNITY', 3 );
/** @}*/ /** @}*/

View file

@ -457,7 +457,7 @@ function settings_post(&$a) {
// Adjust the page flag if the account type doesn't fit to the page flag. // 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))) if (($account_type == ACCOUNT_TYPE_PERSON) AND !in_array($page_flags, array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE)))
$page_flags = PAGE_NORMAL; $page_flags = PAGE_NORMAL;
elseif (($account_type == ACCOUNT_TYPE_COMPANY) AND !in_array($page_flags, array(PAGE_SOAPBOX))) elseif (($account_type == ACCOUNT_TYPE_ORGANISATION) AND !in_array($page_flags, array(PAGE_SOAPBOX)))
$page_flags = PAGE_SOAPBOX; $page_flags = PAGE_SOAPBOX;
elseif (($account_type == ACCOUNT_TYPE_NEWS) AND !in_array($page_flags, array(PAGE_SOAPBOX))) elseif (($account_type == ACCOUNT_TYPE_NEWS) AND !in_array($page_flags, array(PAGE_SOAPBOX)))
$page_flags = PAGE_SOAPBOX; $page_flags = PAGE_SOAPBOX;
@ -1077,24 +1077,31 @@ function settings_content(&$a) {
if(! strlen($a->user['timezone'])) if(! strlen($a->user['timezone']))
$timezone = date_default_timezone_get(); $timezone = date_default_timezone_get();
// Set the account type to "Community" when the page is a community page but the account type doesn't fit
// This is only happening on the first visit after the update
if (in_array($a->user['page-flags'], array(PAGE_COMMUNITY, PAGE_PRVGROUP)) AND
($a->user['account-type'] != ACCOUNT_TYPE_COMMUNITY))
$a->user['account-type'] = ACCOUNT_TYPE_COMMUNITY;
$pageset_tpl = get_markup_template('pagetypes.tpl'); $pageset_tpl = get_markup_template('pagetypes.tpl');
$pagetype = replace_macros($pageset_tpl, array( $pagetype = replace_macros($pageset_tpl, array(
'$account_types'=> t("Account Types"), '$account_types' => t("Account Types"),
'$user' => t("Personal Page Subtypes"), '$user' => t("Personal Page Subtypes"),
'$community' => t("Community Forum Subtypes"), '$community' => t("Community Forum Subtypes"),
'$account_type' => $a->user['account-type'], '$account_type' => $a->user['account-type'],
'$type_person' => ACCOUNT_TYPE_PERSON, '$type_person' => ACCOUNT_TYPE_PERSON,
'$type_company' => ACCOUNT_TYPE_COMPANY, '$type_organisation' => ACCOUNT_TYPE_ORGANISATION,
'$type_news' => ACCOUNT_TYPE_NEWS, '$type_news' => ACCOUNT_TYPE_NEWS,
'$type_community' => ACCOUNT_TYPE_COMMUNITY, '$type_community' => ACCOUNT_TYPE_COMMUNITY,
'$account_person' => array('account-type', t('Personal Page'), ACCOUNT_TYPE_PERSON, '$account_person' => array('account-type', t('Personal Page'), ACCOUNT_TYPE_PERSON,
t('This account is a regular personal profile'), t('This account is a regular personal profile'),
($a->user['account-type'] == ACCOUNT_TYPE_PERSON)), ($a->user['account-type'] == ACCOUNT_TYPE_PERSON)),
'$account_company' => array('account-type', t('Company Page'), ACCOUNT_TYPE_COMPANY, '$account_organisation' => array('account-type', t('Organisation Page'), ACCOUNT_TYPE_ORGANISATION,
t('This account is a company profile'), t('This account is a profile for an organisation'),
($a->user['account-type'] == ACCOUNT_TYPE_COMPANY)), ($a->user['account-type'] == ACCOUNT_TYPE_ORGANISATION)),
'$account_news' => array('account-type', t('News Page'), ACCOUNT_TYPE_NEWS, '$account_news' => array('account-type', t('News Page'), ACCOUNT_TYPE_NEWS,
t('This account is a news account/reflector'), t('This account is a news account/reflector'),

View file

@ -1723,3 +1723,8 @@ function update_1190() {
return UPDATE_SUCCESS; return UPDATE_SUCCESS;
} }
function update_1202() {
$r = q("UPDATE `user` SET `account-type` = %d WHERE `page-flags` IN (%d, %d)",
dbesc(ACCOUNT_TYPE_COMMUNITY), dbesc(PAGE_COMMUNITY), dbesc(PAGE_PRVGROUP));
}

View file

@ -1,6 +1,6 @@
<h4>{{$account_types}}</h4> <h4>{{$account_types}}</h4>
{{include file="field_radio.tpl" field=$account_person}} {{include file="field_radio.tpl" field=$account_person}}
{{include file="field_radio.tpl" field=$account_company}} {{include file="field_radio.tpl" field=$account_organisation}}
{{include file="field_radio.tpl" field=$account_news}} {{include file="field_radio.tpl" field=$account_news}}
{{include file="field_radio.tpl" field=$account_community}} {{include file="field_radio.tpl" field=$account_community}}
@ -11,7 +11,7 @@
{{include file="field_radio.tpl" field=$page_freelove}} {{include file="field_radio.tpl" field=$page_freelove}}
{{/if}} {{/if}}
{{if $account_type == $type_company}} {{if $account_type == $type_organisation}}
<input type='hidden' name='page-flags' value='1'> <input type='hidden' name='page-flags' value='1'>
{{/if}} {{/if}}