*/
_proxy: null,
+ /**
+ * maximum number of labels the user may create
+ * @var integer
+ */
+ _maxLabels: 0,
+
+ /**
+ * number of labels the user created
+ * @var integer
+ */
+ _labelCount: 0,
+
/**
* Initializes the label manager for conversations.
*
*/
init: function(link) {
this._deletedLabelID = 0;
+ this._maxLabels = 0;
+ this._labelCount = 0;
this._link = link;
this._labels = WCF.Dropdown.getDropdownMenu('conversationLabelFilter').children('.scrollableDropdownMenu');
break;
case 'getLabelManagement':
+ this._maxLabels = parseInt(data.returnValues.maxLabels);
+ this._labelCount = parseInt(data.returnValues.labelCount);
+
// render dialog
this._dialog.empty().html(data.returnValues.template);
this._dialog.wcfDialog({
this._labels.append($listItem);
this._notification.show();
+
+ this._labelCount++;
+
+ if (this._labelCount >= this._maxLabels) {
+ $('#conversationLabelManagementForm').hide();
+ }
},
/**
$('#labelName').on('input', $.proxy(this._updateLabels, this));
}
+ if (this._labelCount >= this._maxLabels) {
+ $('#conversationLabelManagementForm').hide();
+ this._dialog.wcfDialog('render');
+ }
+
$('#addLabel').disable().click($.proxy(this._addLabel, this));
$('#editLabel').disable();
* @param object event
*/
_edit: function(event) {
+ if (this._labelCount >= this._maxLabels) {
+ $('#conversationLabelManagementForm').show();
+ this._dialog.wcfDialog('render');
+ }
+
var $label = $(event.currentTarget);
// replace legends
return array(
'actionName' => 'getLabelManagement',
- 'template' => WCF::getTPL()->fetch('conversationLabelManagement')
+ 'template' => WCF::getTPL()->fetch('conversationLabelManagement'),
+ 'maxLabels' => WCF::getSession()->getPermission('user.conversation.maxLabels'),
+ 'labelCount' => count(ConversationLabel::getLabelsByUser())
);
}
throw new PermissionDeniedException();
}
+ // check if user has already created maximum number of labels
+ if (count(ConversationLabel::getLabelsByUser()) >= WCF::getSession()->getPermission('user.conversation.maxLabels')) {
+ throw new PermissionDeniedException();
+ }
+
$this->readString('labelName', false, 'data');
$this->readString('cssClassName', false, 'data');
if (!in_array($this->parameters['data']['cssClassName'], ConversationLabel::getLabelCssClassNames())) {