public static function update($id) { if (!self::check_logged_in()) { Redirect::to('/login', array('error' => 'You must log in to access this resource.')); return; } $params = $_POST; $oldsurvey = Survey::find($id); $user = self::get_user_logged_in(); $attributes = array('person' => $user->id, 'id' => $id, 'description' => $params['description'], 'type' => $oldsurvey->type); if ($attributes['type'] == 'int-value') { if ($params['min_value']) { if (is_numeric($params['min_value'])) { $attributes['min_value'] = $params['min_value']; } } if ($params['max_value']) { if (is_numeric($params['max_value'])) { $attributes['max_value'] = $params['max_value']; } } } $survey = new Survey($attributes); $errors = $survey->errors(); if (count($errors) == 0) { $survey->update(); Redirect::to('/survey/' . $survey->id, array('message' => 'Survey successfully updated!')); } else { Redirect::to('/survey/' . $survey->id . '/edit', array('errors' => $errors, 'attributes' => $attributes)); } }
function count_item($i) { $field = array('selected'); $m = new Survey(); $m->clear(); $m->setField($field); $m->setTable('vcb_survey_item'); $m->setWhere('id', '=', $i); $data = $m->select(); $add = $data[0]['selected'] + 1; $field1 = array('selected' => $add); $m1 = new Survey(); $m1->clear(); $m1->setField($field1); $m1->setTable('vcb_survey_item'); $m1->setWhere('id', '=', $i); $data_l = $m1->update(); //var_dump($data_l); }
if (!session_loggedin() || !user_ismember($group_id, 'A')) { echo "<h1>" . _('Permission denied') . "</h1>"; $sh->footer(array()); exit; } if (getStringFromRequest('post') == "Y") { if (!form_key_is_valid(getStringFromRequest('form_key'))) { exit_form_double_submit(); } $survey_title = getStringFromRequest('survey_title'); $to_add = getStringFromRequest('to_add'); $to_del = getStringFromRequest('to_del'); $is_active = getStringFromRequest('is_active'); if ($survey_id) { /* Modify */ $s->update($survey_title, $to_add, $to_del, $is_active); $feedback = _('UPDATE SUCCESSFUL'); } else { /* Add */ $s->create($survey_title, $to_add, $is_active); $feedback = _('Survey Inserted'); } } /* Order changes */ if (getStringFromRequest('updown') == "Y") { $question_id = getIntFromRequest('question_id'); $is_up = getStringFromRequest('is_up'); $s->updateOrder($question_id, $is_up); $feedback = _('UPDATE SUCCESSFUL'); } /* Error on previous transactions? */