Hide form when at or over service_class['limit_identities']

This commit is contained in:
M.Dent 2018-09-27 22:42:42 -04:00
parent c15de3b68b
commit fe8b723622
2 changed files with 26 additions and 20 deletions

View File

@ -142,9 +142,12 @@ class New_channel extends \Zotlabs\Web\Controller {
} }
$limit = account_service_class_fetch(get_account_id(),'total_identities'); $limit = account_service_class_fetch(get_account_id(),'total_identities');
$canadd = true;
if($r && ($limit !== false)) { if($r && ($limit !== false)) {
$channel_usage_message = sprintf( t("You have created %1$.0f of %2$.0f allowed channels."), $r[0]['total'], $limit); $channel_usage_message = sprintf( t("You have created %1$.0f of %2$.0f allowed channels."), $r[0]['total'], $limit);
if ($r[0]['total'] >= $limit) {
$canadd = false;
}
} }
else { else {
$channel_usage_message = ''; $channel_usage_message = '';
@ -186,7 +189,8 @@ class New_channel extends \Zotlabs\Web\Controller {
'$nickname' => $nickname, '$nickname' => $nickname,
'$validate' => t('Validate'), '$validate' => t('Validate'),
'$submit' => t('Create'), '$submit' => t('Create'),
'$channel_usage_message' => $channel_usage_message '$channel_usage_message' => $channel_usage_message,
'$canadd' => $canadd
)); ));
return $o; return $o;

View File

@ -13,23 +13,25 @@
</div> </div>
{{/if}} {{/if}}
{{/if}} {{/if}}
<form action="new_channel" method="post" id="newchannel-form"> {{if $canadd}}
{{if $default_role}} <form action="new_channel" method="post" id="newchannel-form">
<input type="hidden" name="permissions_role" value="{{$default_role}}" /> {{if $default_role}}
{{else}} <input type="hidden" name="permissions_role" value="{{$default_role}}" />
{{include file="field_select_grouped.tpl" field=$role}} {{else}}
{{/if}} {{include file="field_select_grouped.tpl" field=$role}}
{{/if}}
{{include file="field_input.tpl" field=$name}}
{{include file="field_input.tpl" field=$name}}
{{include file="field_input.tpl" field=$nickname}}
<button class="btn btn-primary" type="submit" id="newchannel-submit-button">{{$submit}}</button> {{include file="field_input.tpl" field=$nickname}}
<button class="btn btn-primary" type="submit" id="newchannel-submit-button">{{$submit}}</button>
<div id="newchannel-submit-end" class="clear"></div>
<div id="newchannel-submit-end" class="clear"></div>
<div id="newchannel-import-link" class="descriptive-paragraph" >{{$label_import}}</div>
<div id="newchannel-import-end" class="clear"></div> <div id="newchannel-import-link" class="descriptive-paragraph" >{{$label_import}}</div>
</form> <div id="newchannel-import-end" class="clear"></div>
</form>
{{/if}}
</div> </div>
</div> </div>