public static function _validation_valid_group_fb($val) { if (self::_empty($val)) { return true; } return Model_Base_GroupFb::valid_field('id', $val); }
public function post_add_group() { $val = Validation::forge(); $val->add_callable('MyRules'); $val->add_field('group', Lang::get('label.group'), 'required'); if ($val->run()) { $group = $val->validated('group'); $group_data = $this->check_group_id($group); if (!empty($group_data)) { if (Model_Base_GroupFb::valid_field('group_id', $group_data->id)) { $this->data['error'] = Lang::get($this->controller . '.' . $this->action . '.error.exist'); } else { $group_props = array('group_id' => $group_data->id, 'group_name' => $group_data->name, 'privacy' => $group_data->privacy); if ($id = Model_Base_GroupFb::insert($group_props)) { $this->data['success'] = Lang::get($this->controller . '.' . $this->action . '.success'); $this->data['group'] = array('id' => $id, 'name' => $group_data->name); } else { $this->data['error'] = Lang::get($this->controller . '.' . $this->action . '.error.exist'); } } } else { $this->data['error'] = Lang::get($this->controller . '.' . $this->action . '.error.not_found'); } } else { $this->data['errors'] = $val->error_message(); } return $this->response($this->data); }