/** * Create a bind for the field * * @param Field $field the field * @param string $type the type of bind. If empty, STATIK * @param array $bind_data the data used to create the bind * * @return Bind null if error */ public function createBind($field, $type, $bind_data) { $bind = null; switch ($type) { case '': //default is static //default is static case self::STATIK: $dao = new Tracker_FormElement_Field_List_Bind_StaticDao(); if ($dao->save($field->getId(), 0)) { $bind = new Tracker_FormElement_Field_List_Bind_Static($field, 0, array(), array(), array()); $bind->process($bind_data, 'no redirect'); } break; case self::USERS: $dao = new Tracker_FormElement_Field_List_Bind_UsersDao(); if ($dao->save($field->getId(), array())) { $bind = new Tracker_FormElement_Field_List_Bind_Users($field, '', array(), array()); $bind->process($bind_data, 'no redirect'); } break; case self::UGROUPS: $bind = new Tracker_FormElement_Field_List_Bind_Ugroups($field, array(), array(), array(), $this->ugroup_manager, $this->getUgroupsValueDao()); $bind->process($bind_data, 'no redirect'); break; default: break; } return $bind; }
/** * Saves a bind in the database * * @return void */ public function saveObject() { $dao = new Tracker_FormElement_Field_List_Bind_UsersDao(); $dao->save($this->field->getId(), $this->getValueFunction()); parent::saveObject(); }