Example #1
0
 static function create_extended_user($username, $title, $forname, $surname, $email, $course, $gender, $year, $role, $sid, $db, $school, $coursedesc, $initials = null, $password = '')
 {
     $courseok = CourseUtils::add_course($school, $course, $coursedesc, $db);
     if ($courseok !== true and $course != '' or $username == '' or $surname == '' or $email == '') {
         return false;
     }
     if (!in_array($role, array('Staff', 'Student', 'SysAdmin', 'Admin', 'graduate', 'left', 'External Examiner'))) {
         // not a valid role
         return false;
     }
     $userid = self::create_user($username, $password, $title, $forname, $surname, $email, $course, $gender, $year, $role, $sid, $db, $initials);
     return $userid;
 }
Example #2
0
 /**
  * Check for already existing and then add new course data into the database.
  *
  * @param integer $schoolid ID of the school the course belongs to
  * @param string $name code of the course e.g. B140
  * @param string $description a title for the course e.g. Neuroscience BSc
  * @param object $db database connection
  *
  * @return bool depending on insert success
  */
 static function add_course($schoolid, $name, $description, $db)
 {
     if ($name == '') {
         return false;
     }
     if (CourseUtils::course_exists($name, $db) === true) {
         return true;
     }
     if (!is_int($schoolid)) {
         //school name given not school id so convert
         $schoolid = SchoolUtils::get_school_id_by_name($schoolid, $db);
         if (!$schoolid) {
             return false;
         }
     }
     $result = $db->prepare("INSERT INTO courses VALUES (NULL, ?, ?, NULL, ?)");
     $result->bind_param('ssi', $name, $description, $schoolid);
     $result->execute();
     $result->close();
     if ($db->errno != 0) {
         return false;
     }
     return true;
 }
Example #3
0
 for ($a = 0; $a < strlen($_POST['new_grade2']); $a++) {
     $b = substr($_POST['new_grade2'], $a, 1);
     if (ctype_upper($b) or ctype_digit($b)) {
         $new_moduleid = $new_moduleid . $b;
     }
 }
 $new_moduleid = $new_moduleid . $maxmodid;
 // Check for unique username
 if (UserUtils::username_exists($_POST['new_username'], $mysqli) or UserUtils::username_exists($_POST['new_username'] . '-stu', $mysqli)) {
     $unique_username = false;
 } else {
     $unique_username = true;
 }
 $schoolID = SchoolUtils::add_school(1, 'School of Practice', $mysqli);
 // Make sure the 'School of Practice' school exists.
 CourseUtils::add_course($schoolID, 'A10DEMO', 'Demonstration BSc', $mysqli);
 // Make sure demo course exists.
 $new_modid = module_utils::add_modules($new_moduleid, $_POST['new_grade2'], 1, $schoolID, NULL, NULL, true, true, true, false, false, true, false, $mysqli, 0, 0, 1, 1, '07/01');
 if ($unique_username == true) {
     $_POST['new_grade'] = $new_moduleid;
     $session = date_utils::get_current_academic_year();
     // Add staff account
     $new_username = trim($_POST['new_username']);
     $useridstf = adduser('Staff', 'Staff', $new_username, $mysqli);
     UserUtils::add_staff_to_module_by_modulecode($useridstf, $new_moduleid, $mysqli);
     // Add staff to the new module
     UserUtils::add_staff_to_module_by_modulecode($useridstf, 'DEMO', $mysqli);
     // Add staff to the general DEMO module
     // Add student account
     $max_sid = 0;
     $new_username = $new_username . '-stu';
Example #4
0
if (!CourseUtils::courseid_exists($courseID, $mysqli)) {
    $msg = sprintf($string['furtherassistance'], $configObject->get('support_email'), $configObject->get('support_email'));
    $notice->display_notice_and_exit($mysqli, $string['pagenotfound'], $msg, $string['pagenotfound'], '../artwork/page_not_found.png', '#C00000', true, true);
}
$unique_course = true;
$tmp_course = '';
$result = $mysqli->prepare("SELECT schoolid, name, description FROM courses WHERE id = ? LIMIT 1");
$result->bind_param('i', $courseID);
$result->execute();
$result->bind_result($current_school, $name, $description);
$result->fetch();
$result->close();
if (isset($_POST['submit']) and $_POST['course'] != $_POST['old_course']) {
    // Check for unique course name
    $new_course = trim($_POST['course']);
    $course_exists = CourseUtils::course_exists($new_course, $mysqli);
}
if (isset($_POST['submit']) and $course_exists == false) {
    $new_course = trim($_POST['course']);
    $new_school = $_POST['school'];
    $new_description = trim($_POST['description']);
    $result = $mysqli->prepare("UPDATE courses SET name = ?, description = ?, schoolid = ? WHERE id = ?");
    $result->bind_param('ssii', $new_course, $new_description, $new_school, $courseID);
    $result->execute();
    $result->close();
    $logger = new Logger($mysqli);
    if ($name != $new_course) {
        $logger->track_change('Course', $courseID, $userObject->get_user_ID(), $name, $new_course, 'code');
    }
    if ($description != $new_description) {
        $logger->track_change('Course', $courseID, $userObject->get_user_ID(), $description, $new_description, 'name');
Example #5
0
    $msg = sprintf($string['furtherassistance'], $configObject->get('support_email'), $configObject->get('support_email'));
    $notice->display_notice_and_exit($mysqli, $string['pagenotfound'], $msg, $string['pagenotfound'], '../artwork/page_not_found.png', '#C00000', true, true);
}
require '../tools/colour_picker/colour_picker.inc';
require '../include/user_search_options.inc';
require '../include/toprightmenu.inc';
echo draw_toprightmenu();
if ($demo == true) {
    // Hide the personal details.
    $user_details['surname'] = demo_replace($user_details['surname'], $demo);
    $user_details['first_names'] = demo_replace($user_details['first_names'], $demo);
    $user_details['initials'] = demo_replace($user_details['initials'], $demo);
    $user_details['student_id'] = demo_replace_number($user_details['student_id'], $demo);
    $user_details['email'] = demo_replace_username($user_details['email'], $demo);
}
$course_details = CourseUtils::get_course_details_by_name($user_details['grade'], $mysqli);
if ($user_details['user_deleted'] == '') {
    $bg_color = '#EEF4FF';
} else {
    $bg_color = '#FFC0C0';
}
?>
<div id="content">
<table cellpadding="0" cellspacing="0" border="0" style="background-color:<?php 
echo $bg_color;
?>
; width:100%; line-height:175%; padding-bottom:10px">
<form name="myform" action="<?php 
echo $_SERVER['PHP_SELF'];
?>
?userID=<?php 
Example #6
0
                         $schoolID = $school_list[trim($fields[2])];
                     } else {
                         if ($unknown_schoolID == 0) {
                             $result = $mysqli->prepare("SELECT id FROM faculty WHERE name='Administrative and Support Units' LIMIT 1");
                             $result->execute();
                             $result->bind_result($facultyID);
                             $result->fetch();
                             $result->close();
                             $unknown_schoolID = SchoolUtils::add_school($facultyID, '', $mysqli);
                         }
                         $schoolID = $unknown_schoolID;
                     }
                     if (in_array($courseid, $course_list)) {
                         echo "<tr><td></td><td class=\"existing\">{$courseid}</td><td class=\"existing\">{$description}</td><td class=\"existing\">" . $string['alreadyexists'] . "</td></tr>\n";
                     } else {
                         $success = CourseUtils::add_course($schoolID, $courseid, $description, $mysqli);
                         if ($success) {
                             echo "<tr><td><img src=\"../artwork/green_plus_16.png\" wodth=\"16\" height=\"16\" alt=\"Add\" /></td><td class=\"added\">{$courseid}</td><td class=\"added\">{$description}</td><td class=\"added\">" . $string['added'] . "</td></tr>\n";
                             $coursesAdded++;
                         } else {
                             echo "<tr><td><img src=\"../artwork/red_cross_16.png\" wodth=\"16\" height=\"16\" alt=\"Failed\" /></td><td class=\"failed\">{$courseid}</td><td class=\"failed\">{$description}</td><td class=\"failed\">" . $string['failed'] . "</td></tr>\n";
                         }
                     }
                 }
             }
         }
     }
 }
 unlink($configObject->get('cfg_tmpdir') . $userObject->get_user_ID() . "_course_create.csv");
 echo "</table>";
 echo "<div style=\"text-align:center\"><input type=\"button\" name=\"ok\" value=\"" . $string['ok'] . "\" onclick=\"window.location='list_courses.php'\" style=\"width:100px\" /></div>\n<br />\n";
Example #7
0
//
// You should have received a copy of the GNU General Public License
// along with Rogō.  If not, see <http://www.gnu.org/licenses/>.
/**
*
* @author Simon Wilkinson
* @version 1.0
* @copyright Copyright (c) 2014 The University of Nottingham
* @package
*/
require '../include/sysadmin_auth.inc';
$unique_course = true;
if (isset($_POST['submit'])) {
    // Check for unique username
    $tmp_course = trim($_POST['course']);
    if (CourseUtils::course_exists($tmp_course, $mysqli)) {
        $unique_course = false;
    } else {
        $unique_course = true;
    }
}
if (isset($_POST['submit']) and $unique_course == true) {
    $tmp_school = $_POST['school'];
    $tmp_course = trim($_POST['course']);
    $tmp_description = trim($_POST['description']);
    $result = $mysqli->prepare("INSERT INTO courses VALUES (NULL, ?, ?, NULL, ?)");
    $result->bind_param('ssi', $tmp_course, $tmp_description, $tmp_school);
    $result->execute();
    $result->close();
    $mysqli->close();
    header("location: list_courses.php");