当前位置: 首页>>代码示例>>PHP>>正文


PHP Group::exists方法代码示例

本文整理汇总了PHP中Group::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Group::exists方法的具体用法?PHP Group::exists怎么用?PHP Group::exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Group的用法示例。


在下文中一共展示了Group::exists方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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'));
 }
开发者ID:andrejjursa,项目名称:list-lms,代码行数:58,代码来源:groups.php

示例2: create

 public function create()
 {
     $this->load->library('form_validation');
     $this->form_validation->set_rules('room[name]', 'lang:admin_rooms_form_field_name', 'required');
     $this->form_validation->set_rules('room[time_begin]', 'lang:admin_rooms_form_field_time_begin', 'required|callback__is_time');
     $this->form_validation->set_rules('room[time_end]', 'lang:admin_rooms_form_field_time_end', 'required|callback__is_time|callback__is_later_time');
     $this->form_validation->set_rules('room[time_day]', 'lang:admin_rooms_form_field_time_day', 'required|callback__is_day');
     $this->form_validation->set_rules('room[capacity]', 'lang:admin_rooms_form_field_capacity', 'required|integer|greater_than[0]');
     $this->form_validation->set_rules('room[group_id]', 'group_id', 'required');
     $this->form_validation->set_message('_is_time', $this->lang->line('admin_rooms_form_error_message_is_time'));
     $this->form_validation->set_message('_is_day', $this->lang->line('admin_rooms_form_error_message_is_day'));
     $this->form_validation->set_message('_is_later_time', $this->lang->line('admin_rooms_form_error_message_is_later_time'));
     if ($this->form_validation->run()) {
         $room_data = $this->input->post('room');
         $this->_transaction_isolation();
         $this->db->trans_begin();
         $group = new Group();
         $group->get_by_id($room_data['group_id']);
         if ($group->exists()) {
             $room = new Room();
             $room->name = $room_data['name'];
             $room->time_day = intval($room_data['time_day']);
             $room->time_begin = $this->time_to_int($room_data['time_begin']);
             $room->time_end = $this->time_to_int($room_data['time_end']);
             $room->capacity = intval($room_data['capacity']);
             if (trim($room_data['teachers_plain']) != '') {
                 $room->teachers_plain = trim($room_data['teachers_plain']);
             } else {
                 $room->teachers_plain = NULL;
             }
             $teachers = new Teacher();
             if (is_array($room_data['teachers']) && count($room_data['teachers'])) {
                 foreach ($room_data['teachers'] as $teacher_id) {
                     $teachers->or_where('id', $teacher_id);
                 }
                 $teachers->get();
             }
             if ($room->save(array($teachers->all)) && $group->save($room) && $this->db->trans_status()) {
                 $this->db->trans_commit();
                 $this->messages->add_message('lang:admin_rooms_flash_message_save_successful', Messages::MESSAGE_TYPE_SUCCESS);
                 $this->_action_success();
                 $room->group->get();
                 $this->output->set_internal_value('course_id', $room->group->course_id);
             } else {
                 $this->db->trans_rollback();
                 $this->messages->add_message('lang:admin_rooms_flash_message_save_failed', Messages::MESSAGE_TYPE_ERROR);
             }
         } else {
             $this->db->trans_rollback();
             $this->messages->add_message('lang:admin_rooms_flash_message_group_not_found', Messages::MESSAGE_TYPE_ERROR);
         }
         redirect(create_internal_url('admin_rooms/new_room_form/' . intval($room_data['group_id'])));
     } else {
         $room_data = $this->input->post('room');
         $this->new_room_form(intval($room_data['group_id']));
     }
 }
开发者ID:andrejjursa,项目名称:list-lms,代码行数:57,代码来源:rooms.php

示例3: User

$group_manager = Group_Manager::getInstance();
if (isset($_GET['user']) && !empty($_GET['user']) && isset($_GET['group']) && !empty($_GET['group'])) {
    // Trim user input:
    $trimmed_input = array_map('trim', $_GET);
    // User being removed:
    $user_to_remove = new User($trimmed_input['user']);
    // Check user being removed exists:
    if (!$user_to_remove->exists()) {
        echo '<center><p>User doesn\'t exist</p></center>';
        include FOOTER;
        exit;
    }
    // Group to remove user from:
    $group = new Group($trimmed_input['group']);
    // Check group exists:
    if (!$group->exists()) {
        echo '<center><p>Group doesn\'t exist</p></center>';
        include FOOTER;
        exit;
    }
    // If user is attempting to remove themself then redirect to Leave Group script:
    if ($user->profile_link() === $user_to_remove->profile_link()) {
        echo '<center><p>Redirect to Leave Group</p></center>';
        include FOOTER;
        exit;
    }
    // Ensure logged in user is owner before proceeding:
    if ($group_manager->user_access_level($user, $group) < OWNER) {
        echo '<center><p>Insufficient privileges</p></center>';
        include FOOTER;
        exit;
开发者ID:boxtar,项目名称:prototype,代码行数:31,代码来源:remove_user_from_group.php

示例4: send_group_mail

 public function send_group_mail($group_id)
 {
     $group = new Group();
     $group->get_by_id($group_id);
     if ($group->exists()) {
         $this->load->library('form_validation');
         $this->form_validation->set_rules('group_mail[subject]', 'lang:admin_groups_group_email_form_field_subject', 'required');
         $this->form_validation->set_rules('group_mail[body]', 'lang:admin_groups_group_email_form_field_body', 'required_no_html');
         $this->form_validation->set_rules('group_mail[from]', 'lang:admin_groups_group_email_form_field_from', 'required');
         $this->form_validation->set_rules('group_mail[student][]', 'lang:admin_groups_group_email_form_field_students', 'required');
         if ($this->form_validation->run()) {
             $data = $this->input->post('group_mail');
             $students = new Student();
             $students->where_related('participant/group', 'id', $group->id);
             $students->where_related('participant/course', 'id', $group->course_id);
             $students->where_related('participant', 'allowed', 1);
             $students->where_in('id', $data['student']);
             $students->get();
             if ($students->exists()) {
                 $from = NULL;
                 $from_name = '';
                 $teacher = new Teacher();
                 $teacher->get_by_id($this->usermanager->get_teacher_id());
                 if ($data['from'] == 'me') {
                     $from = $teacher->email;
                     $from_name = $teacher->fullname;
                 }
                 $sender_copy = isset($data['sender_copy']) && $data['sender_copy'] == 1 ? TRUE : FALSE;
                 $sender_email = $teacher->email;
                 if ($this->_send_multiple_emails($students, $data['subject'], '{$data.body|add_base_url}', array('data' => $data), $from, $from_name, $sender_copy, $sender_email)) {
                     $this->messages->add_message('lang:admin_groups_group_email_success_sent', Messages::MESSAGE_TYPE_SUCCESS);
                 } else {
                     $this->messages->add_message('lang:admin_groups_group_email_error_send_failed', Messages::MESSAGE_TYPE_ERROR);
                 }
             } else {
                 $this->messages->add_message('lang:admin_groups_group_email_error_no_students_selected', Messages::MESSAGE_TYPE_ERROR);
             }
             redirect(create_internal_url('admin_groups/group_mail/' . $group_id));
         } else {
             $this->group_mail($group_id);
         }
     } else {
         $this->messages->add_message('lang:admin_groups_group_email_error_group_not_found', Messages::MESSAGE_TYPE_ERROR);
         redirect(create_internal_url('admin_groups/group_mail/' . $group_id));
     }
 }
开发者ID:andrejjursa,项目名称:list-lms,代码行数:46,代码来源:groups.php

示例5: delete_group

 public function delete_group($group_id = NULL)
 {
     if (is_null($group_id)) {
         add_error_flash_message('Skupina sa nenašla.');
         redirect(site_url('groups'));
     }
     $this->db->trans_begin();
     $group = new Group();
     $persons_count = $group->person;
     $persons_count->select_func('COUNT', array('@id'), 'persons_count');
     $persons_count->where_related_group('id', '${parent}.id');
     $group->select_subquery($persons_count, 'persons_count');
     $group->select('*');
     $group->get_by_id((int) $group_id);
     if (!$group->exists()) {
         $this->db->trans_rollback();
         add_error_flash_message('Skupina sa nenašla.');
         redirect(site_url('groups'));
     }
     if ((int) $group->persons_count > 0) {
         $this->db->trans_rollback();
         add_error_flash_message('Nie je možné vymazať skupinu, ktorá má členov.');
         redirect(site_url('groups'));
     }
     $success_message = 'Skupina <strong>' . $group->title . '</strong> s ID <strong>' . $group->id . '</strong> bola vymazaná úspešne.';
     $error_message = 'Skupinu <strong>' . $group->title . '</strong> s ID <strong>' . $group->id . '</strong> sa nepodarilo vymazať.';
     if ($group->delete() && $this->db->trans_status()) {
         $this->db->trans_commit();
         add_success_flash_message($success_message);
     } else {
         $this->db->trans_rollback();
         add_error_flash_message($error_message);
     }
     redirect(site_url('groups'));
 }
开发者ID:andrejjursa,项目名称:lstme-ledcoin,代码行数:35,代码来源:groups.php

示例6: change_group

 public function change_group($participant_id)
 {
     $group_id = $this->input->post('group_id');
     $this->_transaction_isolation();
     $this->db->trans_begin();
     $participant = new Participant();
     $participant->get_by_id($participant_id);
     $group = new Group();
     $group->get_by_id($group_id);
     $course = $participant->course->get();
     if ($group->exists()) {
         if ($group->is_related_to($course)) {
             $participant->save($group);
         }
     } else {
         $current_group = $participant->group->get();
         $participant->delete($current_group);
     }
     $is_ok = TRUE;
     if ($group->exists()) {
         if ($participant->allowed == 1) {
             $group_for_test = new Group();
             $rooms = $group_for_test->room;
             $rooms->select_min('capacity');
             $rooms->where('group_id', '${parent}.id', FALSE);
             $group_for_test->select_subquery($rooms, 'group_capacity');
             $group_for_test->include_related_count('participant');
             $group_for_test->where_related_participant('allowed', 1);
             $group_for_test->get_by_id(intval($participant->group_id));
             if ($group_for_test->exists()) {
                 if (intval($group_for_test->participant_count) > intval($group_for_test->group_capacity)) {
                     $is_ok = FALSE;
                 }
             }
         }
     }
     if ($is_ok && $this->db->trans_status()) {
         $this->db->trans_commit();
         $this->_action_success();
         $this->output->set_internal_value('student_id', $participant->student_id);
         $this->output->set_internal_value('course_id', $participant->course_id);
     } else {
         $this->db->trans_rollback();
     }
     $participant->include_related('group', 'name');
     $participant->get_by_id($participant_id);
     $this->parser->parse('backend/participants/group_column.tpl', array('participant' => $participant));
 }
开发者ID:andrejjursa,项目名称:list-lms,代码行数:48,代码来源:participants.php

示例7: remove_role_from_group

 /**
  * Remove Role From Group
  * Removes a role from a group
  * 
  * @param mixed $group_id
  * @param mixed $role_id
  */
 public function remove_role_from_group($group_id, $role_id)
 {
     $g = new Group($group_id);
     $r = new Role($role_id);
     if ($g->exists() and $r->exists()) {
         $g->delete($r);
     }
 }
开发者ID:Moro3,项目名称:duc,代码行数:15,代码来源:Auth_simpleauth.php

示例8: editGroupAction

 /**
  * edit group action pagge
  */
 public function editGroupAction()
 {
     $group = new Group($this->input->post('id'));
     if (!$group->exists()) {
         show_error(lang('system_group_not_found'));
     }
     $group->name = $this->input->post('name');
     $group->description = $this->input->post('description');
     $group->save();
     redirect('users_editor');
 }
开发者ID:kabircse,项目名称:Codeigniter-Egypt,代码行数:14,代码来源:users_editor.php

示例9: get_valuation_table_data

 private function get_valuation_table_data($course_id, $group_id = NULL, $condensed = FALSE)
 {
     $table_data = array('header' => array(), 'content' => array());
     $course = new Course();
     $course->get_by_id(intval($course_id));
     $group = new Group();
     $group->get_by_id((int) $group_id);
     if ($course->exists()) {
         $students = new Student();
         $students->select('id, fullname, email');
         $students->include_related('participant/group', array('id', 'name'));
         $students->where_related('participant/course', 'id', $course->id);
         $students->where_related('participant', 'allowed', 1);
         $students->order_by_as_fullname('fullname');
         if ($group->exists()) {
             $students->where_related('participant/group', 'id', (int) $group_id);
         }
         $students->get_iterated();
         $task_sets_out_of_group_ids = array(0);
         $task_sets_data = array();
         $task_sets_ids = array();
         $projects_ids = array();
         if ($group->exists()) {
             $students_filter = new Student();
             $students_filter->select('id');
             $students_filter->where_related('participant/course', 'id', $course->id);
             $students_filter->where_related('participant', 'allowed', 1);
             $students_filter->where_related('participant/group', 'id', (int) $group->id);
             $solutions_filter = new Solution();
             $solutions_filter->select('id');
             $solutions_filter->where_in_subquery('student_id', $students_filter);
             $task_sets_out_of_group = new Task_set();
             $task_sets_out_of_group->select('id');
             $task_sets_out_of_group->where_in_subquery('id', $solutions_filter);
             $task_sets_out_of_group->where('published', 1);
             $task_sets_out_of_group->get();
             $task_sets_out_of_group_ids = $task_sets_out_of_group->all_to_single_array('id');
             $task_sets_out_of_group_ids[] = 0;
         }
         $content_type_task_set = new Task_set();
         $content_type_task_set->select('id, name, content_type, group_id, task_set_type_id');
         $content_type_task_set->include_related('task_set_type', 'name');
         $content_type_task_set->include_related('group', 'name');
         $content_type_task_set->where('content_type', 'task_set');
         $content_type_task_set->where('published', 1);
         $content_type_task_set->where_related_course($course);
         $content_type_task_set->order_by_related_with_constant('task_set_type', 'name', 'asc');
         $content_type_task_set->order_by('task_set_type_id', 'asc');
         $content_type_task_set->order_by('publish_start_time', 'asc');
         if ($group->exists()) {
             $content_type_task_set->group_start();
             $content_type_task_set->group_start('', 'OR ');
             $content_type_task_set->group_start();
             $content_type_task_set->or_where('group_id', NULL);
             $content_type_task_set->or_where('group_id', (int) $group_id);
             $content_type_task_set->group_end();
             $content_type_task_set->where_subquery(0, '(SELECT COUNT(`tsp`.`id`) AS `count` FROM `task_set_permissions` tsp WHERE `tsp`.`task_set_id` = `task_sets`.`id` AND `tsp`.`enabled` = 1)');
             $content_type_task_set->group_end();
             $content_type_task_set->group_start('', 'OR ');
             $content_type_task_set->where_related('task_set_permission', 'group_id', (int) $group_id);
             $content_type_task_set->where_related('task_set_permission', 'enabled', 1);
             $content_type_task_set->group_end();
             $content_type_task_set->or_where_in('id', $task_sets_out_of_group_ids);
             $content_type_task_set->group_end();
         }
         $content_type_task_set->get();
         $header_items = array();
         if ($content_type_task_set->result_count() > 0) {
             $last_task_set_type_id = NULL;
             foreach ($content_type_task_set->all as $task_set) {
                 $permissions = new Task_set_permission();
                 $permissions->select('id, group_id');
                 $permissions->include_related('group', 'name');
                 $permissions->where_related_task_set($task_set);
                 $permissions->where('enabled', 1);
                 $permissions->get_iterated();
                 if ($permissions->result_count() > 0) {
                     $group_ids = array();
                     $group_names = array();
                     foreach ($permissions as $permission) {
                         $group_ids[] = $permission->group_id;
                         $group_names[] = $this->lang->text($permission->group_name);
                     }
                     $task_sets_data[$task_set->id] = array('group_id' => $group_ids, 'group_name' => $group_names);
                 } else {
                     $task_sets_data[$task_set->id] = array('group_id' => array($task_set->group_id), 'group_name' => $this->lang->text($task_set->group_name));
                 }
                 if ($task_set->task_set_type_id !== $last_task_set_type_id) {
                     $last_task_set_type_id = $task_set->task_set_type_id;
                     $header_items[] = array('type' => 'task_set_type', 'id' => $task_set->task_set_type_id, 'name' => $this->lang->text($task_set->task_set_type_name), 'title' => '');
                 }
                 if (!$condensed) {
                     $header_items[] = array('type' => 'task_set', 'id' => $task_set->id, 'name' => $this->lang->get_overlay_with_default('task_sets', $task_set->id, 'name', $task_set->name), 'title' => is_array($task_sets_data[$task_set->id]['group_name']) ? implode(', ', $task_sets_data[$task_set->id]['group_name']) : $task_sets_data[$task_set->id]['group_name']);
                 }
                 $task_sets_ids[] = $task_set->id;
             }
         }
         $table_data['header']['content_type_task_set'] = array('content_type_name' => $this->lang->line('admin_solutions_valuation_tables_header_content_type_task_sets'), 'items' => $header_items);
         $content_type_project = new Task_set();
         $content_type_project->where('content_type', 'project');
//.........这里部分代码省略.........
开发者ID:andrejjursa,项目名称:list-lms,代码行数:101,代码来源:solutions.php

示例10: remove_user_from_group

 /**
  * Removes the provided user from the provided group.
  *
  * @param User $user_to_remove The user to be removed.
  * @param Group $group The group to remove the user from.
  *
  * @return mixed[string] 'status'=>bool indicating success or failure. 'msg'=>string Message that can be displayed
  */
 public function remove_user_from_group($user_to_remove, $group)
 {
     // Create object for user invoking the script:
     $curr_user = new User();
     // Ensure all parties involved actually exists:
     if ($curr_user->exists() && $user_to_remove->exists() && $group->exists()) {
         // If current user is trying to remove themself then redirect to leave group:
         if ($curr_user->profile_link() === $user_to_remove->profile_link()) {
             return ['status' => false, 'msg' => 'Cannot remove yourself from a group'];
         }
         // Ensure current user has sufficient access rights:
         if ($this->user_access_level($curr_user, $group) < OWNER) {
             return ['status' => false, 'msg' => 'You do not have sufficient Access Rights for ' . $group->name()];
         }
         if (!$this->is_user_active_member($user_to_remove, $group)) {
             return ['status' => false, 'msg' => $user_to_remove->name() . ' is not a member of ' . $group->name()];
         }
         if ($this->remove_from_intermediary_table($user_to_remove->data()->id, $group->data()->id)) {
             return ['status' => true, 'msg' => 'User removed'];
         } else {
             return ['status' => false, 'msg' => 'Could not remove'];
         }
     }
     return ['status' => false, 'msg' => 'Unable to remove ' . $user_to_remove->exists() ? $user_to_remove->name() : 'Invalid User' . ' from ' . $group->exists() ? $group->name() : 'Invalid Group'];
 }
开发者ID:boxtar,项目名称:prototype,代码行数:33,代码来源:Group_Manager.php

示例11: delete

 function delete($id = NULL, $page = 1)
 {
     $files_to_delete = array();
     //filter & Sanitize $id
     $id = $id != 0 ? filter_var($id, FILTER_VALIDATE_INT) : NULL;
     //redirect if it´s no correct
     if (!$id) {
         $this->session->set_flashdata('message', array('type' => 'warning', 'text' => lang('web_object_not_exist')));
         redirect('groups');
     }
     //search the item to delete
     if (Group::exists($id)) {
         $group = Group::find($id);
     } else {
         $this->session->set_flashdata('message', array('type' => 'warning', 'text' => lang('web_object_not_exist')));
         redirect('groups');
     }
     //delete the item
     if ($group->delete() == TRUE) {
         $this->session->set_flashdata('message', array('type' => 'success', 'text' => lang('web_delete_success')));
     } else {
         $this->session->set_flashdata('message', array('type' => 'error', 'text' => lang('web_delete_failed')));
     }
     redirect("/admin/groups/");
 }
开发者ID:csiber,项目名称:CodeIgniter-Starter,代码行数:25,代码来源:groups.php

示例12: User

        // currently logged in user:
        $curr_user = new User();
        // Validate provided access permissions:
        if (isset($trimmed['access']) && is_numeric($trimmed['access']) && ($trimmed['access'] > 0 && $trimmed['access'] < 3)) {
            $access_rights = $trimmed['access'];
        } else {
            $access_rights = false;
            echo '<center><p class="red">Invalid access rights provided</p></center>';
        }
        // user to add to group:
        $user_to_add = new User(strtolower($trimmed['name']));
        // group being added to:
        $group = new Group(strtolower($trimmed['group']));
        // Set page title:
        $page_title = 'Add User To ';
        $page_title .= $group->exists() ? $group->name() : 'Group';
        include HEADER;
        include UTILITIES . 'brand_img.inc.php';
        $status = $group_manager->add_user_to_group($user_to_add, $group, ADMIN);
        if ($status['status'] === true) {
            echo '<br/><center><p><span class="green">' . escape($status['msg']) . '</span><br/>Return to <a href="manage_groups.php">Group Management</a></p></center>';
        } else {
            echo '<br/><center><p><span class="red">' . escape($status['msg']) . '</span><br/>Return to <a href="manage_groups.php">Group Management</a></p></center>';
        }
    } else {
        include HEADER;
        include UTILITIES . 'brand_img.inc.php';
        echo '<br/><center><p><span class="red">Invalid Form Submission. Please Try Again</p></center>';
    }
} else {
    redirect('manage_groups.php');
开发者ID:boxtar,项目名称:prototype,代码行数:31,代码来源:add_user_to_group.php


注:本文中的Group::exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。