public function onUninstall() { // Drop tables and configuration values $a = eF_executeNew("DROP TABLE `module_BBB`;"); $b = eF_executeNew("DROP TABLE `module_BBB_users_to_meeting`;"); $c = eF_executeNew("DELETE FROM `configuration` WHERE `name` = 'module_BBB_server';"); $d = eF_executeNew("DELETE FROM `configuration` WHERE `name` = 'module_BBB_salt';"); $e = eF_executeNew("DELETE FROM `configuration` WHERE `name` = 'module_BBB_server_version';"); return $a && $b && $c && $d && $e; }
public function onUpgrade() { $columns = mysql_query("show columns from `module_workbook_settings`"); $alter1 = true; $found1 = false; $alter2 = true; $found2 = false; if ($columns) { while ($col = mysql_fetch_assoc($columns)) { if ($col['Field'] == 'unit_to_complete') { $found1 = true; } if ($col['Field'] == 'edit_answers') { $found2 = true; } } if ($found1 == false) { $alter1 = eF_executeNew("ALTER TABLE `module_workbook_settings` ADD COLUMN `unit_to_complete` INT(11) NOT NULL DEFAULT '-1' AFTER `allow_export`"); } if ($found2 == false) { $alter2 = eF_executeNew("ALTER TABLE `module_workbook_settings` ADD COLUMN `edit_answers` tinyint(1) NOT NULL DEFAULT '1' AFTER `allow_export`"); } } return $columns && $alter1 && $alter2; }
public function onPageFinishLoadingSmartyTpl() { if (!isset($_SESSION['lesson_rooms'])) { $_SESSION['lesson_rooms'] = array(); } $smarty = $this->getSmartyVar(); $mainScripts = array_merge(array('../modules/module_chat/js/chat'), getMainScripts()); $smarty->assign("T_HEADER_MAIN_SCRIPTS", implode(",", $mainScripts)); if ($this->isPopup()) { $smarty->assign("T_CHAT_MODULE_STATUS", "OFF"); } else { $smarty->assign("T_CHAT_MODULE_STATUS", "ON"); } if (!$_SESSION['chatter']) { $currentUser = $this->getCurrentUser(); $_SESSION['chatter'] = $currentUser->login; $_SESSION['utype'] = $currentUser->getType(); $this->calculateCommonality($currentUser->login); eF_executeNew("INSERT IGNORE INTO module_chat_users (username ,timestamp_) VALUES ('" . $_SESSION['chatter'] . "', CURRENT_TIMESTAMP);"); } else { $currentUser = $this->getCurrentUser(); if ($_SESSION['chatter'] != $currentUser->login) { $_SESSION['chatter'] = $currentUser->login; $_SESSION['utype'] = $currentUser->getType(); $this->calculateCommonality($currentUser->login); eF_executeNew("INSERT IGNORE INTO module_chat_users (username ,timestamp_) VALUES ('" . $_SESSION['chatter'] . "', CURRENT_TIMESTAMP);"); } } $smarty->assign("T_CHAT_MODULE_BASEURL", $this->moduleBaseUrl); $smarty->assign("T_CHAT_MODULE_BASELINK", $this->moduleBaseLink); $smarty->assign("T_CHAT_MODULE_BASEDIR", $this->moduleBaseDir); $onlineUsers = EfrontUser::getUsersOnline(); $smarty->assign("T_CHAT_MODULE_ONLINEUSERS", $onlineUsers); return $this->moduleBaseDir . "module_chat.tpl"; }
$all_users = eF_getTableDataFlat("users", "login", "user_type = 'student'"); } if (empty($existing_test_users)) { $non_existing_users = $all_users['login']; } else { $non_existing_users = array_diff($all_users['login'], $existing_test_users['users_LOGIN']); } foreach ($non_existing_users as $user_to_add) { if (!$all_users_to_add) { $all_users_to_add = "('" . $_GET['edit_test'] . "','" . $user_to_add . "' , '0')"; } else { $all_users_to_add .= ",('" . $_GET['edit_test'] . "','" . $user_to_add . "' , '0')"; } } if (isset($all_users_to_add)) { eF_executeNew("INSERT INTO users_to_skillgap_tests (tests_ID, users_LOGIN, solved) VALUES " . $all_users_to_add); } } else { if (isset($_GET['removeAll'])) { // Different management if a users' filter is set or not if ($_GET['filter']) { $all_current_users = eF_getTableData("users_to_skillgap_tests JOIN users ON users_LOGIN = login", "login, name, surname", ""); isset($_GET['filter']) ? $all_current_users = eF_filterData($all_current_users, $_GET['filter']) : null; foreach ($all_current_users as $test_user) { eF_deleteTableData("users_to_skillgap_tests", "tests_ID = '" . $_GET['edit_test'] . "' AND users_LOGIN = '******'login'] . "' "); } } else { eF_deleteTableData("users_to_skillgap_tests", "tests_ID = '" . $_GET['edit_test'] . "'"); } } }
/** * Restore system * * This function is used to restore a backup previously taken * <br/>Example: * <code> * </code> * * @param EfrontFile $restoreFile The file restore from * @param boolean $force Force restore even if versions are incompatible * @since 3.5.2 * @access public */ public static function restore($restoreFile, $force = false) { if (!$restoreFile instanceof EfrontFile) { $restoreFile = new EfrontFile($restoreFile); } $tempDir = G_BACKUPPATH . 'temp/'; if (is_dir($tempDir)) { $dir = new EfrontDirectory($tempDir); $dir->delete(); } mkdir($tempDir, 0755); $restoreFile = $restoreFile->copy($tempDir . '/'); $restoreFile->uncompress(false); $filesystem = new FileSystemTree($tempDir); $iterator = new EfrontFileOnlyFilterIterator(new RecursiveIteratorIterator($filesystem->tree, RecursiveIteratorIterator::SELF_FIRST)); foreach ($iterator as $key => $value) { if (strpos($key, 'version.txt') !== false) { $backupVersion = file_get_contents($key); } } if (version_compare($backupVersion, G_VERSION_NUM) != 0 && !$force) { throw new Exception(_INCOMPATIBLEVERSIONS . '<br/> ' . _BACKUPVERSION . ':' . $backupVersion . ' / ' . _CURRENTVERSION . ': ' . G_VERSION_NUM, EfrontSystemException::INCOMPATIBLE_VERSIONS); } $sql = file_get_contents($tempDir . 'db_backup/sql.txt'); $sql = explode(";\n", $sql); $node = $filesystem->seekNode($tempDir . 'db_backup'); for ($i = 0; $i < sizeof($sql); $i += 2) { preg_match("/drop table (.+)/", $sql[$i], $matches); if ($matches[1]) { $temp[$matches[1]] = array($sql[$i], $sql[$i + 1]); } } $sql = $temp; //For each one of the tables that have backup data, recreate its table and import data $iterator = new EfrontFileOnlyFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($node), RecursiveIteratorIterator::SELF_FIRST)); $GLOBALS['db']->Execute("SET FOREIGN_KEY_CHECKS=0"); foreach ($iterator as $file => $value) { $tableName = preg_replace("/\\.\\d+/", "", basename($file)); if (isset($sql[$tableName])) { try { eF_executeNew($sql[$tableName][0]); } catch (Exception $e) { /*Don't halt for missing tables that can't be deleted*/ } eF_executeNew($sql[$tableName][1]); unset($sql[$tableName]); } if (strpos($file, 'sql.txt') === false && strpos($file, 'version.txt') === false) { $data = unserialize(file_get_contents($file)); $tableExists = false; try { $tableExists = eF_describeTable($tableName); } catch (Exception $e) { } if ($tableExists !== false && !preg_match("/^\\w+_view\$/", $tableName)) { eF_insertTableDataMultiple($tableName, $data); } } } $GLOBALS['db']->Execute("SET FOREIGN_KEY_CHECKS=1"); //Turn off foreign key checks in order to be able to run "drop table" queries eF_executeNew("SET FOREIGN_KEY_CHECKS = 0;"); //For each one of the tables that don't have backup data, simply recreate foreach ($sql as $tableName => $query) { try { eF_executeNew($query[0]); } catch (Exception $e) { /*Don't halt for missing tables that can't be deleted*/ } eF_executeNew($query[1]); } eF_executeNew("SET FOREIGN_KEY_CHECKS = 1;"); if (is_dir(G_BACKUPPATH . 'temp/upload')) { $dir = new EfrontDirectory(G_BACKUPPATH . 'temp/upload'); $dir->copy(G_ROOTPATH . 'upload', true); } if (is_dir(G_BACKUPPATH . 'temp/lessons')) { $dir = new EfrontDirectory(G_BACKUPPATH . 'temp/lessons'); $dir->copy(G_CONTENTPATH . 'lessons', true); } if (is_dir(G_BACKUPPATH . 'temp/efront_root')) { $dir = new EfrontDirectory(G_BACKUPPATH . 'temp/efront_root'); $dir->copy(G_ROOTPATH, true); } if (is_dir(G_BACKUPPATH . 'temp/certificate_templates')) { $dir = new EfrontDirectory(G_BACKUPPATH . 'temp/certificate_templates'); $dir->copy(G_ROOTPATH . 'www/certificate_templates', true); } if (is_dir(G_BACKUPPATH . 'temp/editor_templates')) { $dir = new EfrontDirectory(G_BACKUPPATH . 'temp/editor_templates'); $dir->copy(G_ROOTPATH . 'www/content/editor_templates', true); } $dir = new EfrontDirectory($tempDir); $dir->delete(); if (function_exists('apc_clear_cache')) { apc_clear_cache('user'); } return true; }
private function doChangeLogin() { $smarty = $this->getSmartyVar(); $currentUser = $this->getCurrentUser(); $form = new HTML_QuickForm("change_login_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=module&op=module_administrator_tools&do=user", "", null, true); $form->addElement('static', 'sidenote', '<img id = "module_administrator_tools_busy" src = "images/16x16/clock.png" style="display:none;" alt = "' . _LOADING . '" title = "' . _LOADING . '"/>'); $form->addElement('text', 'selection_user', _MODULE_ADMINISTRATOR_TOOLS_SELECTUSERTOCHANGELOGINFOR, 'id = "module_administrator_tools_autocomplete_users" class = "autoCompleteTextBox" style = "width:400px"'); $form->addElement('static', 'autocomplete_note', _STARTTYPINGFORRELEVENTMATCHES); $form->addElement('text', 'new_login', _MODULE_ADMINISTRATOR_TOOLS_NEWLOGIN, 'class = "inputText"'); $form->addElement('hidden', 'users_LOGIN', '', 'id="module_administrator_tools_users_LOGIN"'); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); $form->addRule('selection_user', _THEFIELD . ' "' . _USER . '" ' . _ISMANDATORY, 'required', null, 'client'); $form->addRule('users_LOGIN', _MODULE_ADMINISTRATOR_TOOLS_THISUSERWASNOTFOUND, 'required', null, 'client'); $form->addRule('new_login', _THEFIELD . ' ' . _MODULE_ADMINISTRATOR_TOOLS_NEWLOGIN . ' ' . _HASINVALIDCHARACTERS . '. ' . _ONLYALLOWEDCHARACTERSLOGIN, 'checkParameter', 'login'); $form->addElement('submit', 'submit', _SUBMIT, 'class = "flatButton"'); if ($form->isSubmitted() && $form->validate()) { try { $values = $form->exportValues(); if (!$values['new_login']) { throw new Exception(_MODULE_ADMINISTRATOR_TOOLS_YOUMUSTDEFINEUSER); } $user = EfrontUserFactory::factory($values['users_LOGIN']); try { $existingUser = true; if (strcasecmp($values['new_login'], $values['users_LOGIN']) === 0) { //Allow changing same user, for case conversions etc $existingUser = false; } else { $newUser = EfrontUserFactory::factory($values['new_login']); } } catch (Exception $e) { $existingUser = false; } if ($existingUser) { throw new Exception(_MODULE_ADMINISTRATOR_TOOLS_USERALREADYEXISTS); } $existingTables = $GLOBALS['db']->GetCol("show tables"); $views = $GLOBALS['db']->GetCol("show tables like '%_view'"); $errors = array(); foreach ($existingTables as $table) { try { if (!in_array($table, $views)) { $this->changeLogin($table, $values['users_LOGIN'], $values['new_login']); } } catch (Exception $e) { $errors[] = $e->getMessage(); } } EfrontCache::getInstance()->deleteCache('usernames'); if (empty($errors)) { $message = _OPERATIONCOMPLETEDSUCCESSFULLY; $message_type = 'success'; } else { $message = _MODULE_ADMINISTRATOR_TOOLS_OPERATIONCOMPLETEDSUCCESSFULLYBUTHEFOLLOWINGTABLESCOULDNOTBEUPDATED . ': <br>' . implode("<br>", $errors); $message_type = 'failure'; } } catch (Exception $e) { $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString()); $message = $e->getMessage() . ' (' . $e->getCode() . ') <a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>'; $message_type = 'failure'; } $this->setMessageVar($message, $message_type); } $smarty->assign("T_TOOLS_FORM", $form->toArray()); try { if (isset($_GET['ajax']) && isset($_GET['user']) && eF_checkParameter($_GET['user'], 'login')) { $user = EfrontUserFactory::factory($_GET['user']); echo json_encode(array('status' => 1, 'supervisors' => $supervisors, 'supervisor_names' => $supervisorNames)); exit; } elseif (isset($_GET['ajax']) && $_GET['ajax'] == 'fix_case') { $existingTables = $GLOBALS['db']->GetCol("show tables"); $views = $GLOBALS['db']->GetCol("show tables like '%_view'"); $users = eF_getTableDataFlat("users", "login"); $errors = array(); foreach ($existingTables as $table) { $t = microtime(true); try { if (!in_array($table, $views)) { $fields = $GLOBALS['db']->GetCol("describe {$table}"); foreach ($users['login'] as $key => $login) { foreach ($fields as $value) { if (stripos($value, 'login') !== false) { eF_executeNew("update {$table} set {$value}='{$login}' where {$value}='{$login}'"); } } if ($table == 'f_personal_messages') { eF_updateTableData($table, array("sender" => $login), "sender = '" . $login . "'"); } if ($table == 'notifications' || $table == 'sent_notifications') { eF_updateTableData($table, array("recipient" => $login), "recipient = '" . $login . "'"); } if ($table == 'surveys' || $table == 'module_hcd_events') { eF_updateTableData($table, array("author" => $login), "author = '" . $login . "'"); } } } } catch (Exception $e) { $errors[] = $e->getMessage(); } //pr("Time for $table: ".(microtime(true)-$t));flush();ob_flush(); } EfrontCache::getInstance()->deleteCache('usernames'); echo json_encode(array('status' => 1)); exit; } } catch (Exception $e) { handleAjaxExceptions($e); } }
public function onUnInstall() { eF_executeNew("drop table module_rss_feeds"); return true; }
public function onUninstall() { eF_executeNew("DROP TABLE module_links;"); return true; }
public function onUninstall() { $res1 = eF_executeNew("DROP TABLE module_crossword_users;"); $res2 = eF_executeNew("DROP TABLE module_crossword_words;"); $res3 = eF_executeNew("DROP TABLE words;"); return $res1 && $res2 && $res3 && $res4; }
public function onUpgrade() { $t1 = eF_executeNew("CREATE TABLE IF NOT EXISTS `module_journal_settings` (\n\t\t\t\t\t`id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t`name` varchar(45) NOT NULL,\n\t\t\t\t\t`value` tinyint(1) NOT NULL,\n\t\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8"); $resultNew = eF_getTableData("module_journal_settings", "*"); if (count($resultNew) == 0) { $result = eF_getTableData("module_journal_allow_export", "*"); eF_insertTableData("module_journal_settings", array('name' => 'export', 'value' => $result[0]['allow'])); eF_insertTableData("module_journal_settings", array('name' => 'preview', 'value' => 1)); } $t2 = eF_executeNew("DROP TABLE IF EXISTS `module_journal_allow_export`"); return $t1 && $t2; }
public function onUninstall() { return eF_executeNew("DROP TABLE module_youtube;"); }
/** * Either refresh the 'time' field of the current user/session/entity, or create a new entry * if the user just entered an entity during this session */ function refreshLogin() { if ($_SESSION['s_login']) { $entity = getUserTimeTarget($_SERVER['REQUEST_URI']); //Something like 'system', 'lesson' or 'unit' //$entity = $_SESSION['s_time_target']; $result = eF_getTableData("user_times", "time, timestamp_now", "session_expired=0 and session_custom_identifier = '" . $_SESSION['s_custom_identifier'] . "' and users_LOGIN='******'s_login'] . "' and entity='" . current($entity) . "' and entity_id='" . key($entity) . "'"); $totalTimeSoFar = false; if (!empty($result) && $result[0]['timestamp_now'] >= time() - 5 * $GLOBALS['configuration']['updater_period'] / 1000) { //5 failed updates: reset $totalTimeSoFar = true; } if ($totalTimeSoFar === false) { //Nullify current entry for the same entity eF_updateTableData("user_times", array("session_expired" => 1), "session_expired = 0 and session_custom_identifier = '" . $_SESSION['s_custom_identifier'] . "' and users_LOGIN = '******'s_login'] . "'\n\t\t\t\t\t\t\t\t\t\t\tand entity = '" . current($entity) . "' and entity_id = '" . key($entity) . "'"); //Insert a new entry for this entity, to start counting time for $fields = array("session_timestamp" => time(), "session_id" => session_id(), "session_custom_identifier" => $_SESSION['s_custom_identifier'], "session_expired" => 0, "users_LOGIN" => $_SESSION['s_login'], "timestamp_now" => time(), "time" => 0, "lessons_ID" => $_SESSION['s_lessons_ID'] ? $_SESSION['s_lessons_ID'] : null, "courses_ID" => $_SESSION['s_courses_ID'] ? $_SESSION['s_courses_ID'] : null, "entity" => current($entity), "entity_id" => key($entity)); eF_insertTableData("user_times", $fields); } else { //Update times for this entity $result = eF_executeNew("update user_times set time=time+(" . time() . "-timestamp_now),timestamp_now=" . time() . "\n\t\t\t\t\t\t\t\t\twhere session_expired = 0 and session_custom_identifier = '" . $_SESSION['s_custom_identifier'] . "' and users_LOGIN = '******'s_login'] . "'\n\t\t\t\t\t\t\t\t\t\tand entity = '" . current($entity) . "' and entity_id = '" . key($entity) . "'"); } eF_updateTableData("user_times", array("session_expired" => 1), "session_expired = 0 and session_custom_identifier = '" . $_SESSION['s_custom_identifier'] . "' and users_LOGIN = '******'s_login'] . "'\n\t\t\t\t\t\t\t\t\t\tand (entity != '" . current($entity) . "' or entity_id != '" . key($entity) . "')"); } }
public function onUninstall() { $t1 = eF_executeNew("DROP TABLE IF EXISTS `module_gradebook_ranges`"); $t2 = eF_executeNew("DROP TABLE IF EXISTS `module_gradebook_objects`"); $t3 = eF_executeNew("DROP TABLE IF EXISTS `module_gradebook_grades`"); $t4 = eF_executeNew("DROP TABLE IF EXISTS `module_gradebook_users`"); return $t1 && $t2 && $t3 && $t4; }
public function onUninstall() { $res1 = eF_executeNew("DROP TABLE module_flashcards_users_to_cards;"); $res2 = eF_executeNew("DROP TABLE module_flashcards_decks;"); return $res1 && $res2 && $res3 && $res4; }
/** * Execute code directly -- Changed to an alias of eF_executeNew * * @deprecated * @param $sql * @return unknown_type */ function eF_execute($sql) { return eF_executeNew($sql); }
public static function sendNextNotifications($limit = false) { if (!$limit) { $limit = 5; } $init_limit = $limit; $result = eF_getTableData("notifications", "*", "active = 1 AND timestamp <" . time(), "timestamp ASC LIMIT {$limit}"); // Delete notifications for inactive users $notifications_to_delete = eF_getTableData("notifications as n, users as u", "n.id", "n.recipient=u.login AND u.active=0"); foreach ($notifications_to_delete as $notification) { eF_deleteTableData("notifications", "id = '" . $notification['id'] . "'"); } $notifications_to_send = array(); foreach ($result as $next_notification) { $notification = new EfrontNotification($next_notification); // Try to send all messages of this notification // Get message recipients: one or more $recipients = $notification->getRecipients(); try { foreach ($recipients as $login => $recipient) { // Send message if ($notification->sendTo($recipient)) { $limit--; } unset($recipients[$login]); if (!$limit) { break; } } } catch (Exception $e) { $sendingErrors[] = $e->getMessage(); } // Check if the notification is periodical - if so arrange (insert) the next notification // Note here: generated single recipient notifications should never have a send interval if ($notification->notification['send_interval'] != "") { $notification->scheduleNext(); } else { // Pop this notification - delete it eF_deleteTableData("notifications", "id = '" . $notification->notification['id'] . "'"); } if ($sendingErrors) { throw new Exception(implode(",", $sendingErrors)); } // If all $limit messages have been sent, check whether some recipients still remain if (!$limit) { // Push all remaining recipients back to the notifications list, as single user notifications if (sizeof($recipients) > 0) { $notifications_to_send = array(); foreach ($recipients as $login => $recipient) { $notifications_to_send[] = time() . "', '" . $login . "', '" . $notification->notification['message'] . "', '" . $notification->notification['subject'] . "', '" . $notification->notification['id_type_entity']; } if (sizeof($notifications_to_send)) { eF_executeNew("INSERT INTO notifications (timestamp, recipient, message, subject, id_type_entity) VALUES ('" . implode("'),('", $notifications_to_send) . "')"); } } return $init_limit; // all messages have been sent } } return $init_limit - $limit; }
function loginToChat() { eF_executeNew("INSERT IGNORE INTO module_chat_users (username ,timestamp_) VALUES ('" . $_SESSION['chatter'] . "', CURRENT_TIMESTAMP);"); }
public static function createViews() { try { if (G_VERSIONTYPE != 'community') { #cpp#ifndef COMMUNITY if (G_VERSIONTYPE != 'standard') { #cpp#ifndef STANDARD eF_executeNew('drop view if exists ' . G_DBNAME . '.users_view'); eF_executeNew('create view ' . G_DBNAME . '.users_view as select * from users'); eF_executeNew('drop view if exists ' . G_DBNAME . '.lessons_status_view'); eF_executeNew('create view ' . G_DBNAME . '.lessons_status_view as select users_LOGIN as lessons_login,sum(completed>0) as sum_lessons,count(users_to_lessons.from_timestamp) as count_lessons from users_to_lessons, lessons where users_to_lessons.archive=0 and (users_to_lessons.user_type="student" or users_to_lessons.user_type in (select id from user_types where basic_user_type = "student")) and id=lessons_ID and lessons.active=1 and course_only=0 group by lessons_login'); eF_executeNew('drop view if exists ' . G_DBNAME . '.ceus_view'); eF_executeNew('create view ' . G_DBNAME . '.ceus_view as select ucc.users_LOGIN,ucc.courses_ID, ceu as ceus from courses cc join users_to_courses ucc on ucc.courses_ID=cc.id where completed=1'); eF_executeNew('drop view if exists ' . G_DBNAME . '.courses_status_view'); eF_executeNew('create view ' . G_DBNAME . '.courses_status_view as select users_to_courses.users_LOGIN as courses_login,sum(completed>0) as sum_courses,count(users_to_courses.from_timestamp) as count_courses,sum(issued_certificate != "") as certifications, sum(ceus_view.ceus) as ceus from (users_to_courses,courses) left outer join ceus_view on users_to_courses.courses_ID=ceus_view.courses_ID and users_to_courses.users_LOGIN=ceus_view.users_LOGIN where courses.id=users_to_courses.courses_ID and courses.active=1 and courses.archive = 0 and users_to_courses.archive=0 and (users_to_courses.user_type="student" or users_to_courses.user_type in (select id from user_types where basic_user_type = "student")) group by courses_login'); //eF_executeNew('drop view if exists '.G_DBNAME.'.logins_view'); //eF_executeNew('create view '.G_DBNAME.'.logins_view as select users_LOGIN as logs_login,max(timestamp) as last_login from logs where action="login" group by logs_login'); eF_executeNew('drop view if exists ' . G_DBNAME . '.skills_view'); eF_executeNew('create view ' . G_DBNAME . '.skills_view as select users_LOGIN as skills_login,count(skill_ID) as total_skills from module_hcd_employee_has_skill group by skills_login'); if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE eF_executeNew('drop view if exists ' . G_DBNAME . '.employees_view'); eF_executeNew('create view ' . G_DBNAME . '.employees_view as select users_LOGIN,hired_on,left_on,marital_status,way_of_working,driving_licence,sex,office,city from module_hcd_employees'); eF_executeNew('drop view if exists ' . G_DBNAME . '.works_at_branch_view'); eF_executeNew('create view ' . G_DBNAME . '.works_at_branch_view as select me.users_LOGIN as branch_login,count(me.job_description_ID) as sum_jobs, count(mj.branch_ID) as sum_branch, mj.branch_ID as branch, mj.job_description_ID as job_description, sum(wb.supervisor) > 0 as supervisor from module_hcd_employee_has_job_description me, module_hcd_job_description mj, module_hcd_employee_works_at_branch wb where wb.users_LOGIN=me.users_LOGIN and wb.branch_ID=mj.branch_ID and mj.job_description_ID = me.job_description_ID group by branch_login'); } #cpp#endif } #cpp#endif } #cpp#endif } catch (Exception $e) { } }
$entity = getUserTimeTarget($_GET['HTTP_REFERER']); //Update times for this entity if ($_SESSION['s_lesson_user_type'] == 'student' && isset($_POST['user_total_time_in_unit']) && current($entity) == 'unit' && eF_checkParameter(key($entity), 'id')) { $newTime = $_POST['user_total_time_in_unit']; $jsonValues['entity'] = current($entity); $jsonValues['entity_id'] = current($entity); if ($newTime && is_numeric($newTime)) { $result = eF_executeNew("insert into users_to_content (users_LOGIN, content_ID, lessons_ID) values('" . $_SESSION['s_login'] . "', " . key($entity) . ", " . $_SESSION['s_lessons_ID'] . ") on duplicate key update total_time={$newTime}"); $jsonValues['time_in_unit'] = EfrontTimes::formatTimeForReporting($newTime); } else { $jsonValues['old_time_in_unit'] = EfrontTimes::formatTimeForReporting(EfrontLesson::getUserActiveTimeInUnit($_SESSION['s_login'], key($entity))); $jsonValues['old_time_in_lesson'] = EfrontTimes::formatTimeForReporting(EfrontLesson::getUserActiveTimeInLesson($_SESSION['s_login'], $_SESSION['s_lessons_ID'])); } } if (empty($_SESSION['last_periodic_check']) || time() - $_SESSION['last_periodic_check'] >= ceil($GLOBALS['configuration']['updater_period'] / 1000)) { $result = eF_executeNew("update user_times set time=time+(" . time() . "-timestamp_now),timestamp_now=" . time() . "\r\n\t\t\t\t\t\twhere session_expired = 0 and session_custom_identifier = '" . $_SESSION['s_custom_identifier'] . "' and users_LOGIN = '******'s_login'] . "'\r\n\t\t\t\t\t\tand entity = '" . current($entity) . "' and entity_id = '" . key($entity) . "'"); $_SESSION['last_periodic_check'] = time(); if ($currentTheme->options['sidebar_interface'] == 0) { if (empty($_SESSION['last_periodic_check_users']) || time() - $_SESSION['last_periodic_check_users'] >= 300) { $_SESSION['last_periodic_check_users'] = $_SESSION['last_periodic_check']; $online = EfrontUser::getUsersOnline($GLOBALS['configuration']['autologout_time'] * 60); $_SESSION['online_users'] = $online; if ($currentTheme->options['sidebar_interface'] == 0) { $jsonValues['online'] = $online; } } else { if ($currentTheme->options['sidebar_interface'] == 0) { $jsonValues['online'] = $_SESSION['online_users']; } } }
function eF_local_archive_table($table_name, $time_limit) { $result = eF_executeNew("show tables like '{$table_name}_%'"); $indexes = array(); foreach ($result->getAll() as $value) { $index = str_replace("{$table_name}_", '', current(array_values($value))); $indexes[$index] = $index; } $count = 1; while (isset($indexes[$count])) { $count++; } $result = eF_executeNew("show create table {$table_name}"); $data = $result->getAll(); eF_executeNew(str_replace("`{$table_name}`", "`{$table_name}_{$count}`", $data[0]['Create Table'])); return "{$table_name}_{$count}"; }
public function onUninstall() { return eF_executeNew("DROP TABLE module_outlook_invitation;"); }
$all_skills = eF_getTableDataFlat("module_hcd_skills", "skill_ID", ""); } if (empty($existing_question_skills)) { $non_existing_skills = $all_skills['skill_ID']; } else { $non_existing_skills = array_diff($all_skills['skill_ID'], $existing_question_skills['skills_ID']); } foreach ($non_existing_skills as $skill_to_add) { if (!$all_skills_to_add) { $all_skills_to_add = "('" . $_GET['edit_question'] . "','" . $skill_to_add . "' , '2')"; } else { $all_skills_to_add .= ",('" . $_GET['edit_question'] . "','" . $skill_to_add . "' , '2')"; } } if (isset($all_skills_to_add)) { eF_executeNew("INSERT INTO questions_to_skills (questions_id, skills_ID, relevance) VALUES " . $all_skills_to_add); } } else { if (isset($_GET['removeAll'])) { if ($_GET['filter']) { $all_related_skills = eF_getTableData("questions_to_skills JOIN module_hcd_skills ON skills_ID = skill_ID", "skills_ID, description", "questions_ID = '" . $_GET['edit_question'] . "'"); if (!empty($all_related_skills)) { $all_related_skills = eF_filterData($all_related_skills, $_GET['filter']); $skills_to_remove = array(); foreach ($all_related_skills as $skill) { $skills_to_remove[] = $skill['skills_ID']; } if (!empty($skills_to_remove)) { eF_deleteTableData("questions_to_skills", "questions_ID = '" . $_GET['edit_question'] . "' AND skills_ID IN ('" . implode("','", $skills_to_remove) . "')"); } }
/** * Insert the skill corresponding to this lesson: Every lesson is mapped to a skill like "Knowledge of that lesson" * This insertion takes place when a lesson is changed from course_only to regular lesson * * <br/>Example: * <code> * $lesson -> insertLessonSkill(); * </code> * * @return the id of the newly created record in the module_hcd_lesson_offers_skill table or false if something went wrong * @since 3.5.2 * @access public */ public function insertLessonSkill() { $this->skills = false; // If insertion of a self-contained lesson add the corresponding skill // Insert the corresponding lesson skill to the skill and lesson_offers_skill tables $lessonSkillId = eF_insertTableData("module_hcd_skills", array("description" => _KNOWLEDGEOFLESSON . " " . $this->lesson['name'], "categories_ID" => -1)); // Insert question to lesson skill records for all lesson questions $questions = eF_getTableData("questions", "id", "lessons_ID = " . $this->lesson['id']); $insert_string = ""; foreach ($questions as $question) { if ($insert_string != "") { $insert_string .= ",('" . $question['id'] . "','" . $lessonSkillId . "',2)"; } else { $insert_string .= "('" . $question['id'] . "','" . $lessonSkillId . "',2)"; } } if ($insert_string != "") { eF_executeNew("INSERT INTO questions_to_skills VALUES " . $insert_string); } return eF_insertTableData("module_hcd_lesson_offers_skill", array("lesson_ID" => $this->lesson['id'], "skill_ID" => $lessonSkillId)); }
public function onUninstall() { return eF_executeNew("DROP TABLE module_billboard;"); }
/** * Insert the skill corresponding to this course: Every course is mapped to a skill like "Knowledge of that course" * This insertion takes place when a course is changed from course_only to regular course * * <br/>Example: * <code> * $course -> insertCourseSkill(); * </code> * * @return the id of the newly created record in the module_hcd_course_offers_skill table or false if something went wrong * @since 3.6.2 * @access public */ public function insertCourseSkill() { $this->skills = false; // If insertion of a self-contained course add the corresponding skill // Insert the corresponding course skill to the skill and course_offers_skill tables $courseSkillId = eF_insertTableData("module_hcd_skills", array("description" => _KNOWLEDGEOFCOURSE . " " . $this->course['name'], "categories_ID" => -1)); // Insert question to course skill records for all course questions $questions = eF_getTableData("questions", "id", "lessons_ID in ('" . implode("','", array_keys($this->getCourseLessons())) . "')"); $insert_string = ""; foreach ($questions as $question) { if ($insert_string != "") { $insert_string .= ",('" . $question['id'] . "','" . $courseSkillId . "',2)"; } else { $insert_string .= "('" . $question['id'] . "','" . $courseSkillId . "',2)"; } } if ($insert_string != "") { eF_executeNew("INSERT INTO questions_to_skills VALUES " . $insert_string); } return eF_insertTableData("module_hcd_course_offers_skill", array("courses_ID" => $this->course['id'], "skill_ID" => $courseSkillId)); }
public function onUninstall() { $res1 = eF_executeNew("DROP TABLE module_blogs_comments;"); $res2 = eF_executeNew("DROP TABLE module_blogs_articles;"); $res3 = eF_executeNew("DROP TABLE module_blogs"); $res4 = eF_executeNew("DROP TABLE module_blogs_users"); return $res1 && $res2 && $res3 && $res4; }