/** * 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; }
/** * 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 = null; 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; default: break; } return $bind; }