本文整理汇总了PHP中Participant::is_related_to方法的典型用法代码示例。如果您正苦于以下问题:PHP Participant::is_related_to方法的具体用法?PHP Participant::is_related_to怎么用?PHP Participant::is_related_to使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Participant
的用法示例。
在下文中一共展示了Participant::is_related_to方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: select_group
public function select_group()
{
$group_id = $this->input->post('group_id');
$this->_transaction_isolation();
$this->db->trans_begin();
$group = new Group();
$group->get_by_id($group_id);
if ($group->exists()) {
$course = $group->course->get();
if (is_null($course->groups_change_deadline) || date('U', strtotime($course->groups_change_deadline)) >= time()) {
$student = new Student();
$student->get_by_id($this->usermanager->get_student_id());
if ($student->is_related_to('active_course', $course->id)) {
$participant = new Participant();
$participant->where_related($student);
$participant->where_related($course);
$participant->where('allowed', 1);
$participant->get();
if ($participant->exists()) {
if (!$participant->is_related_to($group)) {
$participant->save($group);
$participant->where_related($course);
$participant->where_related($group);
$participant->where('allowed', 1);
$participants_count = $participant->count();
$room = new Room();
$room->where_related($group)->order_by('capacity', 'asc')->limit(1)->get();
if ($participants_count > intval($room->capacity)) {
$this->db->trans_rollback();
$this->messages->add_message('lang:groups_message_group_is_full', Messages::MESSAGE_TYPE_ERROR);
} else {
$this->db->trans_commit();
$this->messages->add_message(sprintf($this->lang->line('groups_message_group_changed'), $this->lang->text($group->name)), Messages::MESSAGE_TYPE_SUCCESS);
$this->_action_success();
$this->output->set_internal_value('course_id', $participant->course_id);
}
} else {
$this->db->trans_rollback();
$this->messages->add_message('lang:groups_message_you_are_in_group', Messages::MESSAGE_TYPE_ERROR);
}
} else {
$this->db->trans_rollback();
$this->messages->add_message('lang:groups_message_cant_found_participant_record', Messages::MESSAGE_TYPE_ERROR);
}
} else {
$this->db->trans_rollback();
$this->messages->add_message('lang:groups_message_cant_change_group_of_inactive_course', Messages::MESSAGE_TYPE_ERROR);
}
} else {
$this->db->trans_rollback();
$this->messages->add_message('lang:groups_message_groups_switching_disabled', Messages::MESSAGE_TYPE_ERROR);
}
} else {
$this->db->trans_rollback();
$this->messages->add_message('lang:groups_message_group_not_found', Messages::MESSAGE_TYPE_ERROR);
}
redirect(create_internal_url('groups'));
}