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_challenge(array $args) { $this->load_object($args); try { $grp = new fi_openkeidas_groups_group($args['group']); } catch (midgard_error_exception $e) { throw new midgardmvc_exception_notfound($e->getMessage()); } if (!$this->is_challenger()) { throw new midgardmvc_exception_unauthorized("Only challenger can challenge"); } midgardmvc_core::get_instance()->authorization->enter_sudo('fi_openkeidas_diary'); $participant = new fi_openkeidas_diary_challenge_participant(); $participant->grp = $grp->id; $participant->challenge = $this->object->id; $participant->create(); midgardmvc_core::get_instance()->authorization->leave_sudo(); midgardmvc_core::get_instance()->head->relocate($this->get_url_read()); }