/** * Saves a bind in the database * * @return void */ public function saveObject() { if (is_array($this->default_values)) { $t = array(); foreach ($this->default_values as $value) { $t[$value->getId()] = $value; } $this->default_values = $t; if (count($this->default_values)) { $this->getDefaultValueDao()->save($this->field->getId(), array_keys($this->default_values)); } } if (is_array($this->decorators) && !empty($this->decorators)) { $values = $this->getBindValues(); foreach ($this->decorators as $decorator) { $hexacolor = ColorHelper::RGBtoHexa($decorator->r, $decorator->g, $decorator->b); Tracker_FormElement_Field_List_BindDecorator::save($this->field->getId(), $values[$decorator->value_id]->getId(), $hexacolor); } } }
/** * Process the request * * @param array $params the request parameters * @param bool $no_redirect true if we do not have to redirect the user * * @return void */ public function process($params, $no_redirect = false, $redirect = false) { $hp = Codendi_HTMLPurifier::instance(); $value_dao = $this->getValueDao(); foreach ($params as $key => $value) { switch ($key) { case 'is_rank_alpha': $is_rank_alpha = $value ? 1 : 0; if ($this->is_rank_alpha != $is_rank_alpha) { $this->getDao()->save($this->field->id, $is_rank_alpha); $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_tracker_formelement_admin', 'alpha_ranking_updated')); } break; case 'delete': if (($row = $value_dao->searchById((int) $value)->getRow()) && $value_dao->delete((int) $value)) { $params['decorator'] = array((int) $value => null); $redirect = true; $GLOBALS['Response']->addFeedback('info', 'Value ' . $hp->purify($row['label'], CODENDI_PURIFIER_CONVERT_HTML) . ' deleted'); } break; case 'order': if (is_string($value) && $value != '') { $ids_in_right_order = explode(',', $value); $value_dao->reorder($ids_in_right_order); } break; case 'edit': foreach ($value as $value_id => $info) { if (isset($this->values[$value_id])) { $new_label = null; $new_description = null; $new_is_hidden = null; if (isset($info['label']) && trim($info['label']) != $this->values[$value_id]->getLabel()) { $new_label = trim($info['label']); } if (isset($info['description']) && trim($info['description']) != $this->values[$value_id]->getDescription()) { $new_description = trim($info['description']); } if (isset($info['is_hidden']) && trim($info['is_hidden']) != $this->values[$value_id]->isHidden()) { $new_is_hidden = trim($info['is_hidden']); } if ($new_label !== null || $new_description !== null || $new_is_hidden !== null) { //something has changed. we can save it $value_dao->save($value_id, $this->field->getId(), isset($new_label) ? $new_label : $this->values[$value_id]->getLabel(), isset($new_description) ? $new_description : $this->values[$value_id]->getDescription(), $this->values[$value_id]->getRank(), isset($new_is_hidden) ? $new_is_hidden : $this->values[$value_id]->isHidden()); unset($new_label, $new_description); } } } break; case 'add': $valueMapping = array(); foreach (explode("\n", $value) as $new_value) { $id = $this->addValue($new_value); if ($id) { $redirect = true; $this->values[$id] = $value_dao->searchById($id)->getRow(); $valueMapping[] = $id; } } if (isset($params['decorators'])) { $params['decorator'] = array(); foreach ($params['decorators'] as $key => $deco) { $params['decorator'][$valueMapping[$key]] = ColorHelper::RGBtoHexa($deco->r, $deco->g, $deco->b); } } break; default: break; } } return parent::process($params, $no_redirect, $redirect); }