function confirmModCourseEdition() { checkPerm('mod'); require_once _base_ . '/lib/lib.upload.php'; require_once _base_ . '/lib/lib.multimedia.php'; $array_lang = Docebo::langManager()->getAllLangCode(); $array_lang[] = 'none'; list($id_course_edition) = each($_POST['mod_course_edition']); $path = '/appLms/' . Get::sett('pathcourse'); if (substr($path, -1) != '/' && substr($path, -1) != '\\') { $path = $path . '/'; } $error = 0; $show_level = 0; $file_edition_material = ''; $file_edition_othermaterial = ''; // manage file upload ----------------------------------------- if (is_array($_FILES) && !empty($_FILES) || is_array($_POST["file_to_del"])) { sl_open_fileoperations(); } if (is_array($_POST["file_to_del"])) { foreach ($_POST["file_to_del"] as $field_id => $old_file) { sl_unlink($path . $old_file); } } if (isset($_FILES['course_edition_material']) && $_FILES['course_edition_material']['tmp_name'] != '') { // delete old file if (isset($_POST["old_course_edition_material"]) && !empty($_POST["old_course_edition_material"])) { sl_unlink($path . $_POST["old_course_edition_material"]); } // upload new file $file_edition_material = 'usermaterial_' . mt_rand(0, 100) . '_' . time() . '_' . $_FILES['course_edition_material']['name']; if (!sl_upload($_FILES['course_edition_material']['tmp_name'], $path . $file_edition_material)) { $error = true; $file_edition_material = ''; } } elseif (!isset($_POST["file_to_del"]["course_edition_material"])) { // new not loaded use old file $file_edition_material = isset($_POST["old_course_edition_material"]) ? $_POST["old_course_edition_material"] : ""; } if (isset($_FILES['course_edition_othermaterial']) && $_FILES['course_edition_othermaterial']['tmp_name'] != '') { // delete old file if (isset($_POST["old_course_edition_othermaterial"]) && !empty($_POST["old_course_edition_othermaterial"])) { sl_unlink($path . $_POST["old_course_edition_othermaterial"]); } // upload new file $file_edition_othermaterial = 'otherusermaterial_' . mt_rand(0, 100) . '_' . time() . '_' . $_FILES['course_edition_othermaterial']['name']; if (!sl_upload($_FILES['course_edition_othermaterial']['tmp_name'], $path . $file_edition_othermaterial)) { $error = true; $file_edition_othermaterial = ''; } } else { if (!isset($_POST["file_to_del"]["course_edition_othermaterial"])) { // new not loaded use old file $file_edition_othermaterial = isset($_POST["old_course_edition_othermaterial"]) ? $_POST["old_course_edition_othermaterial"] : ""; } } sl_close_fileoperations(); // save mod in db --------------------------------------- if ($_POST["can_subscribe"] != "2") { $sub_start_date = "NULL"; $sub_end_date = "NULL"; } else { $sub_start_date = "'" . Format::dateDb($_POST["sub_start_date"], "date") . "'"; $sub_end_date = "'" . Format::dateDb($_POST["sub_end_date"], "date") . "'"; } $date_begin = Format::dateDb($_POST['course_edition_date_begin'], 'date'); $date_end = Format::dateDb($_POST['course_edition_date_end'], 'date'); $hour_begin = '-1'; $hour_end = '-1'; if ($_POST['hour_begin']['hour'] != '-1') { $hour_begin = strlen($_POST['hour_begin']['hour']) == 1 ? '0' . $_POST['hour_begin']['hour'] : $_POST['hour_begin']['hour']; if ($_POST['hour_begin']['quarter'] == '-1') { $hour_begin .= ':00'; } else { $hour_begin .= ':' . $_POST['hour_begin']['quarter']; } } if ($_POST['hour_end']['hour'] != '-1') { $hour_end = strlen($_POST['hour_end']['hour']) == 1 ? '0' . $_POST['hour_end']['hour'] : $_POST['hour_end']['hour']; if ($_POST['hour_end']['quarter'] == '-1') { $hour_end .= ':00'; } else { $hour_end .= ':' . $_POST['hour_end']['quarter']; } } $query_course_edition = "\r\n\tUPDATE " . $GLOBALS['prefix_lms'] . "_course_edition\r\n\tSET code \t\t\t\t= '" . $_POST['course_edition_code'] . "',\r\n\t\tname \t\t\t\t= '" . $_POST['course_edition_name'] . "',\r\n\t\tdescription \t\t= '" . $_POST['course_edition_descr'] . "',\r\n\t\tstatus \t\t\t\t= '" . (int) $_POST['course_edition_status'] . "',\r\n\r\n\t\timg_material \t\t='" . $file_edition_material . "',\r\n\t\timg_othermaterial \t='" . $file_edition_othermaterial . "',\r\n\r\n\t\tdate_begin \t\t\t= '" . $date_begin . "',\r\n\t\tdate_end \t\t\t= '" . $date_end . "',\r\n\t\thour_begin \t\t\t= '" . $hour_begin . "',\r\n\t\thour_end \t\t\t= '" . $hour_end . "',\r\n\r\n\t\tmin_num_subscribe \t= '" . (int) $_POST["min_num_subscribe"] . "',\r\n\t\tmax_num_subscribe \t= '" . (int) $_POST["max_num_subscribe"] . "',\r\n\t\tprice \t\t\t\t= '" . $_POST["edition_price"] . "',\r\n\t\tadvance \t\t\t= '" . $_POST["edition_advance"] . "',\r\n\r\n\t\tedition_type \t\t= '" . $_POST["edition_type"] . "',\r\n\t\tallow_overbooking \t= '" . (isset($_POST["allow_overbooking"]) ? 1 : 0) . "',\r\n\t\tcan_subscribe \t\t= '" . (int) $_POST["can_subscribe"] . "',\r\n\t\tsub_start_date \t\t= " . $sub_start_date . ",\r\n\t\tsub_end_date \t\t= " . $sub_end_date . "\r\n\r\n\tWHERE idCourseEdition = '" . $id_course_edition . "'"; if (!sql_query($query_course_edition)) { $error = 1; if ($file_edition_material != '') { sl_unlink($path . $file_edition_material); } if ($file_edition_othermaterial != '') { sl_unlink($path . $file_edition_othermaterial); } } else { $acl_manager =& Docebo::user()->getAclManager(); $group = '/lms/course_edition/' . $id_course_edition . '/subscribed'; $group_idst = $acl_manager->getGroupST($group); if ($group_idst === FALSE) { $group_idst = $acl_manager->registerGroup($group, 'all the user of a course edition', true, "course"); } // -- Let's update the classroom occupation schedule if course type is classroom ---- if (hasClassroom($_POST["edition_type"])) { $old_date_begin = $_POST["old_date_begin"]; $old_date_end = $_POST["old_date_end"]; updateCourseTimtable($_POST["course_id"], $id_course_edition, $date_begin, $date_end, $old_date_begin, $old_date_end); } // ---------------------------------------------------------------------------------- } Util::jump_to('index.php?modname=course&op=course_list&course_category_status=' . importVar('course_category_status') . '&result=ok_course'); }
function extendedParsing($arrayState) { // set filter for base fields require_once $GLOBALS['where_framework'] . '/modules/field/class.field.php'; $field = new Field(0); $arr_fields = Field::getArrFieldValue_Filter($_POST, $this->add_nat_fields, $this->id, '_'); foreach ($arr_fields as $fname => $fvalue) { if (isset($fvalue['value'])) { $this->arr_fields_filter[$fname] = $fvalue; } } if (isset($_POST['pw_more_usersel'])) { $this->_expand_user = key($_POST['pw_more_usersel']); } // set filter for custom fields $arr_all_fields = $this->field_list->getAllFields(); $arr_fields = Field::getArrFieldValue_Filter($_POST, $arr_all_fields, $this->id, '_'); foreach ($arr_fields as $fname => $fvalue) { if (isset($fvalue['value'])) { $this->arr_fields_filter[$fname] = $fvalue; } } if (isset($arrayState[$this->id])) { // this test first - not correct in foreach if (isset($arrayState[$this->id]['directory_lessmore'])) { $this->more_filter = $arrayState[$this->id]['directory_lessmore']; } if (isset($arrayState[$this->id]['order_state'])) { $this->arr_fields_order = unserialize(urldecode($arrayState[$this->id]['order_state'])); } $isFieldsSet = FALSE; foreach ($arrayState[$this->id] as $key => $val) { switch ($key) { case $this->_getOpEditItemId(): $this->itemSelected = key($arrayState[$this->id][$this->_getOpEditItemId()]); $this->op = 'editperson'; break; case $this->_getOpDeleteItemId(): $this->itemSelected = key($arrayState[$this->id][$this->_getOpDeleteItemId()]); $this->op = 'deleteperson'; break; case $this->_getOpSuspendItemId(): $this->itemSelected = key($arrayState[$this->id][$this->_getOpSuspendItemId()]); $this->op = 'suspendperson'; break; case $this->_getOpRecoverItemId(): $this->itemSelected = key($arrayState[$this->id][$this->_getOpRecoverItemId()]); $this->op = 'recoverperson'; break; case $this->_getOpRemoveItemId(): $this->itemSelected = key($arrayState[$this->id][$this->_getOpRemoveItemId()]); $this->op = 'removeperson'; break; case 'cfield_state': if (!$isFieldsSet) { $this->cFields = unserialize(urldecode($val)); } break; case DIRECTORY_CFIELD: $isFieldsSet = TRUE; foreach ($val as $nField => $idField) { $this->cFields[$nField] = $idField; } break; case DIRECTORY_ORDER: $arr_order = array(); foreach ($val as $fieldName => $dummyvar) { if (isset($this->arr_fields_order[$fieldName])) { if ($this->arr_fields_order[$fieldName]) { // is DESC // do nothing, therefore remove order } else { // is ASC, go to DESC $arr_order[$fieldName] = TRUE; } } else { // is unordered $arr_order[$fieldName] = FALSE; } } $this->arr_fields_order = $arr_order; break; case 'directory_more': $this->more_filter = 'more'; break; case 'directory_less': $this->more_filter = 'less'; break; case 'flat_mode': $this->flat_mode = $val == 'flat_mode'; break; case 'add_filter': $id_field = $arrayState[$this->id]['add_field_filter']; if (is_numeric($id_field)) { $this->arr_fields_filter['ff' . count($this->arr_fields_filter) . '_' . $id_field] = $arr_all_fields[$id_field]; } else { $this->arr_fields_filter['ff' . count($this->arr_fields_filter) . '_' . $id_field] = $this->add_nat_fields[$id_field]; } break; case 'del_filter': if (is_array($val)) { unset($this->arr_fields_filter[key($val)]); } else { $this->arr_fields_filter = array(); } break; } } } else { // default initializations $this->cFields = unserialize(urldecode(Docebo::user()->preference->getPreference('ui.directory.custom_columns'))); $this->arr_fields_order = unserialize(urldecode(Docebo::user()->preference->getPreference('ui.directory.order_columns'))); $this->arr_fields_filter = unserialize(urldecode(Docebo::user()->preference->getPreference('ui.directory.filters.current'))); } // remove anonymous ================================================ if ($this->hide_anonymous === true) { $this->data->addCustomFilter('', " idst <> '" . $this->anonymous_idst . "' "); } if ($this->hide_suspend === true) { $this->data->addCustomFilter('', " valid <> '0' "); } // filter by editions ============================================== if ($this->lms_editions_filter === true) { if (isset($GLOBALS['course_descriptor']) && $GLOBALS['course_descriptor']->hasEdition()) { $fvalue = isset($_POST[$this->id]['edition_filter']) ? strip_tags(html_entity_decode($_POST[$this->id]['edition_filter'])) : ''; if ($fvalue != false) { $acl_man =& Docebo::user()->getAclManager(); $members = $acl_man->getGroupAllUser($fvalue); if ($members && !empty($members)) { $this->data->addCustomFilter('', "idst IN (" . implode(',', $members) . ") "); } } else { $ed_list = array(); if ($this->editions == false) { $this->editions = $GLOBALS['course_descriptor']->getEditionsSimpleList(getLogUserId(), true); } $this->data->intersectGroupFilter(array_keys($this->editions)); } } } // show filter ============================================================ if ($this->show_simple_filter === true) { $fvalue = isset($_POST[$this->id]['simple_fulltext_search']) ? strip_tags(html_entity_decode($_POST[$this->id]['simple_fulltext_search'])) : ''; if (trim($fvalue !== '')) { $this->data->addCustomFilter('', " ( userid LIKE '%" . $fvalue . "%' OR firstname LIKE '%" . $fvalue . "%' OR lastname LIKE '%" . $fvalue . "%' ) "); } } else { if (is_array($this->arr_fields_filter)) { foreach ($this->arr_fields_filter as $fname => $fvalue) { if (isset($fvalue['value'])) { if (isset($fvalue['fieldname'])) { if ($fvalue['field_type'] == 'upload') { $this->data->addFieldFilter($fvalue['fieldname'], '', '<>'); } else { if ($fvalue['value'] == '') { $search_op = " = "; $search_val = ""; } else { $search_op = " LIKE "; $search_val = "%" . $fvalue['value'] . "%"; } $this->data->addFieldFilter($fvalue['fieldname'], $search_val, $search_op); } } else { if ($fvalue[FIELD_INFO_TYPE] == 'upload') { $this->data->addCustomFilter(" LEFT JOIN " . $field->_getUserEntryTable() . " AS " . $fname . " ON ( {$fname}.id_common = '" . (int) $fvalue[FIELD_INFO_ID] . "'" . " AND {$fname}.id_user = idst ) ", " ({$fname}.user_entry IS " . ($fvalue['value'] == 'true' ? 'NOT' : '') . " NULL ) "); } else { if ($fvalue['value'] == '') { $where = " ({$fname}.user_entry = '' OR {$fname}.user_entry IS NULL )"; } elseif ($fvalue[FIELD_INFO_TYPE] == 'date') { $where = " ({$fname}.user_entry LIKE '%" . Format::dateDb($fvalue['value'], 'date') . "%' ) "; } else { $where = " ({$fname}.user_entry LIKE '%" . $fvalue['value'] . "%' ) "; } $this->data->addCustomFilter(" LEFT JOIN " . $field->_getUserEntryTable() . " AS " . $fname . " ON ( {$fname}.id_common = '" . (int) $fvalue[FIELD_INFO_ID] . "'" . " AND {$fname}.id_user = idst ) ", $where); } } } } } } // end else simple filter }
public function modactionTask() { if (!$this->permissions['mod']) { $output = array('success' => false, 'message' => $this->_getMessage("no permission")); echo $this->json->encode($output); } //prepare output variable $output = array('success' => false); //read inputs and validate data $id = Get::req('id', DOTY_INT, 0); if ($id <= 0) { echo $this->json->encode($output); return; } $title = Get::req('title', DOTY_STRING, ''); $start_date = Get::req('start_date', DOTY_STRING, ''); $end_date = Get::req('end_date', DOTY_STRING, ''); $start_date = Format::dateDb($start_date, 'date'); $end_date = Format::dateDb($end_date, 'date'); //prepare parameters object $params = new stdClass(); $params->id = $id; $params->title = $title; $params->start_date = $start_date; $params->end_date = $end_date; //update data in DB $output['success'] = $this->model->updateTimePeriod($params); echo $this->json->encode($output); }
public static function getInputDatefield($css_field, $id, $name, $value = '', $date_format = FALSE, $sel_time = FALSE, $alt_name = '', $other_param = '') { $value = $value == '00-00-0000' ? '' : $value; if ($date_format == false) { $regset = Format::instance(); $date_format = $regset->date_token; } if ($css_field == false) { $css_field = 'textfield'; } Form::loadDatefieldScript($date_format); $date = ""; $iso = Format::dateDb($value, 'date'); if ($value != '' && $value != '0000-00-00 00:00:00') { $timestamp = mktime(0, 0, 0, (int) substr($iso, 5, 2), (int) substr($iso, 8, 2), (int) substr($iso, 0, 4)); $date = date("m/d/Y", $timestamp); } $other_after_b = '<span id="calendar_button_' . $id . '" class="yui-button"><span class="first-child docebo_calendar">' . '<button type="button"></button></span></span>' . '<div id="calendar_menu_' . $id . '"><div id="calendar_container_' . $id . '"></div></div>'; if (defined("IS_AJAX")) { if (!isset($GLOBALS['date_inputs'])) { $GLOBALS['date_inputs'] = array(); } $GLOBALS['date_inputs'][] = array($id, $date, $date_format); } else { $script = '<script type="text/javascript">' . 'YAHOO.util.Event.onDOMReady(function() {' . ' YAHOO.dateInput.setCalendar("' . $id . '", "' . $date . '", "' . $date_format . '");' . '});</script>'; cout($script, 'scripts'); //script in the scripts page section, this ensure to have it after the YAHOO.dateInput declaration } return Form::getInputTextfield($css_field, $id, $name, Format::date($iso, 'date'), $alt_name, '30', ''); }
function get_user_filter() { $back_url = $this->back_url; $jump_url = $this->jump_url; $next_url = $this->next_url; require_once _base_ . '/lib/lib.form.php'; require_once _adm_ . '/lib/lib.directory.php'; require_once _adm_ . '/class.module/class.directory.php'; require_once _lms_ . '/lib/lib.course.php'; $lang =& DoceboLanguage::createInstance('report', 'framework'); $org_chart_subdivision = importVar('org_chart_subdivision', true, 0); //detect the step in which we are $substep = _SUBSTEP_USERS; //first substep switch (Get::req('substep', DOTY_STRING, 'no_step')) { case 'users_selection': $substep = _SUBSTEP_USERS; break; case 'columns_selection': $substep = _SUBSTEP_COLUMNS; break; } //draw page depending on the $substep variable if (!isset($_SESSION['report_tempdata']['columns_filter'])) { $_SESSION['report_tempdata']['columns_filter'] = array('time_belt' => array('time_range' => '', 'start_date' => '', 'end_date' => ''), 'org_chart_subdivision' => 0, 'show_classrooms_editions' => false, 'showed_cols' => array(), 'show_percent' => true, 'show_suspended' => false, 'only_students' => false, 'show_assessment' => false); } $ref =& $_SESSION['report_tempdata']['columns_filter']; switch ($substep) { case _SUBSTEP_COLUMNS: //set session data if (Get::req('is_updating', DOTY_INT, 0) > 0) { $ref['showed_cols'] = Get::req('cols', DOTY_MIXED, array()); $ref['show_percent'] = Get::req('show_percent', DOTY_INT, 0) > 0 ? true : false; $ref['time_belt'] = array('time_range' => $_POST['time_belt'], 'start_date' => Format::dateDb($_POST['start_time'], 'date'), 'end_date' => Format::dateDb($_POST['end_time'], 'date')); $ref['org_chart_subdivision'] = isset($_POST['org_chart_subdivision']) ? 1 : 0; $ref['show_classrooms_editions'] = isset($_POST['show_classrooms_editions']) ? true : false; $ref['show_suspended'] = Get::req('show_suspended', DOTY_INT, 0) > 0; $ref['only_students'] = Get::req('only_students', DOTY_INT, 0) > 0; $ref['show_assessment'] = Get::req('show_assessment', DOTY_INT, 0) > 0; } else { //... } //check action if (isset($_POST['cancelselector'])) { Util::jump_to($jump_url . '&substep=users_selection'); } if (isset($_POST['import_filter']) || isset($_POST['show_filter']) || isset($_POST['pre_filter'])) { $temp_url = $next_url; if (isset($_POST['pre_filter'])) { $temp_url .= '&show=1&nosave=1'; } if (isset($_POST['show_filter'])) { $temp_url .= '&show=1'; } Util::jump_to($temp_url); } cout($this->page_title, 'content'); function is_showed($which, &$arr) { if (isset($arr['showed_cols'])) { return in_array($which, $arr['showed_cols']); } else { return false; } } /*$go_to_second_step = (isset($_POST['go_to_second_step']) ? true : false); $we_are_in_second_step = Get::req('second_step', DOTY_INT, false);*/ $time_belt = array(0 => $lang->def('_CUSTOM_BELT'), 7 => $lang->def('_LAST_WEEK'), 31 => $lang->def('_LAST_MONTH'), 93 => $lang->def('_LAST_THREE_MONTH'), 186 => $lang->def('_LAST_SIX_MONTH'), 365 => $lang->def('_LAST_YEAR')); cout(Form::openForm('user_report_rows_courses', $jump_url) . Form::getHidden('update_tempdata', 'update_tempdata', 1) . Form::getHidden('is_updating', 'is_updating', 1) . Form::getHidden('substep', 'substep', 'columns_selection'), 'content'); //box for time belt $box = new ReportBox('timebelt_box'); $box->title = $lang->def('_REPORT_USER_TITLE_TIMEBELT'); $box->description = Lang::t('_TIME_PERIOD_FILTER', 'report'); $box->body = Form::getDropdown($lang->def('_TIME_BELT'), 'time_belt_' . $this->id_report, 'time_belt', $time_belt, isset($ref['time_belt']['time_range']) ? $ref['time_belt']['time_range'] : '', '', '', ' onchange="report_disableCustom( \'time_belt_' . $this->id_report . '\', \'start_time_' . $this->id_report . '\', \'end_time_' . $this->id_report . '\' )"') . Form::getOpenFieldset($lang->def('_CUSTOM_BELT'), 'fieldset_' . $this->id_report) . Form::getDatefield($lang->def('_START_TIME'), 'start_time_' . $this->id_report, 'start_time', Format::date($ref['time_belt']['start_date'], 'date')) . Form::getDatefield($lang->def('_TO'), 'end_time_' . $this->id_report, 'end_time', Format::date($ref['time_belt']['end_date'], 'date')) . Form::getCloseFieldset(); cout($box->get() . Form::getBreakRow(), 'content'); $box = new ReportBox('other_options'); $box->title = Lang::t('_OTHER_OPTION', 'course'); $box->description = false; $box->body = Form::getCheckbox($lang->def('ORG_CHART_SUBDIVISION'), 'org_chart_subdivision_' . $this->id_report, 'org_chart_subdivision', 1, $ref['org_chart_subdivision'] == 1 ? true : false) . Form::getCheckbox(Lang::t('_SHOW_SUSPENDED', 'organization_chart'), 'show_suspended', 'show_suspended', 1, (bool) $ref['show_suspended']) . Form::getCheckbox(Lang::t('_SHOW_ONLY', 'subscribe') . ': ' . Lang::t('_STUDENTS', 'coursereport'), 'only_students', 'only_students', 1, (bool) $ref['only_students']) . Form::getCheckbox(Lang::t('_SHOW', 'standard') . ': ' . Lang::t('_ASSESSMENT', 'standard'), 'show_assessment', 'show_assessment', 1, (bool) $ref['show_assessment']); cout($box->get() . Form::getBreakRow(), 'content'); $glang =& DoceboLanguage::createInstance('course', 'lms'); $show_classrooms_editions = $ref['show_classrooms_editions']; cout('<script type="text/javascript"> function activateClassrooms() { var Y = YAHOO.util.Dom; var b1 = Y.get("not_classrooms"), b2 = Y.get("use_classrooms"); var action = b1.style.display == "none" ? "hide" : "show"; switch (action) { case "hide": { b1.style.display = "block"; b2.style.display = "none"; } break; case "show": { b1.style.display = "none"; b2.style.display = "block"; } break; } } </script>', 'page_head'); $box = new ReportBox('columns_sel_box'); $box->title = $lang->def('_SELECT_THE_DATA_COL_NEEDED'); $box->description = false; $box->body = Form::getHidden('is_updating', 'is_updating', 2) . Form::getOpenFieldset($lang->def('_COURSE_FIELDS'), 'fieldset_course_fields') . Form::getCheckBox($lang->def('_COURSE_CODE'), 'col_sel_coursecode', 'cols[]', '_CODE_COURSE', is_showed('_CODE_COURSE', $ref)) . Form::getCheckBox($glang->def('_COURSE_NAME'), 'col_sel_coursename', 'cols[]', '_NAME_COURSE', is_showed('_NAME_COURSE', $ref)) . Form::getCheckBox($glang->def('_CATEGORY'), 'col_sel_category', 'cols[]', '_COURSE_CATEGORY', is_showed('_COURSE_CATEGORY', $ref)) . Form::getCheckBox($glang->def('_STATUS'), 'col_sel_status', 'cols[]', '_COURSESTATUS', is_showed('_COURSESTATUS', $ref)) . Form::getCheckBox($glang->def('_CATALOGUE'), 'col_sel_catalogue', 'cols[]', '_COURSECATALOGUE', is_showed('_COURSECATALOGUE', $ref)) . Form::getCheckBox($glang->def('_CREATION_DATE'), 'col_sel_publication', 'cols[]', '_PUBLICATION_DATE', is_showed('_PUBLICATION_DATE', $ref)) . Form::getCloseFieldset() . Form::getOpenFieldset(Form::getInputCheckbox('show_classrooms_editions', 'show_classrooms_editions', 1, $show_classrooms_editions, "onclick=activateClassrooms();") . " " . Lang::t('_CLASSROOM_FIELDS', 'report'), 'fieldset_classroom_fields') . '<div id="not_classrooms" style="display:' . ($show_classrooms_editions ? "none" : "block") . '">' . Lang::t('_ACTIVATE_CLASSROOM_FIELDS', 'report') . '</div>' . '<div id="use_classrooms" style="display:' . ($show_classrooms_editions ? "block" : "none") . '">' . Form::getCheckBox(Lang::t('_NAME', 'standard'), 'col_sel_classroomname', 'cols[]', '_TH_CLASSROOM_CODE', is_showed('_TH_CLASSROOM_CODE', $ref)) . Form::getCheckBox(Lang::t('_CODE', 'standard'), 'col_sel_classroomcode', 'cols[]', '_TH_CLASSROOM_NAME', is_showed('_TH_CLASSROOM_NAME', $ref)) . Form::getCheckBox(Lang::t('_DATE_BEGIN', 'standard'), 'col_sel_classroomdatebegin', 'cols[]', '_TH_CLASSROOM_MIN_DATE', is_showed('_TH_CLASSROOM_MIN_DATE', $ref)) . Form::getCheckBox(Lang::t('_DATE_END', 'standard'), 'col_sel_classroomdateend', 'cols[]', '_TH_CLASSROOM_MAX_DATE', is_showed('_TH_CLASSROOM_MAX_DATE', $ref)) . '</div>' . Form::getCloseFieldset() . Form::getOpenFieldset($lang->def('_COURSE_FIELDS_INFO'), 'fieldset_course_fields') . Form::getCheckBox($glang->def('_COURSE_LANG_METHOD'), 'col_course_lang_method', 'cols[]', '_LANGUAGE', is_showed('_LANGUAGE', $ref)) . Form::getCheckBox($glang->def('_DIFFICULTY'), 'col_course_difficult', 'cols[]', '_DIFFICULT', is_showed('_DIFFICULT', $ref)) . Form::getCheckBox($glang->def('_DATE_BEGIN'), 'col_date_begin', 'cols[]', '_DATE_BEGIN', is_showed('_DATE_BEGIN', $ref)) . Form::getCheckBox($glang->def('_DATE_END'), 'col_date_end', 'cols[]', '_DATE_END', is_showed('_DATE_END', $ref)) . Form::getCheckBox($glang->def('_HOUR_BEGIN'), 'col_time_begin', 'cols[]', '_TIME_BEGIN', is_showed('_TIME_BEGIN', $ref)) . Form::getCheckBox($glang->def('_HOUR_END'), 'col_time_end', 'cols[]', '_TIME_END', is_showed('_TIME_END', $ref)) . Form::getCheckBox($glang->def('_MAX_NUM_SUBSCRIBE'), 'col_max_num_subscribe', 'cols[]', '_MAX_NUM_SUBSCRIBED', is_showed('_MAX_NUM_SUBSCRIBED', $ref)) . Form::getCheckBox($glang->def('_MIN_NUM_SUBSCRIBE'), 'col_min_num_subscribe', 'cols[]', '_MIN_NUM_SUBSCRIBED', is_showed('_MIN_NUM_SUBSCRIBED', $ref)) . Form::getCheckBox(Lang::t('_CREDITS', 'standard'), 'col_credits', 'cols[]', '_CREDITS', is_showed('_CREDITS', $ref)) . Form::getCheckBox($glang->def('_COURSE_PRIZE'), 'col_course_price', 'cols[]', '_PRICE', is_showed('_PRICE', $ref)) . Form::getCheckBox($glang->def('_COURSE_ADVANCE'), 'col_course_advance', 'cols[]', '_ADVANCE', is_showed('_ADVANCE', $ref)) . Form::getCheckBox($glang->def('_COURSE_TYPE'), 'col_course_type', 'cols[]', '_COURSE_TYPE', is_showed('_COURSE_TYPE', $ref)) . Form::getCheckBox($glang->def('_COURSE_AUTOREGISTRATION_CODE'), 'col_autoregistration_code', 'cols[]', '_AUTOREGISTRATION_CODE', is_showed('_AUTOREGISTRATION_CODE', $ref)) . Form::getCloseFieldset() . Form::getOpenFieldset($lang->def('_STATS_FIELDS_INFO'), 'fieldset_course_fields') . Form::getCheckBox($lang->def('_USER_STATUS_SUBS'), 'col_inscr', 'cols[]', '_INSCR', is_showed('_INSCR', $ref)) . Form::getCheckBox($lang->def('_MUSTBEGIN'), 'col_mustbegin', 'cols[]', '_MUSTBEGIN', is_showed('_MUSTBEGIN', $ref)) . Form::getCheckBox($lang->def('_USER_STATUS_BEGIN'), 'col_user_status_begin', 'cols[]', '_USER_STATUS_BEGIN', is_showed('_USER_STATUS_BEGIN', $ref)) . Form::getCheckBox($lang->def('_COMPLETED'), 'col_completecourse', 'cols[]', '_COMPLETECOURSE', is_showed('_COMPLETECOURSE', $ref)) . Form::getCheckBox($lang->def('_TOTAL_SESSION'), 'col_total_session', 'cols[]', '_TOTAL_SESSION', is_showed('_TOTAL_SESSION', $ref)) . Form::getBreakRow() . Form::getCheckBox($lang->def('_PERCENTAGE'), 'show_percent', 'show_percent', '1', $ref['show_percent']) . Form::getCloseFieldset(); cout($box->get(), 'content'); cout(Form::openButtonSpace() . Form::getBreakRow() . Form::getButton('pre_filter', 'pre_filter', $lang->def('_SHOW_NOSAVE', 'report')) . Form::getButton('ok_filter', 'import_filter', $lang->def('_SAVE_BACK')) . Form::getButton('show_filter', 'show_filter', $lang->def('_SAVE_SHOW')) . Form::getButton('undo_filter', 'undo_filter', $lang->def('_UNDO')) . Form::closeButtonSpace() . Form::closeForm(), 'content'); cout('</div>', 'content'); //stdblock div break; case _SUBSTEP_USERS: //$aclManager = new DoceboACLManager(); $user_select = new UserSelector(); $user_select->use_suspended = true; if (Get::req('is_updating', DOTY_INT, 0) > 0) { $ref['all_users'] = Get::req('all_users', DOTY_INT, 0) > 0 ? true : false; } else { //maybe redoundant if (!isset($ref['all_users'])) { $ref['all_users'] = false; } if (!isset($ref['users'])) { $ref['users'] = array(); } $user_select->requested_tab = PEOPLEVIEW_TAB; $user_select->resetSelection($ref['users']); //$ref['users'] = array(); it should already have been set to void array, if non existent } if (isset($_POST['cancelselector'])) { Util::jump_to($back_url); } elseif (isset($_POST['okselector'])) { $elem_selected = $user_select->getSelection($_POST); $ref['all_users'] = Get::req('all_users', DOTY_INT, 0) > 0 ? true : false; $ref['users'] = $elem_selected; Util::jump_to($jump_url . '&substep=columns_selection'); } //set page if ($org_chart_subdivision == 0) { $user_select->show_user_selector = TRUE; $user_select->show_group_selector = TRUE; } else { $user_select->show_user_selector = FALSE; $user_select->show_group_selector = FALSE; } $user_select->show_orgchart_selector = TRUE; //$user_select->show_orgchart_simple_selector = FALSE; //$user_select->multi_choice = TRUE; $user_select->addFormInfo(Form::getCheckbox($lang->def('_REPORT_FOR_ALL'), 'all_users', 'all_users', 1, $ref['all_users'] ? 1 : 0) . Form::getBreakRow() . Form::getHidden('org_chart_subdivision', 'org_chart_subdivision', $org_chart_subdivision) . Form::getHidden('is_updating', 'is_updating', 1) . Form::getHidden('substep', 'substep', 'user_selection') . Form::getHidden('second_step', 'second_step', 1)); cout($this->page_title, 'content'); $user_select->loadSelector(Util::str_replace_once('&', '&', $jump_url), false, $this->lang->def('_CHOOSE_USER_FOR_REPORT'), true); break; } }
function modEvent() { checkPerm('view'); require_once _base_ . '/lib/lib.form.php'; $id_event = importVar('id_event', true, 0); $lang =& DoceboLanguage::createInstance('reservation'); $out = $GLOBALS['page']; $out->setWorkingZone('content'); $man_res = new Man_Reservation(); if (isset($_GET['confirm'])) { $confirm = importVar('confirm', true, 0); $id_course = importVar('id_course', true, 0); $id_laboratory = importVar('id_laboratory', true, 0); $id_category = importVar('id_category', true, 0); $title = importVar('title', false, ''); $description = importVar('description', false, ''); $date = importVar('date', false, ''); $max_user = importVar('max_user', true, 0); $deadline = importVar('deadline', false, ''); $from_time_h = importVar('from_time_h', false, ''); $from_time_m = importVar('from_time_m', false, ''); $to_time_h = importVar('to_time_h', false, ''); $to_time_m = importVar('to_time_m', false, ''); $date = Format::dateDb($date, 'date'); $deadline = Format::dateDb($deadline, 'date'); $from_time = $from_time_h . ':' . $from_time_m . ':00'; $to_time = $to_time_h . ':' . $to_time_m . ':00'; if ($date < date('Y-m-d') || $date < $deadline || $deadline < date('Y-m-d')) { Util::jump_to('index.php?modname=reservation&op=mod_event&id_event=' . $id_event . '&error=date'); } if ($from_time >= $to_time) { Util::jump_to('index.php?modname=reservation&op=mod_event&id_event=' . $id_event . '&error=time'); } if ($confirm) { $result = $man_res->modEvent($id_event, $id_course, $id_laboratory, $id_category, $title, $description, $date, $max_user, $deadline, $from_time, $to_time); } if ($result) { Util::jump_to('index.php?modname=reservation&op=reservation&active_tab=subscribed_user'); } Util::jump_to('index.php?modname=reservation&op=mod_event&id_event=' . $id_event . '&error=laboratory'); } $out->add(getTitleArea($lang->def('_SAVE'), '', $lang->def('_EVENT')) . '<div class="std_block">'); $error = importVar('error', false, ''); if ($error !== '') { switch ($error) { case 'date': $out->add(getErrorUi($lang->def('_WRONG_DATE'))); break; case 'time': $out->add(getErrorUi($lang->def('_WRONG_TIME'))); break; case 'laboratory': $out->add(getErrorUi($lang->def('_LOCATION_BUSY'))); break; } } $event = array(); $event = $man_res->getEventInfo($id_event); $date = Format::date($event[EVENT_DATE], 'date'); $deadline = Format::date($event[EVENT_DEADLINE], 'date'); $from_time_h = $event[EVENT_FROM_TIME][0] . $event[EVENT_FROM_TIME][1]; $from_time_m = $event[EVENT_FROM_TIME][3] . $event[EVENT_FROM_TIME][4]; $to_time_h = $event[EVENT_TO_TIME][0] . $event[EVENT_TO_TIME][1]; $to_time_m = $event[EVENT_TO_TIME][3] . $event[EVENT_TO_TIME][4]; $out->add(Form::openForm('form_event', 'index.php?modname=reservation&op=mod_event&confirm=1') . Form::openElementSpace() . Form::getHidden('id_event', 'id_event', $event[EVENT_ID]) . Form::getHidden('id_course', 'id_course', $event[EVENT_ID_COURSE]) . Form::getTextfield($lang->def('_TITLE'), 'title', 'title', 255, $event[EVENT_TITLE]) . Form::getTextarea($lang->def('_DESCRIPTION'), 'description', 'description', $event[EVENT_DESCRIPTION]) . Form::getDropdown($lang->def('_LOCATION'), 'id_laboratory', 'id_laboratory', $man_res->getLaboratories(), $event[EVENT_ID_LABORATORY]) . Form::getDropdown($lang->def('_CATEGORY'), 'id_category', 'id_category', $man_res->getCategory(), $event[EVENT_ID_CATEGORY]) . Form::getDateField($lang->def('_DATE'), 'date', 'date', $date) . Form::getDateField($lang->def('_DEADLINE'), 'deadline', 'deadline', $deadline) . Form::getTextfield($lang->def('_MAX_USER'), 'max_user', 'max_user', 255, $event[EVENT_MAX_USER]) . Form::getLineBox($lang->def('_FROM_TIME'), Form::getInputDropdown('', 'from_time_h', 'from_time_h', $man_res->getHours(), $from_time_h, false) . ' : ' . Form::getInputDropdown('', 'from_time_m', 'from_time_m', $man_res->getMinutes(), $from_time_m, false)) . Form::getLineBox($lang->def('_TO_TIME'), Form::getInputDropdown('', 'to_time_h', 'to_time_h', $man_res->getHours(), $to_time_h, false) . ' : ' . Form::getInputDropdown('', 'to_time_m', 'to_time_m', $man_res->getMinutes(), $to_time_m, false)) . Form::closeElementSpace() . Form::openButtonSpace() . Form::getButton('mod_event', 'mod_event', $lang->def('_SAVE')) . Form::getButton('undo', 'undo', $lang->def('_UNDO')) . Form::closeButtonSpace() . Form::closeForm()); $out->add('</div>', 'content'); }
function conference_modconf() { $lang =& DoceboLanguage::createInstance('conference', 'lms'); $id_room = Get::req('id', DOTY_INT, 0); $conference = new Conference_Manager(); $room_info = $conference->roomInfo($id_room); if (isset($_POST['update_conf'])) { switch ($room_info['room_type']) { case 'teleskill': $start_date = Format::dateDb($_POST['start_date'], 'date'); $start_date = substr($start_date, 0, 10); $start_time = (strlen($_POST['start_time']['hour']) == 1 ? '0' : '') . $_POST['start_time']['hour'] . ':' . (strlen($_POST['start_time']['minute']) == 1 ? '0' : '') . $_POST['start_time']['minute'] . ':00'; $start_timestamp = fromDatetimeToTimestamp($start_date . ' ' . $start_time); $conference_name = trim($_POST["conference_name"]) ? trim($_POST["conference_name"]) : $lang->def('_VIDEOCONFERENCE'); $meetinghours = (int) $_POST["meetinghours"]; $end_timestamp = $start_timestamp + $meetinghours * 3600; $maxparticipants = (int) $_POST["maxparticipants"]; $teleskill = new Teleskill_Management(); $teleskill->updateRoom($id_room, getLogUserId(), $conference_name, $start_timestamp, $end_timestamp, false, false, $maxparticipants, isset($_POST['bookable']) ? 1 : 0); Util::jump_to('index.php?modname=conference&op=list'); break; default: Util::jump_to('index.php?modname=conference&op=list'); break; } } else { cout(getTitleArea($lang->def('_MOD_CONFERENCE')) . '<div class="std_block">'); switch ($room_info['room_type']) { case 'teleskill': $teleskill = new Teleskill_Management(); $teleskill->getModUi($room_info); break; default: Util::jump_to('index.php?modname=conference&op=list'); break; } cout('</div>'); } }
/** * save some score info related with id_test and is_user * @param int $id_test the id of the test, * @param array $users_scores the score of the users associated with the proper idst_userid * @param array $date_attempts the date of the attempt time * @param array $comments comments to the test */ function saveTestUsersScores($id_test, $users_scores, $date_attempts, $comments) { require_once $GLOBALS['where_lms'] . '/class.module/track.test.php'; $query_test = "\r\n\t\tSELECT point_required, show_only_status \r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_test \r\n\t\tWHERE idTest = '" . $id_test . "'"; $re_test = sql_query($query_test); list($point_required, $show_only_status) = sql_fetch_row($re_test); $old_scores =& $this->getTestsScores(array($id_test), false, true); $re = true; while (list($idst_user, $score) = each($users_scores)) { $query_scores = "\r\n\t\t\tUPDATE " . $GLOBALS['prefix_lms'] . "_testtrack\r\n\t\t\tSET date_attempt_mod = '" . Format::dateDb($date_attempts[$idst_user]) . "', \r\n\t\t\t\tbonus_score = '" . ($score - $old_scores[$id_test][$idst_user]['score']) . "', \r\n\t\t\t\tscore_status = 'valid',\r\n\t\t\t\tcomment = '" . $comments[$idst_user] . "'\r\n\t\t\tWHERE idTest = '" . $id_test . "' AND idUser = '******'"; $re &= sql_query($query_scores); if ($score >= $point_required) { // update status in lesson $id_track = Track_Test::getTrack($id_test, $idst_user); if ($id_track) { $test_track = new Track_Test($id_track); $test_track->setDate(date('Y-m-d H:i:s')); $test_track->status = 'passed'; $test_track->update(); } } else { $id_track = Track_Test::getTrack($id_test, $idst_user); if ($id_track) { $test_track = new Track_Test($id_track); $test_track->setDate(date('Y-m-d H:i:s')); $test_track->status = 'failed'; $test_track->update(); } } $test_man = new TestManagement($id_test); $play_man = new PlayTestManagement($id_test, $idst_user, $id_track, $test_man); $test_info = $test_man->getTestAllInfo(); $track_info = $play_man->getTrackAllInfo(); $test_status = $score >= $point_required ? 'passed' : 'failed'; if ($test_info['use_suspension']) { $suspend_info = array(); if ($test_status == 'failed') { $suspend_info['attempts_for_suspension'] = $track_info['attempts_for_suspension'] + 1; if ($suspend_info['attempts_for_suspension'] >= $test_info['suspension_num_attempts']) { //should we reset learning_test.suspension_num_attempts ?? $suspend_info['attempts_for_suspension'] = 0; //from now on, it uses the suspended_until parameter, so only the date is needed, we can reset the attempts count $suspend_info['suspended_until'] = date("Y-m-d H:i:s", time() + $test_info['suspension_num_hours'] * 3600); } $re = Track_Test::updateTrack($id_track, $suspend_info); } else { if ($test_status == 'completed' || $test_status == 'passed') { $suspend_info['attempts_for_suspension'] = 0; $re = Track_Test::updateTrack($id_track, $suspend_info); } } } } return $re; }
function getUsers($param = false) { //retrieve all users matching given conditions $output = array(); $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); $a_obj = new DoceboACLManager(); $fman = new FieldList(); $user_to_check = Get::req('user', DOTY_INT, false); $f_arr = $param ? $param : urldecode(stripslashes(Get::req($this->id . "_input", DOTY_STRING, false))); $filter = is_string($f_arr) ? $json->decode(stripslashes($f_arr)) : $f_arr; $exclusive = $filter['exclusive']; $conds = $filter['filters']; //return a void array if no conditions specified if (count($conds) <= 0) { return array(); } //compose nested query // base query /Anonymous $base_query = "SELECT idst, userid " . " FROM %adm_user "; $std_condition = array(); $in_conditions = array(); $other_conditions = array(); foreach ($conds as $cond) { $id_field = $cond['id_field']; $params = $json->decode($cond['value']); if ($params == null) { $params = $cond['value']; } $res = $exclusive; list($id_type, $id) = explode('_', $id_field); switch ($id_type) { case _STANDARD_FIELDS_PREFIX: require_once _adm_ . '/modules/field/class.field.php'; require_once _adm_ . '/modules/field/class.date.php'; switch ($id) { case 0: //userid $temp = " userid "; switch ($params['cond']) { case 2: $temp .= " = '" . $a_obj->absoluteId($params['value']) . "' "; break; //equals //equals case 0: $temp .= " LIKE '%" . $params['value'] . "%' "; break; //contains //contains case 3: $temp .= " <> '" . $a_obj->absoluteId($params['value']) . "' "; break; //not equal //not equal case 1: $temp .= " NOT LIKE '%" . $params['value'] . "%' "; break; //does not contain //does not contain case 4: $temp .= " LIKE '" . $a_obj->absoluteId($params['value']) . "%' "; break; //starts with //starts with case 5: $temp .= " LIKE '%" . $params['value'] . "' "; break; //ends with //ends with default: $temp .= " NOT LIKE '%' "; //unexistent } $std_condition[] = $temp; break; case 1: //firstname $temp = " firstname "; switch ($params['cond']) { case 2: $temp .= " = '" . $params['value'] . "' "; break; //equals //equals case 0: $temp .= " LIKE '%" . $params['value'] . "%' "; break; //contains //contains case 3: $temp .= " <> '" . $params['value'] . "' "; break; //not equal //not equal case 1: $temp .= " NOT LIKE '%" . $params['value'] . "%' "; break; //does not contain //does not contain case 4: $temp .= " LIKE '" . $params['value'] . "%' "; break; //starts with //starts with case 5: $temp .= " LIKE '%" . $params['value'] . "' "; break; //ends with //ends with default: $temp .= " NOT LIKE '%' "; //unexistent } $std_condition[] = $temp; break; case 2: //lastname $temp = " lastname "; switch ($params['cond']) { case 2: $temp .= " = '" . $params['value'] . "' "; break; //equals //equals case 0: $temp .= " LIKE '%" . $params['value'] . "%' "; break; //contains //contains case 3: $temp .= " <> '" . $params['value'] . "' "; break; //not equal //not equal case 1: $temp .= " NOT LIKE '%" . $params['value'] . "%' "; break; //does not contain //does not contain case 4: $temp .= " LIKE '" . $params['value'] . "%' "; break; //starts with //starts with case 5: $temp .= " LIKE '%" . $params['value'] . "' "; break; //ends with //ends with default: $temp .= " NOT LIKE '%' "; //unexistent } $std_condition[] = $temp; break; case 3: //email $temp = " email "; switch ($params['cond']) { case 2: $temp .= " = '" . $params['value'] . "' "; break; //equals //equals case 0: $temp .= " LIKE '%" . $params['value'] . "%' "; break; //contains //contains case 3: $temp .= " <> '" . $params['value'] . "' "; break; //not equal //not equal case 1: $temp .= " NOT LIKE '%" . $params['value'] . "%' "; break; //does not contain //does not contain case 4: $temp .= " LIKE '" . $params['value'] . "%' "; break; //starts with //starts with case 5: $temp .= " LIKE '%" . $params['value'] . "' "; break; //ends with //ends with default: $temp .= " NOT LIKE '%' "; //unexistent } $std_condition[] = $temp; break; case 4: //register date $date = substr(Format::dateDb($params['value'], 'date'), 0, 10); $temp = " register_date "; switch ($params['cond']) { case 0: $temp .= " < '" . $date . " 00:00:00' "; break; //< //< case 1: $temp .= " <= '" . $date . " 23:59:59' "; break; //<= //<= case 2: $temp = " ( register_date >= '" . $date . " 00:00:00' AND register_date <= '" . $date . " 23:59:59' ) "; break; //= //= case 3: $temp .= " >= '" . $date . " 00:00:00' "; break; //>= //>= case 4: $temp .= " > '" . $date . " 23:59:59' "; break; //> //> default: $temp .= " NOT LIKE '%' "; //unexistent } $std_condition[] = $temp; break; case 5: //lastenter $date = substr(Format::dateDb($params['value'], 'date'), 0, 10); $temp = " lastenter "; switch ($params['cond']) { case 0: $temp .= " < '" . $date . " 00:00:00' "; break; //< //< case 1: $temp .= " <= '" . $date . " 23:59:59' "; break; //<= //<= case 2: $temp = " ( lastenter >= '" . $date . " 00:00:00' AND lastenter <= '" . $date . " 23:59:59' ) "; break; //= //= case 3: $temp .= " >= '" . $date . " 00:00:00' "; break; //>= //>= case 4: $temp .= " > '" . $date . " 23:59:59' "; break; //> //> default: $temp .= " NOT LIKE '%' "; //unexistent } $std_condition[] = $temp; break; default: } break; // filter on a custom field // filter on a custom field case _CUSTOM_FIELDS_PREFIX: $fobj = $fman->getFieldInstance($id); $in_conditions[] = $fobj->getFieldQuery($params); break; // other special field // other special field case _OTHER_FIELDS_PREFIX: $ofobj = new OtherFieldsTypes(); $other_conditions[] = $ofobj->getFieldQuery($id, $params); break; default: } //end switch } //end foreach if ($exclusive) { $query = $base_query . ' WHERE 1 ' . (!empty($std_condition) ? " AND " . implode(" AND ", $std_condition) : '') . (!empty($in_conditions) ? ' AND idst IN ( ' . implode(" ) AND idst IN ( ", $in_conditions) . ' ) ' : '') . (!empty($other_conditions) ? ' AND idst IN ( ' . implode(" ) AND idst IN ( ", $other_conditions) . ' ) ' : ''); } else { $query = $base_query . ' WHERE 0 ' . (!empty($std_condition) ? ' OR ( ' . implode(" ) OR idst IN ( ", $std_condition) . ' ) ' : '') . (!empty($in_conditions) ? ' OR idst IN ( ' . implode(" ) OR idst IN ( ", $in_conditions) . ' ) ' : '') . (!empty($other_conditions) ? ' OR idst IN ( ' . implode(" ) OR idst IN ( ", $other_conditions) . ' ) ' : ''); } //produce output $output = array(); $re = $this->db->query($query); while ($rw = $this->db->fetch_assoc($re)) { if ($rw['userid'] != '/Anonymous') { $output[] = $rw['idst']; } } return $output; }
public function multimod_actionTask() { if (!$this->permissions['mod_user']) { $output = array('success' => false, 'message' => $this->_getErrorMessage('no permission')); echo $this->json->encode($output); return; } $output = false; $users_str = Get::req('users', DOTY_STRING, ""); if (!$users_str) { $output = array('success' => false, 'message' => $this->_getErrorMessage('invalid input')); echo $this->json->encode($output); return; } $users = explode(",", $users_str); if (empty($users)) { $output = array('success' => false, 'message' => $this->_getErrorMessage('invalid input')); echo $this->json->encode($output); return; } $info = new stdClass(); $to_update = Get::req('to_change', DOTY_MIXED, array()); $count_updated = 0; if (!empty($to_update)) { foreach ($to_update as $property) { } } //read input data $sel_properties = Get::req('multimod_sel', DOTY_MIXED, array()); $pref_properties = Get::req('multimod_selpref', DOTY_MIXED, array()); $field_properties = Get::req('multimod_selfield', DOTY_MIXED, array()); //validate input data $info = new stdClass(); if (isset($sel_properties['firstname'])) { $info->firstname = Get::req('firstname', DOTY_STRING, ""); } if (isset($sel_properties['lastname'])) { $info->lastname = Get::req('lastname', DOTY_STRING, ""); } if (isset($sel_properties['email'])) { $info->email = Get::req('email', DOTY_STRING, ""); } if (isset($sel_properties['password'])) { $pwd_1 = Get::req('new_password', DOTY_STRING, ""); $pwd_2 = Get::req('new_password_confirm', DOTY_STRING, ""); if ($pwd_1 == $pwd_2) { $info->password = $pwd_1; } else { $output = array('success' => false, 'message' => $this->_getErrorMessage('password mismatch')); echo $this->json->encode($output); return; } } if (isset($sel_properties['force_change'])) { $info->force_change = Get::req('force_change', DOTY_INT, 0) > 0; } if (isset($sel_properties['level'])) { $info->level = Get::req('level', DOTY_STRING, ""); } /* if (isset($sel_properties['facebook_id'])) $info->facebook_id = Get::req('facebook_id', DOTY_STRING, ""); if (isset($sel_properties['twitter_id'])) $info->twitter_id = Get::req('twitter_id', DOTY_STRING, ""); if (isset($sel_properties['linkedin_id'])) $info->linkedin_id = Get::req('linkedin_id', DOTY_STRING, ""); if (isset($sel_properties['google_id'])) $info->google_id = Get::req('google_id', DOTY_STRING, ""); */ if (!empty($field_properties)) { require_once _adm_ . '/lib/lib.field.php'; $fields = new FieldList(); $selected_fields = array_keys($field_properties); $finfo = $fields->getFieldsFromArray($selected_fields); $field_info = array(); foreach ($finfo as $id_field => $data) { $input_data = Get::req('field_' . $data[FIELD_INFO_TYPE], DOTY_MIXED, array()); if (isset($input_data[$id_field])) { $value_to_set = ""; switch ($data[FIELD_INFO_TYPE]) { case "": $value_to_set = Format::dateDb($input_data[$id_field], 'date'); break; default: $value_to_set = $input_data[$id_field]; } $field_info[$id_field] = $value_to_set; } } $info->__fields = $field_info; } if (!empty($pref_properties)) { $info->__preferences = $pref_properties; } $res = $this->model->updateMultipleUsers($users, $info); if (!$res) { $output = array('success' => false, 'message' => $this->_getErrorMessage('server error')); } else { $output = array('success' => true, 'update' => $count_updated); } echo $this->json->encode($output); }
public function multimod_coursepath() { $id_path = Get::req('id_path', DOTY_INT, 0); if ($id_path <= 0) { //... return; } $output = array(); $users = Get::req('users', DOTY_STRING, ''); if ($users == '') { $output['success'] = false; $output['message'] = Lang::t('_NO_USER_SELECTED', 'subscribe'); } else { $set_date_begin = Get::req('multimod_date_begin_set', DOTY_INT, 0); $set_date_expire = Get::req('multimod_date_expire_set', DOTY_INT, 0); if ($set_date_begin <= 0 && $set_date_expire <= 0) { $output['success'] = false; $output['message'] = UIFeedback::info($this->_getMessage('no options selected'), true); } else { $users_list = explode(',', $users); require_once _lms_ . '/lib/lib.coursepath.php'; $sman = new CoursePath_Manager(); $res1 = true; if ($set_date_begin > 0) { $new_date_begin = Get::req('multimod_date_begin', DOTY_STRING, ""); $res3 = $sman->updateUserDateBeginValidityInCourse($users_list, $id_path, Format::dateDb($new_date_begin, 'date')); } $res2 = true; if ($set_date_expire > 0) { $new_date_expire = Get::req('multimod_date_expire', DOTY_STRING, ""); $res4 = $sman->updateUserDateExpireValidityInCourse($users_list, $id_path, Format::dateDb($new_date_expire, 'date')); } $success = $res1 && $res2; $output['success'] = $success; if (!$success) { $message = ""; if (!$res1) { $message .= 'Unable to change date begin;'; } //TO DO: make translation if (!$res2) { $message .= 'Unable to change date expire;'; } //TO DO: make translation $output['message'] = $message; } } } echo $this->json->encode($output); }
protected function update() { if (!$this->permissions['mod']) { $this->render('invalid', array('message' => $this->_getMessage('no permission'), 'back_url' => 'index.php?r=alms/communication/show')); return; } if (Get::req('undo', DOTY_MIXED, false) !== false) { Util::jump_to('index.php?r=alms/communication/show'); } $data = array(); $data['id_comm'] = Get::req('id_comm', DOTY_MIXED, ''); $data['title'] = Get::req('title', DOTY_MIXED, ''); $data['publish_date'] = Get::req('publish_date', DOTY_MIXED, Format::date(date('Y-m-d'), 'date')); $data['description'] = Get::req('description', DOTY_MIXED, ''); $data['type_of'] = Get::req('type_of', DOTY_STRING, ''); $data['id_course'] = Get::req('id_course', DOTY_INT, 0); $data['publish_date'] = Format::dateDb($data['publish_date'], 'date'); $id_comm = $this->model->save($data); if (!$id_comm) { UIFeedback::error(Lang::t('_OPERATION_FAILURE', 'communication')); $this->add($data); } elseif ($data['type_of'] != 'none') { Util::jump_to('index.php?r=alms/communication/mod_obj&id_comm=' . $id_comm); } else { Util::jump_to('index.php?r=alms/communication/show&success=1'); } }
function getFieldQuery($filter) { $date = Format::dateDb($filter['value'], 'date'); $output = "SELECT id_user " . "FROM " . $GLOBALS['prefix_fw'] . "_field_userentry " . "WHERE id_common = '" . $this->id_common . "' AND "; $temp = " user_entry "; switch ($filter['cond']) { case 0: $temp .= " < '" . $date . ".' 00:00:00'' "; break; //< //< case 1: $temp .= " <= '" . $date . ".' 23:59:59'' "; break; //<= //<= case 2: $temp = " ( user_entry >= '" . $date . " 00:00:00' AND user_entry <= '" . $date . " 23:59:59' ) "; break; //= //= case 3: $temp .= " >= '" . $date . " 00:00:00' "; break; //>= //>= case 4: $temp .= " > '" . $date . ".' 23:59:59'' "; break; //> //> default: $temp .= " NOT LIKE '%' "; //unexistent } return $output . $temp; }
/** * @version $Id:$ * @author Fabio Pirovano <fabio [at] docebo-com> * @package course */ function displayCourseList(&$url, $order_type) { require_once _base_ . '/lib/lib.form.php'; require_once _base_ . '/lib/lib.user_profile.php'; require_once _base_ . '/lib/lib.navbar.php'; require_once $GLOBALS['where_lms'] . '/lib/lib.preassessment.php'; require_once $GLOBALS['where_lms'] . '/lib/lib.catalogue.php'; require_once $GLOBALS['where_lms'] . '/lib/lib.course.php'; require_once $GLOBALS['where_lms'] . '/lib/lib.coursereport.php'; require_once $GLOBALS["where_framework"] . "/lib/lib.ajax_comment.php"; require_once $GLOBALS['where_lms'] . '/lib/lib.classroom.php'; // cahce classroom $classroom_man = new ClassroomManager(); $classrooms = $classroom_man->getClassroomNameList(); $lang =& DoceboLanguage::createInstance('catalogue'); $lang_c =& DoceboLanguage::createInstance('course'); $nav_bar = new NavBar('ini', Get::sett('visuItem'), 0); $man_course = new Man_Course(); $id_parent = importVar('id_parent', false, 0); $nav_url = $id_parent != 0 ? $url->getUrl('id_parent=' . $id_parent) : $url->getUrl(); $nav_bar->setLink($nav_url); $ini = $nav_bar->getSelectedElement(); $profile = new UserProfile(getLogUserId()); $profile->init('profile', 'framework', '', 'ap'); $profile->addStyleSheet('lms'); // searching courses $use_category = $order_type == 'category'; $select_course = "" . " SELECT c.idCourse, c.course_type, c.idCategory, c.code, c.name, c.description, c.lang_code, c.difficult, " . "\tc.subscribe_method, c.date_begin, c.date_end, c.max_num_subscribe, " . "\tc.selling, c.prize, c.create_date, c.status AS course_status, c.course_edition, " . "\tc.classrooms, c.img_material, c.course_demo, c.course_vote, COUNT(*) as enrolled, " . "\tc.can_subscribe, c.sub_start_date, c.sub_end_date, c.allow_overbooking, c.max_num_subscribe, c.min_num_subscribe, c.direct_play, " . "\tc.valid_time, c.userStatusOp, u.level, u.date_inscr, u.date_first_access, u.date_complete, u.status AS user_status, u.waiting, c.advance "; $from_course = " FROM " . $GLOBALS['prefix_lms'] . "_course AS c " . "\tLEFT JOIN " . $GLOBALS['prefix_lms'] . "_courseuser AS u " . "\t\tON ( c.idCourse = u.idCourse ) "; $where_course = " c.status <> '" . CST_PREPARATION . "' "; if (Get::sett('catalogue_hide_ended') == 'on') { $where_course .= " AND ( c.date_end = '0000-00-00'" . " OR c.date_end > '" . date('Y-m-d') . "' ) "; } $group_by_course = " GROUP BY c.idCourse "; switch ($order_type) { case "mostscore": $order_course = " ORDER BY c.course_vote DESC "; break; case "popular": $order_course = " ORDER BY enrolled DESC "; break; case "recent": $order_course = " ORDER BY c.create_date DESC "; break; default: $order_course = " ORDER BY c.name "; } $limit_course = " LIMIT " . $ini . ", " . Get::sett('visuItem'); $where_course .= " AND c.course_type <> 'assessment'"; if (Docebo::user()->isAnonymous()) { $where_course .= " AND c.show_rules = 0"; } else { $where_course .= " AND c.show_rules <> 2"; } // maybe a must apply some filter to remove from the list some courses -------------- $cat_man = new Catalogue_Manager(); $catalogues =& $cat_man->getUserAllCatalogueId(getLogUserId()); // at least one catalogue is assigned to this user if (!empty($catalogues)) { $cat_courses = $cat_man->getAllCourseOfUser(getLogUserId()); if (empty($cat_courses)) { $where_course .= " AND 0 "; } else { $where_course .= " AND c.idCourse IN ( " . implode(',', $cat_courses) . " ) "; } } elseif (Get::sett('on_catalogue_empty') == 'off') { $where_course .= " AND 0 "; } if (!Docebo::user()->isAnonymous()) { if (!isset($_SESSION['cp_assessment_effect'])) { $pa_man = new AssessmentList(); $arr_assessment = $pa_man->getUserAssessmentSubsription(Docebo::user()->getArrSt()); $report = new CourseReportManager(); $user_result = $report->getAllUserFinalScore(getLogUserId(), $arr_assessment['course_list']); $rule_man = new AssessmentRule(); $ass_elem = $rule_man->getCompleteEffectListForAssessmentWithUserResult($arr_assessment['course_list'], $user_result); $_SESSION['cp_assessment_effect'] = urlencode(serialize($ass_elem)); } else { $ass_elem = unserialize(urldecode($_SESSION['cp_assessment_effect'])); } if (!empty($ass_elem['parsed']['course'])) { $where_course = " ( ( " . $where_course . " ) OR c.idCourse IN (" . implode(',', $ass_elem['parsed']['course']) . ") ) "; } } // apply search filter -------------------------------------------------------------- $s_searched = get_searched('simple_search', ''); $filter_lang = get_searched('filter_lang', 'all'); $filter_date_begin = get_searched('filter_date_begin', ''); if ($filter_date_begin != '') { $filter_date_begin = Format::dateDb($filter_date_begin, 'date') . ' 00:00:00'; } $filter_date_end = get_searched('filter_date_end', ''); if ($filter_date_end != '') { $filter_date_end = Format::dateDb($filter_date_end, 'date') . ' 00:00:00'; } $all_lang = Docebo::langManager()->getAllLangCode(); if (must_search_filter()) { if (trim($s_searched) != '') { $where_course .= " AND ( c.code LIKE '%" . $s_searched . "%' " . " OR c.name LIKE '%" . $s_searched . "%' " . " OR c.description LIKE '%" . $s_searched . "%' ) "; } if ($filter_lang != 'all') { $where_course .= " AND c.lang_code = '" . $all_lang[$filter_lang] . "' "; } if ($filter_date_begin != '') { $where_course .= " AND ( c.date_begin >= '" . $filter_date_begin . "' OR c.course_edition = 1 ) "; } if ($filter_date_end != '') { $where_course .= " AND ( c.date_end <= '" . $filter_date_end . "' OR c.course_edition = 1 ) "; } } if ($use_category) { $where_course .= " AND c.idCategory = '" . (int) $id_parent . "'"; } $re_course = sql_query($select_course . $from_course . " WHERE " . $where_course . $group_by_course . $order_course . $limit_course); list($course_number) = sql_fetch_row(sql_query("SELECT COUNT(*) " . " FROM " . $GLOBALS['prefix_lms'] . "_course AS c " . " WHERE " . $where_course)); $nav_bar->setElementTotal($course_number); // retrive editions ---------------------------------------------------------------- $select_edition = " SELECT e.* "; $from_edition = " FROM " . $GLOBALS["prefix_lms"] . "_course_edition AS e"; $where_edition = " WHERE e.status <> '" . CST_PREPARATION . "' "; $where_edition .= " AND (e.date_begin > '" . date("Y-m-d H:i:s") . "' OR e.date_begin = '0000-00-00 00:00:00')"; $order_edition = " ORDER BY date_begin "; if (must_search_filter()) { if ($filter_date_begin != '') { $where_edition .= " AND date_begin >= '" . $filter_date_begin . "' "; } if ($filter_date_end != '') { $where_edition .= " AND date_end <= '" . $filter_date_end . "' "; } } $re_edition = sql_query($select_edition . $from_edition . $where_edition . $order_edition); $editions = array(); if ($re_edition) { while ($edition_elem = mysql_fetch_assoc($re_edition)) { $edition_elem['classrooms'] = isset($classrooms[$edition_elem['classrooms']]) ? $classrooms[$edition_elem['classrooms']] : ''; $edition_elem['waiting'] = 0; $edition_elem['user_count'] = 0; $edition_elem['theacher_list'] = getSubscribed($edition_elem["idCourse"], false, 6, true, $edition_elem["idCourseEdition"]); $editions[$edition_elem["idCourse"]][$edition_elem["idCourseEdition"]] = $edition_elem; } } // retrive editions subscribed ----------------------------------------------------- $select_ed_count = "SELECT u.idCourse, u.edition_id, sum(u.waiting) as waiting, COUNT(*) as user_count "; $from_ed_count = " FROM " . $GLOBALS["prefix_lms"] . "_courseuser AS u"; $where_ed_count = " WHERE u.edition_id <> 0 " . " AND u.level = '3'" . " AND u.status IN ('" . _CUS_CONFIRMED . "', '" . _CUS_SUBSCRIBED . "', '" . _CUS_BEGIN . "', '" . _CUS_END . "', '" . _CUS_SUSPEND . "', '" . _CUS_WAITING_LIST . "')" . " AND u.absent = '0'"; $group_ed_count = "GROUP BY u.edition_id "; $re_ed_count = sql_query($select_ed_count . $from_ed_count . $where_ed_count . $group_ed_count); if ($re_ed_count) { while ($ed_count_elem = mysql_fetch_assoc($re_ed_count)) { if (isset($editions[$ed_count_elem["idCourse"]][$ed_count_elem["edition_id"]])) { $editions[$ed_count_elem["idCourse"]][$ed_count_elem["edition_id"]]['waiting'] = $ed_count_elem['waiting']; $editions[$ed_count_elem["idCourse"]][$ed_count_elem["edition_id"]]['user_count'] = $ed_count_elem['user_count']; } } } // retrive course subscription ----------------------------------------------------- $man_courseuser = new Man_CourseUser(); $usercourses = $man_courseuser->getUserSubscriptionsInfo(getLogUserId(), false); $user_score = $man_courseuser->getUserCourseScored(getLogUserId()); require_once $GLOBALS['where_lms'] . '/lib/lib.orgchart.php'; $first_is_scorm = OrganizationManagement::objectFilter(array_keys($usercourses), 'scormorg'); // load search form ---------------------------------------------------------------- $GLOBALS['page']->add(searchForm($url, $lang), 'content'); if ($use_category && !must_search_filter()) { // show category selection ----------------------------------------------------- $descendant = $man_course->getCategoryCourseAndSonCount(); $GLOBALS['page']->add('<p class="category_path">' . '<b>' . $lang->def('_CATEGORY_PATH', 'course') . ' :</b> ' . $man_course->getCategoryPath($id_parent, $lang->def('_MAIN_CATEGORY', 'course'), $lang->def('_TITLE_CATEGORY_JUMP', 'course'), $url->getUrl(), 'id_parent') . '</p>', 'content'); $categories =& $man_course->getCategoriesInfo($id_parent); if (!empty($categories)) { $GLOBALS['page']->add('<ul class="category_list">', 'content'); while (list($id_cat, $cat) = each($categories)) { $GLOBALS['page']->add('<li' . (!isset($descendant[$id_cat]) ? ' class="empty_folder"' : '') . '>' . '<a href="' . $url->getUrl('id_parent=' . $id_cat) . '">' . $cat['name'] . '<br />' . '<b>' . str_replace(array('[course]', '[category]'), array(isset($descendant[$id_cat]['course']) ? $descendant[$id_cat]['course'] : 0, isset($descendant[$id_cat]['category']) ? $descendant[$id_cat]['category'] : 0), $lang->def('_COURSE_CONTENT', 'course')) . '</b>' . '</a></li>', 'content'); } $GLOBALS['page']->add('</ul>' . '<div class="nofloat"></div>', 'content'); } } if (!$re_course || !mysql_num_rows($re_course)) { // no course found for the criteria -------------------------------------------- $GLOBALS['page']->add('<p class="no_course_found">' . $lang->def('_NO_COURSE_FOUND') . '</p>' . '</div>', 'content'); return; } $ax_comm = new AjaxComment('course', 'lms'); $comment_count = $ax_comm->getResourceCommentCount(); $GLOBALS['page']->add($nav_bar->getNavBar($ini), 'content'); $i = 0; $direct_play = false; while ($cinfo = mysql_fetch_assoc($re_course)) { if (must_search_filter()) { $s_searched = get_searched('simple_search', ''); if ($s_searched != '') { $cinfo['code'] = preg_replace("/" . $s_searched . "/i", '<b class="filter_evidence">' . $s_searched . '</b>', $cinfo['code']); $cinfo['name'] = preg_replace("/" . $s_searched . "/i", '<b class="filter_evidence">' . $s_searched . '</b>', $cinfo['name']); $cinfo['description'] = preg_replace("/" . $s_searched . "/i", '<b class="filter_evidence">' . $s_searched . '</b>', $cinfo['description']); } } $cinfo['theacher_list'] = getSubscribed($cinfo['idCourse'], false, 6, true); $cinfo['edition_list'] = isset($editions[$cinfo['idCourse']]) ? $editions[$cinfo['idCourse']] : array(); $cinfo['edition_available'] = count($cinfo['edition_list']); $cinfo['user_score'] = isset($user_score[$cinfo['idCourse']]) ? $user_score[$cinfo['idCourse']] : NULL; $cinfo['classrooms'] = isset($classrooms[$cinfo['classrooms']]) ? $classrooms[$cinfo['classrooms']] : ''; if (isset($first_is_scorm[$cinfo['idCourse']])) { $cinfo['first_is_scorm'] = $first_is_scorm[$cinfo['idCourse']]; } else { $cinfo['first_is_scorm'] = false; } if (isset($comment_count[$cinfo['idCourse']])) { $cinfo['comment_count'] = $comment_count[$cinfo['idCourse']]; } $view = true; if (must_search_filter()) { if ($cinfo['course_edition'] == 1 && empty($cinfo['edition_list'])) { $view = false; } } if ($view) { $GLOBALS['page']->add(dashcourse($url, $lang_c, $cinfo, isset($usercourses[$cinfo['idCourse']]) ? $usercourses[$cinfo['idCourse']] : false, $i++), 'content'); } if ($cinfo['direct_play'] == 1) { $direct_play = true; } } if ($direct_play) { $GLOBALS['page']->add('' . ' <link href="' . getPathTemplate() . '/style/shadowbox.css" rel="stylesheet" type="text/css" />' . '<script type="text/javascript" src="' . $GLOBALS['where_framework_relative'] . '/addons/shadowbox/shadowbox-yui.js"></script>' . "\n" . '<script type="text/javascript" src="' . $GLOBALS['where_framework_relative'] . '/addons/shadowbox/shadowbox.js"></script>' . "\n", 'page_head'); $GLOBALS['page']->add('<script type="text/javascript"> YAHOO.util.Event.onDOMReady(function() { var options = { listenOverlay:false, overlayOpacity:"0.8", loadingImage:"' . getPathImage('lms') . 'standard/loading.gif", overlayBgImage:"' . getPathImage('lms') . 'standard/overlay-85.png", text: {close: "' . Lang::t('_CLOSE') . '", cancel: "' . Lang::t('_UNDO') . '", loading:"' . Lang::t('_LOADING') . '" }, onOpen: function (gallery) { window.onbeforeunload = function() { return "' . Lang::t('_CONFIRM_EXIT', 'organization', 'lms') . '"; } } }; Shadowbox.init(options); Shadowbox.close = function() { window.onbeforeunload = null; window.frames[\'shadowbox_content\'].uiPlayer.closePlayer(true, window); } }); </script>'); } $GLOBALS['page']->add($nav_bar->getNavBar($ini), 'content'); }
public function updateDate() { $date_info = $this->getDateInfoFromPost(); $array_day_tmp = explode(',', $date_info['date_selected']); $array_day = array(); for ($i = 0; $i < count($array_day_tmp); $i++) { $array_day[$i]['date_begin'] = $array_day_tmp[$i] . ' ' . $_POST['b_hours_' . $i] . ':' . $_POST['b_minutes_' . $i] . ':00'; $array_day[$i]['pause_begin'] = $array_day_tmp[$i] . ' ' . $_POST['pb_hours_' . $i] . ':' . $_POST['pb_minutes_' . $i] . ':00'; $array_day[$i]['pause_end'] = $array_day_tmp[$i] . ' ' . $_POST['pe_hours_' . $i] . ':' . $_POST['pe_minutes_' . $i] . ':00'; $array_day[$i]['date_end'] = $array_day_tmp[$i] . ' ' . $_POST['e_hours_' . $i] . ':' . $_POST['e_minutes_' . $i] . ':00'; $array_day[$i]['classroom'] = $_POST['classroom_' . $i]; } $res = $this->classroom_man->upDate($this->id_date, $date_info['code'], $date_info['name'], $date_info['description'], $date_info['medium_time'], $date_info['max_par'], $date_info['price'], $date_info['overbooking'], $date_info['status'], $date_info['test'], Format::dateDb($date_info['sub_start_date'], 'date') . ' 00:00:00', Format::dateDb($date_info['sub_end_date'], 'date') . ' 00:00:00', Format::dateDb($date_info['unsubscribe_date_limit'], 'date') . ' 00:00:00'); if ($res) { return $this->classroom_man->insDateDay($this->id_date, $array_day); } else { return false; } }
function edit_news($mode = "edit") { require_once _base_ . '/lib/lib.form.php'; $form = new Form(); $out =& $GLOBALS['page']; $out->setWorkingZone('content'); $lang =& DoceboLanguage::createInstance('project', "lms"); // Controllo che l'utente non cerchi di entrare in progetti a cui non e' iscritto. $id = $_GET["id"]; $itemid = importVar("itemid"); $myprj = user_projects(Docebo::user()->getIdSt()); $view_perm = checkPerm('view', true); if ($view_perm && in_array($id, $myprj) && (is_owner(Docebo::user()->getIdSt(), $id) || is_admin(Docebo::user()->getIdSt(), $id))) { //area title $out->add(getTitleArea($lang->def("_PROJECT_MANAGER"), "project")); $out->add('<div class="std_block">'); if ($mode == "edit") { $goto = "prjedititem"; } if ($mode == "new") { $goto = "prjadditem"; } if (isset($_POST["applychanges"])) { $ndate = Format::dateDb($_POST["ndate"], "date"); $ntitle = $_POST["ntitle"]; $ntxt = $_POST["ntxt"]; if ($mode == "new") { $query = sql_query("INSERT INTO " . $GLOBALS["prefix_lms"] . "_prj_news (pid,ntitle,ntxt,ndate) VALUES('{$id}','{$ntitle}','{$ntxt}','{$ndate}');"); } if ($mode == "edit") { $query = sql_query("UPDATE " . $GLOBALS["prefix_lms"] . "_prj_news SET ndate='{$ndate}',ntitle='{$ntitle}',ntxt='{$ntxt}' WHERE id='{$itemid}' LIMIT 1;"); } Util::jump_to(" index.php?modname=project&op=showprj&id={$id}"); } $url = "index.php?modname=project&op=showprj&id=" . $id; $out->add(getBackUi($url, $lang->def('_BACK'))); if ($mode == "edit") { $query = sql_query("SELECT * FROM " . $GLOBALS["prefix_lms"] . "_prj_news WHERE pid='{$id}' AND id='{$itemid}';"); if ($query && mysql_num_rows($query) > 0) { $row = mysql_fetch_array($query); $ndate = Format::date($row["ndate"], "date"); } $label = $lang->def("_SAVE"); } else { if ($mode == "new") { $row = array(); $label = $lang->def("_SAVE"); } } if (empty($ndate)) { $ndate = Format::date(date("Y-m-d"), "date"); } $ntitle = isset($row["ntitle"]) ? $row["ntitle"] : ''; $ntxt = isset($row["ntxt"]) ? $row["ntxt"] : ''; $url = "index.php?modname=project&op={$goto}&type=news&id={$id}&itemid=" . $itemid; $out->add($form->openForm("form_name", $url)); $out->add($form->openElementSpace()); $out->add($form->getDatefield($lang->def("_DATE"), "ndate", "ndate", $ndate)); $out->add($form->getTextfield($lang->def("_TITLE"), "ntitle", "ntitle", 255, $ntitle)); $out->add($form->getTextarea($lang->def("_TEXTOF"), "ntxt", "ntxt", $ntxt)); $out->add($form->getHidden("applychanges", "applychanges", 1)); $out->add($form->closeElementSpace()); $out->add($form->openButtonSpace()); $out->add($form->getButton('save', 'save', $label)); $out->add($form->getButton('undo', 'undo', $lang->def('_UNDO'))); $out->add($form->closeButtonSpace()); $out->add($form->closeForm()); $out->add('</div>'); return 0; $out->add("<form method=\"post\" action=\"index.php?modname=project&op={$goto}&type=news&id={$id}&itemid={$itemid}\">\n" . '<input type="hidden" id="authentic_request_prj" name="authentic_request" value="' . Util::getSignature() . '" />'); $query = sql_query("SELECT * FROM " . $GLOBALS["prefix_lms"] . "_prj_news WHERE pid='{$id}' AND id='{$itemid}';"); if ($query && mysql_num_rows($query) > 0 || $mode == "new") { if ($mode == "edit") { $row = mysql_fetch_array($query); } if ($mode == "new") { $row = array(); } //$out->add("<table border=\"0\" cellpadding=\"4\" cellspacing=\"1\" bgcolor=\"#DDDDEE\" style=\"border-spacing: 1px;\" >\n"); $i = 0; $out->add("<table><tr>\n"); if ($mode == "edit") { //$datearr=explode("-",$row["ndate"]); $ndate = Format::date($row["ndate"]); //$datearr[2]."-".$datearr[1]."-".$datearr[0]; } if ($mode == "new") { $ndate = Format::date(date("Y-m-d H:i:s")); } $out->add("<td><input type=\"text\" size=\"10\" id=\"ndate\" name=\"ndate\" value=\"" . $ndate . "\" /></td>\n"); $out->add("<td><input type=\"text\" size=\"26\" id=\"ntitle\" name=\"ntitle\" value=\"" . (isset($row["ntitle"]) ? $row["ntitle"] : '') . "\" />\n"); $out->add("</td></tr><tr><td colspan=\"2\"><textarea rows=\"6\" cols=\"30\" id=\"ntxt\" name=\"ntxt\">\n"); $out->add(isset($row["ntxt"]) ? $row["ntxt"] : ''); $out->add("</textarea><br />\n"); $out->add("</td></tr></table>\n"); } if ($mode == "edit") { $label = $lang->def("_SAVE"); } if ($mode == "new") { $label = $lang->def("_SAVE"); } $out->add("<input type=\"hidden\" id=\"applychanges\" name=\"applychanges\" value=\"1\" />\n"); $out->add("<input class=\"button\" type=\"submit\" value=\"" . $label . "\" />\n"); $out->add("</form>\n"); // $out->add("<div align=\"center\"><b>[ <a href=\"index.php?modname=project&op=showprj&id=$id\">".$lang->def("_BACK")."</a> ]</b></div>\n"); $url = "index.php?modname=project&op=showprj&id=" . $id; $out->add(getBackUi($url, $lang->def('_BACK'))); $out->add('<br /></div>'); } else { die("You can't access"); } }
function modifyItem($arrData, $idCourse = FALSE, $strips = false) { $folder = $this->getFolderById($arrData['idItem']); require_once _base_ . '/lib/lib.tab.php'; $tv = new TabView('organization_properties', '#'); $tv->addTab(new TabElemDefault('prereqisites', '', getPathImage() . 'standard/property.png')); $tv->addTab(new TabElemDefault('settings', '', getPathImage() . 'standard/property.png')); //$tv->addTab( new TabElemDefault( 'catalogation', '', getPathImage().'standard/edit.png' ) ); $tv->parseInput($_POST, $_POST); $prerequisite = ''; if ($tv->getActiveTab() === 'prereqisites') { if (isset($arrData['organization']['REPO_OP_SELECTITEM'])) { $prerequisite = implode(',', $arrData['organization']['REPO_OP_SELECTITEM']); } } else { $prerequisite = $arrData['prerequisites']; } // unmodifiable values $this->org_objectType = $folder->otherValues[REPOFIELDOBJECTTYPE]; $this->org_idResource = $folder->otherValues[REPOFIELDIDRESOURCE]; $this->org_idUser = $folder->otherValues[REPOFIELDIDUSER]; $this->org_idAuthor = $folder->otherValues[REPOFIELDIDAUTHOR]; $this->org_dateInsert = $folder->otherValues[REPOFIELDDATEINSERT]; $this->org_title = isset($arrData['title']) ? $this->_strip($arrData['title'], $strips) : stripslashes($folder->otherValues[REPOFIELDTITLE]); $this->org_idCategory = isset($arrData['idCategory']) ? $arrData['idCategory'] : $folder->otherValues[REPOFIELDIDCATEGORY]; $this->org_version = isset($arrData['version']) ? $arrData['version'] : $folder->otherValues[REPOFIELDVERSION]; $this->org_difficult = isset($arrData['difficult']) ? $arrData['difficult'] : $folder->otherValues[REPOFIELDDIFFICULT]; $this->org_description = isset($arrData['description']) ? $this->_strip($arrData['description'], $strips) : $folder->otherValues[REPOFIELDDESCRIPTION]; $this->org_language = isset($arrData['language']) ? $this->_strip($arrData['language'], $strips) : $folder->otherValues[REPOFIELDLANGUAGE]; $this->org_resource = isset($arrData['resource']) ? $this->_strip($arrData['resource'], $strips) : $folder->otherValues[REPOFIELDRESOURCE]; $this->org_objective = isset($arrData['objective']) ? $this->_strip($arrData['objective'], $strips) : $folder->otherValues[REPOFIELDOBJECTIVE]; if (isset($arrData['prerequisites'])) { $this->org_prerequisites = $this->makePrerequisites($arrData['idItem'], $prerequisite, $arrData['selfPrerequisites']); } else { $this->org_prerequisites = $folder->otherValues[ORGFIELDPREREQUISITES]; } $this->org_isTerminator = isset($arrData['isTerminator']) ? $arrData['isTerminator'] : $folder->otherValues[ORGFIELDISTERMINATOR]; $this->org_idParam = $folder->otherValues[ORGFIELDIDPARAM]; $this->org_visible = isset($arrData['visibility']) ? $arrData['visibility'] : $folder->otherValues[ORGFIELDVISIBLE]; if ($idCourse === FALSE) { $this->org_idCourse = $this->idCourse; } else { $this->org_idCourse = $idCourse; } if (isset($arrData['milestone'])) { $this->org_milestone = $arrData['milestone']; /* reset milestone */ if ($this->org_milestone != '-' && $this->org_milestone != $folder->otherValues[ORGFIELDMILESTONE]) { $this->_resetMilestone($this->org_milestone, $this->org_idCourse); } } else { $this->org_milestone = $folder->otherValues[ORGFIELDMILESTONE]; } $this->org_width = isset($arrData['obj_width']) ? $arrData['obj_width'] : $folder->otherValues[ORGFIELD_WIDTH]; $this->org_height = isset($arrData['obj_height']) ? $arrData['obj_height'] : $folder->otherValues[ORGFIELD_HEIGHT]; $arrData['publish_from'] = Format::dateDb($arrData['publish_from'], 'date'); $arrData['publish_to'] = Format::dateDb($arrData['publish_to'], 'date'); if ($arrData['publish_from'] > $arrData['publish_to'] && $arrData['publish_to'] != "") { $temp = $arrData['publish_from']; $arrData['publish_from'] = $arrData['publish_to']; $arrData['publish_to'] = $temp; } $this->org_publish_from = isset($arrData['publish_from']) ? $arrData['publish_from'] : $folder->otherValues[ORGFIELD_PUBLISHFROM]; $this->org_publish_to = isset($arrData['publish_to']) ? $arrData['publish_to'] : $folder->otherValues[ORGFIELD_PUBLISHTO]; $this->org_access = $folder->otherValues[ORGFIELD_ACCESS]; $this->org_publish_for = isset($arrData['publish_for']) ? $arrData['publish_for'] : $folder->otherValues[ORGFIELD_PUBLISHFOR]; $this->changeOtherData($folder); if (isset($arrData['accessGroups'])) { if ($arrData['accessGroups'] == '') { $arrGroups = array(); } else { $arrGroups = unserialize(urldecode($arrData['accessGroups'])); } if ($arrData['accessUsers'] == '') { $arrUsers = array(); } else { $arrUsers = unserialize(urldecode($arrData['accessUsers'])); } $this->setAccess($arrData['idItem'], $arrGroups, $arrUsers); } if ($this->org_objectType != '' && isset($arrData['customParam'])) { // ---- custom LO parameters $lo = createLO($this->org_objectType, $this->org_idResource, $this->org_idParam, array()); $arrParamsInfo = $lo->getParamInfo(); if ($arrParamsInfo !== FALSE) { require_once $GLOBALS['where_lms'] . '/lib/lib.param.php'; while ($param = current($arrParamsInfo)) { if (isset($arrData[$param['param_name']])) { setLOParam($this->org_idParam, $param['param_name'], $arrData[$param['param_name']]); } next($arrParamsInfo); } } } }
public function upCourse() { require_once _base_ . '/lib/lib.upload.php'; require_once _base_ . '/lib/lib.multimedia.php'; require_once _lms_ . '/lib/lib.course.php'; require_once _lms_ . '/lib/lib.manmenu.php'; $array_lang = Docebo::langManager()->getAllLangCode(); $array_lang[] = 'none'; $acl_man =& Docebo::user()->getAclManager(); $id_course = Get::req('id_course', DOTY_INT, 0); require_once _lms_ . '/admin/models/LabelAlms.php'; $label_model = new LabelAlms(); $label = Get::req('label', DOTY_INT, 0); $label_model->associateLabelToCourse($label, $id_course); // calc quota limit $quota = $_POST['course_quota']; if (isset($_POST['inherit_quota'])) { $quota = Get::sett('course_quota'); $_POST['course_quota'] = COURSE_QUOTA_INHERIT; } $quota = $quota * 1024 * 1024; $course_man = new DoceboCourse($id_course); $used = $course_man->getUsedSpace(); if ($_POST['course_name'] == '') { $_POST['course_name'] = Lang::t('_NO_NAME', 'course', 'lms'); } // restriction on course status ------------------------------------------ $user_status = 0; if (isset($_POST['user_status'])) { while (list($status) = each($_POST['user_status'])) { $user_status |= 1 << $status; } } // level that will be showed in the course -------------------------------- $show_level = 0; if (isset($_POST['course_show_level'])) { while (list($lv) = each($_POST['course_show_level'])) { $show_level |= 1 << $lv; } } // save the file uploaded ------------------------------------------------- $error = false; $quota_exceeded = false; $path = Get::sett('pathcourse'); $path = '/appLms/' . Get::sett('pathcourse') . (substr($path, -1) != '/' && substr($path, -1) != '\\' ? '/' : ''); $old_file_size = 0; if (is_array($_FILES) && !empty($_FILES) || is_array($_POST["file_to_del"])) { sl_open_fileoperations(); } // load user material --------------------------------------------------------------------------- $arr_file = $this->manageCourseFile('course_user_material', $_POST["old_course_user_material"], $path, $quota != 0 ? $quota - $used : false, isset($_POST['file_to_del']['course_user_material'])); $error |= $arr_file['error']; $quota_exceeded |= $arr_file['quota_exceeded']; $file_material = $arr_file['filename']; $used = $used + ($arr_file['new_size'] - $arr_file['old_size']); $old_file_size += $arr_file['old_size']; // course otheruser material ------------------------------------------------------------------- $arr_file = $this->manageCourseFile('course_otheruser_material', $_POST["old_course_otheruser_material"], $path, $quota != 0 ? $quota - $used : false, isset($_POST['file_to_del']['course_otheruser_material'])); $error |= $arr_file['error']; $quota_exceeded |= $arr_file['quota_exceeded']; $file_othermaterial = $arr_file['filename']; $used = $used + ($arr_file['new_size'] - $arr_file['old_size']); $old_file_size += $arr_file['old_size']; // course demo----------------------------------------------------------------------------------- $arr_file = $this->manageCourseFile('course_demo', $_POST["old_course_demo"], $path, $quota != 0 ? $quota - $used : false, isset($_POST['file_to_del']['course_demo'])); $error |= $arr_file['error']; $quota_exceeded |= $arr_file['quota_exceeded']; $file_demo = $arr_file['filename']; $used = $used + ($arr_file['new_size'] - $arr_file['old_size']); $old_file_size += $arr_file['old_size']; // course sponsor--------------------------------------------------------------------------------- $arr_file = $this->manageCourseFile('course_sponsor_logo', $_POST["old_course_sponsor_logo"], $path, $quota != 0 ? $quota - $used : false, isset($_POST['file_to_del']['course_sponsor_logo']), true); $error |= $arr_file['error']; $quota_exceeded |= $arr_file['quota_exceeded']; $file_sponsor = $arr_file['filename']; $used = $used + ($arr_file['new_size'] - $arr_file['old_size']); $old_file_size += $arr_file['old_size']; // course logo----------------------------------------------------------------------------------- $arr_file = $this->manageCourseFile('course_logo', $_POST["old_course_logo"], $path, $quota != 0 ? $quota - $used : false, isset($_POST['file_to_del']['course_logo']), true); $error |= $arr_file['error']; $quota_exceeded |= $arr_file['quota_exceeded']; $file_logo = $arr_file['filename']; $used = $used + ($arr_file['new_size'] - $arr_file['old_size']); $old_file_size += $arr_file['old_size']; // ---------------------------------------------------------------------------------------------- sl_close_fileoperations(); $date_begin = Format::dateDb($_POST['course_date_begin'], "date"); $date_end = Format::dateDb($_POST['course_date_end'], "date"); if ($_POST["can_subscribe"] == "2") { $sub_start_date = Format::dateDb($_POST["sub_start_date"], "date"); $sub_end_date = Format::dateDb($_POST["sub_end_date"], "date"); } $hour_begin = '-1'; $hour_end = '-1'; if ($_POST['hour_begin']['hour'] != '-1') { $hour_begin = strlen($_POST['hour_begin']['hour']) == 1 ? '0' . $_POST['hour_begin']['hour'] : $_POST['hour_begin']['hour']; if ($_POST['hour_begin']['quarter'] == '-1') { $hour_begin .= ':00'; } else { $hour_begin .= ':' . $_POST['hour_begin']['quarter']; } } if ($_POST['hour_end']['hour'] != '-1') { $hour_end = strlen($_POST['hour_end']['hour']) == 1 ? '0' . $_POST['hour_end']['hour'] : $_POST['hour_end']['hour']; if ($_POST['hour_end']['quarter'] == '-1') { $hour_end .= ':00'; } else { $hour_end .= ':' . $_POST['hour_end']['quarter']; } } // update database ---------------------------------------------------- $query_course = "\n\t\tUPDATE " . $GLOBALS['prefix_lms'] . "_course\n\t\tSET code \t\t\t\t= '" . $_POST['course_code'] . "',\n\t\t\tname \t\t\t\t= '" . $_POST['course_name'] . "',\n\t\t\tidCategory \t\t\t= '" . (int) $_POST['idCategory'] . "',\n\t\t\tdescription \t\t= '" . $_POST['course_descr'] . "',\n\t\t\tlang_code \t\t\t= '" . $array_lang[$_POST['course_lang']] . "',\n\t\t\tstatus \t\t\t\t= '" . (int) $_POST['course_status'] . "',\n\t\t\tlevel_show_user \t= '" . $show_level . "',\n\t\t\tsubscribe_method \t= '" . (int) $_POST['course_subs'] . "',\n\t\t\tidCategory\t\t\t= '" . (int) $_POST['idCategory'] . "',\n\t\t\tcredits\t\t\t\t= '" . (int) $_POST['credits'] . "',\n\n\t\t\tlinkSponsor \t\t= '" . $_POST['course_sponsor_link'] . "',\n\n\t\t\timgSponsor \t\t\t= '" . $file_sponsor . "',\n\t\t\timg_course \t\t\t= '" . $file_logo . "',\n\t\t\timg_material \t\t= '" . $file_material . "',\n\t\t\timg_othermaterial \t= '" . $file_othermaterial . "',\n\t\t\tcourse_demo \t\t= '" . $file_demo . "',\n\n\t\t\tmediumTime \t\t\t= '" . $_POST['course_medium_time'] . "',\n\t\t\tpermCloseLO \t\t= '" . $_POST['course_em'] . "',\n\t\t\tuserStatusOp \t\t= '" . $user_status . "',\n\t\t\tdifficult \t\t\t= '" . $_POST['course_difficult'] . "',\n\n\t\t\tshow_progress \t\t= '" . (isset($_POST['course_progress']) ? 1 : 0) . "',\n\t\t\tshow_time \t\t\t= '" . (isset($_POST['course_time']) ? 1 : 0) . "',\n\n\t\t\tshow_who_online\t\t= '" . $_POST['show_who_online'] . "',\n\n\t\t\tshow_extra_info \t= '" . (isset($_POST['course_advanced']) ? 1 : 0) . "',\n\t\t\tshow_rules \t\t\t= '" . (int) $_POST['course_show_rules'] . "',\n\n\t\t\tdirect_play \t\t= '" . (isset($_POST['direct_play']) ? 1 : 0) . "',\n\n\t\t\tdate_begin \t\t\t= '" . $date_begin . "',\n\t\t\tdate_end \t\t\t= '" . $date_end . "',\n\t\t\thour_begin \t\t\t= '" . $hour_begin . "',\n\t\t\thour_end \t\t\t= '" . $hour_end . "',\n\n\t\t\tvalid_time \t\t\t= '" . (int) $_POST['course_day_of'] . "',\n\n\t\t\tmin_num_subscribe \t= '" . (int) $_POST['min_num_subscribe'] . "',\n\t\t\tmax_num_subscribe \t= '" . (int) $_POST['max_num_subscribe'] . "',\n\n\t\t\tcourse_type \t\t= '" . $_POST['course_type'] . "',\n\t\t\tpoint_to_all \t\t= '" . (isset($_POST['point_to_all']) ? $_POST['point_to_all'] : 0) . "',\n\t\t\tcourse_edition \t\t= '" . (isset($_POST['course_edition']) ? $_POST['course_edition'] : 0) . "',\n\t\t\tselling \t\t\t= '" . (isset($_POST['course_sell']) ? 1 : 0) . "',\n\t\t\tprize \t\t\t\t= '" . (isset($_POST['course_prize']) ? $_POST['course_prize'] : 0) . "',\n\t\t\tpolicy_point \t\t= '" . $_POST['policy_point'] . "',\n\n\t\t\tcourse_quota \t\t= '" . $_POST['course_quota'] . "',\n\n\t\t\tallow_overbooking \t= '" . (isset($_POST["allow_overbooking"]) ? 1 : 0) . "',\n\t\t\tcan_subscribe \t\t= '" . (int) $_POST["can_subscribe"] . "',\n\t\t\tsub_start_date \t\t= " . ($_POST["can_subscribe"] == "2" ? "'" . $sub_start_date . "'" : 'NULL') . ",\n\t\t\tsub_end_date \t\t= " . ($_POST["can_subscribe"] == "2" ? "'" . $sub_end_date . "'" : 'NULL') . ",\n\n\t\t\tadvance \t\t\t= '" . $_POST['advance'] . "',\n\t\t\tshow_result \t\t= '" . (isset($_POST['show_result']) ? 1 : 0) . "',\n\n\n\t\t\tuse_logo_in_courselist = '" . (isset($_POST['use_logo_in_courselist']) ? '1' : '0') . "',\n\n\t\t\tauto_unsubscribe = '" . (int) $_POST['auto_unsubscribe'] . "',\n\t\t\tunsubscribe_date_limit = " . (isset($_POST['use_unsubscribe_date_limit']) && $_POST['use_unsubscribe_date_limit'] > 0 ? "'" . Format::dateDb($_POST['unsubscribe_date_limit'], 'date') . "'" : 'NULL') . ""; if (isset($_POST['random_course_autoregistration_code'])) { $control = 1; $str = ''; while ($control) { for ($i = 0; $i < 10; $i++) { $seed = mt_rand(0, 10); if ($seed > 5) { $str .= mt_rand(0, 9); } else { $str .= chr(mt_rand(65, 90)); } } $control_query = "SELECT COUNT(*)" . " " . $GLOBALS['prefix_lms'] . "_course" . " WHERE autoregistration_code = '" . $str . "'" . " AND idCourse <> '" . $id_course . "'"; $control_result = sql_query($control_query); list($result) = sql_fetch_row($control_result); $control = $result; } $query_course .= ", autoregistration_code = '" . $str . "'"; } else { $query_course .= ", autoregistration_code = '" . $_POST['course_autoregistration_code'] . "'"; } $query_course .= " WHERE idCourse = '" . $id_course . "'"; if (!sql_query($query_course)) { if ($file_sponsor != '') { sl_unlink($path . $file_sponsor); } if ($file_logo != '') { sl_unlink($path . $file_logo); } if ($file_material != '') { sl_unlink($path . $file_material); } if ($file_othermaterial != '') { sl_unlink($path . $file_othermaterial); } if ($file_demo != '') { sl_unlink($path . $file_demo); } $course_man->subFileToUsedSpace(false, $old_file_size); return array('err' => '_err_course'); } // cascade modify on all the edition of the course if (isset($_POST['cascade_on_ed']) && $id_course > 0) { $cinfo = $this->getInfo($id_course); $has_editions = $cinfo['course_edition'] > 0; $has_classrooms = $cinfo['course_type'] == 'classroom'; if ($has_editions) { $query_editon = "UPDATE %lms_course_editions " . " SET code = '" . $_POST['course_code'] . "', " . " name = '" . $_POST['course_name'] . "', " . " description = '" . $_POST['course_descr'] . "' " . " WHERE id_course = '" . $id_course . "' "; sql_query($query_editon); } if ($has_classrooms) { $query_editon = "UPDATE %lms_course_date " . " SET code = '" . $_POST['course_code'] . "', " . " name = '" . $_POST['course_name'] . "', " . " description = '" . $_POST['course_descr'] . "' " . " WHERE id_course = '" . $id_course . "' "; sql_query($query_editon); } } $res = array(); if ($quota_exceeded) { $res['limit_reach'] = 1; } //AUTO SUBSCRIPTION $userId = Docebo::user()->getIdSt(); $userSubscribed = $this->isUserSubscribedInCourse($userId, $id_course); if (intval($userSubscribed[0]) <= 0) { if (isset($_POST['auto_subscription']) && $_POST['auto_subscription'] == 1) { if (!$this->autoUserRegister($userId, $id_course)) { die('Error during autosubscription'); } } } $res['res'] = '_ok_course'; return $res; }
function get_games_filter() { $back_url = $this->back_url; $jump_url = $this->jump_url; $next_url = $this->next_url; //preliminary checks if (isset($_POST['undo_filter'])) { Util::jump_to($back_url); } if (!isset($_SESSION['report_tempdata']['columns_filter'])) { $_SESSION['report_tempdata']['columns_filter'] = array('comp_selection' => array(), 'all_games' => false, 'comp_start_date' => '', 'comp_end_date' => ''); } $ref =& $_SESSION['report_tempdata']['columns_filter']; if (isset($_POST['update_tempdata'])) { $ref['all_games'] = Get::req('all_games', DOTY_INT, 0) > 0; $ref['comp_selection'] = Get::req('comp_selection', DOTY_MIXED, array()); $ref['comp_start_date'] = Format::dateDb(Get::req('comp_start_date', DOTY_STRING, ''), 'date'); $ref['comp_end_date'] = Format::datedb(Get::req('comp_end_date', DOTY_STRING, ''), 'date'); } else { //... } //filter setting done, go to next step if (isset($_POST['import_filter']) || isset($_POST['show_filter']) || isset($_POST['pre_filter'])) { $temp_url = $next_url; if (isset($_POST['pre_filter'])) { $temp_url .= '&show=1&nosave=1'; } if (isset($_POST['show_filter'])) { $temp_url .= '&show=1'; } Util::jump_to($temp_url); } //draw filter boxes $html = ''; //time period $box = new ReportBox('comm_selector'); $box->title = Lang::t('_TIME_PERIOD_FILTER', 'report'); $box->description = false; $box->body .= Form::getDatefield(Lang::t('_FROM', 'standard'), 'comp_start_date', 'comp_start_date', $ref['comp_start_date']); $box->body .= Form::getDatefield(Lang::t('_TO', 'standard'), 'comp_end_date', 'comp_end_date', $ref['comp_end_date']); $html .= $box->get(); //draw games selector $box = new ReportBox('comp_selector'); $box->title = Lang::t('_CONTEST'); $box->description = false; require_once _lms_ . '/lib/lib.report.php'; //the comm. table function $box->body .= Form::getCheckbox(Lang::t('_ALL', 'report'), 'all_games', 'all_games', 1, $ref['all_games']); $box->body .= '<br />'; $box->body .= getGamesTable($ref['comp_selection']); $box->body .= Form::getHidden('update_tempdata', 'update_tempdata', 1); $html .= $box->get(); cout($html); }
protected function update() { if (!$this->permissions['mod']) { $this->render('invalid', array('message' => $this->_getMessage('no permission'), 'back_url' => 'index.php?r=alms/games/show')); return; } $data = array(); $data['id_game'] = Get::req('id_game', DOTY_MIXED, ''); $data['title'] = Get::req('title', DOTY_MIXED, ''); $data['start_date'] = Get::req('start_date', DOTY_MIXED, Format::date(date('Y-m-d'), 'date')); $data['end_date'] = Get::req('end_date', DOTY_MIXED, Format::date(date('Y-m-d'), 'date')); $data['play_chance'] = Get::req('play_chance', DOTY_STRING, ''); $data['description'] = Get::req('description', DOTY_MIXED, ''); $data['type_of'] = Get::req('type_of', DOTY_STRING, ''); $data['start_date'] = Format::dateDb($data['start_date'], 'date'); $data['end_date'] = Format::dateDb($data['end_date'], 'date'); $id_game = $this->model->save($data); if (!$id_game) { UIFeedback::error(Lang::t('_OPERATION_FAILURE', 'games')); $this->add($data); } elseif ($data['type_of'] != 'none') { Util::jump_to('index.php?r=alms/games/mod_obj&id_game=' . $id_game); } else { Util::jump_to('index.php?r=alms/games/show&success=1'); } }
function getOldRoomNumber($id_course) { $query = "SELECT COUNT(*)" . " FROM " . $this->_getRoomTable() . "" . " WHERE idCourse = '" . $id_course . "'" . " AND endtime < '" . time() . "'"; $date = Get::req('filter_date', DOTY_MIXED, ''); if ($date !== '') { $date = substr(Format::dateDb($date, 'date'), 0, 10); $query .= " AND starttime >= '" . fromDatetimeToTimestamp($date) . "'" . " AND starttime <= '" . fromDatetimeToTimestamp($date . ' 23:59:59') . "'"; } list($result) = sql_fetch_row(sql_query($query)); return $result; }
public function getCourseDate($id_course, $all = true, $ini = 0, $num_element = 0) { $res = array(); if (empty($id_course) || $id_course <= 0) { return $res; } if (is_numeric($id_course)) { $id_course = array((int) $id_course); } if (!is_array($id_course)) { return false; } $query = "SELECT dt.*, MIN(dy.date_begin) AS date_begin, MAX(dy.date_end) AS date_end, COUNT(dy.id_day) as num_day, COUNT(DISTINCT du.id_user) as user_subscribed" . " FROM " . $this->date_table . " as dt" . " JOIN " . $this->day_date_table . " as dy ON dy.id_date = dt.id_date" . " LEFT JOIN " . $this->user_date_table . " as du ON du.id_date = dt.id_date" . " WHERE dt.id_course IN (" . implode(",", $id_course) . ") " . " GROUP BY dt.id_date" . " ORDER BY dy.date_begin" . ($num_element > 0 ? " LIMIT " . $ini . "," . $num_element : ''); $result = sql_query($query); while ($row = mysql_fetch_assoc($result)) { if (strcmp($row['date_begin'], date('Y-m-d H:i:s')) > 0 || $all) { $row['classroom'] = $this->getDateClassrooms($row['id_date']); if ($row['user_subscribed'] > 1) { $row['num_day'] = $row['num_day'] / $row['user_subscribed']; } if (isset($_SESSION['date_begin_filter']) && $_SESSION['date_begin_filter'] !== '' && isset($_SESSION['date_end_filter']) && $_SESSION['date_end_filter'] !== '') { if (strcmp(Format::dateDb($_SESSION['date_begin_filter']), $row['date_begin']) <= 0 && strcmp(Format::dateDb($_SESSION['date_end_filter']), $row['date_end']) >= 0) { $res[$row['id_date']] = $row; } } elseif (isset($_SESSION['date_begin_filter']) && $_SESSION['date_begin_filter'] !== '') { if (strcmp(Format::dateDb($_SESSION['date_begin_filter']), $row['date_begin']) <= 0) { $res[$row['id_date']] = $row; } } elseif (isset($_SESSION['date_end_filter']) && $_SESSION['date_end_filter'] !== '') { if (strcmp(Format::dateDb($_SESSION['date_end_filter']), $row['date_end']) >= 0) { $res[$row['id_date']] = $row; } } else { $res[$row['id_date']] = $row; } } } return $res; }
public function modEdition($id_edition, $code, $name, $description, $status, $max_par, $min_par, $price, $date_begin, $date_end, $overbooking, $can_subscribe, $sub_date_begin, $sub_date_end) { $date_begin !== '' ? $date_begin = Format::dateDb($date_begin, 'date') : ''; $date_end !== '' ? $date_end = Format::dateDb($date_end, 'date') : ''; $sub_date_begin !== '' ? $sub_date_begin = Format::dateDb($sub_date_begin, 'date') : ''; $sub_date_end !== '' ? $sub_date_end = Format::dateDb($sub_date_end, 'date') : ''; $query = "UPDATE " . $this->edition_table . " SET code = '" . $code . "'," . " name = '" . $name . "'," . " description = '" . $description . "'," . " status = '" . $status . "'," . " max_num_subscribe = '" . $max_par . "'," . " min_num_subscribe = '" . $min_par . "'," . " price = '" . $price . "'," . " date_begin = '" . $date_begin . "'," . " date_end = '" . $date_end . "'," . " overbooking = '" . $overbooking . "'," . " can_subscribe = '" . $can_subscribe . "'," . " sub_date_begin = '" . $sub_date_begin . "'," . " sub_date_end = '" . $sub_date_end . "'" . " WHERE id_edition = " . (int) $id_edition; return sql_query($query); }
function saveReportScore($id_report, $users_scores, $date_attempts, $comments) { $old_scores =& $this->getReportsScores(array($id_report)); $re = true; while (list($idst_user, $score) = each($users_scores)) { if (!isset($old_scores[$id_report][$idst_user])) { $query_scores = "\r\n\t\t\t\tINSERT INTO " . $GLOBALS['prefix_lms'] . "_coursereport_score\r\n\t\t\t\t( id_report, id_user, date_attempt, score, score_status, comment ) VALUES ( \r\n\t\t\t\t\t'" . $id_report . "', \r\n\t\t\t\t\t'" . $idst_user . "', \r\n\t\t\t\t\t'" . Format::dateDb($date_attempts[$idst_user], 'date') . "', \r\n\t\t\t\t\t'" . $score . "', \r\n\t\t\t\t\t'valid',\r\n\t\t\t\t\t'" . $comments[$idst_user] . "' )"; } else { $query_scores = "\r\n\t\t\t\tUPDATE " . $GLOBALS['prefix_lms'] . "_coursereport_score\r\n\t\t\t\tSET date_attempt = '" . Format::dateDb($date_attempts[$idst_user], 'date') . "', \r\n\t\t\t\t\tscore = '" . $score . "', \r\n\t\t\t\t\tscore_status = 'valid',\r\n\t\t\t\t\tcomment = '" . $comments[$idst_user] . "'\r\n\t\t\t\t\t" . ($old_scores[$id_report][$idst_user] != $score ? ", score_status = 'valid'" : '') . " \r\n\t\t\t\tWHERE id_report = '" . $id_report . "' AND id_user = '******'"; } $re &= sql_query($query_scores); } return $re; }