public static function update($id) { self::check_admin_logged_in(); $attributes = self::get_attributes(); $attributes['id'] = $id; $attributes['competition_name'] = Competition::find($attributes['competition_id'])->name; $attributes['competitor_name'] = Competitor::find($attributes['competitor_id'])->name; $attributes['standing'] = Participant::find($id)->standing; $participant = new Participant($attributes); $errors = $participant->validate_number(); if (count($errors) == 0) { $participant->update(); Redirect::to('/competition/' . $participant->competition_id . '/participants', array('message' => 'Kilpailijan numeroa muokattu onnistuneesti!')); } else { self::edit_view(array(Competition::find($participant->competition_id)), array(Competitor::find($participant->competitor_id)), $attributes, $errors); } }
private function applySettingsToParticipants() { //only checked attributes are processed //returns FALSE if no attribute and/or no participant is checked //works only for single-Select-Inputs! //checked value = COL_NAME //form control name = COL_NAME //form control value = CELL_VALUE $partAttrs = $this->getRequest()->getParam('participantAttributeChecked'); if ($partAttrs == NULL) { //no attribute checked return FALSE; } $data = array(); foreach ($partAttrs as $attr => $attrName) { $attrValue = $this->getRequest()->getParam($attrName); //boolean: write 1 instead of "on" to database if ($attrName == Participant::COL_STOCK_ASSESSMENT && $attrValue == "on") { $attrValue = 1; } $data = $data + array($attrName => $attrValue); } //echo $data; $partIds = $this->getRequest()->getParam(Participant::COL_ID); if ($partIds == NULL) { //no participant checked return FALSE; } $part = new Participant(); foreach ($partIds as $partId) { $where = $part->getAdapter()->quoteInto(Participant::COL_ID . ' = ?', $partId); $part->update($data, $where); } $this->redirectTo('index'); return TRUE; }