function delete_learningplan_record($table, $id, $url, $lp_id = '') { global $DB, $OUTPUT; // Delete Department. $costcenter = new costcenter; if ($table == 'learning_learningplan') { /* * */ //$courses = $DB->get_fieldset_select('learning_plan_training','t_id',array('lp_id'=>$id)); //$users = $DB->get_fieldsetselect('learning_user_learningplan','u_id',array('lp_id'=>$id)); //foreach($users as $user){ // //} $DB->delete_records('learning_plan_training ', array('lp_id' => $id)); $DB->delete_records('learning_user_learningplan ', array('lp_id' => $id)); $DB->delete_records('learning_learningplan', array('id' => $id)); } else if ($table == 'learning_training') { $DB->delete_records('learning_training', array('id' => $id)); $training = $DB->get_field('learning_plan_training','t_id',array('id'=>$id)); $DB->delete_records('enrol',array('enrol'=>'learning_plan','courseid'=>$training)); $DB->delete_records('learning_plan_training', array('t_id' => $id)); } else if ($table == 'learning_plan_training') { $training = $DB->get_field('learning_plan_training','t_id',array('id'=>$id)); $userids = $DB->get_field('learning_user_trainingplan','u_id',array('lpt_id'=>$id)); $studentroleid = $DB->get_field('role', 'id', array('shortname' => 'student'), MUST_EXIST); $lplanenrol = new enrol_learning_plan_plugin; foreach($userids as $userid){ $enrol = $DB->get_record('enrol', array('courseid' => $training, 'enrol' => 'learning_plan')); $lplanenrol->unenrol_user($enrol, $id, $studentroleid); } $DB->delete_records('enrol',array('enrol'=>'learning_plan','courseid'=>$training)); $DB->delete_records('learning_plan_training', array('id' => $id)); } else if ($table == 'learning_user_learningplan') { $DB->delete_records('learning_user_learningplan', array('u_id' => $id, 'lp_id' => $lp_id)); // Remove all training in learning_user_trainingplan $sql = "select id from {learning_plan_training} where lp_id =?"; $lpts = $DB->get_recordset_sql($sql, array('lp_id' => $lp_id), $limitfrom = 0, $limitnum = 0); $training = learningplan_training($lp_id); foreach ($training as $train) { $studentroleid = $DB->get_field('role', 'id', array('shortname' => 'student'), MUST_EXIST); $manualenrol = enrol_get_plugin('manual'); $enrol = $DB->get_record('enrol', array('courseid' => $train->t_id, 'enrol' => 'manual')); $manualenrol->unenrol_user($enrol, $id, $studentroleid); } foreach ($lpts as $lpt) { $DB->delete_records('learning_user_trainingplan', array('u_id' => $id, 'lpt_id' => $lpt->id)); } } $style = array('style' => 'notifysuccess'); $costcenter->set_confirmation(get_string('learningplandeletedsuccess', 'block_learning_plan'), $url, $style); }
$returnurl = new moodle_url('/local/positions/assignusers.php'); $PAGE->url->param('unassign', 1); if ($confirm and confirm_sesskey()) { $positionname = $DB->get_field('local_positions','fullname',array('id'=>$id)); $username = $DB->get_field('user','username',array('id'=>$userid)); $dataobject = new stdClass(); $dataobject->position = $positionname; $dataobject->username = $username; /* * Bug#16 Admin/Training Manager>Manage Positions>Unassign User- Error * Updating position to empty string is not a good idea. updated to '0' */ //$sql = "UPDATE {local_userdata} SET position='' WHERE userid=$userid AND position=$id"; $sql = "UPDATE {local_userdata} SET position=0 WHERE userid=$userid AND position=$id"; $DB->execute($sql); $costcenter->set_confirmation(get_string('unassignedsuccess', 'local_positions',$dataobject), $CFG->wwwroot.'/local/positions', array('style' => 'notifysuccess')); } } } if (!empty($position) and $position >0 and $data = data_submitted()) { // Insert Record $lplans = array(); foreach ($data as $key => $value) { if (preg_match('/^l\d+$/', $key)) { $lplan_id = substr($key, 1); array_push($lplans, $lplan_id); } } foreach($lplans as $key=>$value){
$fromform->timecreated = time(); $fromform->usermodified = $USER->id; if ($fromform->id) { $DB->update_record('learning_learningplan', $fromform); $lp_courses = $DB->get_fieldset_sql('SELECT t_id FROM {learning_plan_training} where lp_id='.$fromform->id.''); array_push($lp_courses,1); $lp_courses = implode(',',$lp_courses); $lp_users = $DB->get_fieldset_sql("select u_id from {learning_user_learningplan} where lp_id=$fromform->id"); $lp_users = implode(',',$lp_users); $enrol = $DB->get_fieldset_sql('select id from {enrol} where courseid in('.$lp_courses.') AND enrol="learning_plan"'); $lp_enrols = implode(',',$enrol); if(!empty($lp_enrols)&& !empty($lp_users)){ $sql = 'UPDATE {user_enrolments} SET timestart='.$fromform->startdate.' ,timeend='.$fromform->enddate.' WHERE enrolid in('.$lp_enrols.') AND userid in('.$lp_users.')'; $DB->execute($sql); } $costcenter->set_confirmation(get_string('learningplanupdatedsuccess', 'block_learning_plan',$fromform), $pageurl, array('style' => 'notifysuccess')); } else { if(is_manager()){ $costcenterid = $DB->get_field('local_costcenter_permissions','costcenterid',array('userid'=>$USER->id)); $fromform->costcenterid = $costcenterid; } $fromform->timemodified = time(); $fromform->timecreated = time(); $fromform->usermodified = $USER->id; // Insert Record $DB->insert_record('learning_learningplan', $fromform); $costcenter->set_confirmation(get_string('learningplancreatedsuccess', 'block_learning_plan',$fromform), $pageurl, array('style' => 'notifysuccess')); } }
else { $evaluation = new stdClass(); $evaluation->id = -1; } $batchid=$DB->get_record('facetoface',array('id'=>$classid)); $returnurl = new moodle_url('/mod/facetoface/view_sessions.php?sessiontype='.$batchid->active.'&batchid='.$batchid->id.''); //$returnurl = new moodle_url('/mod/facetoface/view_sessions.php'); if ($delete ) { $PAGE->url->param('delete', 1); if ($confirm and confirm_sesskey()) { $DB->delete_records('local_evaluation',array('id'=>$id)); //redirect($returnurl); $message = get_string('evaldeleted','local_evaluations'); $style = array('style'=>'notifysuccess'); $costcenter->set_confirmation($message,$returnurl,$style); } $strheading = get_string('deleteevaluation', 'local_evaluations'); $PAGE->navbar->add(get_string('viewevaluations','local_evaluations')); $PAGE->navbar->add($strheading); $PAGE->set_title($strheading); echo $OUTPUT->header(); echo $OUTPUT->heading($strheading); $yesurl = new moodle_url('/local/evaluations/create_evaluation.php', array('id'=>$id, 'clid'=>$classid,'delete'=>1, 'confirm'=>1, 'sesskey'=>sesskey())); $message = get_string('delconfirm', 'local_evaluations'); echo $OUTPUT->confirm($message, $yesurl, $returnurl); echo $OUTPUT->footer(); die; } if ($id > 0)
if (isset($formdata->confirmdelete) AND $formdata->confirmdelete == 1) { if (!$template = $DB->get_record("evaluation_template", array("id"=>$deletetempl))) { print_error('error'); } // if ($template->ispublic) { // $systemcontext = get_system_context(); // require_capability('mod/evaluation:createpublictemplate', $systemcontext); // require_capability('mod/evaluation:deletetemplate', $systemcontext); // } evaluation_delete_template($template); $message = get_string('templatedelsuccess','local_evaluations'); $style = array('style'=>'notifysuccess'); $costcenter->set_confirmation($message,$deleteurl->out(false),$style); //redirect($deleteurl->out(false)); } /// Print the page header $strevaluations = get_string("modulenameplural", "local_evaluations"); $strevaluation = get_string("modulename", "local_evaluations"); $strdeleteevaluation = get_string('delete_template', 'local_evaluations'); //$PAGE->set_heading(format_string($course->fullname)); $PAGE->set_title(format_string($evaluation->name)); echo $OUTPUT->header(); /// Print the main part of the page
if ($parent) { $message = get_string('failure', 'local_costcenter'); $style = array('style' => 'notifyproblem'); } else { $DB->set_field('local_costcenter', 'visible', $disabled, array('id' => $id)); $message_object->costcenter = $DB->get_field('local_costcenter', 'fullname', array('id' => $id)); $message_object->visible = $DB->get_field('local_costcenter', 'visible', array('id' => $id)); if ($message_object->visible == 1) { $message_object->visible = 'Activated'; } else { $message_object->visible = 'Inactivated'; } $message = get_string('success', 'local_costcenter', $message_object); $style = array('style' => 'notifysuccess'); } $costcenter->set_confirmation($message, $returnurl, $style); } if ($visible >= 0 && $id && confirm_sesskey()) { //If it is parent for other costcenter, dont allow to hide it $parent = $DB->record_exists('local_costcenter', array('parentid' => $id)); if ($parent) { $message = get_string('failure', 'local_costcenter'); $style = array('style' => 'notifyproblem'); } else { $DB->set_field('local_costcenter', 'visible', $visible, array('id' => $id)); $message_object->costcenter = $DB->get_field('local_costcenter', 'fullname', array('id' => $id)); $message_object->visible = $DB->get_field('local_costcenter', 'visible', array('id' => $id)); if ($message_object->visible == 1) {