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')); }
* * License: http://www.plupload.com/license * Contributing: http://www.plupload.com/contributing */ require_once "../includes/initialize.php"; global $session; // HTTP headers for no cache etc header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); $folder = $_GET['folder']; // Settings //$targetDir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload"; $targetDir = 'groups/' . Group::get_by_id($session->user_group_id)->name . '/files/' . $folder . '/'; $cleanupTargetDir = true; // Remove old files $maxFileAge = 5 * 3600; // Temp file age in seconds // 5 minutes execution time @set_time_limit(5 * 60); // Uncomment this one to fake upload time // usleep(5000); // Get parameters $chunk = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0; $chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 0; $fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : ''; // Clean the fileName for security reasons $fileName = preg_replace('/[^\\w\\._]+/', '_', $fileName); // Make sure the fileName is unique but only if chunking is disabled
if (!$session->is_logged_in()) { die("you can't touch this page"); } if ($what == "user") { foreach ($ids as $id) { User::get_by_id($id)->delete(); } $response = "success"; } else { if ($what == "question") { foreach ($ids as $id) { Question::get_by_id($id)->delete(); } $response = "success"; } else { if ($what == "group") { foreach ($ids as $id) { Group::get_by_id($id)->delete(); } $response = "success"; } else { if ($what == "score") { foreach ($ids as $id) { Score::get_by_id($id)->delete(); } $response = "success"; } } } } echo $response;
public function new_room_form($group_id) { $group = new Group(); $group->get_by_id($group_id); smarty_inject_days(); $this->inject_teachers(); $this->parser->parse('backend/rooms/new_room_form.tpl', array('group' => $group, 'group_id' => $group_id)); }
/* * jQuery File Upload Plugin PHP Example 5.7 * https://github.com/blueimp/jQuery-File-Upload * * Copyright 2010, Sebastian Tschan * https://blueimp.net * * Licensed under the MIT license: * http://www.opensource.org/licenses/MIT */ error_reporting(E_ALL | E_STRICT); require 'upload.class.php'; require_once "../../includes/initialize.php"; global $session; $group = Group::get_by_id($session->user_group_id); $upload_handler = new UploadHandler($group, "questions"); header('Pragma: no-cache'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Content-Disposition: inline; filename="files.json"'); header('X-Content-Type-Options: nosniff'); header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: OPTIONS, HEAD, GET, POST, PUT, DELETE'); header('Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size'); switch ($_SERVER['REQUEST_METHOD']) { case 'OPTIONS': break; case 'HEAD': case 'GET': $upload_handler->get(); break;
function message_owner() { $group = new Group(); $group->get_by_id($this->group_id); if ($group->name) { return $group->name; } $user = new User(); $user->get_by_id($this->user_id); return $user->full_name(); }
<?php require_once "header.php"; if (isset($_GET['id'])) { $object = Group::get_by_id($_GET['id']); if ($object == false || $object == null || $object == "") { header("location: index.php"); } } else { header("location: index.php?negative"); } if (!$session->is_logged_in()) { header("location: index.php?negative"); } else { $user = User::get_by_id($session->user_id); if ($user->enabled == DISABLED) { header("location: index.php?disabled"); } if (!ClubUser::amIAdmin($session->user_id, $object->id) && !$user->is_super_admin()) { header("location: index.php?negative"); } } $pathinfo = pathinfo($_SERVER["PHP_SELF"]); $basename = $pathinfo["basename"]; $currentFile = str_replace(".php", "", $basename); ?> <div class="container-fluid"> <div class="row-fluid"> <div class="span1"></div> <div class="span9"> <form id="theform" class="form-horizontal" method="post" action="#" enctype="multipart/form-data">
public function update_person($person_id = NULL) { if (is_null($person_id)) { add_error_flash_message('Osoba sa nenašla.'); redirect(site_url('persons')); } $this->db->trans_begin(); $person = new Person(); $person->get_by_id((int) $person_id); if (!$person->exists()) { $this->db->trans_rollback(); add_error_flash_message('Osoba sa nenašla.'); redirect(site_url('persons')); } $form = $this->get_edit_form($person); build_validator_from_form($form); if ($this->form_validation->run()) { $person_data = $this->input->post('person'); if (auth_get_id() == $person->id && $person_data['admin'] != 1) { $this->db->trans_rollback(); add_error_flash_message('Nie je možné odobrať oprávnenie administrátora vlastnému účtu.'); redirect(site_url('persons/edit_person/' . $person->id)); } if (auth_get_id() == $person->id && $person_data['enabled'] != 1) { $this->db->trans_rollback(); add_error_flash_message('Nie je možné odobrať oprávnenie na prihlasovanie sa vlastnému účtu.'); redirect(site_url('persons/edit_person/' . $person->id)); } if ($person_data['password'] != '') { $person->password = sha1($person_data['password']); } $person->from_array($person_data, array('name', 'surname', 'login', 'organisation', 'admin', 'enabled', 'number', 'email')); //edit $group = new Group(); if ($person_data['group_id'] != '') { $group->get_by_id((int) $person_data['group_id']); } if ($person->save($group) && $this->db->trans_status()) { $this->db->trans_commit(); add_success_flash_message('Osoba s ID <strong>' . $person->id . '</strong> bola úspešne aktualizovaná.'); redirect(site_url('persons')); } else { $this->db->trans_rollback(); add_error_flash_message('Osobu s ID <strong>' . $person->id . '</strong> sa nepodarilo aktualizovať.'); redirect(site_url('persons/edit_person/' . (int) $person->id)); } } else { $this->db->trans_rollback(); $this->edit_person($person_id); } }
<div id="uploader"> <p>You browser doesn't have Flash, Silverlight, Gears, BrowserPlus or HTML5 support.</p> </div> </div> <h3>Files Uploaded</h3> <div> <table> <?php $group = Group::get_by_id($session->user_group_id); $directory = PUBLIC_PATH . DS . 'groups' . DS . $group->name . DS . 'files' . DS . 'users' . DS . '*'; foreach (glob($directory) as $file) { $name = basename($file); $ext = pathinfo($file, PATHINFO_EXTENSION); $item = "<tr>"; $item .= "<td><a href='groups/" . Group::get_by_id($session->user_group_id)->name . "/files/users/" . $name . "'>" . $name . "</a></td>"; $item .= "<td><a class='click-button' title=" . $name . ">Delete</a></td>"; $item .= "</tr>"; echo $item; } ?> </table> </div> </div> <script> $(function() { $(".click-button").click(function(){
$users = User::get_by_sql("SELECT * FROM " . T_USERS . " WHERE " . C_USER_GROUP_ID . "=" . $session->user_group_id); $s = "<table>"; $s .= "<tr>"; // $s .= "<td>ID</td>"; $s .= "<td>GROUP</td>"; $s .= "<td>USERNAME</td>"; // $s .= "<td>LEVEL</td>"; // $s .= "<td>PASSWORD</td>"; $s .= "<td>NAME</td>"; $s .= "<td>PICTURE</td>"; // $s .= "<td>ACCESS TOKEN</td>"; $s .= "<td>EMAIL</td>"; // $s .= "<td>ACCESS</td>"; $s .= "</tr>"; foreach ($users as $user) { $s .= "<tr>"; // $s .= "<td>". $user->id."</td>"; $s .= "<td>" . Group::get_by_id($session->user_group_id)->name . "</td>"; $s .= "<td>" . $user->username . "</td>"; // $s .= "<td>". $user->level."</td>"; // $s .= "<td>". $user->password."</td>"; $s .= "<td>" . $user->name . "</td>"; $image_source = "../groups/" . Group::get_by_id($session->user_group_id)->name . "/files/users/" . $user->picture; $s .= "<td><img src=" . $image_source . " height='30' /></td>"; // $s .= "<td>". $user->access_token."</td>"; $s .= "<td>" . $user->email . "</td>"; // $s .= "<td>". $user->access."</td>"; $s .= "</tr>"; } $s .= "</table>"; echo $s;
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'); $content_type_project->where('published', 1); $content_type_project->where_related_course($course); $content_type_project->order_by_related_with_constant('task_set_type', 'name', 'asc'); $content_type_project->order_by('publish_start_time', 'asc'); $content_type_project->get(); $header_items = array(); if ($content_type_project->result_count() > 0) { foreach ($content_type_project->all as $project) { if (!$condensed) { $header_items[] = array('type' => 'task_set', 'id' => $project->id, 'name' => $this->lang->get_overlay_with_default('task_sets', $project->id, 'name', $project->name), 'title' => ''); } $projects_ids[] = $project->id; } } $table_data['header']['content_type_project'] = array('content_type_name' => $this->lang->line('admin_solutions_valuation_tables_header_content_type_project'), 'items' => $header_items); foreach ($students as $student) { $student_line = array('fullname' => $student->fullname, 'email' => $student->email, 'id' => $student->id, 'total_points' => 0, 'task_sets_points' => array(), 'task_sets_points_total' => 0, 'projects_points' => array(), 'projects_points_total' => 0); $solutions_data = array(); if ($content_type_task_set->result_count() > 0 || $content_type_project->result_count() > 0) { $solutions = new Solution(); $solutions->select('task_set_id, points, tests_points, not_considered, revalidate'); $solutions->where_related_student($student); $solutions->group_start(); if (count($task_sets_ids) > 0) { $solutions->or_where_in('task_set_id', $task_sets_ids); } if (count($projects_ids) > 0) { $solutions->or_where_in('task_set_id', $projects_ids); } $solutions->group_end(); $solutions->get_iterated(); foreach ($solutions as $solution) { $solutions_data[$solution->task_set_id] = array('points' => is_null($solution->points) && is_null($solution->tests_points) ? NULL : $solution->points + $solution->tests_points, 'not_considered' => $solution->not_considered, 'revalidate' => $solution->revalidate); } } $task_sets_points_array = array(); if ($content_type_task_set->result_count() > 0) { $task_sets_points = 0; $last_task_set_type_id = NULL; $last_task_set_type_key = NULL; foreach ($content_type_task_set->all as $task_set) { if ($last_task_set_type_id !== $task_set->task_set_type_id) { $last_task_set_type_id = $task_set->task_set_type_id; $task_sets_points_array[] = array('type' => 'task_set_type', 'points' => 0, 'flag' => 'ok'); $last_task_set_type_key = count($task_sets_points_array) - 1; } $points = 0; if (isset($solutions_data[$task_set->id])) { if ($solutions_data[$task_set->id]['not_considered']) { if (!$condensed) { $task_sets_points_array[] = array('type' => 'task_set', 'points' => '*', 'flag' => 'notConsidered'); } } else { if (is_null($solutions_data[$task_set->id]['points'])) { if (!$condensed) { $task_sets_points_array[] = array('type' => 'task_set', 'points' => '!', 'flag' => 'revalidate'); } } elseif ($solutions_data[$task_set->id]['revalidate']) { if (!$condensed) { $task_sets_points_array[] = array('type' => 'task_set', 'points' => $solutions_data[$task_set->id]['points'], 'flag' => 'revalidate'); } $points = floatval($solutions_data[$task_set->id]['points']); } else { if (!$condensed) { $task_sets_points_array[] = array('type' => 'task_set', 'points' => $solutions_data[$task_set->id]['points'], 'flag' => 'ok'); } $points = floatval($solutions_data[$task_set->id]['points']); } } } else { if (!$condensed) { if (!is_null($task_sets_data[$task_set->id]['group_id'][0]) && !in_array($student->participant_group_id, $task_sets_data[$task_set->id]['group_id'])) { $task_sets_points_array[] = array('type' => 'task_set', 'points' => '-', 'flag' => 'notInGroup'); } else { $task_sets_points_array[] = array('type' => 'task_set', 'points' => 'x', 'flag' => 'notSubmitted'); } } } $task_sets_points += $points; $task_sets_points_array[$last_task_set_type_key]['points'] += $points; $student_line['total_points'] += $points; $student_line['task_sets_points_total'] = $task_sets_points; } } $student_line['task_sets_points'] = $task_sets_points_array; $task_sets_points_array = array(); if ($content_type_project->result_count() > 0) { $task_sets_points = 0; foreach ($content_type_project as $task_set) { $points = 0; if (isset($solutions_data[$task_set->id])) { if ($solutions_data[$task_set->id]['not_considered']) { if (!$condensed) { $task_sets_points_array[] = array('type' => 'task_set', 'points' => '*', 'flag' => 'notConsidered'); } } else { if (is_null($solutions_data[$task_set->id]['points'])) { if (!$condensed) { $task_sets_points_array[] = array('type' => 'task_set', 'points' => '!', 'flag' => 'revalidate'); } } elseif ($solutions_data[$task_set->id]['revalidate']) { if (!$condensed) { $task_sets_points_array[] = array('type' => 'task_set', 'points' => $solutions_data[$task_set->id]['points'], 'flag' => 'revalidate'); } $points = floatval($solutions_data[$task_set->id]['points']); } else { if (!$condensed) { $task_sets_points_array[] = array('type' => 'task_set', 'points' => $solutions_data[$task_set->id]['points'], 'flag' => 'ok'); } $points = floatval($solutions_data[$task_set->id]['points']); } } } else { if (!$condensed) { $task_sets_points_array[] = array('type' => 'task_set', 'points' => 'x', 'flag' => 'notSubmitted'); } } $task_sets_points += $points; $student_line['total_points'] += $points; $student_line['projects_points_total'] = $task_sets_points; } } $student_line['projects_points'] = $task_sets_points_array; $table_data['content'][] = $student_line; } } return $table_data; }
public function send_deadline_notifications($lang_idiom = NULL) { $this->load->database(); $this->load->model('translations'); if (!is_null($lang_idiom)) { $this->lang->reinitialize_for_idiom($lang_idiom); } $translations = $this->translations->get_translations_for_idiom($this->lang->get_current_idiom()); $this->lang->add_custom_translations($translations); $this->lang->load('cli'); $current_time = Date('Y-m-d H:i:s'); $one_day_back_time = Date('Y-m-d H:i:s', strtotime('now -1 day')); $task_sets1 = new Task_set(); $task_sets1->select('id, name, course_id, group_id AS common_group_id, upload_end_time AS common_upload_end_time, deadline_notified AS common_deadline_notified, deadline_notification_emails AS common_deadline_notification_emails, deadline_notification_emails_handler AS common_deadline_notification_emails_handler'); $task_sets1->select('null AS `task_set_permission_id`', FALSE); $task_sets1->where('deadline_notified', 0); $task_sets1->where('deadline_notification_emails_handler >', 0); $task_sets1->group_start(); $task_sets1->not_group_start(); $task_sets1->where('upload_end_time', NULL); $task_sets1->group_end(); $task_sets1->where('upload_end_time <', $current_time); $task_sets1->where('upload_end_time >=', $one_day_back_time); $task_sets1->group_end(); $task_sets1->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)'); $task_sets1->where('published', 1); $task_sets2 = new Task_set(); $task_sets2->select('id, name, course_id'); $task_sets2->include_related('task_set_permission', 'group_id', 'common'); $task_sets2->include_related('task_set_permission', 'upload_end_time', 'common'); $task_sets2->include_related('task_set_permission', 'deadline_notified', 'common'); $task_sets2->include_related('task_set_permission', 'deadline_notification_emails', 'common'); $task_sets2->include_related('task_set_permission', 'deadline_notification_emails_handler', 'common'); $task_sets2->include_related('task_set_permission', 'id'); $task_sets2->where_related('task_set_permission', 'enabled', 1); $task_sets2->where_related('task_set_permission', 'deadline_notified', 0); $task_sets2->where_related('task_set_permission', 'deadline_notification_emails_handler >', 0); $task_sets2->group_start(); $task_sets2->not_group_start(); $task_sets2->where_related('task_set_permission', 'upload_end_time', NULL); $task_sets2->group_end(); $task_sets2->where_related('task_set_permission', 'upload_end_time <', $current_time); $task_sets2->where_related('task_set_permission', 'upload_end_time >=', $one_day_back_time); $task_sets2->group_end(); $task_sets2->where('published', 1); $task_sets1->union_iterated($task_sets2, TRUE); $this->load->library('email'); $sent_notifications = 0; foreach ($task_sets1 as $task_set) { if ($task_set->common_deadline_notification_emails_handler > 0) { $emails = trim($task_set->common_deadline_notification_emails) != '' ? explode(',', $task_set->common_deadline_notification_emails) : array(); array_walk($emails, function (&$email, $key) { $email = trim($email); }); if ($task_set->common_deadline_notification_emails_handler == 1) { $groups = new Group(); $groups->where_related('course', 'id', $task_set->course_id); $groups->include_related('room/teacher', '*'); $groups->group_start('NOT'); $groups->where_related('room', 'id', null); $groups->or_where_related('room/teacher', 'id', null); $groups->group_end(); $groups->group_by_related('room/teacher', 'email'); if (!is_null($task_set->common_group_id)) { $groups->where('id', $task_set->common_group_id); } $groups->get_iterated(); foreach ($groups as $teacher) { if (trim($teacher->room_teacher_email) != '') { $email = trim($teacher->room_teacher_email); if (!in_array($email, $emails)) { $emails[] = $email; } } } } $group = new Group(); if (!is_null($task_set->common_group_id)) { $group->get_by_id((int) $task_set->common_group_id); } if (count($emails)) { $this->email->from_system(); $this->email->reply_to_system(); $this->email->build_message_body('file:emails/cli/deadline_notification.tpl', array('task_set' => $task_set, 'group' => $group)); if ($this->config->item('email_multirecipient_batch_mode')) { $this->email->to($emails); $this->email->subject('LIST: ' . $this->lang->line('cli_deadline_notification_subject')); $this->email->send(); } else { foreach ($emails as $email) { $this->email->to($email); $this->email->subject('TEST'); $this->email->send(); } } $sent_notifications++; if (!is_null($task_set->task_set_permission_id)) { $task_set_permission = new Task_set_permission(); $task_set_permission->get_by_id($task_set->task_set_permission_id); if ($task_set_permission->exists()) { $task_set_permission->deadline_notified = 1; $task_set_permission->save(); } } else { $task_set_update = new Task_set(); $task_set_update->get_by_id($task_set->id); if ($task_set_update->exists()) { $task_set_update->deadline_notified = 1; $task_set_update->save(); } } } } } echo "Process finished, {$sent_notifications} notifications were sent ...\n"; }
<?php require_once "../includes/initialize.php"; global $session; if (!$session->is_logged_in()) { redirect_to("index.php"); } else { if ($session->user_level > 0) { redirect_to("index.php"); } } if ($_POST['oper'] == 'add') { $group = new Group(); $group->name = $_POST['name']; $group->description = $_POST['description']; $group->banner = $_POST['banner']; $group->create(); } else { if ($_POST['oper'] == 'edit') { $group = Group::get_by_id($_POST['id']); $group->name = $_POST['name']; $group->description = $_POST['description']; $group->banner = $_POST['banner']; $group->update(); } else { if ($_POST['oper'] == 'del') { Group::get_by_id($_POST['id'])->delete(); } } }
/** * Allows the creation of an Administrator * */ function init($save = FALSE) { $first_time = $this->session->userdata('first_time'); if (!$first_time) { show_error('This page can only be accessed the first time.'); } $user = new User(); if ($save) { $user->trans_start(); $user->from_array($_POST, array('name', 'email', 'username', 'password', 'confirm_password')); $group = new Group(); $group->get_by_id(1); if ($user->save($group)) { $user->password = $this->input->post('password'); if (!$this->login_manager->process_login($user)) { show_error('Errors: <ul><li>' . implode('</li><li>', $user->error->all) . '</li></ul><pre>' . var_export($user->error, TRUE) . '</pre>'); } $this->session->unset_userdata('first_time'); $user->trans_complete(); redirect('welcome'); } } $user->load_extension('htmlform'); // ID is not included because it is not necessary $form_fields = array('Contact Information' => 'section', 'name' => array('label' => 'Your Name'), 'email', 'Login Information' => 'section', 'username', 'password', 'confirm_password'); $this->load->view('template_header', array('title' => 'Set Up Your Account', 'section' => 'admin')); $this->load->view('admin/init', array('user' => $user, 'form_fields' => $form_fields)); $this->load->view('template_footer'); }
$notification->itemtype = "clubuser"; $notification->title = "Invites you"; $notification->create(); $response = "success"; } else { $theuser = ClubUser::getUser($user->id, $_GET['clubid']); if ($theuser->pending == 0) { $response = "This user is already a member."; } else { $response = "This user is already pending."; } } } else { if (isset($_GET['groupid'])) { if (!GroupUser::userExists($user->id, $_GET['groupid'])) { $group = Group::get_by_id($_GET['groupid']); $object = new GroupUser(); $object->userid = $user->id; $object->groupid = $group->id; $object->level = 0; $object->role = "student"; $object->enabled = 1; $object->pending = 1; $object->create(); $notification = new Notification(); $notification->fromuserid = $session->user_id; $notification->touserid = $user->id; $notification->itemid = $object->id; $notification->itemtype = "groupuser"; $notification->title = "Invites you"; $notification->create();
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)); }
<?php require_once "../initialize.php"; $group_id = $_GET["group_id"]; $group = Group::get_by_id($group_id); if ($group == null) { die("Group: " . $group_id . " does not exists."); } $files = array(); $directory = PUBLIC_PATH . DS . 'groups' . DS . $group->name . DS . 'files' . DS . 'questions' . DS . '*'; foreach (glob($directory) as $file) { array_push($files, basename($file)); } echo json_encode($files);
<?php require_once "../includes/initialize.php"; global $session; $folder = $_GET['folder']; $file_name = $_POST['file_name']; $path = "groups/" . Group::get_by_id($session->user_group_id)->name . "/files/" . $folder . "/" . $file_name; $result = "ERROR"; if (unlink($path)) { $result = "success"; } echo $folder . ", " . $path;
<a href="categories.php" data-theme="" data-icon="forward"> Play </a> </li> <li> <a href="../logout.php" data-theme="" data-icon=""> Logout </a> </li> </ul> </div> </div> <div data-role="content"> <div style="display: inline"> <img id="img_picture" style="width: 100px; height: 100%" src="<?php echo "../groups/" . Group::get_by_id($user->group_id)->name . "/files/users/" . $user->picture; ?> " /> </div> <h2 id="lbl_name"> <?php echo $user->name; ?> </h2> <h5 id="lbl_highest_score"> Highest Score: <?php echo $highest_score; ?> </h5> <h5 id="lbl_recent_score"> Recent Score: <?php
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')); }
var textQuestion; var videoQuestion; var imageQuestion; var audioQuestion; var btnA; var btnB; var btnC; var btnSkip; var groupURL = "http://<?php echo $_SERVER['SERVER_NAME']; ?> /BundledFun/public/groups"; var group_name = "<?php echo Group::get_by_id($session->user_group_id)->name; ?> "; var group_id = "<?php echo $session->user_group_id; ?> "; (function($) { $.fn.changeButtonText = function(newText) { return this.each(function() { $this = $(this);
//echo ' <p>'; echo ' Clubs: '; //echo ' <ul>'; foreach ($clubusers as $clubuser) { $club = Club::get_by_id($clubuser->clubid); echo ' <a href="club.php?id=' . $club->id . '">' . $club->name . '</a>, '; } echo ' <br />'; //echo ' </div>'; } if (count($groupusers) > 0) { //echo ' <br />'; echo ' Groups: '; //echo ' <ul>'; foreach ($groupusers as $groupuser) { $group = Group::get_by_id($groupuser->groupid); echo ' <a href="group.php?id=' . $group->id . '">' . $group->name . '</a>, '; } //echo ' </p>'; //echo ' </div>'; } echo ' '; echo ' </div>'; echo ' </div>'; } } } } ?> </div><!--/span--> </div><!--/row-->
if ($notification->itemtype == "sectionuser") { $object = SectionUser::get_by_id($notification->itemid); $section = Section::get_by_id($object->sectionid); $batch = Batch::get_by_id($object->batchid); $school = School::get_by_id($object->schoolid); $html .= "Now a member in Section <a href='section.php?id=" . $section->id . "'>" . $section->name . "</a> of Batch <a href='batch.php?id=" . $batch->id . "'>" . $batch->get_batchyear() . "</a> of School <a href='school.php?id=" . $school->id . "'>" . $school->name . "</a>"; } else { if ($notification->itemtype == "clubuser") { $object = ClubUser::get_by_id($notification->itemid); $club = Club::get_by_id($object->clubid); $school = School::get_by_id($object->schoolid); $html .= "Now a member in Club <a href='club.php?id=" . $club->id . "'>" . $club->name . "</a> of School <a href='school.php?id=" . $school->id . "'>" . $school->name . "</a>"; } else { if ($notification->itemtype == "groupuser") { $object = GroupUser::get_by_id($notification->itemid); $group = Group::get_by_id($object->groupid); $school = School::get_by_id($object->schoolid); $html .= "Now a member in Group <a href='group.php?id=" . $group->id . "'>" . $group->name . "</a> of School <a href='school.php?id=" . $school->id . "'>" . $school->name . "</a>"; } } } } } } $html .= "\t\t<button class='btn btn-mini btndelete pull-right'>x<span hidden class='notificationid'>" . $notification->id . "</span></button>"; } $html .= "\t\t<p>" . $notification->date . "</p>"; $html .= "\t\t</div>"; $html .= " </td>"; $html .= "</tr>"; }
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)); } }
<?php require_once "../initialize.php"; $message = ""; if (isset($_POST['groupid']) && $_POST['groupid'] != "" && isset($_POST['name']) && $_POST['name'] != "") { $object = Group::get_by_id($_POST['groupid']); $file = new File($_FILES['logo']); if ($file->valid) { $object->logo = $file->data; } else { $object->logo = base64_decode($object->logo); } $file = new File($_FILES['cover']); if ($file->valid) { $object->cover = $file->data; } else { $object->cover = base64_decode($object->cover); } if ($message == "") { if (isset($_POST['schoolselect']) && $_POST['schoolselect'] != "NOTHING") { $school = School::get_by_id($_POST['schoolselect']); } $object->schoolid = $school->id; $object->name = $_POST['name']; $object->about = $_POST['about']; $object->enabled = $_POST['enabled']; $object->comments = $_POST['comments']; $object->fbcomments = $_POST['fbcomments']; $object->update(); $log = new Log($session->user_id, $clientip, "WEB", "UPDATED GROUP: " . $object->id); $log->create();
<?php require_once "../initialize.php"; $id = $_GET['id']; $object = Group::get_by_id($id); GroupUser::delete_all_by_sectionid($object->id); $object->delete(); $log = new Log($session->user_id, $clientip, "WEB", "DELETED CLUB: " . $object->id); $log->create(); echo "success";
function list_import_lamsfet_sets(&$sets, $set_types, $courses_terms, $excercise_groups) { echo 'Starting task_sets import (' . count($sets) . ') ['; if (count($sets)) { foreach ($sets as $id => $set) { $task_set_type_id = $set_types[$set->set_type_id]->_list_id; $task_set_type = new Task_set_type(); $task_set_type->get_by_id(intval($task_set_type_id)); $course_id = $courses_terms[$set->course_term_id]->_list_id; $course = new Course(); $course->get_by_id(intval($course_id)); $group_id = !is_null($set->excercise_group_id) ? $excercise_groups[$set->excercise_group_id]->_list_id : NULL; $group = new Group(); if (!is_null($group_id)) { $group->get_by_id(intval($group_id)); } $task_set = new Task_set(); $task_set->name = $set->name; if (!is_null($set->comment)) { $task_set->instructions = nl2br($set->comment); } if (!empty($set->date_from)) { $task_set->publish_start_time = $set->date_from; } if (!empty($set->submit_to)) { $task_set->upload_end_time = $set->submit_to; } $task_set->published = 1; $task_set->save(array($task_set_type, $group, $course)); $sets[$id]->_list_id = $task_set->id; echo '.'; } } echo '] ... done' . "\n"; }