Ejemplo n.º 1
0
 /**
  * Updates the modules on a paper. Removes modules if the user has permission to do so and then adds in the new modules.
  * @param array $paper_modules - An array of modules keyed on idMod
  * @param int $paperID 				- The id of the paper or property_id
  * @param object $db 					- Database connection
  * @param object $userObject 	- Currently authenticated user
  * @return void
  */
 public function update_modules($paper_modules, $paperID, $db, $userObject)
 {
     $staff_modules = $userObject->get_staff_modules();
     if (count($staff_modules) < 0) {
         $user_modules = get_staff_modules($userObject->get_user_ID(), $db, $userObject->get_user_ID());
     }
     if (count($staff_modules) > 0) {
         if ($userObject->has_role('SysAdmin')) {
             $user_can_delete = '';
             // No restrictions
         } else {
             $user_can_delete = "AND idMod IN (" . implode(',', array_keys($staff_modules)) . ")";
             // Users can only remove modules if they are on the team.
         }
         $editProperties = $db->prepare("DELETE FROM properties_modules WHERE property_id = ? {$user_can_delete}");
         $editProperties->bind_param('i', $paperID);
         $editProperties->execute();
         $editProperties->close();
     }
     Paper_utils::add_modules($paper_modules, $paperID, $db);
 }
Ejemplo n.º 2
0
}
// Process the posted modules
$modules = array();
$first = true;
for ($i = 0; $i < $_POST['module_no']; $i++) {
    if (isset($_POST['mod' . $i])) {
        $module_code = module_utils::get_moduleid_from_id($_POST['mod' . $i], $mysqli);
        if ($first == true) {
            $first_module = $_POST['mod' . $i];
            $first = false;
        }
        $modules[$_POST['mod' . $i]] = $module_code;
    }
}
//add the modules to the paper
Paper_utils::add_modules($modules, $property_id, $mysqli);
$stmt = $mysqli->prepare("SELECT UNIX_TIMESTAMP(created), paper_ownerID FROM properties WHERE property_id = ?");
$stmt->bind_param('i', $property_id);
$stmt->execute();
$stmt->bind_result($created, $paper_ownerID);
$stmt->fetch();
$stmt->close();
$hash = $property_id . $created . $paper_ownerID;
// Generate the encrypted name of the paper.
if ($configObject->get('cfg_summative_mgmt') and $_POST['paper_type'] == 'summative') {
    $duration = 0;
    if (isset($_POST['duration_hours'])) {
        $duration += $_POST['duration_hours'] * 60;
    }
    if (isset($_POST['duration_mins'])) {
        $duration += $_POST['duration_mins'];