예제 #1
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;
 }
예제 #2
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');
예제 #3
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");