public function usuarios_por_profesor($inicio = false, $fin = false, $grafica = 'usuarios_por_clases') { if (!$fin) { $fin = current_time('timestamp'); } if (!$inicio) { $inicio = current_time('timestamp') - dias(14); } $unix_time_inicio = strtotime($inicio); $unix_time_fin = strtotime($fin); $dias = ($unix_time_fin - $unix_time_inicio) / 60 / 60 / 24; $html = ''; $profesores = get_posts(array('post_type' => 'instructor', 'posts_per_page' => -1, 'fields' => 'ids')); if (!$profesores) { return; } $html .= $this->js_css(); foreach ($profesores as $profe_id) { $data = array('fechas' => array()); $profe = new Instructor($profe_id); $clases_por_fecha = $profe->get_clases($inicio, $fin, true, true); $maximo_bicis_dia = 0; if ($clases_por_fecha) { foreach ($clases_por_fecha as $fecha => $clase_array) { if (!count($clase_array)) { continue; } /*SETEAMOS EL DIA EN EL QUE TRABAJAMOS*/ if (!isset($data['fechas'][$fecha])) { $data['fechas'][$fecha] = array(); } /*RECORREMOS LAS CLASES*/ foreach ($clase_array as $clase_objeto) { $clase = new Clase($clase_objeto->ID); $bicis_totales = $clase->cantidad_bicis(2); $bicis_disponibles = $clase->cantidad_bicis(1); $bicis_tomadas = $bicis_totales - $bicis_disponibles; if ($maximo_bicis_dia < $bicis_tomadas) { $maximo_bicis_dia = $bicis_tomadas; } $data['fechas'][$fecha][] = array('hora' => date_i18n('H:i', $clase->fecha), 'asistencia' => $bicis_tomadas, 'totales' => $bicis_totales, 'id_clase' => $clase->ID, 'instructor' => get_the_title($clase->instructor)); } } $data['maximo'] = $maximo_bicis_dia; $data['instructor'] = $profe->nombre; $data['instructor_foto'] = $profe->foto; /*UNA VEZ SETEADA LA INFORMACIÓN LA IMPRIMIMOS*/ $html .= $this->crear_grafica('usuarios_por_clases', $data); $html .= $this->crear_grafica('porcentaje_por_clases', $data); } } return $html; }
public function action_index() { $instructors = Instructor::all(); $schedule = Schedule::all('Fall 2012'); //dd($instructors); //dd($schedule); $data = array('itp_instructors' => $instructors, 'scheduled_courses' => $schedule); return View::make('home.index', $data); }
public static function factory($accountType) { if (Instructor::getName() === $accountType) { return new Instructor(); } if (Uploader::getName() === $accountType) { return new Uploader(); } return new Student(); }
public function imprimir($imprimir = true, $clase = '', $defecto = false, $front = false) { $dias = ($this->fecha_fin - $this->fecha_inicio) / dias(1); /*NUMERO DE DIAS A IMPRIMIR*/ $clases_format = array(); switch ($this->classe) { case 'ubicacion': $ubicacion = new Ubicacion($this->data_tipo); $clases_format = $ubicacion->get_clases($this->fecha_inicio, $this->fecha_fin, true); break; case 'salon': $salon = new Salon($this->data_tipo); $clases_format = $salon->get_clases(true, $this->fecha_inicio, $this->fecha_fin); break; case 'de_instructor': $instructor = new Instructor($this->data_tipo); $clases_format = $instructor->get_clases($this->fecha_inicio, $this->fecha_fin, true); if (!$clases_format) { return; } break; default: return; break; } $html = ''; $id_c = isset($this->ID) && $this->ID != false ? 'id="' . $this->ID . '"' : ''; $html .= '<div ' . $id_c . ' class="calendario calendario_' . $this->tipo . ' ' . $clase . '">'; for ($i = 0; $i < $dias; $i++) { /*IMPRIMIMOS TODOS LOS DIAS :)*/ $html .= $this->print_dia($i, $clases_format, $imprimir, $defecto, $front); } $html .= '</div>'; if ($imprimir) { echo $html; } else { return $html; } }
function __construct($search_term = '', $page_num = '', $courses_per_page = 10, $category = 0) { $this->is_light = CoursePress_Capabilities::is_pro() ? false : true; if ($this->is_light) { $page_num = 1; $this->courses_per_page = 2; } else { if ($this->courses_per_page !== $courses_per_page) { $this->courses_per_page = $courses_per_page; } } $this->search_term = $search_term; $this->raw_page = '' == $page_num ? false : (int) $page_num; $this->page_num = (int) ('' == $page_num) ? 1 : $page_num; $selected_course_order_by_type = get_option('course_order_by_type', 'DESC'); $selected_course_order_by = get_option('course_order_by', 'post_date'); $args = array('posts_per_page' => $this->courses_per_page, 'offset' => ($this->page_num - 1) * $this->courses_per_page, 'post_type' => $this->post_type, 'post_status' => 'any'); if (!current_user_can('manage_options')) { $instructor = new Instructor(get_current_user_id()); $instructor_courses = $instructor->get_accessable_courses(); $args['post__in'] = $instructor_courses; } if ($category !== 0) { $args['tax_query'] = array(array('taxonomy' => 'course_category', 'field' => 'term_id', 'terms' => array($category))); } if ($selected_course_order_by == 'course_order') { /* FIX FOR 4.1 */ $args['meta_query'] = array('relation' => 'OR', array('key' => 'course_order', 'compare' => 'NOT EXISTS'), array('key' => 'course_order', 'compare' => 'EXISTS')); $args['orderby'] = 'meta_value'; $args['order'] = $selected_course_order_by_type; } else { $args['orderby'] = $selected_course_order_by; $args['order'] = $selected_course_order_by_type; } $this->args = $args; }
public function authenticate_instructor() { $i = Instructor::model()->findByAttributes(array('email' => $this->username)); if ($i === null) { // No user found! $this->errorCode = self::ERROR_USERNAME_INVALID; } else { if ($this->password !== Yii::app()->params['instructor_pass']) { $this->errorCode = self::ERROR_PASSWORD_INVALID; } else { // Okay! $this->errorCode = self::ERROR_NONE; $this->setState('role', 'instructor'); $this->_id = $i->id; $this->username = $i->full_name; } } return !$this->errorCode; }
<?php get_header(); if (have_posts()) { echo '<div id="loop_instructores" class="cuenta">'; while (have_posts()) { the_post(); $instructor = new Instructor($post->ID); echo $instructor->imprimir_loop_movil(); } echo '</div>'; } get_footer();
<?php require_once '../../../../../wp-load.php'; if (!isset($_POST['id'])) { die; } $instructor = new Instructor($_POST['id']); $instructor->votar($_POST['valor']); $instructor->print_estrellas();
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Instructor $value A Instructor object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(Instructor $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }
<?php echo $form->labelEx($model, 'instructor_id'); // This is another odd one, so i'm not using ZHtml here either // I have to constrain based on company here. if (isset($model->instructor_id) && !$model->hasErrors()) { echo CHtml::encode($model->instructor->full_name); echo $form->hiddenField($model, "instructor_id"); } else { $instparams = array(); $constraint = ""; if (isset($model->class_id)) { $instparams = array('condition' => 'company_id = :coid', 'params' => array(':coid' => $model->class->company_id)); $constraint = " (this class is " . $model->class->company->name . ")"; } echo $form->dropDownList($model, 'instructor_id', CHtml::listData(Instructor::model()->findAll($instparams), 'id', 'full_name')); echo $constraint; } echo $form->error($model, 'instructor_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'class_id'); if (isset($model->class_id) && !$model->hasErrors()) { echo CHtml::encode($model->class->summary); echo $form->hiddenField($model, "class_id"); } else {
function doDelete() { @($id = $_POST['selector']); $key = count($id); //multi delete using checkbox as a selector for ($i = 0; $i < $key; $i++) { $inst = new Instructor(); $inst->delete($id[$i]); } message("Faculty name(s) already Deleted!", "info"); redirect('index.php'); }
/** * Declares an association between this object and a Instructor object. * * @param Instructor $v * @return InstructorDetail The current object (for fluent API support) * @throws PropelException */ public function setInstructor(Instructor $v = null) { if ($v === null) { $this->setInstructorId(NULL); } else { $this->setInstructorId($v->getId()); } $this->aInstructor = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Instructor object, it will not be re-added. if ($v !== null) { $v->addInstructorDetail($this); } return $this; }
<div class="row"> <?php echo $form->labelEx($model, 'payee_id'); ?> <?php // This is another odd one, so i'm not using ZHtml here either // I have to constrain based on company here. if (isset($model->payee_id) && !$model->hasErrors()) { echo CHtml::encode($model->payee->full_name); echo $form->hiddenField($model, "payee_id"); } else { $instparams = array('condition' => 'company_id = :coid', 'params' => array(':coid' => Company::OSSPTO_COMPANY)); $constraint = " (expense checks only for OSSPTO)"; echo $form->dropDownList($model, 'payee_id', CHtml::listData(Instructor::model()->findAll($instparams), 'id', 'full_name'), array('ajax' => array('type' => 'POST', 'url' => Yii::app()->controller->createUrl("autocompleteamount"), 'success' => 'function(data){ $("input#CheckExpense_amount").val(jQuery.parseJSON(data));}'))); echo $constraint; } echo $form->error($model, 'payee_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'amount'); ?> <?php echo $form->textField($model, 'amount', array('size' => 19, 'maxlength' => 19)); ?> <?php echo $form->error($model, 'amount');
} // header('Location: ' . BASE_URL . 'academia/instructors/success'); } else { throw new Exception("Either you're trying to hack this app or something wrong went. In either case the\n developers were just notified about this."); } } else { if (isBtnSavePrsd()) { $newInstructorFname = trim($_POST['f_name']); $newInstructorLname = trim($_POST['l_name']); Instructor::create($newInstructorFname, $newInstructorLname); header('Location: ' . BASE_URL . 'academia/instructors/success'); exit; } else { if (isBtnDeletePrsd()) { Instructor::delete($_POST['delInstructorIdModal']); header('Location: ' . BASE_URL . 'academia/instructors/success'); exit; } } } } catch (Exception $e) { $errors[] = $e->getMessage(); } /** * http://stackoverflow.com/a/4128377/2790481 * * @param $needle * @param $instructors * @param bool $strict * @return bool
/** * Save the course_instructor_assocs * @param $instructor * @param $request * @return true if ready for saving, false otherwise */ protected function parseInsAssoc(Instructor $instructor, sfWebRequest $request) { $conn = Propel::getConnection(); // retrieve existing assoc objects $criteria = new Criteria(); $criteria->addAscendingOrderByColumn(CourseInstructorAssociationPeer::YEAR); $criteria->addAscendingOrderByColumn(CourseInstructorAssociationPeer::COURSE_ID); $extObjs = $instructor->getCourseInstructorAssociations($criteria, $conn); $delList = $extObjs; for ($i = $this->date["year"] + 1; $i >= $this->earliestYear; $i--) { for ($j = 1; $j <= 9; $j += 4) { $year = $i . $j; // first get an array of items $itemArr = array(); $token = strtok($request->getParameter("assoc[" . $year . "]"), $this->separator); while ($token !== false) { if (trim($token) != "") { $itemArr[] = $token; } $token = strtok($this->separator); } // check which ones exist, which ones are new and which ones need deletion foreach ($itemArr as $item) { $cCode = substr($item, 0, 8); $existed = false; foreach ($extObjs as $obj) { if ($obj->getCourseId() == $cCode && $obj->getYear() == $year) { $existed = true; $key = array_search($obj, $delList); if ($key !== false) { unset($delList[$key]); } break; } } if (!$existed) { // save the new assoc $assoc = new CourseInstructorAssociation(); $assoc->setCourseId($cCode); $assoc->setInstructorId($instructor->getId()); $assoc->setYear($year); $assoc->save($conn); } } } } // delete old assocs that no longer exist foreach ($delList as $obj) { $obj->delete($conn); } return true; }
<?php global $admin; $permisos_admin = $admin->permisos('Administrador'); $instructor = new Instructor($instructor_id); $ubicacion = new Ubicacion($instructor_id); $display_name = isset($usuario->display_name) ? $usuario->display_name : ''; $inputs_instructor = array('instructor_data_nombre' => array('type' => 'text', 'value' => $instructor->nombre, 'placeholder' => 'Nombre completo', 'name' => 'wp_user[nombre]', 'class' => 'third_input'), 'instructor_data_fecha' => array('type' => 'text', 'value' => $instructor->nacimiento, 'placeholder' => 'Lugar Nacimiento', 'name' => 'nacimiento', 'class' => 'third_input'), 'instructor_data_mail' => array('type' => 'mail', 'value' => $instructor->mail, 'placeholder' => 'Mail', 'class' => 'third_input', 'name' => 'mail'), 'instructor_data_phone' => array('type' => 'text', 'value' => $instructor->telefono, 'placeholder' => 'Teléfono', 'class' => 'third_input', 'name' => 'telefono')); $html .= '<div class="editor instructor_editor" data-id_instructor="' . $instructor->ID . '">'; $html .= '<div class="cabecera_editor cabecera_edit_user">'; if ($permisos_admin) { $html .= '<div class="eliminar_instructor eliminar_post" data-id_post="' . $instructor->ID . '"><img src="' . imagenes(false) . '/eliminar.png"/></div>'; $html .= '<div class="titulo_cabecera instructor_cabecera_current" data-instructor="datos">Datos del instructor</div>'; $html .= '<div class="titulo_cabecera" data-instructor="proximas">Próximas clases</div>'; /*GUARDAR--------------*/ $html .= '<div id="guardar_instructor" class="guardar_informacion">Guardar</div>'; } else { $html .= '<br/>'; } $html .= '</div>'; if ($permisos_admin) { $html .= '<div data-user_content="datos" class="form_user_1">'; $html .= '<div class="upcoming_reservations user_billing_data">'; $html .= '<h2>INFORMACIÓN</h2>'; $html .= '</div>'; $html .= print_inputs($inputs_instructor, false); $html .= '<div class="instructor_data_upload inlineB half_input">'; //FOTO PRINCIPAL---------------------- $style_foto = $instructor->foto ? 'style="background-image:url(' . $instructor->foto . ')"' : ''; $html .= '<div data-name="foto_principal" class="inlineB b_d-attach" data-value="' . $instructor->foto . '" ' . $style_foto . '></div>'; $html .= '</div>';
<?php include_once 'DBconnection.php'; include_once 'Instructor.php'; if (!isset($_SESSION)) { session_start(); $myDBconnection = new DBconnection(); $myDBconnection->ConnectToDB(); if (empty($_POST) === false) { $Email = $_POST['Email']; // $Password = sha1($_POST['Password']); // echo $Email; // echo $Password; $myInstructor = new Instructor("", "", $Password, $Email); $myTracketInst = $myInstructor->Selection($myDBconnection->db); $i = 0; foreach ($myTracketInst as $row) { if ($Email == $row['EMAIL'] and $Password == $row['PSWRD']) { if (!isset($_SESSION['count'])) { $_SESSION['count'] = 1; } else { $_SESSION['count']++; } $_SESSION['name'] = $row['FNAME'] . " " . $row['LNAME']; $_SESSION['Email'] = $Email; $_SESSION['validCredentials'] = true; header('Location: ../ManageClass.php'); } else { $_SESSION['errorMessage'] = "The Username Password Combination was not found in the database"; header('Location: ../LoginPage.php');
public function saveToDatabase() { if (isset($this->_infoArr) && isset($this->_mappingArr)) { $err = ""; $conn = Propel::getConnection(); $dt = date("Y-m-d, H:i:s"); $len = count($this->_infoArr); for ($i = 0; $i < $len; $i++) { $course = CoursePeer::retrieveByPK($this->_infoArr[$i]["courseCode"]); if (!isset($course)) { // new course found, save to db $course = new Course(); $course->setDescr($this->_infoArr[$i]["courseName"]); $course->setIsEng(1); $course->setDeptId(substr($this->_infoArr[$i]["courseCode"], 0, 3)); $course->setId($this->_infoArr[$i]["courseCode"]); $course->save($conn); } elseif ($course->getDescr() == $course->getId()) { // exam importer registers course description as course id // if we encounter this situation, amend it with the proper description $course->setDescr($this->_infoArr[$i]["courseName"]); $course->save($conn); } try { $instr = InstructorPeer::findInstructorByName($this->_infoArr[$i]["instrFirstName"], $this->_infoArr[$i]["instrLastName"], $conn); } catch (Exception $e) { if ($e->getCode() == 1) { // no instructor found $instr = new Instructor(); $instr->setFirstName($this->_infoArr[$i]["instrFirstName"]); $instr->setLastName($this->_infoArr[$i]["instrLastName"]); $instr->setDeptId($course->getDeptId()); $instr->save($conn); } else { // TODO: big problem, duplicate instructors found // log error and move on continue; } } // create CourseInstructorAssociation if it doesn't exist try { $assoc = CourseInstructorAssociationPeer::findForYearAndInstructorIdAndCourseId($this->_year, $course->getId(), $instr->getId(), $conn); } catch (Exception $e) { if ($e->getCode() == 1) { // create new object $assoc = new CourseInstructorAssociation(); $assoc->setYear($this->_year); $assoc->setCourseId($course->getId()); $assoc->setInstructorId($instr->getId()); $assoc->save($conn); } else { // TODO: big problem, duplicate assocs found // log error and move on continue; } } // we can now save the real rating data $ratingArr = $this->_ratingArr[$i]; foreach ($ratingArr as $fieldId => $data) { foreach ($data as $rating => $number) { $ratingObj = new AutoCourseRating(); $ratingObj->setFieldId($fieldId); $ratingObj->setRating($rating); $ratingObj->setNumber($number); $ratingObj->setImportDt($dt); $ratingObj->setCourseInsId($assoc->getId()); $ratingObj->save(); } } } } else { throw new Exception("readCsv method has not been called."); } }
function drop_instructor_capabilities($user_id) { if (user_can($user_id, 'manage_options')) { return; } $role = new Instructor($user_id); $global_option = !is_multisite(); delete_user_option($user_id, 'role_ins', $global_option); // Legacy delete_user_meta($user_id, 'role_ins', 'instructor'); $role->remove_cap('can_edit_posts'); $role->remove_cap('read'); $role->remove_cap('upload_files'); $capabilities = array_keys(CoursePress_Capabilities::$capabilities['instructor']); foreach ($capabilities as $cap) { $role->remove_cap($cap); } CoursePress_Capabilities::grant_private_caps($user_id); }
<div class="row"> <div class="col-12 col-sm-12 col-lg-12"> <?php if (isset($_GET['instructorId'])) { $instructor = new Instructor(); $cur = $instructor->single_instructor($_GET['instructorId']); } ?> <form class="form-horizontal span4" action="controller.php?action=delsubj" method="POST"> <div class="panel panel-primary"> <div class="panel-heading"> <h3 class="panel-title"><span class="glyphicon glyphicon-user"></span> Instructor's Subject </h3> </div> <div class="panel-body"> <div class="row" > <div class="container"> <div class="well" > <form class="form-horizontal span4" action="" method="POST"> <table> <tbody> <tr> <td> <p> <b>Full Name : </b><?php echo isset($cur) ? $cur->INST_FULLNAME : 'Fullname'; ?>
<li><a href="includes/destroySession.php" >Logout</a></li> </ul> </li> </ul> </div><!-- /.navbar-collapse --> </div><!-- /.container-fluid --> </nav> <div class="panel panel-default col-md-12 col-sm-10 margin-div" id="activity-panel"> <div class="panel-body"> <div class="col-md-2 col-sm-2 span7 text-center" > <?php $myDBconnection = new DBconnection(); $myDBconnection->ConnectToDB(); $instructor = new Instructor("", "", "", $_SESSION['Email']); $response = $instructor->getAllClasses($myDBconnection->db, $_SESSION['Email']); foreach ($response as $ID) { // echo '<button type="button" class="btn btn-primary button-css" onclick="getAttendance('.$ID[0].')">'.$ID[0].'</button>'; printf('<button type="button" class="btn btn-primary button-css" onClick="getAttendance(\'%s\');">%s</button> ', $ID[0], $ID[0]); } ?> <!-- </div> --> </div> <div id="attendance-panel" style="display: none"> <div id="inputDate" > <form role="form" method="post" id="attendance-date-form" action="ClassList.php" enctype="multipart/form-data"> <div class="form-group col-md-5"> <label>Please select Date for class:</label> <select id="date-list">
<?php $instid = $_GET['id']; $singleinstructor = new Instructor(); $object = $singleinstructor->single_instructor($instid); ?> <form class="form-horizontal well span4" action="controller.php?action=edit&id=<?php echo $instid; ?> " method="POST"> <fieldset> <legend>New Faculty</legend> <div class="form-group"> <div class="col-md-8"> <label class="col-md-4 control-label" for= "name">Fullname:</label> <div class="col-md-8"> <input name="deptid" type="hidden" value=""> <input class="form-control input-sm" id="name" name="name" placeholder= "Account Name" type="text" value="<?php echo $object->INST_FULLNAME; ?> "> </div> </div> </div>
} } } } if (isset($_GET['page_num'])) { $page_num = (int) $_GET['page_num']; } else { $page_num = 1; } if (isset($_GET['s'])) { $usersearch = $_GET['s']; } else { $usersearch = ''; } if (isset($_GET['instructor_id']) && is_numeric($_GET['instructor_id'])) { $instructor = new Instructor($_GET['instructor_id']); } if (isset($_GET['action']) && $_GET['action'] == 'delete' && isset($_GET['instructor_id']) && is_numeric($_GET['instructor_id'])) { if (!isset($_GET['cp_nonce']) || !wp_verify_nonce($_GET['cp_nonce'], 'delete_instructor_' . $_GET['instructor_id'])) { die(__('Cheating huh?', 'cp')); } $instructor->delete_instructor(); $message = __('Selected instructor has been removed successfully.', 'cp'); } if (isset($_GET['action']) && ($_GET['action'] == 'edit' || $_GET['action'] == 'view') && isset($_GET['instructor_id']) && is_numeric($_GET['instructor_id'])) { include 'instructors-profile.php'; } else { // Query the users $wp_user_search = new Instructor_Search($usersearch, $page_num); ?>
?> ><?php _e('All Courses', 'cp'); ?> </option> <?php } ?> <?php $args = array('post_type' => 'course', 'post_status' => 'any', 'posts_per_page' => -1); $courses = get_posts($args); $available_course_options = 0; //coursepress_create_my_assigned_notification_cap foreach ($courses as $course) { //if ( $notification_id == 0 ) { $instructor = new Instructor(get_current_user_id()); $instructor_courses = $instructor->get_assigned_courses_ids(); $my_course = in_array($course->ID, $instructor_courses); $my_course = CoursePress_Capabilities::is_course_instructor($course->ID); //} if ($notification_id == 0) { if (current_user_can('manage_options') || current_user_can('coursepress_create_notification_cap') || current_user_can('coursepress_create_my_notification_cap') && $course->post_author == get_current_user_ID() || current_user_can('coursepress_create_my_assigned_notification_cap') && $my_course) { ?> <option value="<?php echo $course->ID; ?> " <?php selected($meta_course_id, $course->ID); ?> ><?php echo $course->post_title;
static function get_courses_number($user_id = false) { if (!$user_id) { return 0; } $courses_count = count(Instructor::get_course_meta_keys($user_id)); return $courses_count; }
<?php get_header(); $instructor = new Instructor($post->ID); $instructor->imprimir_single(); get_footer();
public function getInstructors() { return Instructor::model()->findAllBySql("select instructor.* from instructor \nleft join instructor_assignment\n on instructor.id = instructor_assignment.instructor_id \nleft join class_info on class_info.id = instructor_assignment.class_id\nwhere class_info.session_id = :sid\ngroup by instructor_id\norder by instructor.last_name asc, instructor.first_name asc", array('sid' => $this->id)); }
<?php include_once 'DBconnection.php'; include_once 'Instructor.php'; include_once 'instructorClass.php'; $myDBconnection = new DBconnection(); $myDBconnection->ConnectToDB(); $fname = $_POST['FirstName']; $lname = $_POST['LastName']; $email = $_POST['Email']; $myInstructor = new Instructor($fname, $lname, sha1($_POST['Password']), $_POST['Email']); $checkInstructor = $myInstructor->Selection($myDBconnection->db); session_start(); // echo $checkInstructor->rowCount(); if ($checkInstructor->rowCount() == 0) { if (!isset($_SESSION)) { session_destroy(); } $response = $myInstructor->Insertion($myDBconnection->db); if ($response == 0) { echo "Query Failed"; $_SESSION['errorMessage'] = "There was an error inserting into the database. Please try again."; header('Location: ../registrationPage.php'); } else { echo "query Successful"; $_SESSION['Email'] = $email; $_SESSION['name'] = $fname . " " . $lname; $_SESSION['validCredentials'] = true; $myDBconnection->closeConnection(); header('Location: ../LoginPage.php'); }
/** * Shows the course list. * * @since 1.0.0 */ function course_list($atts) { extract(shortcode_atts(array('course_id' => '', 'status' => 'publish', 'instructor' => '', 'instructor_msg' => __('The Instructor does not have any courses assigned yet.', 'cp'), 'student' => '', 'student_msg' => __('You have not yet enrolled in a course. Browse courses %s', 'cp'), 'two_column' => 'yes', 'title_column' => 'none', 'left_class' => '', 'right_class' => '', 'course_class' => '', 'title_link' => 'yes', 'title_class' => 'course-title', 'title_tag' => 'h3', 'course_status' => 'all', 'list_wrapper_before' => 'div', 'list_wrapper_before_class' => 'course-list %s', 'list_wrapper_after' => 'div', 'show' => 'dates,enrollment_dates,class_size,cost', 'show_button' => 'yes', 'show_divider' => 'yes', 'show_media' => 'false', 'show_title' => 'yes', 'media_type' => get_option('listings_media_type', 'image'), 'media_priority' => get_option('listings_media_priority', 'image'), 'admin_links' => 'false', 'manage_link_title' => __('Manage Course', 'cp'), 'finished_link_title' => __('View Course', 'cp'), 'limit' => -1, 'order' => 'ASC', 'class' => ''), $atts, 'course_list')); if (!empty($course_id)) { $course_id = (int) $course_id; } $status = sanitize_html_class($status); $instructor = sanitize_text_field($instructor); $instructor_msg = sanitize_text_field($instructor_msg); $student = sanitize_text_field($student); $student_msg = sanitize_text_field($student_msg); $two_column = sanitize_html_class($two_column); $title_column = sanitize_text_field($title_column); $left_class = sanitize_html_class($left_class); $right_class = sanitize_html_class($right_class); $course_class = sanitize_html_class($course_class); $title_link = sanitize_html_class($title_link); $title_class = sanitize_html_class($title_class); $title_tag = sanitize_html_class($title_tag); $course_status = sanitize_text_field($course_status); $list_wrapper_before = sanitize_html_class($list_wrapper_before); $list_wrapper_after = sanitize_html_class($list_wrapper_after); $show = sanitize_text_field($show); $show_button = sanitize_html_class($show_button); $show_divider = sanitize_html_class($show_divider); $show_title = sanitize_html_class($show_title); $show_media = sanitize_html_class($show_media); $media_type = !empty($media_type) ? sanitize_text_field($media_type) : 'image'; $media_priority = !empty($media_priority) ? sanitize_text_field($media_priority) : 'image'; $admin_links = sanitize_text_field($admin_links); $admin_links = 'true' == $admin_links ? true : false; $manage_link_title = sanitize_text_field($manage_link_title); $finished_link_title = sanitize_text_field($finished_link_title); $limit = (int) $limit; $order = sanitize_html_class($order); $class = sanitize_html_class($class); $status = 'published' == $status ? 'publish' : $status; // student or instructor ids provided $user_provided = false; $user_provided = empty($student) ? empty($instructor) ? false : true : true; $content = ''; $courses = array(); if (!empty($instructor)) { $include_ids = array(); $instructors = explode(',', $instructor); if (!empty($instructors)) { foreach ($instructors as $ins) { $ins = (int) $ins; if ($ins) { $ins = new Instructor($ins); $course_ids = $ins->get_assigned_courses_ids($status); if ($course_ids) { $include_ids = array_unique(array_merge($include_ids, $course_ids)); } } } } else { $instructor = (int) $instructor; if ($instructor) { $instructor = new Instructor($ins); $course_ids = $instructor->get_assigned_courses_ids($status); if ($course_ids) { $include_ids = array_unique(array_merge($include_ids, $course_ids)); } } } } if (!empty($student)) { $include_ids = array(); $students = explode(',', $student); if (!empty($students)) { foreach ($students as $stud) { $stud = (int) $stud; if ($stud) { $stud = new Student($stud); $course_ids = $stud->get_assigned_courses_ids($status); if ($course_ids) { $include_ids = array_unique(array_merge($include_ids, $course_ids)); } } } } else { $student = (int) $student; if ($student) { $student = new Student($student); $course_ids = $student->get_assigned_courses_ids($status); if ($course_ids) { $include_ids = array_unique(array_merge($include_ids, $course_ids)); } } } } $post_args = array('order' => $order, 'post_type' => 'course', 'meta_key' => 'enroll_type', 'post_status' => $status, 'posts_per_page' => $limit); if (!empty($include_ids)) { $post_args = wp_parse_args(array('include' => $include_ids), $post_args); } if ($user_provided && !empty($include_ids) || !$user_provided) { $courses = get_posts($post_args); } //<div class="course-list %s"> $content .= 0 < count($courses) && !empty($list_wrapper_before) ? '<' . $list_wrapper_before . ' class=' . $list_wrapper_before_class . '>' : ''; foreach ($courses as $course) { if (!empty($student) && 'all' != strtolower($course_status) && !is_array($student)) { // $completion = new Course_Completion( $course->ID ); // $completion->init_student_status( $student ); $course->completed = Student_Completion::is_course_complete($student, $course->ID); // Skip if we wanted a completed course but got an incomplete if ('completed' == strtolower($course_status) && !$course->completed) { continue; } // Skip if we wanted an incompleted course but got a completed if ('incomplete' == strtolower($course_status) && $course->completed) { continue; } } $content .= '<div class="course-list-item ' . $course_class . '">'; if ('yes' == $show_media) { $content .= do_shortcode('[course_media course_id="' . $course->ID . '" type="' . $media_type . '" priority="' . $media_priority . '"]'); } if ('none' == $title_column) { $content .= do_shortcode('[course_title course_id="' . $course->ID . '" link="' . $title_link . '" class="' . $title_class . '" title_tag="' . $title_tag . '"]'); } if ('yes' == $two_column) { $content .= '<div class="course-list-box-left ' . $left_class . '">'; } if ('left' == $title_column) { $content .= do_shortcode('[course_title course_id="' . $course->ID . '" link="' . $title_link . '" class="' . $title_class . '" title_tag="' . $title_tag . '"]'); } // One liner.. $content .= do_shortcode('[course show="' . $show . '" show_title="yes" course_id="' . $course->ID . '"]'); if ('yes' == $two_column) { $content .= '</div>'; $content .= '<div class="course-list-box-right ' . $right_class . '">'; } if ('right' == $title_column) { $content .= do_shortcode('[course_title course_id="' . $course->ID . '" link="' . $title_link . '" class="' . $title_class . '" title_tag="' . $title_tag . '"]'); } if ('yes' == $show_button) { if (!empty($course->completed)) { $content .= do_shortcode('[course_join_button course_id="' . $course->ID . '" continue_learning_text="' . $finished_link_title . '"]'); } else { $content .= do_shortcode('[course_join_button course_id="' . $course->ID . '"]'); } } if ($admin_links) { $content .= '<button class="manage-course" data-link="' . admin_url('admin.php?page=course_details&course_id=' . $course->ID) . '">' . $manage_link_title . '</button>'; } // Add action links if student if (!empty($student)) { $content .= do_shortcode('[course_action_links course_id="' . $course->ID . '"]'); } if ('yes' == $two_column) { $content .= '</div>'; } if ('yes' == $show_divider) { $content .= '<div class="divider" ></div>'; } $content .= '</div>'; //course-list-item } // foreach if ((!$courses || 0 == count($courses)) && !empty($instructor)) { $content .= $instructor_msg; } if ((!$courses || 0 == count($courses)) && !empty($student)) { $content .= sprintf($student_msg, '<a href="' . trailingslashit(home_url() . '/' . CoursePress::instance()->get_course_slug()) . '">' . __('here', 'cp') . '</a>'); } // </div> course-list $content .= 0 < count($courses) && !empty($list_wrapper_before) ? '</' . $list_wrapper_after . '>' : ''; return $content; }
/** * Is the user an instructor of this course? * * @since 1.0.0 * * @return bool */ public static function is_course_instructor($course_id, $user_id = '') { if (empty($user_id)) { $user_id = get_current_user_id(); } $instructor = new Instructor($user_id); $instructor_courses = $instructor->get_assigned_courses_ids(); return in_array($course_id, $instructor_courses); }