public function testGetTypeValuesAndLabels() { $typeValuesAndLabels = WorkflowEmailMessageRecipientForm::getTypeValuesAndLabels('Account', Workflow::TYPE_ON_SAVE); $compareData = array('DynamicTriggeredModelUser', 'DynamicTriggeredModelRelationUser', 'StaticRole', 'DynamicTriggeredByUser', 'StaticUser', 'StaticAddress', 'StaticGroup', 'DynamicTriggeredModelRelation'); $this->assertEquals($compareData, array_keys($typeValuesAndLabels)); $typeValuesAndLabels = WorkflowEmailMessageRecipientForm::getTypeValuesAndLabels('Contact', Workflow::TYPE_ON_SAVE); $compareData = array('DynamicTriggeredModelUser', 'DynamicTriggeredModelRelationUser', 'StaticRole', 'DynamicTriggeredByUser', 'StaticUser', 'StaticAddress', 'StaticGroup', 'DynamicTriggeredModel'); $this->assertEquals($compareData, array_keys($typeValuesAndLabels)); }
protected function renderFormAttributesContent() { $formType = $this->model->getFormType(); $params = array('inputPrefix' => $this->inputPrefixData); $content = null; if ($formType == WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_MODEL_USER) { $dynamicUserTypeElement = new DynamicUserTypeForEmailMessageRecipientStaticDropDownElement($this->model, 'dynamicUserType', $this->form, $params); $dynamicUserTypeElement->editableTemplate = '<div class="value-data">{content}{error}</div>'; $content .= $dynamicUserTypeElement->render(); } elseif ($formType == WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_MODEL_RELATION_USER) { $relationElement = new ModelRelationForEmailMessageRecipientStaticDropDownElement($this->model, 'relation', $this->form, $params); $relationElement->editableTemplate = '<div class="value-data">{content}{error}</div>'; $dynamicUserTypeElement = new DynamicUserTypeForEmailMessageRecipientStaticDropDownElement($this->model, 'dynamicUserType', $this->form, $params); $dynamicUserTypeElement->editableTemplate = '<div class="value-data">{content}{error}</div>'; $allRelatedDropdowns = Zurmo::t('WorkflowsModule', '<span>For all related</span> {relationsDropDown}', array('{relationsDropDown}' => $relationElement->render())); $allRelatedDropdowns .= $dynamicUserTypeElement->render(); $content .= ZurmoHtml::tag('div', array('class' => 'all-related-field'), $allRelatedDropdowns); } elseif ($formType == WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_BY_USER || $formType == WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_MODEL) { //nothing to render } elseif ($formType == WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_MODEL_RELATION) { $relationElement = new ModelRelationForEmailMessageRecipientStaticDropDownElement($this->model, 'relation', $this->form, $params); $relationElement->editableTemplate = '<div class="value-data">{content}{error}</div>'; $allRelatedDropdowns = Zurmo::t('WorkflowsModule', '<span>For all related</span> {relationsDropDown}', array('{relationsDropDown}' => $relationElement->render())); $content .= ZurmoHtml::tag('div', array('class' => 'all-related-field'), $allRelatedDropdowns); } elseif ($formType == WorkflowEmailMessageRecipientForm::TYPE_STATIC_ADDRESS) { $toNameElement = new TextElement($this->model, 'toName', $this->form, $params); $toNameElement->editableTemplate = '<div class="value-data"><span>{label}</span>{content}{error}</div>'; $toAddressElement = new TextElement($this->model, 'toAddress', $this->form, $params); $toAddressElement->editableTemplate = '<div class="value-data"><span>{label}</span>{content}{error}</div>'; $toNameAndAddressElements = null; $toNameAndAddressElements .= $toNameElement->render(); $toNameAndAddressElements .= $toAddressElement->render(); $content .= ZurmoHtml::tag('div', array('class' => 'static-address-field'), $toNameAndAddressElements); } elseif ($formType == WorkflowEmailMessageRecipientForm::TYPE_STATIC_GROUP) { $staticGroupElement = new AllGroupsStaticDropDownElement($this->model, 'groupId', $this->form, $params); $staticGroupElement->editableTemplate = '<div class="value-data">{content}{error}</div>'; $content .= $staticGroupElement->render(); } elseif ($formType == WorkflowEmailMessageRecipientForm::TYPE_STATIC_ROLE) { $staticRoleElement = new AllRolesStaticDropDownElement($this->model, 'roleId', $this->form, $params); $staticRoleElement->editableTemplate = '<div class="value-data">{content}{error}</div>'; $content .= $staticRoleElement->render(); } elseif ($formType == WorkflowEmailMessageRecipientForm::TYPE_STATIC_USER) { $staticUserElement = new UserNameIdElement($this->model, 'userId', $this->form, $params); $staticUserElement->setIdAttributeId('userId'); $staticUserElement->setNameAttributeName('stringifiedModelForValue'); $staticUserElement->editableTemplate = '<div class="value-data">{content}{error}</div>'; $content .= $staticUserElement->render(); } else { throw new NotSupportedException(); } return $content; }
/** * @return array */ public function rules() { return array_merge(parent::rules(), array(array('dynamicUserType', 'type', 'type' => 'string'), array('dynamicUserType', 'required'))); }
/** * @return array */ public function rules() { return array_merge(parent::rules(), array(array('userId', 'type', 'type' => 'integer'), array('userId', 'required'))); }
/** * Override to add relation attribute */ public function rules() { return array_merge(parent::rules(), array(array('relation', 'type', 'type' => 'string'), array('relation', 'required'), array('relationFilter', 'type', 'type' => 'string'), array('relationFilter', 'validateRelationFilter'))); }
/** * @return array */ protected function resolveRecipientTypeDataAndLabels() { $data = array('' => Zurmo::t('WorkflowsModule', 'Add Recipient')); return array_merge($data, WorkflowEmailMessageRecipientForm::getTypeValuesAndLabels($this->model->getModelClassName(), $this->model->getWorkflowType())); }
/** * @return array */ public function rules() { return array_merge(parent::rules(), array(array('toName', 'type', 'type' => 'string'), array('toName', 'required'), array('toName', 'length', 'max' => 64), array('toAddress', 'email'), array('toAddress', 'required'))); }