public static function update_challenge_members(fi_openkeidas_diary_challenge $challenge, $params) { if (!$challenge->challenger) { return; } midgardmvc_core::get_instance()->authorization->enter_sudo('fi_openkeidas_diary'); $participant = new fi_openkeidas_diary_challenge_participant(); $participant->grp = $challenge->challenger; $participant->challenge = $challenge->id; $participant->create(); $participant->approve(); midgardmvc_core::get_instance()->authorization->leave_sudo(); }
public function post_accept(array $args) { $this->load_object($args); try { $participant = new fi_openkeidas_diary_challenge_participant($args['participant']); } catch (midgard_error_exception $e) { throw new midgardmvc_exception_notfound($e->getMessage()); } $found = false; foreach ($this->data['user_groups'] as $group) { if ($group->id == $participant->grp) { $found = true; } } if (!$found) { throw new midgardmvc_exception_notfound("Your group hasn't been challenged"); } midgardmvc_core::get_instance()->authorization->enter_sudo('fi_openkeidas_diary'); $participant->approve(); midgardmvc_core::get_instance()->authorization->leave_sudo(); midgardmvc_core::get_instance()->head->relocate($this->get_url_read()); }