* - Show any staff who have cancelled * - Shouldn't throw an error if there are previously declined attendees */ // Allowed actions are actions the user has permissions to do $allowed_actions = array(); $can_view_session =false; if(is_siteadmin()) $can_view_session = true; elseif(is_teammanager()) $can_view_session = true; elseif(is_reportingmanager()) $can_view_session = true; elseif(is_trainingmanager()) $can_view_session = true; elseif(is_odmanager()) $can_view_session = true; else{ if (!$can_view_session) { $return = new moodle_url('/mod/facetoface/view.php', array('f' => $facetoface->id)); redirect($return); die(); } } // Available actions are actions that have a point. e.g. view the cancellations page whhen there are no cancellations is not an "available" action, but it maybe be an "allowed" action $available_actions = array(); $context = context_course::instance($course->id); $contextmodule = context_module::instance($cm->id); if (!$onlycontent) { // Need to check this for security issues
function select_from_users_course_enrol($enrolid=0,$costcenter=null,$skillset=null,$designation=null,$supervisor=0,$zone=null,$branch=null,$role=0,$category=null,$level=null,$userid=0){ global $DB,$USER; if(!is_siteadmin() && $userid!=0){ $userdepartment=$DB->get_record('local_userdata',array('userid'=>$userid)); if($userdepartment->lms_category==''){ $userdepartment_lms_category=0; $sql = "SELECT u.* FROM {user} u JOIN {local_userdata} ud ON u.id =ud.userid WHERE u.id >1 AND u.deleted=0 AND u.suspended=0 AND (ud.lms_category!='AST-EXT')"; }else{ $userdepartment_lms_category=$userdepartment->lms_category; $sql = "SELECT u.* FROM {user} u JOIN {local_userdata} ud ON u.id =ud.userid WHERE u.id >1 AND u.deleted=0 AND u.suspended=0 AND (ud.lms_category!='')"; } }elseif(is_siteadmin()){ $sql = "SELECT u.* FROM {user} u JOIN {local_userdata} ud ON u.id =ud.userid WHERE u.id >1 AND u.deleted=0 AND u.suspended=0 AND (ud.lms_category!='AST-EXT')"; } if($enrolid!=0){ $enrolid_users=$DB->get_fieldset_sql("SELECT userid FROM {user_enrolments} where enrolid=$enrolid"); array_push($enrolid_users, 1); $enrolid_userss = implode(',',$enrolid_users); if(!empty($enrolid_userss)){ $sql .=' AND ud.userid in(' . $enrolid_userss . ')'; } } if (!is_siteadmin() && !is_odmanager()) { //$costcenterid=$DB->get_record('local_userdata',array('userid'=>$USER->id)); // $users_list = $DB->get_fieldset_sql('select userid from {local_userdata} where costcenterid='.$costcenterid->costcenterid.''); // $useridin = implode(',',$users_list); // if(!empty($users_list)) // $sql .= " AND u.id in ($useridin)"; //$userdepartment=$DB->get_record('local_userdata',array('userid'=>$USER->id)); // //echo $userdepartment->lms_category; // if($userdepartment->lms_category==''){ // $userdepartment_lms_category=0; // $users_list = $DB->get_fieldset_sql("SELECT ud.userid FROM {user} u JOIN {local_userdata} ud ON u.id =ud.userid WHERE u.id >1 AND u.deleted=0 AND u.suspended=0 "); //}else{ // $userdepartment_lms_category=$userdepartment->lms_category; // $users_list = $DB->get_fieldset_sql("SELECT ud.userid FROM {user} u JOIN {local_userdata} ud ON u.id =ud.userid WHERE u.id >1 AND u.deleted=0 AND u.suspended=0 AND (ud.lms_category!='')"); //} // $useridin = implode(',',$users_list); //if(!empty($users_list)) //$sql.= " AND u.id in($useridin)"; } if(!empty($designation) && $designation !=='null'){ $designations= implode("','",$designation); if($designations !=='null' && $designations !=='-1'){ $sql.= " AND ud.designation IN('{$designations}')"; } if($designations =='-1'){ $design=list_departments(); $alldesignation= implode("','",$design); $sql.= " AND ud.designation IN('{$alldesignation}')"; } } if(!empty($skillset) && $skillset !=='null'){ $skillsets= implode("','",$skillset); if($skillsets !=='null' && $skillsets !=='-1'){ $sql.= " AND ud.jobfunction IN('{$skillsets}')"; } if($skillsets =='-1'){ $skill=list_skillsets(); //print_object($skill); $allskills= implode("','",$skill); $sql.= " AND ud.jobfunction IN('{$allskills}')"; } } if($costcenter !==0 && $costcenter !=='null') { $costcenters= implode("','",$costcenter); if($costcenters !==null && $costcenters !=="-1"){ $sql .= " AND ud.department IN('{$costcenters}')"; } if($costcenters =='-1'){ $centers=get_costcenter_set(); $allcenters= implode("','",$centers); $sql.= " AND ud.department IN('{$allcenters}')"; } } if(!empty($category) && $category !=='null'){ if (in_array("hr", $category)) { $array=array(); foreach($category as $categor){ if($categor=='hr'){ $array[]=""; }else{ $array[]=$categor; } } $categorys= implode("','",$array); }else{ $categorys= implode("','",$category); } if($categorys !=='null' && $categorys !=='-1'){ $sql.= " AND ud.lms_category IN('{$categorys}')"; } if($categorys =='-1'){ $skill=get_category_set(); $allskills= implode("','",$skill); $sql.= " AND ud.lms_category IN('{$allskills}')"; } } if($supervisor !==0 && $supervisor !=='null') { //print_object($supervisor); $supervisors= implode(",",$supervisor); if($supervisors !==null && $supervisors !=="-1"){ $sql .= " AND ud.supervisorid IN({$supervisors})"; } if($supervisors =='-1'){ $centers=list_supervisors(); $allcenters= implode(",",$centers); $sql.= " AND ud.supervisorid IN({$allcenters})"; } } if(!empty($zone) && $zone !=='null') { //echo $sql; $zones= implode("','",$zone); if($zones !=='null' && $zones !=='-1'){ $sql.= " AND ud.zone IN('{$zones}')"; } if($zones =='-1'){ $szone=list_zones(); $allzones= implode("','",$szone); $sql.= " AND ud.zone IN('{$allzones}')"; } } if(!empty($branch) && $branch !=='null') { //echo $sql; $branches= implode("','",$branch); //echo "A Zone".$zones; if($branches !=='null' && $branches !=='-1'){ $sql.= " AND ud.branch IN('{$branches}')"; } if($branches =='-1'){ $sbranch=list_branches(); $allbranches= implode("','",$sbranch); $sql.= " AND ud.branch IN('{$allbranches}')"; } } if($role !==0 && $role !=='null') { //echo $sql; $roles= implode("','",$role); if($roles !==0 && $roles !=='-1'){ $sql.= " AND ud.roleid IN('{$roles}')"; } if($roles =='-1'){ $sroles=list_roles(); $allroles= implode("','",$sroles); $sql.= " AND ud.roleid IN('{$allroles}')"; } } if(!empty($level) && $level !=='null'){ //print_object($level); $levels= implode("','",$level); if($levels !=='null' && $levels !=='-1'){ $sql.= " AND ud.level IN('{$levels}')"; } if($levels =='-1'){ $skill=get_level_set(); $allskills= implode("','",$skill); $sql.= " AND ud.level IN('{$allskills}')"; } } $attendees = $DB->get_records_sql($sql); return $attendees; }
FROM {user} u LEFT JOIN {local_userdata} ud ON u.id =ud.userid LEFT JOIN {facetoface_signups} su ON ud.userid = su.userid AND su.sessionid = {$session->id} LEFT JOIN {facetoface_signups_status} ss ON su.id = ss.signupid AND ss.superceded != 1 WHERE {$where}"; if (is_trainingmanager()) { $costcenterid = $DB->get_field('local_costcenter_permissions','costcenterid',array('userid'=>$USER->id)); $users_list = $DB->get_fieldset_sql('select userid from {local_userdata} where costcenterid='.$costcenterid.''); $useridin = implode(',',$users_list); if(!empty($users_list)) $sql .= " AND u.id in($useridin)"; } if(is_odmanager()){ $users_list = $DB->get_fieldset_sql('select userid from {local_userdata}'); $useridin = implode(',',$users_list); if(!empty($users_list)) $sql .= " AND u.id in($useridin)"; } //echo $sql; // list($attendeesin, $params) = $DB->get_in_or_equal($attendee_array); $availableusers = $DB->get_recordset_sql($sql,$params); } // Prints a form to add/remove users from the session