/** * Deletes users from waiting list * * @param object/objectArray $users_info * @param object $course_info * @return bool */ function removeFromWaitingList($users_info, $course_info) { $user_ids = array(); if (is_array($users_info)) { foreach ($users_info as $user_info) { $user_ids[] = $user_info->user_id; } } else { $user_ids = array($users_info->user_id); } $dbo =& JFactory::GetDbo(); //delete user from waiting list $query = "DELETE FROM #__lms_waiting_lists WHERE course_id={$course_info->course_id} AND user_id IN (" . implode(',', $user_ids) . ")"; $dbo->setQuery($query); $dbo->query(); return true; }
function botAssociateCEO($users_info) { $_JLMS_PLUGINS =& JLMSFactory::getPlugins(); $dbo =& JFactory::GetDbo(); //---->get bot info if (!isset($_JLMS_PLUGINS->_user_bot_params['ceoassoc'])) { // load mambot params info $query = "SELECT params" . "\n FROM #__lms_plugins" . "\n WHERE element = 'ceoassoc'" . "\n AND folder = 'user'"; $dbo->setQuery($query); $bot = $dbo->loadObject(); // save query to class variable $_JLMS_PLUGINS->_user_bot_params['ceoassoc'] = $bot; } // pull query data from class variable $bot = $_JLMS_PLUGINS->_user_bot_params['ceoassoc']; $botParams = new jlmsPluginParameters($bot->params); $botParams->def('ceo_user_id', 0); //<---- if ($parent_id = $botParams->get('ceo_user_id', 0)) { if (is_array($users_info)) { foreach ($users_info as $user_info) { //---->check if user already associated to CEO and add associate if not $query = "SELECT COUNT(*) FROM #__lms_user_parents WHERE parent_id = {$parent_id} AND user_id = {$user_info->user_id}"; $dbo->setQuery($query); if (!$dbo->loadResult()) { $query = "INSERT INTO #__lms_user_parents (`parent_id`, `user_id`) VALUES ({$parent_id}, {$user_info->user_id})"; $dbo->setQuery($query); $dbo->query(); } //<---- } } else { $user_info = $users_info; //---->check if user already associated to CEO and add associate if not $query = "SELECT COUNT(*) FROM #__lms_user_parents WHERE parent_id = {$parent_id} AND user_id = {$user_info->user_id}"; $dbo->setQuery($query); if (!$dbo->loadResult()) { $query = "INSERT INTO #__lms_user_parents (`parent_id`, `user_id`) VALUES ({$parent_id}, {$user_info->user_id})"; $dbo->setQuery($query); $dbo->query(); } //<---- } } return; }
function notifyCourseJoined($users_info) { $_JLMS_PLUGINS =& JLMSFactory::getPlugins(); $JLMS_CONFIG =& JLMSFactory::getConfig(); //---->get bot info $dbo =& JFactory::GetDbo(); if (!isset($_JLMS_PLUGINS->_nontify_bot_params['coursejoinnotify'])) { // load mambot params info $query = "SELECT params" . "\n FROM #__lms_plugins" . "\n WHERE element = 'coursejoinnotify'" . "\n AND folder = 'notifications'"; $dbo->setQuery($query); $bot = $dbo->loadObject(); // save query to class variable $_JLMS_PLUGINS->_notify_bot_params['coursejoinnotify'] = $bot; } // pull query data from class variable $bot = $_JLMS_PLUGINS->_notify_bot_params['coursejoinnotify']; $botParams = new jlmsPluginParameters($bot->params); $botParams->def('mail_template', 'Hello {user_name}, You have just been added to the course {course_name} attendees list.'); $botParams->def('mail_subject', 'Course joining notification'); //<---- foreach ($users_info as $info_ids) { $query = "SELECT c.course_name AS course_name, u.name AS user_name, u.email AS mail_address FROM #__lms_courses AS c, #__users AS u" . "\n WHERE c.id={$info_ids->course_id} AND u.id={$info_ids->user_id}"; $dbo->setQuery($query); $info_text = $dbo->loadObject(); $mail_address = $dbo->getEscaped($info_text->mail_address); $mail_subject = $dbo->getEscaped($botParams->get('mail_subject')); $mail_text = $botParams->get('mail_template'); $mail_text = str_replace('{user_name}', $info_text->user_name, $mail_text); $mail_text = str_replace('{course_name}', $info_text->course_name, $mail_text); $mail_text = str_replace('{site_URL}', $JLMS_CONFIG->get('live_site'), $mail_text); $mail_text = $dbo->getEscaped($mail_text); $query = "INSERT INTO #__lms_notifications (assigned, mail_address, mail_subject, mail_body, sent) VALUES" . "\n ({$info_ids->teacher_id}, '{$mail_address}', '{$mail_subject}', '{$mail_text}', 0)"; $dbo->setQuery($query); $dbo->query(); } }
private function _replaceRequest($msg) { $db = JFactory::GetDbo(); $request = JRequest::get('request'); foreach ($request as $key => $val) { if (is_string($val)) { // $$$ hugh - escape the key so preg_replace won't puke if key contains / $key = str_replace('/', '\\/', $key); $msg = preg_replace("/\\{{$key}\\}/", $db->Quote(urldecode($val)), $msg); } } return $msg; }
function editCourse(&$row, &$lists, $option, $params = '', $levels = array()) { global $JLMS_CONFIG; JHTML::_('behavior.tooltip'); mosCommonHTML::loadCalendar(); $db =& JFactory::GetDbo(); if ($JLMS_CONFIG->get('multicat_use', 0)) { $multicat = array(); $i = 0; foreach ($lists as $key => $item) { if (substr($key, 0, 6) == 'level_') { $multicat[] = $lists['level_' . $i]; $i++; } } } ?> <script language="javascript" type="text/javascript"> <!-- function submitbutton(pressbutton) { var form = document.adminForm; if (pressbutton == 'cancel_course') { submitform( pressbutton ); return; } if (pressbutton == 'save_course' || pressbutton == 'apply_course' ) { submitform( pressbutton ); return; } } <?php if (JLMS_J16version()) { ?> Joomla.submitbutton = submitbutton; <?php } ?> <?php if ($JLMS_CONFIG->get('multicat_use', 0)) { ?> var old_filters = new Array(); function read_filter(){ var form = document.adminForm; var count_levels = '<?php echo count($levels); ?> '; for(var i=0;i<parseInt(count_levels);i++){ if(form['level_id_'+i] != null){ old_filters[i] = form['level_id_'+i].value; } } } function write_filter(){ var form = document.adminForm; var count_levels = '<?php echo count($levels); ?> '; var j; for(var i=0;i<parseInt(count_levels);i++){ if(form['level_id_'+i+''] != null && form['level_id_'+i+''].value != old_filters[i]){ j = i; } if(i > j){ if(form['level_id_'+i] != null){ form['level_id_'+i].value = 0; } } } } <?php } ?> //--> </script> <form action="index.php" method="post" name="adminForm"> <table width="100%" > <tr> <td valign="top" width="220"> <div> <?php echo joomla_lms_adm_html::JLMS_menu(); ?> </div> </td> <td valign="top"> <div class="width-100"> <fieldset class="adminform"> <?php if (!class_exists('JToolBarHelper')) { ?> <table class="adminheading"> <tr> <th class="user"> <?php echo _JOOMLMS_COMP_NAME; ?> : <small> <?php echo $row->id ? _JLMS_CRSS_EDIT_COURSE : _JLMS_CRSS_NEW_COURSE; ?> </small> </th> </tr> </table> <?php } ?> <table width="100%" border="0"> <tr> <td valign="top"> <table width="100%" > <tr> <th colspan="2"><?php echo _JLMS_CRSS_COURSE_DETAILS; ?> </th> <tr> <tr> <td align="right" width="20%"><?php echo _JLMS_PRICE; ?> :</td> <td><input class="text_area" type="text" name="course_price" size="8" maxlength="100" value="<?php echo $row->course_price; ?> " /></td> </tr> <?php if ($JLMS_CONFIG->get('multicat_use', 0)) { for ($i = 0; $i < count($multicat); $i++) { ?> <tr> <td align="right" width="20%"> <?php echo isset($levels[$i]->cat_name) && $levels[$i]->cat_name != '' ? $levels[$i]->cat_name : _JLMS_CRSS_COURSE_CATS; ?> </td> <td> <?php echo $multicat[$i]; ?> </td> </tr> <?php } } else { ?> <tr> <td align="right" width="20%"><?php echo _JLMS_SELECT_CATEGORY; ?> :</td> <td><?php echo $lists['cat_id']; ?> </td> </tr> <?php } $query = "SELECT lms_config_value FROM #__lms_config WHERE lms_config_var='sec_cat_use'"; $db->setQuery($query); if ($db->loadResult()) { ?> <tr> <td align="left" valign="middle" style="vertical-aligh:middle "><?php echo _JLMS_CRSS_SECOND_CATS; ?> :</td> <td><?php echo $lists['sec_cat_id']; ?> </td> </tr> <?php } ?> <tr> <td align="left" valign="middle" style="vertical-align:middle "><?php echo _JLMS_CRSS_CRS_NAME; ?> :</td> <td><input class="text_area" type="text" name="course_name" style="width:266px;" maxlength="100" value="<?php echo str_replace('"', '"', $row->course_name); ?> " /></td> </tr> <tr> <td align="right" width="20%"><?php echo _JLMS_PUBLISHED; ?> :</td> <td> <fieldset class="radio"> <?php echo $lists['published']; ?> </fieldset> </td> </tr> <tr> <td align="right" width="20%"><?php echo _JLMS_START_DATE; ?> :</td> <td> <fieldset class="radio"> <?php echo $lists['publish_start']; //$sf_date = mosFormatDate($row->start_date, "%Y-%m-%d"); $format = '%Y-%m-%d'; $class = 'inputbox'; $id = 'start_date'; $name = 'start_date'; $value = $row->start_date; //($sf_date != '-')?$sf_date:''; if (class_exists('JHTML')) { $joomla_generated_code = JHTML::_('calendar', $value, $name, $id, $format, array('class' => $class)); //ignore joomla generated code ;) echo '<input type="text" name="' . $name . '" id="' . $id . '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '" size="10" maxlength="10" /> ' . '<img class="calendar" src="' . JURI::root() . 'templates/system/images/calendar.png" alt="calendar" id="' . $id . '_img" align="absbottom" />'; } else { ?> <input class="text_area" type="text" name="<?php echo $name; ?> " id="<?php echo $id; ?> " size="10" maxlength="10" value="<?php echo $value; ?> " /> <input type="button" class="button" value="..." onclick="showCalendar('<?php echo $id; ?> ', 'y-mm-dd');return showCalendar('<?php echo $id; ?> ', 'y-mm-dd');" /> <?php } ?> </fieldset> </td> </tr> <tr> <td align="right" width="20%"><?php echo _JLMS_END_DATE; ?> :</td> <td> <fieldset class="radio"> <?php echo $lists['publish_end']; //$sf_date = mosFormatDate($row->end_date, "Y-%m-%d"); $format = '%Y-%m-%d'; $class = 'inputbox'; $id = 'end_date'; $name = 'end_date'; $value = $row->end_date; //($sf_date != '-')?$row->end_date:''; if (class_exists('JHTML')) { $joomla_generated_code = JHTML::_('calendar', $value, $name, $id, $format, array('class' => $class)); //ignore joomla generated code ;) echo '<input type="text" name="' . $name . '" id="' . $id . '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '" size="10" maxlength="10" /> ' . '<img class="calendar" src="' . JURI::root() . 'templates/system/images/calendar.png" alt="calendar" id="' . $id . '_img" align="absbottom" />'; } else { ?> <input class="text_area" type="text" name="<?php echo $name; ?> " id="<?php echo $id; ?> " size="10" maxlength="10" value="<?php echo $value; ?> " /> <input type="button" class="button" value="..." onclick="showCalendar('<?php echo $id; ?> ', 'y-mm-dd');return showCalendar('<?php echo $id; ?> ', 'y-mm-dd');" /> <?php } ?> </fieldset> </td> </tr> <tr> <td align="left" valign="top" style="vertical-align:top "><?php echo _JLMS_CRSS_ACCESS_LEVEL; ?> :</td> <td><?php echo $lists['gid']; ?> </td> </tr> <tr> <td align="left" valign="top"><?php echo _JLMS_DESCRIPTION; ?> :</td> <td> <?php JLMS_editorArea('editor1', $row->course_description, 'course_description', '100%;', '250', '40', '20'); ?> </td> </tr> <tr> <td align="left" valign="top" style="vertical-align:top"><?php echo _JLMS_SHORT_DESC; ?> :</td> <td><textarea class="inputbox" name="course_sh_description" cols="50" rows="3"><?php echo $row->course_sh_description; ?> </textarea></td> </tr> <tr> <td align="left" valign="top"><?php echo _JLMS_CRSS_META_DATA; ?> :</td> <td> <textarea class="text_area" name="metadesc" cols="50" rows="3"><?php echo $row->metadesc; ?> </textarea> </td> </tr> <tr> <td align="left" valign="top"><?php echo _JLMS_CRSS_META_KEYS; ?> :</td> <td> <textarea class="text_area" name="metakeys" cols="50" rows="3"><?php echo $row->metakeys; ?> </textarea> </td> </tr> <tr> <td align="right" width="20%"><?php echo _JLMS_LANGUAGE; ?> :</td> <td><?php echo $lists['language']; ?> </td> </tr> <tr> <td align="right" width="20%"><?php echo _JLMS_CRSS_ENABLE_CHAT; ?> :</td> <td> <fieldset class="radio"> <?php echo $lists['add_chat']; ?> </fieldset> </td> </tr> <tr> <td align="right" width="20%"><?php echo _JLMS_CRSS_ENABLE_HOMEWORKS; ?> :</td> <td> <fieldset class="radio"> <?php echo $lists['add_hw']; ?> </fieldset> </td> </tr> <tr> <td align="right" width="20%"><?php echo _JLMS_CRSS_USR_REG_ATTEND; ?> :</td> <td> <fieldset class="radio"> <?php echo $lists['add_attend']; ?> </fieldset> </td> </tr> <tr> <td align="right" width="20%"><?php echo _JLMS_CRSS_ENBL_SELF_REG; ?> :</td> <td> <fieldset class="radio"> <?php echo $lists['self_reg']; ?> </fieldset> </td> </tr> <tr> <td align="left" width="15%" valign="middle" style="vertical-align:middle "><?php echo _JLMS_CRSS_FEE_TYPE; ?> :</td> <td> <fieldset class="radio"> <input type="radio" name="paid" id="free_type" value="0" <?php echo $row->paid ? '' : 'checked'; ?> /> <label for="free_type"><?php echo _JLMS_FREE; ?> </label> <input type="radio" name="paid" id="paid_type" value="1" <?php echo $row->paid ? 'checked' : ''; ?> /> <label for="paid_type"><?php echo _JLMS_PAID; ?> </label> </fieldset> </td> </tr> <?php //Course Properties Event// if (isset($lists['plugin_return']) && count($lists['plugin_return'])) { $fields = $lists['plugin_return']; foreach ($fields as $field) { ?> <tr> <td align="left" width="20%" valign="middle" style="vertical-align:middle "> <br /> <?php echo $field->name; ?> : </td> <td colspan="2"> <br /> <?php echo $field->control; ?> </td> </tr> <?php } } //Course Properties Event// ?> <tr> <td align="right" width="20%"><?php echo _JLMS_CRSS_ENBL_FORUM; ?> :</td> <td> <fieldset class="radio"> <?php echo $lists['add_forum']; echo _JLMS_CRSS_TIP_ENBL_FORUM; ?> </fieldset> </td> </tr> <tr> <td align="right" width="20%"><?php echo _JLMS_CRSS_SET_MAX_A_COUNTS; ?> </td> <td><input type="text" name="params[max_attendees]" class="text_area" value="<?php echo $params->get('max_attendees', 0); ?> " /> <?php if (isset($params->_params)) { foreach ($params->_params as $name => $value) { switch ($name) { case 'max_attendees': break; default: echo "<input type='hidden' name='params[{$name}]' value='{$value}' />"; break; } } } elseif (isset($params->_registry['_default']['data'])) { foreach ($params->_registry['_default']['data'] as $name => $value) { switch ($name) { case 'max_attendees': break; default: echo "<input type='hidden' name='params[{$name}]' value='{$value}' />"; break; } } } ?> </td> </tr> <tr> <td align="right" width="20%"><?php echo _JLMS_CRSS_CRS_AUTHOR_ID; ?> :</td> <td><input class="text_area" type="text" name="owner_id" value="<?php echo $row->owner_id; ?> " /></td> </tr> </table> <br /> </td> </tr> </table> </fieldset> </div> </td> </tr> </table> <input type="hidden" name="option" value="<?php echo $option; ?> " /> <input type="hidden" name="id" value="<?php echo $row->id; ?> " /> <input type="hidden" name="task" value="editA_course" /> </form> <?php }
function saveToDb(&$db) { $dbo =& JFactory::GetDbo(); $query = "DELETE FROM `#__lms_config` WHERE lms_config_var != 'jlms_version' "; $dbo->setQuery($query); $dbo->query(); $this->attendance_days = serialize($this->attendance_days); $vars = $this->getPublicVars(); foreach ($vars as $v) { if ($v == 'maxConfClients') { $this->{$v} = intval($this->{$v}); } elseif ($v == 'backend_access_gid' && is_array($this->{$v})) { $this->{$v} = implode(',', $this->{$v}); } $query = "INSERT INTO `#__lms_config` (lms_config_var, lms_config_value) " . "VALUES (" . $dbo->Quote($v) . ", " . $dbo->Quote($this->{$v}) . ")"; $dbo->setQuery($query); $dbo->query(); } }
} foreach (H5PCore::$scripts as $script) { $doc->addScript(JURI::root(true) . '/libraries/h5pcore/core/' . $script . $h5p_file_suffix); } $doc->addScript(JURI::root(true) . '/libraries/h5pcore/js/h5pjoomla.js' . $h5p_file_suffix); $doc->addScript(JURI::root(true) . '/libraries/h5pcore/js/jquery.ba-resize.min.js' . $h5p_file_suffix); $user = JFactory::getUser(); $script = 'H5PIntegration = H5PIntegration || {};'; $script .= 'H5PIntegration.content = H5PIntegration.content || {};'; $script .= 'H5PIntegration.jsonContentPath = "' . $h5p_path . 'content/";'; $script .= 'H5PIntegration.libraryPath = "' . $h5p_path . 'libraries/";'; $script .= 'H5P.ajaxPath = "' . JURI::root(true) . '/index.php?option=com_h5p&format=raw&task=";'; $script .= 'H5P.postUserStatistics = ' . ($user->get('id') === 0 ? 'false' : 'true') . ';'; $input = JFactory::getApplication()->input; $h5pId = $input->getCmd('cid'); $db = JFactory::GetDbo(); $db->setQuery(sprintf("SELECT h.json_content, hl.machine_name, hl.fullscreen, hl.semantics\n\t FROM #__h5p as h, #__h5p_libraries as hl\n\t WHERE h.h5p_id = %s\n\t AND hl.library_id = h.main_library_id", $db->quote($h5pId))); $h5p = $db->loadObject(); // Add dependent lib javascripts $db->setQuery(sprintf("SELECT hl.library_id, hl.machine_name as machineName, hl.major_version as majorVersion,\n\t hl.minor_version as minorVersion, hl.patch_version as patchVersion, preloaded_css, preloaded_js, hnl.drop_css\n\t FROM #__h5p_library_dependencies hnl\n\t JOIN #__h5p_libraries hl\n\t ON hnl.library_id = hl.library_id\n\t WHERE hnl.h5p_id = %s\n\t AND hnl.preloaded = 1", $db->quote($h5pId))); $res = $db->loadAssocList(); foreach ($res as $library_data) { $libname = $h5p_core->libraryToString($library_data, TRUE); if (!empty($library_data['preloaded_js'])) { foreach (explode(',', $library_data['preloaded_js']) as $value) { $doc->addScript($h5p_path . 'libraries/' . $libname . '/' . trim($value) . '?pv=' . $library_data['patchVersion']); } } if (!empty($library_data['preloaded_css']) && $library_data['drop_css'] != 1) { foreach (explode(',', $library_data['preloaded_css']) as $value) { $doc->addStyleSheet($h5p_path . 'libraries/' . $libname . '/' . trim($value) . '?pv=' . $library_data['patchVersion']);
function ALU_saveItem($option, $page) { $db =& JFactory::GetDbo(); $redirect = JRequest::getCmd('redirect'); $edit_manager = JRequest::getCmd('edit_manager'); $old_group_id = JRequest::getCmd('old_group_id'); $user_id = JRequest::getInt('user_id'); $group_id = JRequest::getInt('group_id'); $query = "SELECT count(*) FROM #__lms_user_assign_groups WHERE user_id = {$user_id} AND group_id = {$group_id}"; $db->setQuery($query); $count_yet = $db->LoadResult(); if ($count_yet) { $msg = _JLMS_USERS_USR_EXISTS; } else { if ($edit_manager) { $query = "UPDATE #__lms_user_assign_groups SET group_id = {$group_id} WHERE user_id = {$user_id} AND group_id = {$old_group_id}"; } else { $query = "INSERT INTO #__lms_user_assign_groups (user_id, group_id) VALUES ({$user_id}, {$group_id})"; } $db->setQuery($query); if (!$db->query()) { echo "<script> alert('" . $db->getErrorMsg() . "'); window.history.go(-1); </script>\n"; } $msg = _JLMS_USERS_MSG_USR_ADDED; } $app =& JFactory::getApplication('administrator'); if ($redirect) { $app->redirect("index.php?option={$option}&task=classes", $msg); } else { $app->redirect("index.php?option={$option}&task=group_managers", $msg); } }