public function build(Tracker_FormElement $field, $type, array $permissions) { $this->field_id = JsonCast::toInt($field->getId()); $this->name = $field->getName(); $this->label = $field->getLabel(); if ($field instanceof Tracker_FormElement_Field) { $this->required = JsonCast::toBoolean($field->isRequired()); $this->collapsed = false; } else { $this->required = false; $this->collapsed = (bool) $field->isCollapsed(); } $this->default_value = $field->getDefaultValue(); $this->type = $type; $this->values = null; if ($field->getRESTAvailableValues()) { $this->values = $field->getRESTAvailableValues(); } $bindings = $field->getSoapBindingProperties(); $this->bindings = array(self::BIND_TYPE => $bindings[Tracker_FormElement_Field_List_Bind::SOAP_TYPE_KEY], self::BIND_LIST => array_map(function ($binding) { return array(Tracker_REST_FieldRepresentation::BIND_ID => $binding[Tracker_FormElement_Field_List_Bind_Users::SOAP_BINDING_LIST_ID], Tracker_REST_FieldRepresentation::BIND_LABEL => $binding[Tracker_FormElement_Field_List_Bind_Users::SOAP_BINDING_LIST_LABEL]); }, $bindings[Tracker_FormElement_Field_List_Bind::SOAP_LIST_KEY])); $this->permissions = array_map(function ($permission) { switch ($permission) { case Tracker_FormElement::SOAP_PERMISSION_READ: return Tracker_REST_FieldRepresentation::PERM_READ; case Tracker_FormElement::SOAP_PERMISSION_UPDATE: return Tracker_REST_FieldRepresentation::PERM_UPDATE; case Tracker_FormElement::SOAP_PERMISSION_SUBMIT: return Tracker_REST_FieldRepresentation::PERM_CREATE; } }, $permissions); }
public function fetchNameForShared() { $hp = Codendi_HTMLPurifier::instance(); $html = ''; $html .= '<p>'; $html .= '<label>' . $GLOBALS['Language']->getText('plugin_tracker_include_type', 'name') . '</label>'; $html .= $hp->purify($this->formElement->getName(), CODENDI_PURIFIER_CONVERT_HTML); $html .= '</p>'; return $html; }