public function getFullRESTValue(Tracker_FormElement_Field $field) { $class_user_representation = '\\Tuleap\\Project\\REST\\UserGroupRepresentation'; $ugroup_representation = new $class_user_representation(); $ugroup_manager = new UGroupManager(); $project = $field->getTracker()->getProject(); $ugroup_representation->build($project->getID(), $ugroup_manager->getById($this->getUgroupId())); return $ugroup_representation; }
/** * Extract Field data from XML input * * @param Tracker_FormElement_Field $field * @param SimpleXMLElement $field_change * * @return mixed */ public function getFieldData(Tracker_FormElement_Field $field, SimpleXMLElement $field_change) { $data = array('use_artifact_permissions' => (int) $field_change['use_perm'], 'u_groups' => array()); foreach ($field_change->ugroup as $ugroup_xml) { if (isset($ugroup_xml['ugroup_id'])) { $data['u_groups'][] = (int) $ugroup_xml['ugroup_id']; } elseif (isset($ugroup_xml['ugroup_name'])) { $ugroup_manager = new UGroupManager(); $ugroup = $ugroup_manager->getUGroupByName($field->getTracker()->getProject(), (string) $ugroup_xml['ugroup_name']); $data['u_groups'][] = $ugroup->getId(); } } return $data; }
/** * Say if a field is used to define a workflow * * @param Tracker_FormElement_Field $field The field * * @return bool */ public function isWorkflowField(Tracker_FormElement_Field $field) { $workflow = $this->getWorkflowByTrackerId($field->getTracker()->getId()); if ($workflow) { return $field->getId() == $workflow->getFieldId(); } return false; }
/** * Build a binder associated to a list field. * @param Tracker_FormElement_Field $field * @param string $type ('ug', 'submit', 'Static') */ public function getBind($field, $type) { $default_value = array(); $dao = new Tracker_FormElement_Field_List_Bind_DefaultvalueDao(); foreach ($dao->searchByFieldId($field->id) as $row) { $default_value[$row['value_id']] = true; } $decorators = array(); $dao = new Tracker_FormElement_Field_List_BindDecoratorDao(); foreach ($dao->searchByFieldId($field->id) as $row) { $decorators[$row['value_id']] = new Tracker_FormElement_Field_List_BindDecorator($row['field_id'], $row['value_id'], $row['red'], $row['green'], $row['blue']); } $bind = new Tracker_FormElement_Field_List_Bind_Null($field); switch ($type) { case self::STATIK: $dao = new Tracker_FormElement_Field_List_Bind_StaticDao(); if ($row = $dao->searchByFieldId($field->id)->getRow()) { $values = array(); $dao = new Tracker_FormElement_Field_List_Bind_Static_ValueDao(); foreach ($dao->searchByFieldId($field->id, $row['is_rank_alpha']) as $row_value) { $values[$row_value['id']] = $this->getStaticValueInstance($row_value['id'], $row_value['label'], $row_value['description'], $row_value['rank'], $row_value['is_hidden']); } $bind = new Tracker_FormElement_Field_List_Bind_Static($field, $row['is_rank_alpha'], $values, $default_value, $decorators); } break; case self::USERS: $dao = new Tracker_FormElement_Field_List_Bind_UsersDao(); if ($row = $dao->searchByFieldId($field->id)->getRow()) { $bind = new Tracker_FormElement_Field_List_Bind_Users($field, $row['value_function'], $default_value, $decorators); } break; case self::UGROUPS: $values = array(); foreach ($this->getUgroupsValueDao()->searchByFieldId($field->id) as $row_value) { $values[$row_value['id']] = $this->getUgroupsValueInstance($row_value['id'], $field->getTracker()->getProject(), $row_value['ugroup_id'], $row_value['is_hidden']); } $bind = new Tracker_FormElement_Field_List_Bind_Ugroups($field, array_filter($values), $default_value, $decorators, $this->ugroup_manager, $this->getUgroupsValueDao()); break; default: trigger_error('Unknown bind "' . $type . '"', E_USER_WARNING); break; } return $bind; }