/** * 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); }
// Build up a list of all past reviewers and labs for the 'changes' tab $changed_reviewers = array(); $changed_labs = array(); $change_callbacks = setup_change_callbacks($changed_reviewers, $changed_labs); $logger = new Logger($mysqli); // Get the changes to be used later $changes = $logger->get_changes('Paper', $paperID, $change_callbacks); if ($properties->get_summative_lock() and !$userObject->has_role('SysAdmin')) { $locked = true; $disabled = ' disabled'; } else { $locked = false; $disabled = ''; } if (!isset($staff_modules)) { $staff_modules = get_staff_modules($userObject->get_user_ID(), $mysqli, $userObject); } function format_color($color) { return '<div style="background-color:' . $color . '; border:1px solid #C0C0C0; width:50px; height:15px"></div>'; } function format_referencematerial($ID, $refID) { if ($ID == '') { return ''; } return $refID[$ID]; } function format_folders($id, $folders) { if ($id == '') {