} } if (isset($_GET['postAjaxRequest']) && $_change_skills_) { try { $_GET['specification'] = urldecode($_GET['specification']); if (isset($_GET['add_skill'])) { if ($_GET['insert'] == "true") { $editedEmployee->addSkills($_GET['add_skill'], $_GET['specification'], $_GET['score']); } else { if ($_GET['insert'] == "false") { $editedEmployee->removeSkills($_GET['add_skill']); } else { if (isset($_GET['addAll']) || isset($_GET['removeAll'])) { $skills = array_keys($editedEmployee->getSkills()); $allSkills = EfrontSkill::getAllSkills(); isset($_GET['filter']) ? $allSkills = eF_filterData($allSkills, $_GET['filter']) : null; foreach ($allSkills as $skill) { if (isset($_GET['removeAll'])) { if (in_array($skill['skill_ID'], $skills)) { $editedEmployee->removeSkills($skill['skill_ID']); } } else { if (!in_array($skill['skill_ID'], $skills)) { $editedEmployee->addSkills($skill['skill_ID'], ""); } } } } else { if (isset($_GET['from_skillgap_test'])) { $skillsToAdd = array(); foreach ($_GET as $getkey => $getvalue) {
} else { $smarty->assign("T_LAYOUT_CLASS", $currentTheme->options['toolbar_position'] == "left" ? "hideRight" : "hideLeft"); //Whether to show the sidemenu on the left or on the right $folderMessages = eF_getTableData("f_personal_messages", "*", "users_LOGIN='******'login'] . "' and f_folders_ID=" . $currentFolder, "priority desc, viewed,timestamp desc"); if (isset($_GET['ajax']) && $_GET['ajax'] == 'messagesTable') { isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'uint') ? $limit = $_GET['limit'] : ($limit = G_DEFAULT_TABLE_SIZE); if (isset($_GET['sort']) && eF_checkParameter($_GET['sort'], 'text')) { $sort = $_GET['sort']; isset($_GET['order']) && $_GET['order'] == 'desc' ? $order = 'desc' : ($order = 'asc'); } else { $sort = 'priority'; } $smarty->assign("T_MESSAGES_SIZE", sizeof($folderMessages)); $folderMessages = eF_multiSort($folderMessages, $_GET['sort'], $order); if (isset($_GET['filter'])) { $folderMessages = eF_filterData($folderMessages, $_GET['filter']); } if (isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'int')) { isset($_GET['offset']) && eF_checkParameter($_GET['offset'], 'int') ? $offset = $_GET['offset'] : ($offset = 0); $folderMessages = array_slice($folderMessages, $offset, $limit); } foreach ($folderMessages as $key => $value) { $recipients = explode(",", $folderMessages[$key]['recipient']); foreach ($recipients as $k => $login) { $recipients[$k] = formatLogin(trim($login)); } $folderMessages[$key]['recipient'] = implode(", ", $recipients); } $smarty->assign("T_MESSAGES", $folderMessages); //$smarty -> assign("T_MESSAGES_SIZE", sizeof($messages)); $smarty->display($currentUser->user['user_type'] . '.tpl');
} $scormData = eF_multiSort($scormData, $sort, $order); if ($_SESSION['s_type'] != 'administrator' && $_SESSION['s_current_branch']) { //this applies to branch urls $currentBranch = new EfrontBranch($_SESSION['s_current_branch']); $branchTreeUsers = array_keys($currentBranch->getBranchTreeUsers()); foreach ($scormData as $key => $value) { if ($value['type'] != 'global' && !in_array($value['users_LOGIN'], $branchTreeUsers)) { unset($scormData[$key]); } } $scormData = array_values($scormData); } $smarty->assign("T_USERS_SIZE", sizeof($scormData)); if (isset($_GET['filter'])) { $scormData = eF_filterData($scormData, $_GET['filter']); } if (isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'int')) { isset($_GET['offset']) && eF_checkParameter($_GET['offset'], 'int') ? $offset = $_GET['offset'] : ($offset = 0); $scormData = array_slice($scormData, $offset, $limit); } $smarty->assign("T_SCORM_DATA", $scormData); $smarty->display('professor.tpl'); exit; } foreach ($scormData as $value) { $scormIds[] = $value['id']; } if (isset($_GET['delete']) && in_array($_GET['delete'], $scormIds)) { eF_deleteTableData("scorm_data", "id=" . $_GET['delete']); $user = EfrontUserFactory::factory($scormData[0]['users_LOGIN']);
if (!$skillgap_tests) { $recentTests = eF_getTableData("completed_tests ct, tests t, users u, users_to_lessons ul", "t.name, u.name as username, u.surname, ct.id, ct.status, ct.tests_ID, ct.score, ct.time_end, ct.users_LOGIN, ct.pending", "u.login=ul.users_login and ul.archive=0 and ul.lessons_ID=t.lessons_ID and ct.status != 'deleted' and ct.status != 'incomplete' and t.id = ct.tests_ID AND ct.users_login = u.login AND u.archive=0 and ct.tests_id IN ('" . implode("','", $testIds) . "')", "ct.pending DESC"); } else { $recentTests = eF_getTableData("completed_tests JOIN tests ON tests_id = tests.id JOIN users ON completed_tests.users_LOGIN = users.login JOIN users_to_skillgap_tests ON completed_tests.users_LOGIN = users_to_skillgap_tests.users_LOGIN AND users_to_skillgap_tests.tests_ID = tests.id AND users_to_skillgap_tests.solved = 1", "completed_tests.id, completed_tests.score, users.name as username, users.surname, completed_tests.tests_ID, tests.name, completed_tests.timestamp, completed_tests.users_LOGIN", "completed_tests.status != 'deleted' and completed_tests.tests_id IN ('" . implode("','", $testIds) . "')", "timestamp DESC"); } } isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'uint') ? $limit = $_GET['limit'] : ($limit = G_DEFAULT_TABLE_SIZE); if (isset($_GET['sort']) && eF_checkParameter($_GET['sort'], 'text')) { $sort = $_GET['sort']; isset($_GET['order']) && $_GET['order'] == 'desc' ? $order = 'desc' : ($order = 'asc'); } else { $sort = 'text'; } $recentTests = eF_multiSort($recentTests, $sort, $order); if (isset($_GET['filter'])) { $recentTests = eF_filterData($recentTests, $_GET['filter']); } if ($_SESSION['s_type'] != 'administrator' && $_SESSION['s_current_branch']) { //this applies to supervisors only $currentBranch = new EfrontBranch($_SESSION['s_current_branch']); $branchTreeUsers = array_keys($currentBranch->getBranchTreeUsers()); foreach ($recentTests as $key => $value) { if (!in_array($value['users_LOGIN'], $branchTreeUsers)) { unset($recentTests[$key]); } } } $smarty->assign("T_PENDING_SIZE", sizeof($recentTests)); if (isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'int')) { isset($_GET['offset']) && eF_checkParameter($_GET['offset'], 'int') ? $offset = $_GET['offset'] : ($offset = 0); $recentTests = array_slice($recentTests, $offset, $limit, true);
// Added this to prevent events that changed time in the future as project expiration $new_event = array("time" => $myEvents[$key]->event['time'], "message" => $myEvents[$key]->event['message']); if ($myEvents[$key]->event['editlink']) { $new_event['editlink'] = $myEvents[$key]->event['editlink']; } if ($myEvents[$key]->event['deletelink']) { $new_event['deletelink'] = $myEvents[$key]->event['deletelink']; } // Keep that for the avatar searching after the filtering $new_event['users_LOGIN'] = $event->event['users_LOGIN']; $events[] = $new_event; } } } if (isset($_GET['filter'])) { $events = eF_filterData($events, $_GET['filter']); } if (isset($_GET['ajax'])) { foreach ($events as $key => $event) { $events[$key]['avatar'] = $users_avatars[$event['users_LOGIN']]; try { $file = new EfrontFile($events[$key]['avatar']); list($events[$key]['avatar_width'], $events[$key]['avatar_height']) = eF_getNormalizedDims($file['path'], 50, 50); } catch (EfrontFileException $e) { $events[$key]['avatar'] = G_SYSTEMAVATARSPATH . "unknown_small.png"; $events[$key]['avatar_width'] = 50; $events[$key]['avatar_height'] = 50; } } } $count = sizeof($events);
private function handlePostAjaxRequestForUsersRemoveAll() { $constraints = array('archive' => false, 'active' => true, 'condition' => 'uc.courses_ID is not null'); $users = $this->getCourseUsersIncludingUnassigned($constraints); $users = EfrontUser::convertUserObjectsToArrays($users); isset($_GET['filter']) ? $users = eF_filterData($users, $_GET['filter']) : null; $this->archiveCourseUsers(array_keys($users)); }
/** * Create HTML representation of file system tree * * This function creates the file manager HTML code. It also handles any AJAX calls, * composes and prints upload and create directory forms, as well as makes sure the * correct folder contents are displayed. * <code> * $basedir = G_LESSONSPATH.'test/'; * $filesystem = new FileSystemTree($basedir); //Set the base directory that the file manager displayes * $url = 'administrator.php?ctg=file_manager'; //Set the url where file manager resides * echo $filesystem -> toHTML($url); //Display file manager * </code> * The available options are (the default value in parenthesis): * - show_type (true) //Whether to show the "type" column * - show_date (true) //Whether to show the "last modified" column * - show_name (true) //Whether to show the "name" column * - show_size (true) //Whether to show the "size" column * - show_tools (true) //Whether to show the "tools" column * - metadata (true) //Whether to allow for metadata * - db_files_only (false) //Whether to display only files that have a db representation * - delete (true) //Whether to display delete icon * - download (true) //Whether to display download icon * - zip (true) //Whether to display zip icon * - share (true) //Whether to display share icon * - create_folder (true) //Whether to display create folder link * - upload (true) //Whether to display upload file link * - copy (true) //Whether to display copy icon * - folders (true) //Whether to display folders in files list * * The $extraFileTools, $extraHeaderOptions, $extraDirectoryTools paramaters are used to add custom * extra tools to various places of the file manager. The format of these parameters is of the form: * $extraFileTools = array(array('image' => 'images/16x16/restore.png', 'title' => _RESTORE, 'action' => 'restore')); * $extraHeaderOptions = array(array('image' => 'images/16x16/undo.png', 'title' => _BACKUP, 'action' => 'backup')); * * @param string $url The url where the file manager resides * @param string $currentDirectory The directory to use as base directory * @param array $ajaxOptions AJAX-specific options: sort, order, limit, offset, filter * @param array $options Options for the file manager * @param array $extraFileTools Extra tools for files * @param array $extraDirectoryTools Extra tools for directories * @param array $extraHeaderOptions Extra tools for file manager header * @param array $defaultIterator A specific iterator to use for files display * @param bool $show_tooltip If tooltip is dislayed in name * @return string The HTML representation of the file system * @since 3.5.0 * @access public */ public function toHTML($url, $currentDirectory = '', $ajaxOptions = array(), $options, $extraFileTools = array(), $extraDirectoryTools = array(), $extraHeaderOptions = array(), $defaultIterator = false, $show_tooltip = true, $extraColumns = array()) { //Set default options !isset($options['show_type']) ? $options['show_type'] = true : null; !isset($options['show_date']) ? $options['show_date'] = true : null; !isset($options['show_name']) ? $options['show_name'] = true : null; !isset($options['show_size']) ? $options['show_size'] = true : null; !isset($options['show_tools']) ? $options['show_tools'] = true : null; !isset($options['delete']) ? $options['delete'] = true : null; !isset($options['download']) ? $options['download'] = true : null; !isset($options['zip']) ? $options['zip'] = true : null; !isset($options['share']) ? $options['share'] = true : null; !isset($options['edit']) ? $options['edit'] = true : null; !isset($options['copy']) ? $options['copy'] = true : null; !isset($options['create_folder']) ? $options['create_folder'] = true : null; !isset($options['upload']) ? $options['upload'] = true : null; !isset($options['folders']) ? $options['folders'] = true : null; !isset($options['db_files_only']) ? $options['db_files_only'] = false : null; !isset($options['table_id']) ? $tableId = 'filesTable' : ($tableId = $options['table_id']); //Make sure that current directory is a path //$currentDirectory = new EfrontDirectory($currentDirectory); if ($currentDirectory instanceof EfrontDirectory) { $currentDirectory = $currentDirectory['path']; } if (isset($_POST['upload_current_directory']) && strpos(EfrontDirectory::normalize($_POST['upload_current_directory']), rtrim(G_ROOTPATH, "/")) !== false) { $currentDirectory = $_POST['upload_current_directory']; } if (isset($_POST['current_directory']) && strpos(EfrontDirectory::normalize($_POST['current_directory']), rtrim(G_ROOTPATH, "/")) !== false) { $currentDirectory = $_POST['current_directory']; } if (isset($_POST['copy_current_directory']) && strpos(EfrontDirectory::normalize($_POST['copy_current_directory']), rtrim(G_ROOTPATH, "/")) !== false) { $currentDirectory = $_POST['copy_current_directory']; } if ($currentDirectory && $currentDirectory != $this->dir['path']) { //Check that the current directory actually exists $currentDir = new EfrontDirectory($currentDirectory); //Get its parent directory $parentDir = new EfrontDirectory($currentDir['directory']); //Build a new (shallow) file system tree on the current directory $innerFileSystem = new FileSystemTree($currentDir, false); //Assign each node as a child to the currentDir, thus creating a new tree with currentDir as parent foreach ($innerFileSystem->tree as $key => $value) { $currentDir[$key] = $value; } //$currentDir = $this -> seekNode($currentDirectory); //$parentDir = new EfrontDirectory($currentDir['directory']); } else { $currentDirectory = $this->dir['path']; $currentDir = $this->tree; } try { $uploadForm = new HTML_QuickForm("upload_file_form_{$tableId}", "post", $url, "", "target = 'POPUP_FRAME'", true); $uploadFormString = $this->getUploadForm($uploadForm); if ($uploadForm->isSubmitted() && $uploadForm->validate()) { $uploadedFile = $this->handleUploadForm($uploadForm); $uploadFormString .= ' <script>if (window.name == "POPUP_FRAME") {(parent.eF_js_showDivPopup());parent.eF_js_rebuildTable(parent.$(\'filename_' . $tableId . '\').down().getAttribute(\'tableIndex\'), 0, \'\', \'desc\', \'' . urlencode($currentDirectory) . '\');parent.$(\'uploading_image\').hide()}</script>'; } $createFolderForm = new HTML_QuickForm("create_folder_form", "post", $url, "", "target = 'POPUP_FRAME'", true); $createFolderString = $this->getCreateDirectoryForm($createFolderForm); if ($createFolderForm->isSubmitted() && $createFolderForm->validate()) { $this->handleCreateDirectoryForm($createFolderForm); $createFolderString .= ' <script>if (window.name == "POPUP_FRAME") {(parent.eF_js_showDivPopup());parent.eF_js_rebuildTable(parent.$(\'filename_' . $tableId . '\').down().getAttribute(\'tableIndex\'), 0, \'\', \'desc\', \'' . urlencode($currentDirectory) . '\');}</script>'; } /* $copyForm = new HTML_QuickForm("copy_file_form", "post", $url, "", "", true); foreach ($iterator = new EfrontDirectoryOnlyFilterIterator(new EfrontNodeFilterIterator($currentDir)) as $key => $value) { $directories[$key] = str_replace($this -> dir['path'].'/', '', EfrontFile :: decode($value['path'])); } $copyForm -> addElement('select', 'destination', null, $directories, 'class = "inputText"'); $copyFormString = $this -> getCopyForm($copyForm); if ($copyForm -> isSubmitted() && $copyForm -> validate()) { $copiedFile = $this -> handleCopyForm($copyForm); } */ //pr($currentDirectory); if (isset($_POST['copy_files']) && sizeof($_POST['copy_files']) > 0) { $copyFiles = explode(",", $_POST["copy_files"]); foreach ($copyFiles as $file) { $file = new EfrontFile($file); //pr('copying to '.$currentDirectory.'/'.basename($file['path'])); $file->copy($currentDirectory . '/' . basename($file['path'])); } } } catch (Exception $e) { echo "<script>if (top && top.mainframe) {w=top.mainframe} else {w=parent;}w.document.getElementById('messageError').innerHTML = '" . $e->getMessage() . "';parent.\$('uploading_image').hide();</script>"; //Don't halt for uploading and create directory errors $GLOBALS['smarty']->assign("T_EXCEPTION_TRACE", $e->getTraceAsString()); $GLOBALS['message'] = $e->getMessage() . ' (' . $e->getCode() . ') <a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>'; } $files = array(); $fileArrays = array(); $foldersArray = array(); $filesArray = array(); if ($options['folders']) { $iterator = new EfrontDirectoryOnlyFilterIterator(new ArrayIterator($currentDir)); //Plain ArrayIterator so that it iterates only on the current's folder files if ($options['db_files_only']) { //Filter out directories without database representation $iterator = new EfrontDBOnlyFilterIterator($iterator); } foreach ($iterator as $key => $value) { //We convert iterator to a complete array of files, so we can apply sorting, filtering etc more easily $current = (array) $iterator->current(); foreach ($current as $k => $v) { //Remove child elements, such files, directories etc from the array, so we can successfully apply operations on to them, such as filtering if ($v instanceof ArrayObject) { unset($current[$k]); } } $current['size'] = 0; $current['extension'] = ''; $current['shared'] = 10; //Add these 3 parameters, so that sorting below works correctly (10 means nothing, since a folder cannot be shared, but it is handy for sorting) $foldersArray[] = (array) $current; //Array representation of directory objects, on which we can apply sorting, filtering, etc } $foldersArray = eF_multiSort($foldersArray, 'name', 'asc'); } if ($defaultIterator) { $iterator = $defaultIterator; } else { $iterator = new EfrontFileOnlyFilterIterator(new EfrontNodeFilterIterator(new ArrayIterator($currentDir))); //Plain ArrayIterator so that it iterates only on the current folder's files if ($options['db_files_only']) { //Filter out directories without database representation $iterator = new EfrontDBOnlyFilterIterator($iterator); } } foreach ($iterator as $key => $value) { //We convert iterator to a complete array of files, so we can apply sorting, filtering etc more easily $current = (array) $iterator->current(); foreach ($current as $k => $v) { //Remove child elements, such files, directories etc from the array, so we can successfully apply operations on to them, such as filtering if ($v instanceof ArrayObject) { unset($current[$k]); } } $filesArray[] = (array) $current; //Array representation of file objects, on which we can apply sorting, filtering, etc } $filesArray = eF_multiSort($filesArray, 'name', 'asc'); $fileArrays = array_merge($foldersArray, $filesArray); isset($ajaxOptions['order']) && $ajaxOptions['order'] == 'asc' ? $ajaxOptions['order'] = 'asc' : ($ajaxOptions['order'] = 'desc'); !isset($ajaxOptions['sort']) ? $ajaxOptions['sort'] = 'name' : null; !isset($ajaxOptions['limit']) ? $ajaxOptions['limit'] = 20 : null; !isset($ajaxOptions['offset']) ? $ajaxOptions['offset'] = 0 : null; !isset($ajaxOptions['filter']) ? $ajaxOptions['filter'] = '' : null; $size = sizeof($fileArrays); if ($size) { $fileArrays = eF_multiSort($fileArrays, $ajaxOptions['sort'], $ajaxOptions['order']); $ajaxOptions['filter'] ? $fileArrays = eF_filterData($fileArrays, $ajaxOptions['filter']) : null; $fileArrays = array_slice($fileArrays, $ajaxOptions['offset'], $ajaxOptions['limit']); } $extraColumnsString = ''; foreach ($extraColumns as $value) { $extraColumnsString = '<td class = "topTitle centerAlign" name = "' . $value . '">' . $value . '</td>'; } $filesCode = ' <table class = "sortedTable" style = "width:100%" size = "' . $size . '" id = "' . $tableId . '" useAjax = "1" rowsPerPage = "20" other = "' . urlencode($currentDirectory) . '" url = "' . $url . '&" nomass = "1" currentDir = "' . (isset($currentDir['path']) ? $currentDir['path'] : '') . '"> <tr>' . ($options['show_type'] ? '<td class = "topTitle centerAlign" name = "extension">' . _TYPE . '</td>' : '') . ' ' . ($options['show_name'] ? '<td class = "topTitle" name = "name" id = "filename_' . $tableId . '">' . _NAME . '</td>' : '') . ' ' . ($options['show_size'] ? '<td class = "topTitle" name = "size">' . _SIZE . '</td>' : '') . ' ' . ($options['show_date'] ? '<td class = "topTitle" name = "timestamp">' . _MODIFIED . '</td>' : '') . ' ' . $extraColumnsString . ' ' . ($_SESSION['s_lessons_ID'] && $options['share'] ? '<td class = "topTitle centerAlign" name = "shared">' . _SHARE . '</td>' : '') . ' ' . ($options['show_tools'] ? '<td class = "topTitle centerAlign noSort">' . _OPERATIONS . '</td>' : '') . ' ' . ($options['delete'] || $_SESSION['s_lessons_ID'] && $options['share'] ? '<td class = "topTitle centerAlign">' . _SELECT . '</td>' : '') . ' </tr>'; if (isset($parentDir)) { if ($parentDir['path'] == $this->dir['path']) { $parentDir['path'] = ''; } $filesCode .= ' <tr class = "defaultRowHeight eventRowColor"><td class = "centerAlign" colspan = "100%">' . _CURRENTLYBROWSINGFOLDER . ': ' . EfrontFile::decode(str_replace($this->dir['path'], '', $currentDir['path'])) . '</td></tr> <tr class = "defaultRowHeight oddRowColor"> <td class = "centerAlign"><span style = "display:none"></span><img src = "images/16x16/folder_up.png" alt = "' . _UPONELEVEL . '" title = "' . _UPONELEVEL . '"/></td> <td><a class="editLink" href = "javascript:void(0)" onclick = "eF_js_rebuildTable($(\'filename_' . $tableId . '\').down().getAttribute(\'tableIndex\'), 0, \'\', \'desc\', \'' . urlencode($parentDir['path']) . '\');">.. (' . _UPONELEVEL . ')</a></td> <td colspan = "5"></td></tr>'; } $i = 0; if ($_SESSION['supervises_branches'] != "") { $currentEmployee = EfrontUserFactory::factory($_SESSION['s_login']); $employees = eF_getTableData("users LEFT OUTER JOIN module_hcd_employee_has_job_description ON users.login = module_hcd_employee_has_job_description.users_LOGIN LEFT OUTER JOIN module_hcd_employee_works_at_branch ON users.login = module_hcd_employee_works_at_branch.users_LOGIN", "users.*, count(job_description_ID) as jobs_num", " users.user_type <> 'administrator' AND ((module_hcd_employee_works_at_branch.branch_ID IN (" . $_SESSION['supervises_branches'] . " ) AND module_hcd_employee_works_at_branch.assigned='1') OR EXISTS (SELECT module_hcd_employees.users_login FROM module_hcd_employees LEFT OUTER JOIN module_hcd_employee_works_at_branch ON module_hcd_employee_works_at_branch.users_login = module_hcd_employees.users_login WHERE users.login=module_hcd_employees.users_login AND module_hcd_employee_works_at_branch.branch_ID IS NULL)) GROUP BY login", "login"); $supervisedLogins = array(); foreach ($employees as $key2 => $value2) { if (!$value2['active'] || $value2['archive'] || !$value2['jobs_num']) { unset($employees[$key2]); } else { $supervisedLogins[] = $value2['login']; } } } foreach ($fileArrays as $key => $value) { $toolsString = ''; $sharedString = ''; if (is_file($value['path'])) { $value['id'] == -1 ? $identifier = $value['path'] : ($identifier = $value['id']); //The file/directory identifier will be the id, if the entity has a database representation, or the file path otherwise $value = new EfrontFile($value); //Restore file/directory representation, so we can use its methods $link = $url . '&view=' . urlencode($identifier); foreach ($extraFileTools as $tool) { //$toolsString .= '<a href = "javascript:void(0)"><img src = "'.$tool['image'].'" alt = "'.$tool['title'].'" title = "'.$tool['title'].'" border = "0" onclick = "'.$tool['action'].'(this, \''.urlencode($identifier).'\')" /></a> '; $toolsString .= '<a href = "javascript:void(0)"><img src = "' . $tool['image'] . '" alt = "' . $tool['title'] . '" title = "' . $tool['title'] . '" border = "0" onclick = "' . $tool['action'] . '(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)" /></a> '; } if (($value['extension'] == 'zip' || $value['extension'] == 'gz') && $options['zip']) { $toolsString .= '<a href = "javascript:void(0)"><img src = "images/16x16/uncompress.png" alt = "' . _UNCOMPRESS . '" title = "' . _UNCOMPRESS . '" border = "0" onclick = "uncompressFile(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)" /></a> '; } if ($options['download']) { $toolsString .= '<a href = "' . $url . '&download=' . urlencode($identifier) . '"><img src = "images/16x16/import.png" alt = "' . _DOWNLOADFILE . '" title = "' . _DOWNLOADFILE . '" border = "0"/></a> '; } if ($_SESSION['s_lessons_ID'] && $options['share']) { $sharedString = ' <img class = "ajaxHandle" src = "images/16x16/trafficlight_green.png" alt = "' . _UNSHARE . '" title = "' . _UNSHARE . '" onclick = "unshareFile(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)" style = "' . (!$value['shared'] ? 'display:none' : null) . '" /> <img class = "ajaxHandle" src = "images/16x16/trafficlight_red.png" alt = "' . _SHARE . '" title = "' . _SHARE . '" onclick = "shareFile(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)" style = "' . ($value['shared'] ? 'display:none' : null) . '" />'; } if ($options['metadata']) { $toolsString .= '<a href = "' . $url . '&popup=1&display_metadata=' . urlencode($identifier) . '" target = "POPUP_FRAME"><img src = "images/16x16/information.png" alt = "' . _METADATA . '" title = "' . _METADATA . '" onclick = "eF_js_showDivPopup(event, \'' . _METADATA . '\', 2)" border = "0"/></a> '; } if ($options['edit'] && ($_SESSION['s_type'] == 'administrator' || ($value['users_LOGIN'] == $_SESSION['s_login'] || in_array($value['users_LOGIN'], $supervisedLogins)) && isset($value['users_LOGIN']) || EfrontUser::isOptionVisible('allow_users_to_delete_supervisor_files'))) { $toolsString .= '<img class = "ajaxHandle edit" src = "images/16x16/edit.png" alt = "' . _EDIT . '" title = "' . _EDIT . '" onclick = "toggleEditBox(this, \'' . urlencode($identifier) . '\')"/> '; } if ($options['delete'] && ($_SESSION['s_type'] == 'administrator' || ($value['users_LOGIN'] == $_SESSION['s_login'] || in_array($value['users_LOGIN'], $supervisedLogins) || $value['users_LOGIN'] == "") || EfrontUser::isOptionVisible('allow_users_to_delete_supervisor_files'))) { $toolsString .= '<img class = "ajaxHandle" src = "images/16x16/error_delete.png" alt = "' . _DELETE . '" title = "' . _DELETE . '" onclick = "if (confirm(\'' . _IRREVERSIBLEACTIONAREYOUSURE . '\')) {deleteFile(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)}"/></a> '; } } else { if (is_dir($value['path'])) { $identifier = $value['path']; $value = new EfrontDirectory($value['path']); $link = $url . '&view_dir=' . urlencode($identifier); foreach ($extraDirectoryTools as $tool) { $toolsString .= '<a href = "javascript:void(0)"><img src = "' . $tool['image'] . '" alt = "' . $tool['title'] . '" title = "' . $tool['title'] . '" border = "0" onclick = "' . $tool['action'] . '(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)" /></a> '; } if ($options['edit']) { $toolsString .= '<img class = "ajaxHandle edit" src = "images/16x16/edit.png" alt = "' . _EDIT . '" title = "' . _EDIT . '" onclick = "toggleEditBox(this, \'' . urlencode($identifier) . '\')"/> '; } if ($options['delete']) { $toolsString .= '<img class = "ajaxHandle" src = "images/16x16/error_delete.png" alt = "' . _DELETE . '" title = "' . _DELETE . '" onclick = "if (confirm(\'' . _IRREVERSIBLEACTIONAREYOUSURE . '\')) {deleteFolder(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)}" /> '; } } } $filesCode .= '<tr class = "defaultRowHeight ' . (fmod($i++, 2) ? 'oddRowColor' : 'evenRowColor') . '">'; if ($options['show_type']) { $filesCode .= '<td class = "centerAlign"><span style = "display:none">' . (isset($value['extension']) ? $value['extension'] : '') . '</span>'; if ($value['type'] == 'file') { if (strpos($value['mime_type'], "image") !== false || strpos($value['mime_type'], "text") !== false || strpos($value['mime_type'], "pdf") !== false || strpos($value['mime_type'], "html") !== false || strpos($value['mime_type'], "video") !== false || strpos($value['mime_type'], "flash") !== false) { $filesCode .= '<a href = "javascript:void(0);" onclick = "eF_js_showDivPopup(event, \'' . _PREVIEW . '\', 2, \'preview_table_' . $tableId . '\');$(\'preview_frame\').src = \'' . $link . '\';" ><img src = "' . $value->getTypeImage() . '" alt = "' . $value['mime_type'] . '" title = "' . $value['mime_type'] . '" border = "0"/></a></td>'; } else { $filesCode .= '<a href = "' . $url . '&download=' . urlencode($identifier) . '"><img src = "' . $value->getTypeImage() . '" alt = "' . $value['mime_type'] . '" title = "' . $value['mime_type'] . '" border = "0"/></a>'; } } else { isset($value['mime_type']) ? $mimeType = $value['mime_type'] : ($mimeType = ''); $filesCode .= '<img src = "' . $value->getTypeImage() . '" alt = "' . $mimeType . '" title = "' . $mimeType . '" border = "0"/></td>'; } } if ($options['show_name']) { $filesCode .= '<td><span id = "span_' . urlencode($identifier) . '" style = "display:none;">' . urlencode($identifier) . '</span>'; if ($value['type'] == 'file') { if ($show_tooltip) { $filesCode .= $value->toHTMLTooltipLink($link, true, $tableId); } else { if (strpos($value['mime_type'], "image") !== false || strpos($value['mime_type'], "text") !== false || strpos($value['mime_type'], "pdf") !== false || strpos($value['mime_type'], "flash") !== false || strpos($value['mime_type'], "video") !== false) { $filesCode .= '<a href = "' . $link . '" target = "PREVIEW_FRAME" onclick = "eF_js_showDivPopup(event, \'' . _PREVIEW . '\', 2, \'preview_table_' . $tableId . '\');">' . $value['name'] . '</a>'; } else { $filesCode .= '<a target = "PREVIEW_FRAME" href = "' . $url . '&download=' . urlencode($identifier) . '">' . $value['name'] . '</a>'; } } } else { $filesCode .= '<a class="editLink" href = "javascript:void(0)" onclick = "eF_js_rebuildTable($(\'filename_' . $tableId . '\').down().getAttribute(\'tableIndex\'), 0, \'\', \'desc\', \'' . urlencode($identifier) . '\');">' . $value['name'] . '</a>'; } $filesCode .= '<span id = "edit_' . urlencode($identifier) . '" style = "display:none"><input type = "text" value = "' . $value['name'] . '" onkeypress = "if (event.which == 13 || event.keyCode == 13) {Element.extend(this).next().down().onclick(); return false;}"/> <a href = "javascript:void(0)"><img id = "editImage_' . urlencode($identifier) . '"src = "images/16x16/success.png" style = "vertical-align:middle" onclick = "editFile(this, $(\'span_' . urlencode($identifier) . '\').innerHTML, Element.extend(this).up().previous().value, \'' . $value['type'] . '\',\'' . eF_addslashes($value['name']) . '\')" border = "0"></a></span></td>'; } $extraColumnsString = ''; foreach ($extraColumns as $column) { $extraColumnsString = '<td class = "centerAlign">' . $value[$column] . '</td>'; } $filesCode .= '' . ($options['show_size'] ? '<td>' . ($value['type'] == 'file' ? $value['size'] . ' ' . _KB : '') . '</td>' : '') . ' ' . ($options['show_date'] ? '<td>' . formatTimestamp($value['timestamp'], 'time_nosec') . '</td>' : '') . ' ' . $extraColumnsString . ' ' . ($_SESSION['s_lessons_ID'] && $options['share'] ? '<td class = "centerAlign">' . $sharedString . '</td>' : '') . ' ' . ($options['show_tools'] ? '<td class = "centerAlign">' . $toolsString . '</td>' : '') . ' ' . ($options['delete'] || $_SESSION['s_lessons_ID'] && $options['share'] ? '<td class = "centerAlign">' . ($value['type'] == 'file' ? '<input type = "checkbox" id = "' . $identifier . '" value = "' . $identifier . '" />' : '') . '</td>' : '') . ' </tr>'; } $massOperationsCode = ''; if ($size) { $filesCode .= ' </table>'; if ($options['delete'] || $_SESSION['s_lessons_ID'] && $options['share']) { $massOperationsCode = ' <div class = "horizontalSeparatorAbove"> <span style = "vertical-align:middle">' . _WITHSELECTEDFILES . ':</span> ' . ($_SESSION['s_lessons_ID'] && $options['share'] ? '<a href = "javascript:void(0)"><img src = "images/16x16/trafficlight_green.png" title = "' . _SHARESELECTED . '" alt = "' . _SHARESELECTED . '" border = "0" style = "vertical-align:middle" onclick = "shareSelected()"></a><a href = "javascript:void(0)"><img src = "images/16x16/trafficlight_red.png" title = "' . _UNSHARESELECTED . '" alt = "' . _UNSHARESELECTED . '" border = "0" style = "vertical-align:middle" onclick = "unshareSelected()"></a>' : ''); if ($options['copy']) { $massOperationsCode .= ' <form name = "copy_files_form" id = "copy_files_form" method = "post" style = "display:none;"><input type = "hidden" name = "copy_current_directory" id = "copy_current_directory"><input type = "hidden" name = "copy_files" id = "copy_files" value = "" /></form> <img class = "ajaxHandle" src = "images/16x16/copy.png" title = "' . _COPYSELECTED . '" alt = "' . _COPYSELECTED . '" onclick = "copyFiles(this);"> <img style = "display:none" class = "ajaxHandle" src = "images/16x16/paste.png" title = "' . _PASTESELECTED . '" alt = "' . _PASTESELECTED . '" onclick = "pasteFiles(this, \'' . $tableId . '\');"> '; } $massOperationsCode .= ($options['delete'] ? '<a href = "javascript:void(0)"><img src = "images/16x16/error_delete.png" title = "' . _DELETESELECTED . '" alt = "' . _DELETESELECTED . '" border = "0" style = "vertical-align:middle" onclick = "if (confirm(\'' . _IRREVERSIBLEACTIONAREYOUSURE . '\')) deleteSelected()"></a>' : '') . ' </div>'; } } elseif (!isset($parentDir)) { //Don't display 'no data found' if in subdirectory, because it doesn't show up well with the .. (up one level) $filesCode .= ' <tr class = "oddRowColor defaultRowHeight"><td colspan = "100%" class = "emptyCategory">' . _NODATAFOUND . '</td></tr> </table>'; } $str = ' <div class = "headerTools">'; if ($options['upload']) { $str .= ' <span> <img src = "images/16x16/add.png" alt = "' . _UPLOADFILE . '" title = "' . _UPLOADFILE . '"/> <a href = "javascript:void(0)" onclick = "$(\'url_upload\').value = \'\';$$(\'input\').each(function(s) {if (s.type == \'file\') s.value = \'\'});$(\'upload_current_directory\').value = $(\'' . $tableId . '\').getAttribute(\'currentDir\');eF_js_showDivPopup(event, \'' . _UPLOADFILE . '\', 0, \'upload_file_table_' . $tableId . '\')">' . _UPLOADFILE . '</a> </span>'; } if ($options['create_folder']) { $str .= ' <span> <img src = "images/16x16/folder_add.png" alt = "' . _CREATEFOLDER . '" title = "' . _CREATEFOLDER . '"> <a href = "javascript:void(0)" onclick = "$(\'current_directory\').value = $(\'' . $tableId . '\').getAttribute(\'currentDir\');eF_js_showDivPopup(event, \'' . _CREATEFOLDER . '\', 0, \'create_directory_table_' . $tableId . '\')">' . _CREATEFOLDER . '</a> </span>'; } foreach ($extraHeaderOptions as $option) { $str .= ' <span> <img src = "' . $option['image'] . '" alt = "' . $option['title'] . '" title = "' . $option['title'] . '"> <a href = "' . (isset($option['href']) ? $option['href'] : 'javascript:void(0)') . '" onclick = "' . $option['action'] . '">' . $option['title'] . '</a> </span>'; } $str .= ' </div> <table style = "width:100%"> <tr><td> <!--ajax:' . $tableId . '--> ' . $filesCode . ' <!--/ajax:' . $tableId . '--> ' . $massOperationsCode . ' </td></tr> </table> <script> var url = "' . $url . '"; var tableId = "' . $tableId . '"; </script> <div id = "upload_file_table_' . $tableId . '" style = "display:none;" class = "filemanagerBlock">' . $uploadFormString . '</div> <div id = "create_directory_table_' . $tableId . '" style = "display:none;" class = "filemanagerBlock">' . $createFolderString . '</div> <div id = "preview_table_' . $tableId . '" style = "height:100%;display:none" class = "filemanagerBlock"> <iframe name = "PREVIEW_FRAME" id = "preview_frame" src = "about:blank" style = "border-width:0px;width:100%;height:400px;padding:0px 0px 0px 0px">Sorry, but your browser needs to support iframes to see this</iframe> </div>'; /* $GLOBALS['smarty'] -> assign("T_BLOCK_DATA", $uploadFormString); $GLOBALS['smarty'] -> assign("T_DISPLAY_BLOCK", '<div id = "upload_file_table_'.$tableId.'" style = "display:none;">{eF_template_printBlock title="'._UPLOADFILE.'" data=$T_BLOCK_DATA image="32x32/import.png"}</div>'); $str .= $GLOBALS['smarty'] -> fetch("display_code.tpl"); $GLOBALS['smarty'] -> assign("T_BLOCK_DATA", $createFolderString); $GLOBALS['smarty'] -> assign("T_DISPLAY_BLOCK", '<div id = "create_directory_table_'.$tableId.'" style = "display:none;">{eF_template_printBlock title="'._CREATEFOLDER.'" data=$T_BLOCK_DATA image="32x32/folder.png"}</div>'); $str .= $GLOBALS['smarty'] -> fetch("display_code.tpl"); $GLOBALS['smarty'] -> assign("T_DISPLAY_BLOCK", '<div id = "preview_table_'.$tableId.'" style = "display:none">{eF_template_printBlock title="'._PREVIEW.'" data="<iframe name = \"PREVIEW_FRAME\" id = \"preview_frame\" src = \"about:blank\" style = \"border-width:0px;width:100%;height:100%;padding:0px\">Sorry, but your browser needs to support iframes to see this</iframe>" image="32x32/folder.png"}</div>'); $str .= $GLOBALS['smarty'] -> fetch("display_code.tpl"); */ return $str; }
private function getAjaxResults() { $smarty = $this->getSmartyVar(); $vLabData = eF_getTableData("module_vLab_data", "*"); isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'uint') ? $limit = $_GET['limit'] : ($limit = G_DEFAULT_TABLE_SIZE); if (isset($_GET['sort']) && eF_checkParameter($_GET['sort'], 'text')) { $sort = $_GET['sort']; isset($_GET['order']) && $_GET['order'] == 'desc' ? $order = 'desc' : ($order = 'asc'); } else { $sort = 'login'; } $vLabData = eF_multiSort($vLabData, $sort, $order); $smarty->assign("T_TABLE_SIZE", sizeof($vLabData)); if (isset($_GET['filter'])) { $vLabData = eF_filterData($vLabData, $_GET['filter']); } if (isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'int')) { isset($_GET['offset']) && eF_checkParameter($_GET['offset'], 'int') ? $offset = $_GET['offset'] : ($offset = 0); $vLabData = array_slice($vLabData, $offset, $limit); } $smarty->assign("T_DATA_SOURCE", $vLabData); }
private function handlePostAjaxRequestForUsersRemoveAll() { $constraints = array('archive' => false, 'active' => true, 'condition' => 'uc.courses_ID is not null'); $users = $this->getCourseUsersIncludingUnassigned($constraints); $users = EfrontUser::convertUserObjectsToArrays($users); isset($_GET['filter']) ? $users = eF_filterData($users, $_GET['filter']) : null; $this->archiveCourseUsers(array_keys($users)); // Delete notifications related to the users and this course foreach ($users as $login => $value) { $notifications_to_delete = eF_getTableData("notifications", "id", "recipient='" . $login . "' AND id_type_entity LIKE '%_%_" . $this->course['id'] . "'"); foreach ($notifications_to_delete as $notification) { eF_deleteTableData("notifications", "id = '" . $notification['id'] . "'"); } } }
} } } } } if ($found) { $employees = eF_getTableData($dif_tables, "users.*", $search_string, ""); // @todo: problem with professors in one and students in another course foreach ($employees as $userId => $employee) { if ($employee['user_type'] != 'student') { unset($employees[$userId]); } } $employees = eF_multiSort($employees, $_GET['sort'], $order); if (isset($_GET['filter'])) { $employees = eF_filterData($employees, $_GET['filter']); } $smarty->assign("T_EMPLOYEES_SIZE", sizeof($employees)); if (isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'int')) { isset($_GET['offset']) && eF_checkParameter($_GET['offset'], 'int') ? $offset = $_GET['offset'] : ($offset = 0); $employees = array_slice($employees, $offset, $limit); } } else { $employees = array(); } $recipients = basename($_SERVER['PHP_SELF']) . "?ctg=messages&add=1&recipient="; $first = 1; foreach ($employees as $employee) { if ($first) { $recipients .= $employee['login']; $first = 0;
function eF_filterHcdData($dataSource, $filter, $userField = false) { $filters = trim(urldecode(explode("||||", $filter))); if ($filters[0] != "" && $filters[0] != _FILTER . "...") { $dataSource = eF_filterData($dataSource, $filters[0]); // the default filter } if ($filters[1] != "" && $filters[1] != "all") { $branchFilterExtraTable = " JOIN module_hcd_employee_works_at_branch ON module_hcd_employee_works_at_branch.users_login = users.login "; $branchFilterCondition = " AND module_hcd_employee_works_at_branch.branch_ID = '" . $filters[1] . "' AND module_hcd_employee_works_at_branch.assigned = 1"; $enterprise_filters = true; } if ($filters[2] != "" && $filters[2] != _ALLJOBS) { $jobFilterExtraTable = " LEFT OUTER JOIN module_hcd_employee_has_job_description ON module_hcd_employee_has_job_description.users_login = users.login JOIN module_hcd_job_description ON module_hcd_job_description.job_description_ID = module_hcd_employee_has_job_description.job_description_ID "; $jobFilterCondition = " AND module_hcd_job_description.description = '" . $filters[2] . "'"; $enterprise_filters = true; } if ($enterprise_filters) { if (!$userField) { $userField = 'login'; } $all_users_logins = array(); foreach ($dataSource as $key => $data) { $all_users_logins[] = $data[$userField]; // get only users that are actually in the table - limit returned results } $filtered_users = eF_getTableDataFlat("users {$branchFilterExtraTable} {$jobFilterExtraTable}", "users.login", "users.login IN ('" . implode("','", $all_users_logins) . "') {$branchFilterCondition} {$jobFilterCondition}"); foreach ($dataSource as $key => $data) { if (!in_array($data[$userField], $filtered_users['login'])) { unset($dataSource[$key]); } } } return $dataSource; }
public function getModule() { $currentUser = $this->getCurrentUser(); // Get smarty global variable $smarty = $this->getSmartyVar(); $userRole = $currentUser->getRole($this->getCurrentLesson()); // If user is admin if ($currentUser->getType() == "administrator") { // Create form $form = new HTML_QuickForm("BBB_server_entry_form", "post", $_SERVER['REQUEST_URI'], "", null, true); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); //Register this rule for checking user input with our function, eF_checkParameter $form->addElement('text', 'server', null, 'class = "inputText" id="server_input"'); $form->addRule('server', _BBBTHEFIELDNAMEISMANDATORY, 'required', null, 'client'); $form->addElement('text', 'salt', null, 'class = "inputText" id="salt_input"'); $form->addElement('text', 'logout_url', null, 'class = "inputText" id="logout_url_input"'); $form->addElement('checkbox', 'serverVersion', null); $form->addElement('submit', 'submit_BBB_server', _SUBMIT, 'class = "flatButton"'); // if form isSubmitted if ($form->isSubmitted() && $form->validate()) { $server_name = $form->exportValue('server'); $salt_string = $form->exportValue('salt'); $version_choice = $form->exportValue('serverVersion'); $logout_url = $form->exportValue('logout_url'); if ($server_name[strlen($server_name) - 1] == "/") { $server_name = substr($server_name, 0, strlen($server_name) - 1); } // register BBB configuration values EfrontConfiguration::setValue("module_BBB_server", $server_name); EfrontConfiguration::setValue("module_BBB_salt", $salt_string); EfrontConfiguration::setValue("module_BBB_server_version", $version_choice); EfrontConfiguration::setValue("module_BBB_logout_url", $logout_url); $this->setMessageVar(_BBB_SUCCESFULLYCHANGEDSERVER, "success"); } $form->setDefaults(array('server' => $this->getBBBServer())); $form->setDefaults(array('salt' => $this->getBBBSalt())); $form->setDefaults(array('serverVersion' => $this->getBBBServerVer())); $form->setDefaults(array('logout_url' => $this->getBBBLogoutUrl())); //echo 'My server version is 0.7+: '.$this -> getBBBServerVer(); $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); $form->accept($renderer); $smarty->assign('T_BBB_FORM', $renderer->toArray()); } /*** Ajax Methods - Add/remove skills/jobs***/ if (isset($_GET['postAjaxRequest'])) { /** Post skill - Ajax skill **/ if (eF_checkParameter($_GET['edit_BBB'], 'id') === false) { header("HTTP/1.0 500 "); echo _UNPRIVILEGEDATTEMPT; exit; } if ($_GET['insert'] == "true") { // Adding a user to a conference eF_insertTableData("module_BBB_users_to_meeting", array('users_LOGIN' => $_GET['user'], 'meeting_ID' => $_GET['edit_BBB'])); } else { if ($_GET['insert'] == "false") { // Removing a user from a conference eF_deleteTableData("module_BBB_users_to_meeting", "users_LOGIN = '******'user'] . "' AND meeting_ID = '" . $_GET['edit_BBB'] . "'"); } else { if (isset($_GET['addAll'])) { // Add all users to a conference $users = eF_getTableData("users JOIN users_to_lessons ON users.login = users_to_lessons.users_LOGIN LEFT OUTER JOIN module_BBB_users_to_meeting ON users.login = module_BBB_users_to_meeting.users_LOGIN", "users.login, users.name, users.surname, meeting_ID", "users_to_lessons.lessons_ID = '" . $_SESSION['s_lessons_ID'] . "' AND (meeting_ID <> '" . $_GET['edit_BBB'] . "' OR meeting_ID IS NULL)"); $users_attending = eF_getTableDataFlat("users JOIN users_to_lessons ON users.login = users_to_lessons.users_LOGIN LEFT OUTER JOIN module_BBB_users_to_meeting ON users.login = module_BBB_users_to_meeting.users_LOGIN", "users.login", "users_to_lessons.lessons_ID = '" . $_SESSION['s_lessons_ID'] . "' AND meeting_ID = '" . $_GET['edit_BBB'] . "'"); isset($_GET['filter']) ? $users = eF_filterData($users, $_GET['filter']) : null; $users_attending = $users_attending['login']; foreach ($users as $user) { if (!in_array($user['login'], $users_attending)) { eF_insertTableData("module_BBB_users_to_meeting", array('users_LOGIN' => $user['login'], 'meeting_ID' => $_GET['edit_BBB'])); $users_attending[] = $user['login']; } } } else { if (isset($_GET['removeAll'])) { // Remove all users from a conference $users_attending = eF_getTableData("users JOIN users_to_lessons ON users.login = users_to_lessons.users_LOGIN LEFT OUTER JOIN module_BBB_users_to_meeting ON users.login = module_BBB_users_to_meeting.users_LOGIN", "users.login", "users_to_lessons.lessons_ID = '" . $_SESSION['s_lessons_ID'] . "' AND meeting_ID = '" . $_GET['edit_BBB'] . "'"); //$users_attending = $users_attending['login']; isset($_GET['filter']) ? $users_attending = eF_filterData($users_attending, $_GET['filter']) : null; $users_to_delete = array(); foreach ($users_attending as $user) { $users_to_delete[] = $user['login']; } eF_deleteTableData("module_BBB_users_to_meeting", "meeting_ID = '" . $_GET['edit_BBB'] . "' AND users_LOGIN IN ('" . implode("','", $users_to_delete) . "')"); } else { if (isset($_GET['mail_users']) && $_GET['mail_users'] == 1) { $currentLesson = $this->getCurrentLesson(); $meeting_users = eF_getTableData("module_BBB_users_to_meeting JOIN users ON module_BBB_users_to_meeting.users_LOGIN = users.login", "users.login, users.name, users.surname, users.email", "meeting_ID = " . $_GET['edit_BBB'] . " AND users.login <> '" . $currentUser->user['login'] . "'"); isset($_GET['filter']) ? $meeting_users = eF_filterData($meeting_users, $_GET['filter']) : null; $meeting_info = eF_getTableData("module_BBB", "*", "id = " . $_GET['edit_BBB']); $subject = _BBB_MEETING; $count = 0; foreach ($meeting_users as $user) { $body = _BBB_DEAR . " " . $user['name'] . ",\n\n" . _BBB_YOUHAVEBEENINVITEDBYPROFESSOR . " " . $currentUser->user['name'] . " " . $currentUser->user['surname'] . " " . _BBB_TOATTENDACONFERENCE . " \"" . $meeting_info[0]['name'] . "\" " . _BBB_FORLESSON . " \"" . $currentLesson->lesson['name'] . "\" " . _BBB_SCHEDULEDFOR . "\n\n" . date("D d.m.y, g:i a", $meeting_info[0]['timestamp']) . "\n\n" . _BBBYOUCANJOINTHEMEETINGDIRECTLYBYCLICKINGTHEFOLLOWINGLINKAFTERITSTARTS . ":\n\n"; $userObject = EfrontUserFactory::factory($user['login']); //$body .= $this -> createBBBUrl($userObject, $meeting_info[0], true); $body .= "\n\n" . _BBB_SINCERELY . ",\n" . $currentUser->user['name'] . " " . $currentUser->user['surname']; $my_email = $currentUser->user['email']; $user_mail = $user['email']; $header = array('From' => $GLOBALS['configuration']['system_email'], 'To' => $user_mail, 'Subject' => $subject, 'Content-type' => 'text/plain;charset="UTF-8"', 'Content-Transfer-Encoding' => '7bit'); $smtp = Mail::factory('smtp', array('auth' => $GLOBALS['configuration']['smtp_auth'] ? true : false, 'host' => $GLOBALS['configuration']['smtp_host'], 'password' => $GLOBALS['configuration']['smtp_pass'], 'port' => $GLOBALS['configuration']['smtp_port'], 'username' => $GLOBALS['configuration']['smtp_user'], 'timeout' => $GLOBALS['configuration']['smtp_timeout'])); if ($smtp->send($user_mail, $header, $body)) { $count++; } } echo $count; exit; } } } } } } // The form with all students clicked or not is posted //pr($_GET); if (isset($_GET['start_meeting']) && eF_checkParameter($_GET['start_meeting'], 'id')) { $BBB_server = $this->getBBBServer(); if ($BBB_server != "") { $BBB = eF_getTableData("module_BBB", "*", "id=" . $_GET['start_meeting']); if ($BBB[0]['status'] != 2) { $BBBUrl = $this->createBBBUrl($currentUser, $BBB[0]); $smarty->assign("T_BBB_CREATEMEETINGURL", $BBBurl); // TESTING if ($currentUser->getRole($this->getCurrentLesson()) == "professor" && $meeting_info['status'] == 0) { eF_updateTableData("module_BBB", array('status' => '1'), "id=" . $_GET['start_meeting']); } //echo $BBBUrl."<BR>"; header("location:" . $BBBUrl); } else { $this->setMessageVar(_BBBMEETINGHASFINISHED, "failure"); } } else { $this->setMessageVar(_BBB_NOBBBSERVERDEFINED, "failure"); } } if (isset($_GET['finished_meeting']) && eF_checkParameter($_GET['finished_meeting'], 'id')) { if ($userRole == "professor") { eF_updateTableData("module_BBB", array('status' => '2'), "id=" . $_GET['finished_meeting']); } $currentLesson = $this->getCurrentLesson(); $_SESSION['previousSideUrl'] = G_SERVERNAME . "new_sidebar.php?new_lesson_id=" . $currentLesson->lesson['id']; $_SESSION['previousMainUrl'] = G_SERVERNAME . $currentUser->getType() . ".php?ctg=control_panel"; header("location:" . $currentUser->getType() . "page.php"); } if (isset($_GET['delete_BBB']) && eF_checkParameter($_GET['delete_BBB'], 'id') && $userRole == "professor") { eF_deleteTableData("module_BBB", "id=" . $_GET['delete_BBB']); eF_deleteTableData("module_BBB_users_to_meeting", "meeting_ID=" . $_GET['delete_BBB']); header("location:" . $this->moduleBaseUrl . "&message=" . urlencode(_BBB_SUCCESFULLYDELETEDBBBENTRY) . "&message_type=success"); } else { if ($userRole == "professor" && (isset($_GET['add_BBB']) || isset($_GET['edit_BBB']) && eF_checkParameter($_GET['edit_BBB'], 'id'))) { // Create ajax enabled table for meeting attendants if (isset($_GET['edit_BBB'])) { if (isset($_GET['ajax']) && $_GET['ajax'] == 'BBBUsersTable') { isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'uint') ? $limit = $_GET['limit'] : ($limit = G_DEFAULT_TABLE_SIZE); if (isset($_GET['sort']) && eF_checkParameter($_GET['sort'], 'text')) { $sort = $_GET['sort']; isset($_GET['order']) && $_GET['order'] == 'desc' ? $order = 'desc' : ($order = 'asc'); } else { $sort = 'login'; } $users = eF_getTableData("users JOIN users_to_lessons ON users.login = users_to_lessons.users_LOGIN\n JOIN module_BBB ON module_BBB.lessons_ID = users_to_lessons.lessons_ID\n LEFT OUTER JOIN module_BBB_users_to_meeting ON module_BBB.id = module_BBB_users_to_meeting.meeting_ID AND users.login = module_BBB_users_to_meeting.users_LOGIN", "users.login, users.name, users.surname, users.email, meeting_ID", "users_to_lessons.lessons_ID = '" . $_SESSION['s_lessons_ID'] . "' AND users.login <> '" . $currentUser->user['login'] . "' AND module_BBB.id = '" . $_GET['edit_BBB'] . "'"); $users = eF_multiSort($users, $_GET['sort'], $order); if (isset($_GET['filter'])) { $users = eF_filterData($users, $_GET['filter']); } $smarty->assign("T_USERS_SIZE", sizeof($users)); if (isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'int')) { isset($_GET['offset']) && eF_checkParameter($_GET['offset'], 'int') ? $offset = $_GET['offset'] : ($offset = 0); $users = array_slice($users, $offset, $limit); } $smarty->assign("T_USERS", $users); $smarty->display($this->getSmartyTpl()); exit; } else { $users = eF_getTableData("users JOIN users_to_lessons ON users.login = users_to_lessons.users_LOGIN\n JOIN module_BBB ON module_BBB.lessons_ID = users_to_lessons.lessons_ID\n LEFT OUTER JOIN module_BBB_users_to_meeting ON module_BBB.id = module_BBB_users_to_meeting.meeting_ID AND users.login = module_BBB_users_to_meeting.users_LOGIN", "users.login, users.name, users.surname, meeting_ID", "users_to_lessons.lessons_ID = '" . $_SESSION['s_lessons_ID'] . "' AND users.login <> '" . $currentUser->user['login'] . "' AND module_BBB.id = '" . $_GET['edit_BBB'] . "'"); $smarty->assign("T_USERS", $users); } } $form = new HTML_QuickForm("BBB_entry_form", "post", $_SERVER['REQUEST_URI'] . "&tab=users", "", null, true); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); //Register this rule for checking user input with our function, eF_checkParameter $form->addElement('text', 'name', null, 'class = "inputText"'); $form->addRule('name', _BBBTHEFIELDNAMEISMANDATORY, 'required', null, 'client'); // Dates $days = array(); for ($i = 1; $i < 32; $i++) { $days[$i] = $i; } $months = array(); for ($i = 1; $i <= 12; $i++) { $months[$i] = $i; } $years = array(); for ($i = 2008; $i < 2015; $i++) { $years[$i] = $i; } $hours = array(); for ($i = 0; $i <= 9; $i++) { $hours[$i] = "0" . $i; } for ($i = 10; $i <= 23; $i++) { $hours[$i] = $i; } $minutes = array(); $minutes[0] = "00"; for ($i = 15; $i < 60; $i += 15) { $minutes[$i] = $i; } $duration_hours = array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5); $form->addElement('select', 'day', null, $days, 'id="day"'); $form->addElement('select', 'month', null, $months, 'id="month"'); $form->addElement('select', 'year', null, $years, 'id="year"'); $form->addElement('select', 'hour', null, $hours, 'id="hour"'); $form->addElement('select', 'minute', null, $minutes, 'id="minute"'); $form->addElement('select', 'duration_hours', null, $duration_hours, 'id="duration_hours"'); $form->addElement('select', 'duration_minutes', null, $minutes, 'id="duration_minute"'); $form->addElement('select', 'lobby', _BBBUSELOBBYROOM, array("0" => _YES, "1" => _NO), 'id="lobbyId"'); $form->addElement('select', 'presenterAV', _BBBPRESENTERAV, array("0" => _BBBAUDIOVIDEO, "1" => _BBBAUDIOONLY), 'id="presenterAvID"'); $currentLesson = $this->getCurrentLesson(); $students = eF_getTableData("users_to_lessons", "count(users_LOGIN) as total_students", "lessons_ID = '" . $currentLesson->lesson['id'] . "'"); $total_students = $students[0]['total_students']; $students_count = array(); for ($i = 1; $i <= $total_students; $i++) { $students_count[$i] = $i; } $form->addElement('select', 'maxParticipants', _BBBMAXPARTICIPANTS, $students_count, ''); $form->addElement('select', 'maxMics', _BBBMAXMICS, $students_count, ''); $form->addElement('submit', 'submit_BBB', _SUBMIT, 'class = "flatButton"'); if (isset($_GET['edit_BBB'])) { $BBB_entry = eF_getTableData("module_BBB", "*", "id=" . $_GET['edit_BBB']); $timestamp_info = getdate($BBB_entry[0]['timestamp']); $form->setDefaults(array('name' => $BBB_entry[0]['name'], 'presenterAV' => $BBB_entry[0]['confType'], 'maxParticipants' => $BBB_entry[0]['maxParticipants'], 'maxMics' => $BBB_entry[0]['maxMics'], 'lobby' => $BBB_entry[0]['lobby'], 'lessons_ID' => $BBB_entry[0]['lessons_ID'])); } else { $timestamp_info = getdate(time()); $timestamp_info['minutes'] = $timestamp_info['minutes'] - $timestamp_info['minutes'] % 15; } $form->setDefaults(array('day' => $timestamp_info['mday'], 'month' => $timestamp_info['mon'], 'year' => $timestamp_info['year'], 'hour' => $timestamp_info['hours'], 'minute' => $timestamp_info['minutes'], 'maxParticipants' => $BBB_entry[0]['maxParts'] > 0 && $BBB_entry[0]['maxParts'] < $total_students ? $BBB_entry[0]['maxParts'] : $total_students, 'maxMics' => $BBB_entry[0]['maxMics'] > 0 && $BBB_entry[0]['maxMics'] < $total_students ? $BBB_entry[0]['maxMics'] : $total_students)); if ($form->isSubmitted() && $form->validate()) { if (eF_checkParameter($form->exportValue('name'), 'text')) { $smarty = $this->getSmartyVar(); $currentLesson = $this->getCurrentLesson(); $timestamp = mktime($form->exportValue('hour'), $form->exportValue('minute'), 0, $form->exportValue('month'), $form->exportValue('day'), $form->exportValue('year')); $fields = array('name' => $form->exportValue('name'), 'timestamp' => $timestamp, 'lessons_ID' => $currentLesson->lesson['id'], 'durationHours' => $form->exportValue('duration_hours'), 'durationMinutes' => $form->exportValue('duration_minutes'), 'confType' => $form->exportValue('presenterAV'), 'maxParts' => $form->exportValue('maxParticipants') > 0 ? $form->exportValue('maxParticipants') : 20, 'maxMics' => $form->exportValue('maxMics'), 'lobby' => $form->exportValue('lobby')); if (isset($_GET['edit_BBB'])) { if (eF_updateTableData("module_BBB", $fields, "id=" . $_GET['edit_BBB'])) { header("location:" . $this->moduleBaseUrl . "&message=" . urlencode(_BBB_SUCCESFULLYUPDATEDBBBENTRY) . "&message_type=success"); } else { header("location:" . $this->moduleBaseUrl . "&message=" . urlencode(_BBB_PROBLEMUPDATINGBBBENTRY) . "&message_type=failure"); } } else { // The key will be the current time when the event was set concatenated with the initial timestamp for the meeting // If the latter changes after an event editing the key will not be changed $fields['confKey'] = $currentLesson->lesson['id'] . time() . $timestamp; if ($result = eF_insertTableData("module_BBB", $fields)) { header("location:" . $this->moduleBaseUrl . "&edit_BBB=" . $result . "&message=" . urlencode(_BBB_SUCCESFULLYINSERTEDBBBENTRY) . "&message_type=success&tab=users"); } else { header("location:" . $this->moduleBaseUrl . "&message=" . urlencode(_BBB_PROBLEMINSERTINGBBBENTRY) . "&message_type=failure"); } } } else { header("location:" . $this->moduleBaseUrl . "&message=" . urlencode(_BBB_PROBLEMINSERTINGBBBENTRY) . "&message_type=failure"); } } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); $form->accept($renderer); $smarty->assign('T_BBB_FORM', $renderer->toArray()); } else { $currentUser = $this->getCurrentUser(); $currentLesson = $this->getCurrentLesson(); if ($currentUser->getRole($this->getCurrentLesson()) == "professor") { $BBB = eF_getTableData("module_BBB", "*", "lessons_ID = '" . $currentLesson->lesson['id'] . "'"); $smarty->assign("T_BBB_CURRENTLESSONTYPE", "professor"); } else { $BBB = eF_getTableData("module_BBB_users_to_meeting JOIN module_BBB ON id = meeting_ID", "*", "lessons_ID = '" . $currentLesson->lesson['id'] . "' AND users_LOGIN='******'login'] . "'"); $smarty->assign("T_BBB_CURRENTLESSONTYPE", "student"); } $now = time(); foreach ($BBB as $key => $meeting) { if ($meeting['timestamp'] < $now) { $BBB[$key]['mayStart'] = 1; $BBB[$key]['joiningUrl'] = $this->createBBBUrl($currentUser, $meeting, true); $smarty->assign("T_BBB_CREATEMEETINGURL", $BBB[$key]['joiningUrl']); // TESTING } else { $BBB[$key]['mayStart'] = 0; } } //pr($BBB); $smarty->assign("T_BBB", $BBB); $smarty->assign("T_USERINFO", $currentUser->user); } } return true; }
$currentTest->addQuestions($questions_to_add); } else { if (isset($_GET['removeAll'])) { $testQuestions = $currentTest->getQuestions(); if ($skillgap_tests) { // Create a field to simulate the values appearing under the Associated with column of skillgap tests foreach ($testQuestions as $qid => $testQuestion) { if ($testQuestion['lessons_ID'] == 0) { $testQuestions[$qid]['name'] = _SKILLGAPTESTS; } else { $lesson = new EfrontLesson($testQuestion['lessons_ID']); $testQuestions[$qid]['name'] = _LESSON . ": " . $lesson->lesson['name']; } } } isset($_GET['filter']) ? $testQuestions = eF_filterData($testQuestions, $_GET['filter']) : null; $currentTest->removeQuestions(array_keys($testQuestions)); } } } unset($currentTest->options['random_test']); $currentTest->persist(); //ArrayObject is required in order for json to work well with prototype $stats = new ArrayObject($currentTest->questionsInfo()); $stats['difficulties'] = new ArrayObject($stats['difficulties']); $stats['types'] = new ArrayObject($stats['types']); $stats['percentage'] = new ArrayObject($stats['percentage']); $stats['duration'] = eF_convertIntervalToTime($stats['total_duration']); $stats['random_pool'] = $currentTest->options['random_pool']; $stats['test_duration'] = $currentTest->options['duration']; header("content-type:application/json");
$directionPaths = $directionsTree->toPathString(); $smarty->assign("T_DIRECTIONS_PATHS", $directionPaths); $constraints = array('archive' => false, 'condition' => "creator_LOGIN='******'s_login']}'") + createConstraintsFromSortedTable(); $dataSource = EfrontLesson::getAllLessons($constraints); $totalEntries = EfrontLesson::countAllLessons($constraints); $tableName = $_GET['ajax']; $alreadySorted = 1; $smarty->assign("T_TABLE_SIZE", $totalEntries); include "sorted_table.php"; isset($_GET['limit']) ? $limit = $_GET['limit'] : ($limit = G_DEFAULT_TABLE_SIZE); if (isset($_GET['sort'])) { isset($_GET['order']) ? $order = $_GET['order'] : ($order = 'asc'); $lessons = eF_multiSort($lessons, $_GET['sort'], $order); } if (isset($_GET['filter'])) { $lessons = eF_filterData($lessons, $_GET['filter']); } $smarty->assign("T_LESSONS_SIZE", sizeof($lessons)); if (isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'int')) { isset($_GET['offset']) && eF_checkParameter($_GET['offset'], 'int') ? $offset = $_GET['offset'] : ($offset = 0); $lessons = array_slice($lessons, $offset, $limit); } foreach ($lessons as $key => $lesson) { $obj = new EfrontLesson($lesson); //$lessons[$key]['link'] = $obj -> toHTMLTooltipLink(basename($_SERVER['PHP_SELF']).'?ctg=professor_lessons&edit_lesson='.$lesson['id']); $lessons[$key]['direction_name'] = $directionPaths[$lesson['directions_ID']]; $lessons[$key]['price_string'] = $obj->lesson['price_string']; //$lessons[$key]['students'] = sizeof($obj -> getUsers('student')); } $smarty->assign("T_LESSONS_DATA", $lessons); $smarty->display('professor.tpl');
unset($courses[$key]); } } } } $courses = array_values($courses); //Reindex so that sorting works $roles = EfrontLessonUser::getLessonsRoles(true); $smarty->assign("T_ROLES_ARRAY", $roles); isset($_GET['limit']) ? $limit = $_GET['limit'] : ($limit = G_DEFAULT_TABLE_SIZE); if (isset($_GET['sort'])) { isset($_GET['order']) ? $order = $_GET['order'] : ($order = 'asc'); $courses = eF_multiSort($courses, $_GET['sort'], $order); } if (isset($_GET['filter'])) { $courses = eF_filterData($courses, $_GET['filter']); } $smarty->assign("T_COURSES_SIZE", sizeof($courses)); if (isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'int')) { isset($_GET['offset']) && eF_checkParameter($_GET['offset'], 'int') ? $offset = $_GET['offset'] : ($offset = 0); $courses = array_slice($courses, $offset, $limit); } //foreach ($courses as $key => $course) { //$courses[$key]['languages_NAME'] = $languages[$course['languages_NAME']]; //} $smarty->assign("T_COURSES_DATA", $courses); $smarty->display($_SESSION['s_type'] . '.tpl'); exit; } // We change a bit the following typical query to acquire the latest options values for the test - in case a threshold has been changed $result = EfrontCompletedTest::retrieveCompletedTest("completed_tests ct JOIN completed_tests_blob ctb on ct.id=ctb.completed_tests_ID JOIN tests t ON t.id = ct.tests_ID", "ct.*, ctb.test, t.options", "ct.status != 'deleted' and ct.id = '" . $_GET['show_solved_test'] . "'");
/*do nothing, it doesn't matter*/ } if (isset($_GET['filter'])) { foreach ($lessons as $value) { $lessonNames[$value->lesson['id']] = array('name' => $value->lesson['name']); } $filtered = array_keys(eF_filterData($lessonNames, $_GET['filter'])); foreach ($lessons as $key => $value) { if (!in_array($key, $filtered)) { unset($lessons[$key]); } } foreach ($courses as $value) { $courseNames[$value->course['id']] = array('name' => $value->course['name']); } $filtered = array_keys(eF_filterData($courseNames, $_GET['filter'])); foreach ($courses as $key => $value) { if (!in_array($key, $filtered)) { unset($courses[$key]); } } if ($_GET['ajax']) { $options['collapse'] = false; $options['search'] = false; $options['tree_tools'] = false; $treeString = $directionsTree->toHTML(false, $lessons, $courses, false, $options); $smarty->assign("T_DISPLAYCODE", $treeString); $smarty->display('display_code.tpl'); exit; } }
} $user->persist(); echo $token; } else { if (isset($_GET['addAll'])) { isset($_GET['filter']) ? $usersArray = eF_filterData($usersArray, $_GET['filter']) : null; foreach ($usersArray as $key => $value) { if ($value['autologin'] == "") { $autologin = getRandomString(20, true); eF_updateTableData("users", array('autologin' => $autologin), "login='******'"); } } } else { if (isset($_GET['removeAll'])) { if (isset($_GET['filter'])) { $usersArray = eF_filterData($usersArray, $_GET['filter']); $queryString = "'" . implode("','", array_keys($usersArray)) . "'"; eF_updateTableData("users", array('autologin' => ""), "login IN (" . $queryString . ")"); } else { eF_updateTableData("users", array('autologin' => ""), "login !=''"); } } } } exit; } catch (Exception $e) { handleAjaxExceptions($e); } exit; } }
/** * The main functionality * * (non-PHPdoc) * @see libraries/EfrontModule#getModule() */ public function getModule() { $smarty = $this->getSmartyVar(); $currentUser = $this->getCurrentUser(); $directionsTree = new EfrontDirectionsTree(); $directionsPaths = $directionsTree->toPathString(); $smarty->assign("T_MODULE_OUTLOOK_INVITATION_DIRECTION_PATHS", $directionsPaths); $temp = eF_getTableData("module_outlook_invitation as m,courses as c", "m.*,c.name,c.directions_ID", "m.courses_ID=c.id"); $events = array(); foreach ($temp as $value) { $events[$value['courses_ID']] = $value; } if (isset($_GET['delete_event']) && eF_checkParameter($_GET['delete_event'], 'id') && in_array($_GET['delete_event'], array_keys($events))) { try { $event = $events[$_GET['delete_event']]; $course = new EfrontCourse($event['courses_ID']); $users = $course->getCourseUsers(array('active' => true, archive => false, 'return_objects' => false)); $recipients = array(); foreach ($users as $value) { $recipients[] = $value['email']; } $this->cancelInvitation($course->course['id'], $recipients); eF_deleteTableData("module_outlook_invitation", "courses_ID=" . $_GET['delete_event']); } catch (Exception $e) { header("HTTP/1.0 500 "); echo $e->getMessage() . ' (' . $e->getCode() . ')'; } exit; } if ($_SESSION['s_type'] != 'administrator') { $userCourses = $currentUser->getUserCourses(array('archive' => 0, 'active' => true, 'return_objects' => false)); if (G_VERSIONTYPE == 'enterprise') { if ($_SESSION['s_current_branch']) { $result = eF_getTableData("module_hcd_course_to_branch", "courses_ID", "branches_ID='{$_SESSION['s_current_branch']}'"); } else { if ($currentUser->aspects['hcd']->isSupervisor()) { $result = eF_getTableData("module_hcd_course_to_branch", "courses_ID", "branches_ID in (select branches_ID from module_hcd_employee_works_at_branch where users_login='******'login']}' and supervisor=1)"); } } $branchCourses = array(); foreach ($result as $value) { $branchCourses[$value['courses_ID']] = $value['courses_ID']; } foreach ($events as $key => $value) { if (!isset($branchCourses[$key]) && !isset($userCourses[$key])) { unset($events[$key]); } } } else { foreach ($events as $key => $value) { if (!isset($userCourses[$key])) { unset($events[$key]); } } } } if (!isset($_GET['course'])) { $dataSource = $events; $tableName = 'outlookInvitationsTable'; isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'uint') ? $limit = $_GET['limit'] : ($limit = G_DEFAULT_TABLE_SIZE); if (isset($_GET['sort']) && eF_checkParameter($_GET['sort'], 'text')) { $sort = $_GET['sort']; isset($_GET['order']) && $_GET['order'] == 'desc' ? $order = 'desc' : ($order = 'asc'); } else { $sort = 'login'; } $dataSource = eF_multiSort($dataSource, $sort, $order); $smarty->assign("T_TABLE_SIZE", sizeof($dataSource)); if (isset($_GET['filter'])) { $dataSource = eF_filterData($dataSource, $_GET['filter']); } if (isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'int')) { isset($_GET['offset']) && eF_checkParameter($_GET['offset'], 'int') ? $offset = $_GET['offset'] : ($offset = 0); $dataSource = array_slice($dataSource, $offset, $limit); } $smarty->assign("T_DATA_SOURCE", $dataSource); } else { $course = new EfrontCourse($_GET['course']); $form = new HTML_QuickForm("import_outlook_invitation_form", "post", $this->moduleBaseUrl . "&course={$course->course['id']}&add_event=1" . (isset($_GET['popup']) ? '&popup=1' : ''), "", null, true); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); //Register this rule for checking user input with our function, eF_checkParameter $form->addElement('text', 'email', _SENDER, 'class = "inputText"'); $form->addElement('text', 'location', _LOCATION, 'class = "inputText"'); $form->addElement('text', 'subject', _SUBJECT, 'class = "inputText"'); $form->addElement('textarea', 'description', _DESCRIPTION, 'class = "inputTestTextarea" style = "width:80%;height:6em;"'); //$form -> addElement('checkbox', 'calendar', _MODULE_OUTLOOK_INVITATION_CREATE_CALENDAR); //$form -> addElement('static', 'static', _MODULE_OUTLOOK_INVITATION_INFO); $form->addElement('submit', 'submit_event_all', _MODULE_OUTLOOK_INVITATION_SENDALL, 'class=flatButton'); $form->addElement('submit', 'submit_event_new', _MODULE_OUTLOOK_INVITATION_SENDNEW, 'class=flatButton'); if (empty($events[$course->course['id']])) { //new invitation $currentEvent = null; $form->setDefaults(array('email' => $currentUser->user['email'], 'subject' => 'Invitation to attend training: ' . $course->course['name'])); } else { //existing invitation $currentEvent = $events[$course->course['id']]; $form->setDefaults(array('email' => $currentEvent['email'], 'description' => $currentEvent['description'], 'subject' => $currentEvent['subject'], 'location' => $currentEvent['location'])); } if ($form->isSubmitted() && $form->validate()) { try { $message = ""; // Set info to store into database $permanent_info = array("courses_ID" => $course->course['id'], "email" => $form->exportValue('email') ? $form->exportValue('email') : $GLOBALS['configuration']['system_email'], "location" => $form->exportValue('location'), "subject" => $form->exportValue('subject'), "description" => $form->exportValue('description')); if ($currentEvent) { $permanent_info['sequence'] = $currentEvent['sequence'] + 1; eF_updateTableData("module_outlook_invitation", $permanent_info, "courses_ID={$course->course['id']}"); } else { eF_insertTableData("module_outlook_invitation", $permanent_info); } if ($form->exportValue('submit_event_all')) { $users = $course->getCourseUsers(array('active' => true, archive => false, 'return_objects' => false)); $recipients = array(); foreach ($users as $value) { $recipients[] = $value['email']; } $this->sendInvitation($course->course['id'], $recipients); } // $smarty->assign('T_RELOAD', true); if (isset($_GET['popup'])) { $this->setMessageVar(_OPERATIONCOMPLETEDSUCCESSFULLY, 'success'); } else { eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_OPERATIONCOMPLETEDSUCCESSFULLY) . "&message_type=success"); } } catch (Exception $e) { $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString()); $this->setMessageVar($e->getMessage() . ' (' . $e->getCode() . ') <a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>', 'failure'); } } $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR); $form->setRequiredNote(_REQUIREDNOTE); $smarty->assign('T_MODULE_OUTLOOK_INVITATION_FORM', $form->toArray()); } $smarty->assign("T_MODULE_BASEDIR", $this->moduleBaseDir); $smarty->assign("T_MODULE_BASELINK", $this->moduleBaseLink); $smarty->assign("T_MODULE_BASEURL", $this->moduleBaseUrl); return true; }
//isset($_GET['filter']) ? $lessons = eF_filterData($lessons, $_GET['filter']) : null; eF_deleteTableData("lessons_to_groups", "groups_ID=" . $_GET['edit_user_group']); echo "All lessons where deleted from group"; } else { if (isset($_GET['courses_ID']) && eF_checkParameter($_GET['courses_ID'], 'id')) { if ($_GET['insert'] == 1) { $currentGroup->addCourse($_GET['courses_ID']); } else { $currentGroup->removeCourses($_GET['courses_ID']); } } else { if (isset($_GET['addAll']) && $_GET['table'] == "coursesTable") { $constraints = array('archive' => false, 'instance' => false) + createConstraintsFromSortedTable(); $courses = $currentGroup->getGroupCoursesAggregatingResultsIncludingUnassigned($constraints); $courses = EfrontCourse::convertCourseObjectsToArrays($courses); isset($_GET['filter']) ? $courses = eF_filterData($courses, $_GET['filter']) : null; foreach ($courses as $course) { if (!$course['in_group']) { $currentGroup->addCourse($course['id'], 'student'); echo "Added course " . $course['id'] . " to group"; } } } else { if (isset($_GET['removeAll']) && $_GET['table'] == "coursesTable") { //isset($_GET['filter']) ? $lessons = eF_filterData($lessons, $_GET['filter']) : null; eF_deleteTableData("courses_to_groups", "groups_ID=" . $_GET['edit_user_group']); echo "All lessons where deleted from group"; } else { if (isset($_GET['assign_to_all_users']) && $_GET['assign_to_all_users'] == "courses") { $groupUsers = $currentGroup->getGroupUsers(); if ($currentGroup->group['user_types_ID'] == '0') {
} } else { if (isset($_GET['addAll'])) { $constraints = array('archive' => false, 'active' => true, 'condition' => 'r.lessons_ID is null', 'return_objects' => false); $users = $editLesson->getLessonUsersIncludingUnassigned($constraints); isset($_GET['filter']) ? $users = eF_filterData($users, $_GET['filter']) : null; $userTypes = array(); foreach ($users as $user) { $user['user_types_ID'] ? $userTypes[] = $user['user_types_ID'] : ($userTypes[] = $user['user_type']); } $editLesson->addUsers($users, $userTypes); } else { if (isset($_GET['removeAll'])) { $constraints = array('archive' => false, 'active' => true, 'return_objects' => false); $users = $editLesson->getLessonUsers($constraints); isset($_GET['filter']) ? $users = eF_filterData($users, $_GET['filter']) : null; $editLesson->archiveLessonUsers(array_keys($users)); } } } exit; } } catch (Exception $e) { handleAjaxExceptions($e); } } } else { if (isset($_GET['lesson_info']) && eF_checkParameter($_GET['lesson_info'], 'id')) { /***/ require_once "lesson_information.php"; } else {
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) . "')"); } } } else { // Remove all eF_deleteTableData("questions_to_skills", "questions_ID = '" . $_GET['edit_question'] . "'"); } } } }
if (!$lesson->lesson['course_only']) { $lessons[$lesson->lesson['id']] = $lesson->lesson; } } isset($_GET['filter']) ? $lessons = eF_filterData($lessons, $_GET['filter']) : null; $editedUser->addLessons(array_keys($lessons), $editedUser->user['user_types_ID'] ? $editedUser->user['user_types_ID'] : $editedUser->user['user_type'], 1); } else { if (isset($_GET['removeAll'])) { $userLessons = $editedUser->getLessons(true); $lessons = array(); foreach ($userLessons as $key => $lesson) { if (!$lesson->lesson['course_only']) { $lessons[$lesson->lesson['id']] = $lesson->lesson; } } isset($_GET['filter']) ? $lessons = eF_filterData($lessons, $_GET['filter']) : null; $editedUser->archiveUserLessons(array_keys($lessons)); } else { if (isset($_GET['addAllLessonsFromTest'])) { // The missing and required skill set is sent over with the ajax request $skills_missing = array(); $all_skills = ""; foreach ($_GET as $key => $value) { // all skill-related posted values are just the skill_ID ~ a uint value if (eF_checkParameter($key, 'unit')) { if ($value == 1) { $skills_missing[] = $key; } } } // We found all the skills missing
} catch (Exception $e) { $users[$key]['professor_upload_filename'] = ''; } } } isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'uint') ? $limit = $_GET['limit'] : ($limit = G_DEFAULT_TABLE_SIZE); if (isset($_GET['sort']) && eF_checkParameter($_GET['sort'], 'text')) { $sort = $_GET['sort']; isset($_GET['order']) && $_GET['order'] == 'desc' ? $order = 'desc' : ($order = 'asc'); } else { $sort = 'login'; } $users = eF_multiSort($users, $sort, $order); $smarty->assign("T_USERS_SIZE", sizeof($users)); if (isset($_GET['filter'])) { $users = eF_filterData($users, $_GET['filter']); } if (isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'int')) { isset($_GET['offset']) && eF_checkParameter($_GET['offset'], 'int') ? $offset = $_GET['offset'] : ($offset = 0); $users = array_slice($users, $offset, $limit, true); } $smarty->assign("T_CURRENT_USER", $currentUser); $smarty->assign("T_ALL_USERS", $users); $smarty->display('professor.tpl'); exit; } //ajax request to register project grades and comments if (isset($_GET['postAjaxRequest'])) { try { $projectUsers = $currentProject->getUsers(); if (isset($_GET['reset_user']) && eF_checkParameter($_GET['reset_user'], 'login')) {
if (isset($_GET['postAjaxRequest']) && ($_change_groups_ || $_self_groups_)) { $result = eF_getTableData("groups", "*", "active=1"); $groups = array(); foreach ($result as $key => $value) { if ($value['active'] && ($_change_groups_ || $_self_groups_ && $value['self_enroll'])) { $groups[$value['id']] = $value; } } try { if ($_GET['insert'] == "true" && in_array($_GET['add_group'], array_keys($groups))) { $editedUser->addGroups($_GET['add_group']); } else { if ($_GET['insert'] == "false" && in_array($_GET['add_group'], array_keys($groups))) { $editedUser->removeGroups($_GET['add_group']); } else { if (isset($_GET['addAll'])) { isset($_GET['filter']) ? $groups = eF_filterData($groups, $_GET['filter']) : null; $editedUser->addGroups(array_keys($groups)); } else { if (isset($_GET['removeAll'])) { isset($_GET['filter']) ? $groups = eF_filterData($groups, $_GET['filter']) : null; $editedUser->removeGroups(array_keys($groups)); } } } } } catch (Exception $e) { handleAjaxExceptions($e); } exit; }
public function getModule() { $smarty = $this->getSmartyVar(); $currentLesson = $this->getCurrentLesson(); $currentUser = $this->getCurrentUser(); try { $role = $currentUser->getRole($this->getCurrentLesson()); } catch (Exception $e) { $currentUser = EfrontUserFactory::factory($_SESSION['s_login']); $role = $currentUser->getRole($this->getCurrentLesson()); } if (isset($_GET['delete_blog']) && eF_checkParameter($_GET['delete_blog'], 'id')) { $blog = eF_getTableData("module_blogs", "users_LOGIN", "id=" . $_GET['delete_blog']); if ($blog[0]['users_LOGIN'] != $_SESSION['s_login']) { eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode(_BLOGS_NOACCESS)); exit; } $articles = eF_getTableDataFlat("module_blogs_articles", "id", "blogs_ID=" . $_GET['delete_blog']); if (sizeof($articles) > 0) { $articlesList = implode(",", $articles['id']); eF_deleteTableData("module_blogs_comments", "blogs_articles_ID IN ({$articlesList})"); } eF_deleteTableData("module_blogs_articles", "blogs_ID=" . $_GET['delete_blog']); eF_deleteTableData("module_blogs", "id=" . $_GET['delete_blog']); } if (isset($_GET['deactivate_blog']) && eF_checkParameter($_GET['deactivate_blog'], 'id')) { $blog = eF_getTableData("module_blogs", "users_LOGIN", "id=" . $_GET['deactivate_blog']); if ($blog[0]['users_LOGIN'] != $_SESSION['s_login']) { eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode(_BLOGS_NOACCESS)); exit; } if (eF_updateTableData("module_blogs", array('active' => 0), "id=" . $_GET['deactivate_blog'])) { $message = _BLOGS_BLOGDEACTIVATED; $message_type = 'success'; } else { $message = _BLOGS_BLOGDEACTIVATEDPROBLEM; $message_type = "failure"; } } if (isset($_GET['activate_blog']) && eF_checkParameter($_GET['activate_blog'], 'id')) { $blog = eF_getTableData("module_blogs", "users_LOGIN", "id=" . $_GET['activate_blog']); if ($blog[0]['users_LOGIN'] != $_SESSION['s_login']) { eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode(_BLOGS_NOACCESS)); exit; } if (eF_updateTableData("module_blogs", array('active' => 1), "id=" . $_GET['activate_blog'])) { $message = _BLOGS_BLOGACTIVATED; $message_type = 'success'; } else { $message = _BLOGS_BLOGACTIVATEDPROBLEM; $message_type = "failure"; } } if (isset($_GET['delete_article']) && eF_checkParameter($_GET['delete_article'], 'id')) { $blog = eF_getTableData("module_blogs_articles", "blogs_ID,users_LOGIN", "id=" . $_GET['delete_article']); $blogTemp = eF_getTableData("module_blogs", "users_LOGIN", "id=" . $blog[0]['blogs_ID']); if ($blog[0]['users_LOGIN'] != $_SESSION['s_login'] && $blogTemp[0]['users_LOGIN'] != $_SESSION['s_login']) { eF_redirect("" . $this->moduleBaseUrl . "&view_blog=" . $blog[0]['blogs_ID'] . "&message=" . urlencode(_BLOGS_NOACCESS)); exit; } eF_deleteTableData("module_blogs_comments", "blogs_articles_ID=" . $_GET['delete_article']); eF_deleteTableData("module_blogs_articles", "id=" . $_GET['delete_article']); $message = _BLOGS_ARTICLEWASDELETEDSUCCESSFULLY; $message_type = "success"; eF_redirect("" . $this->moduleBaseUrl . "&view_blog=" . $blog[0]['blogs_ID'] . "&message=" . urlencode($message) . "&message_type=" . $message_type); } if (isset($_GET['delete_comment']) && eF_checkParameter($_GET['delete_comment'], 'id')) { $article = eF_getTableData("module_blogs_articles", "blogs_ID,users_LOGIN", "id=" . $_GET['article_id']); $blogTemp = eF_getTableData("module_blogs", "users_LOGIN", "id=" . $article[0]['blogs_ID']); $commentTemp = eF_getTableData("module_blogs_comments", "users_LOGIN", "id=" . $_GET['delete_comment']); if ($commentTemp[0]['users_LOGIN'] != $_SESSION['s_login'] && $blogTemp[0]['users_LOGIN'] != $_SESSION['s_login']) { eF_redirect("" . $this->moduleBaseUrl . "&view_article=" . $_GET['article_id'] . "&message=" . urlencode(_BLOGS_NOACCESS)); exit; } eF_deleteTableData("module_blogs_comments", "id=" . $_GET['delete_comment']); $message = _BLOGS_COMMENTWASDELETEDSUCCESSFULLY; $message_type = "success"; eF_redirect("" . $this->moduleBaseUrl . "&view_article=" . $_GET['article_id'] . "&message=" . urlencode($message) . "&message_type=" . $message_type); } if (isset($_GET['add_blog']) || isset($_GET['edit_blog'])) { if (isset($_GET['add_blog']) && $_SESSION['s_type'] != "professor") { eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode(_BLOGS_NOACCESS)); } if (isset($_GET['edit_blog'])) { $blog_data = eF_getTableData("module_blogs", "*", "id=" . $_GET['edit_blog']); if ($blog_data[0]['users_LOGIN'] != $_SESSION['s_login']) { eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode(_BLOGS_NOACCESS)); } $post_target = $this->moduleBaseUrl . '&edit_blog=' . $_GET['edit_blog']; } else { $post_target = $this->moduleBaseUrl . '&add_blog'; } global $load_editor; $load_editor = true; $form = new HTML_QuickForm("blog_add_form", "post", $post_target . "&blog_id=" . $_GET['blog_id'], "", null, true); //Build the form $form->addElement('text', 'title', _TITLE, 'class = "inputText"'); $form->addRule('title', _THEFIELD . ' "' . _TITLE . '" ' . _ISMANDATORY, 'required', null, 'client'); $form->addElement('textarea', 'description', _DESCRIPTION, 'class = "inputContentTextarea simpleEditor" style = "width:100%;height:20em;"'); $form->addElement("advcheckbox", "registered", _BLOGS_ACCESSIBLE, null, 'class = "inputCheckBox"', array(0, 1)); $form->addElement('submit', 'submit_add_blog', _SUBMIT, 'class = "flatButton"'); if (isset($_GET['edit_blog'])) { $form->setDefaults(array('title' => $blog_data[0]['name'], 'description' => $blog_data[0]['description'], 'registered' => $blog_data[0]['registered'])); } if ($form->isSubmitted() && $form->validate()) { //If the form is submitted and validated $values = $form->exportValues(); $fields = array("name" => $values['title'], "lessons_ID" => $values['lessons_ID'] ? $values['lessons_ID'] : $_SESSION['s_lessons_ID'], "description" => $values['description'], "registered" => $values['registered']); if (isset($_GET['edit_blog'])) { if (eF_updateTableData("module_blogs", $fields, "id=" . $_GET['edit_blog'])) { $message = _BLOGS_BLOGUPDATEDSUCCESSFULLY; $message_type = 'success'; } else { $message = _BLOGS_BLOGNOTUPDATED; $message_type = 'failure'; } eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=" . $message_type); } else { $fields['users_LOGIN'] = $_SESSION['s_login']; $fields['timestamp'] = time(); //pr($fields); $new_id = eF_insertTableData("module_blogs", $fields); if ($new_id) { $message = _BLOGS_BLOGADDEDSUCCESSFULLY; $message_type = 'success'; eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=" . $message_type . "&edit_blog=" . $new_id . "&tab=blog_creators"); } else { $message = _BLOGS_BLOGNOTADDED; $message_type = 'failure'; eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=" . $message_type); } } } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); //Create a smarty renderer $renderer->setRequiredTemplate('{$html}{if $required} <span class = "formRequired">*</span> {/if}'); $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR); //Set javascript error messages $form->setRequiredNote(_REQUIREDNOTE); $form->accept($renderer); //Assign this form to the renderer, so that corresponding template code is created $smarty->assign('T_BLOG_ADD_FORM', $renderer->toArray()); //Assign the form to the template try { $lessonUsers = $currentLesson->getUsers(); //Get all users that have this lesson unset($lessonUsers[$currentUser->login]); //Remove the current user from the list, he can't set parameters for his self! $users = $lessonUsers; $blogsCreators = eF_getTableDataFlat("module_blogs_users", "*", "blogs_ID=" . $_GET['edit_blog']); $creatorsAssoc = array_combine(array_values($blogsCreators['users_LOGIN']), array_values($blogsCreators['users_LOGIN'])); $nonBlogsCreators = array_diff_key($users, $creatorsAssoc); $blogsCreatorsTemp = array_diff_key($users, $nonBlogsCreators); foreach ($users as $key => $user) { in_array($key, array_values($blogsCreators['users_LOGIN'])) ? $users[$key]['blog_creator'] = true : ($users[$key]['blog_creator'] = false); } //pr($users); $roles = eF_getTableDataFlat("user_types", "name", "active=1 AND basic_user_type!='administrator'"); //Get available roles if (sizeof($roles) > 0) { $roles = array_combine($roles['name'], $roles['name']); //Match keys with values, it's more practical this way } $roles = array_merge(array('student' => _STUDENT, 'professor' => _PROFESSOR), $roles); //Append basic user types to the beginning of the array //pr($roles); if (isset($_GET['ajax']) && $_GET['ajax'] == 'usersTable') { isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'uint') ? $limit = $_GET['limit'] : ($limit = G_DEFAULT_TABLE_SIZE); if (isset($_GET['sort']) && eF_checkParameter($_GET['sort'], 'text')) { $sort = $_GET['sort']; isset($_GET['order']) && $_GET['order'] == 'desc' ? $order = 'desc' : ($order = 'asc'); } else { $sort = 'login'; } $users = eF_multiSort($users, $sort, $order); $smarty->assign("T_USERS_SIZE", sizeof($users)); if (isset($_GET['filter'])) { $users = eF_filterData($users, $_GET['filter']); } if (isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'int')) { isset($_GET['offset']) && eF_checkParameter($_GET['offset'], 'int') ? $offset = $_GET['offset'] : ($offset = 0); $users = array_slice($users, $offset, $limit); } $smarty->assign("T_ROLES", $roles); $smarty->assign("T_ALL_USERS", $users); $smarty->assign("T_BLOGS_USERS", $blogsCreators['users_LOGIN']); //We assign separately the lesson's users, to know when to display the checkboxes as "checked" $smarty->assign("T_CURRENT_USER", $currentUser); return true; } } 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'; } if (isset($_GET['postAjaxRequest'])) { try { if (isset($_GET['login']) && eF_checkParameter($_GET['login'], 'login')) { if (!in_array($_GET['login'], array_values($blogsCreators['users_LOGIN']))) { $fields = array('blogs_ID' => $_GET['edit_blog'], 'users_login' => $_GET['login']); $res = eF_insertTableData("module_blogs_users", $fields); } if (in_array($_GET['login'], array_values($blogsCreators['users_LOGIN']))) { eF_deleteTableData("module_blogs_users", "blogs_ID=" . $_GET['edit_blog'] . " AND users_LOGIN='******'login'] . "'"); } } else { if (isset($_GET['addAll'])) { isset($_GET['filter']) ? $nonBlogsCreators = eF_filterData($nonBlogsCreators, $_GET['filter']) : null; foreach ($nonBlogsCreators as $key => $value) { $fields = array('blogs_ID' => $_GET['edit_blog'], 'users_login' => $key); $res = eF_insertTableData("module_blogs_users", $fields); } } else { if (isset($_GET['removeAll'])) { isset($_GET['filter']) ? $blogCreators = eF_filterData($blogsCreatorsTemp, $_GET['filter']) : null; foreach ($blogsCreatorsTemp as $key => $value) { eF_deleteTableData("module_blogs_users", "blogs_ID=" . $_GET['edit_blog'] . " AND users_LOGIN='******'"); } } } } } catch (Exception $e) { header("HTTP/1.0 500 "); echo $e->getMessage() . ' (' . $e->getCode() . ')'; } exit; } } elseif (isset($_GET['add_article']) || isset($_GET['edit_article'])) { $resAccess = eF_getTableData("module_blogs", "*", "id=" . $_GET['blog_id']); if (isset($_GET['edit_article'])) { $article_data = eF_getTableData("module_blogs_articles", "*", "id=" . $_GET['edit_article']); if ($resAccess[0]['users_LOGIN'] != $_SESSION['s_login'] && $article_data[0]['users_LOGIN'] != $_SESSION['s_login']) { eF_redirect("" . $this->moduleBaseUrl . "&view_blog=" . $_GET['blog_id'] . "&message=" . urlencode(_BLOGS_NOACCESS)); } $post_target = $this->moduleBaseUrl . '&edit_article=' . $_GET['edit_article']; } else { $creator = eF_getTableData("module_blogs_users", "*", "blogs_ID=" . $_GET['blog_id'] . " and users_LOGIN='******'s_login'] . "'"); if ($resAccess[0]['users_LOGIN'] != $_SESSION['s_login'] && sizeof($creator) == 0) { eF_redirect("" . $this->moduleBaseUrl . "&view_blog=" . $_GET['blog_id'] . "&message=" . urlencode(_BLOGS_NOACCESS)); } $post_target = $this->moduleBaseUrl . '&add_article'; } global $load_editor; $load_editor = true; $form = new HTML_QuickForm("article_add_form", "post", $post_target . "&blog_id=" . $_GET['blog_id'], "", null, true); //Build the form $form->addElement('text', 'title', _TITLE, 'class = "inputText"'); $form->addRule('title', _THEFIELD . ' "' . _TITLE . '" ' . _ISMANDATORY, 'required', null, 'client'); $form->addElement('textarea', 'data', _DATA, 'class = "simpleEditor" id="blog_article_data" style = "width:100%;height:25em;"'); $form->addElement('submit', 'submit_add_article', _SUBMIT, 'class = "flatButton"'); if (isset($_GET['edit_article'])) { $form->setDefaults(array('title' => $article_data[0]['title'], 'data' => $article_data[0]['data'])); } if ($form->isSubmitted() && $form->validate()) { //If the form is submitted and validated $values = $form->exportValues(); $fields = array("title" => $values['title'], "data" => $values['data']); if (isset($_GET['edit_article'])) { if (eF_updateTableData("module_blogs_articles", $fields, "id=" . $_GET['edit_article'])) { $message = _BLOGS_ARTICLEUPDATEDSUCCESSFULLY; $message_type = 'success'; } else { $message = _BLOGS_ARTICLENOTUPDATED; $message_type = 'failure'; } eF_redirect("" . $this->moduleBaseUrl . "&view_blog=" . $_GET['blog_id'] . "&message=" . urlencode($message) . "&message_type=" . $message_type); } else { $fields['users_LOGIN'] = $_SESSION['s_login']; $fields['timestamp'] = time(); $fields['blogs_ID'] = $_GET['blog_id']; //pr($fields);exit; $new_id = eF_insertTableData("module_blogs_articles", $fields); if ($new_id) { $message = _BLOGS_ARTICLEADDEDSUCCESSFULLY; $message_type = 'success'; } else { $message = _BLOGS_ARTICLENOTADDED; $message_type = 'failure'; } eF_redirect("" . $this->moduleBaseUrl . "&view_blog=" . $_GET['blog_id'] . "&message=" . urlencode($message) . "&message_type=" . $message_type); } } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); //Create a smarty renderer $renderer->setRequiredTemplate('{$html}{if $required} <span class = "formRequired">*</span> {/if}'); $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR); //Set javascript error messages $form->setRequiredNote(_REQUIREDNOTE); $form->accept($renderer); //Assign this form to the renderer, so that corresponding template code is created $smarty->assign('T_ARTICLE_ADD_FORM', $renderer->toArray()); //Assign the form to the template } elseif (isset($_GET['add_comment']) || isset($_GET['edit_comment'])) { if (isset($_GET['edit_comment'])) { $comment_data = eF_getTableData("module_blogs_comments", "*", "id=" . $_GET['edit_comment']); $blogAccess = eF_getTableData("module_blogs_articles", "*", "id=" . $_GET['article_id']); if ($comment_data[0]['users_LOGIN'] != $_SESSION['s_login'] && $blogAccess[0]['users_LOGIN'] != $_SESSION['s_login']) { eF_redirect("" . $this->moduleBaseUrl . "&view_article=" . $_GET['article_id'] . "&message=" . urlencode(_BLOGS_NOACCESS)); } $post_target = $this->moduleBaseUrl . '&edit_comment=' . $_GET['edit_comment']; } else { $post_target = $this->moduleBaseUrl . '&add_comment'; } global $load_editor; $load_editor = true; $form = new HTML_QuickForm("blog_comment_form", "post", $post_target . "&article_id=" . $_GET['article_id'], "", null, true); //Build the form $form->addElement('textarea', 'data', _COMMENT, 'class = "inputContentTextarea simpleEditor" style = "width:80%;height:10em;"'); $form->addElement('submit', 'submit_add_comment', _SUBMIT, 'class = "flatButton"'); if (isset($_GET['edit_comment'])) { $form->setDefaults(array('data' => $comment_data[0]['data'])); } if ($form->isSubmitted() && $form->validate()) { //If the form is submitted and validated $values = $form->exportValues(); $fields = array("data" => $values['data'], "users_LOGIN" => $currentUser->user['login'], "blogs_articles_ID" => $_GET['article_id'], "timestamp" => time()); if (isset($_GET['edit_comment'])) { if (eF_updateTableData("module_blogs_comments", $fields, "id=" . $_GET['edit_comment'])) { $message = _BLOGS_COMMENTUPDATEDSUCCESSFULLY; $message_type = 'success'; } else { $message = _BLOGS_COMMENTNOTUPDATED; $message_type = 'failure'; } eF_redirect("" . $this->moduleBaseUrl . "&view_article=" . $_GET['article_id'] . "&message=" . urlencode($message) . "&message_type=" . $message_type); } else { //pr($fields); $new_id = eF_insertTableData("module_blogs_comments", $fields); if ($new_id) { $message = _BLOGS_COMMENTADDEDSUCCESSFULLY; $message_type = 'success'; } else { $message = _BLOGS_COMMENTNOTADDED; $message_type = 'failure'; } eF_redirect("" . $this->moduleBaseUrl . "&view_article=" . $_GET['article_id'] . "&message=" . urlencode($message) . "&message_type=" . $message_type); } } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); //Create a smarty renderer $renderer->setRequiredTemplate('{$html}{if $required} <span class = "formRequired">*</span> {/if}'); $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR); //Set javascript error messages $form->setRequiredNote(_REQUIREDNOTE); $form->accept($renderer); //Assign this form to the renderer, so that corresponding template code is created $smarty->assign('T_COMMENT_ADD_FORM', $renderer->toArray()); //Assign the form to the template $article = eF_getTableData("module_blogs_articles", "*", "id=" . $_GET['article_id']); $blogComments = eF_getTableData("module_blogs_comments", "*", "blogs_articles_ID=" . $_GET['article_id'], "timestamp asc"); $article[0]['comments'] = sizeof($blogComments); $blog = eF_getTableData("module_blogs", "*", "id=" . $article[0]['blogs_ID']); $creator = eF_getTableData("module_blogs_users", "*", "blogs_ID=" . $article[0]['blogs_ID'] . " and users_LOGIN='******'s_login'] . "'"); if (sizeof($creator) > 0) { $smarty->assign("T_BLOGS_ISBLOGCREATOR", 1); } $smarty->assign("T_BLOGS_BLOG", $blog[0]); $smarty->assign("T_BLOGS_ARTICLE", $article[0]); $smarty->assign("T_BLOGS_COMMENTS", $blogComments); } elseif (isset($_GET['view_blog'])) { $blog = eF_getTableData("module_blogs", "*", "id=" . $_GET['view_blog']); $creator = eF_getTableData("module_blogs_users", "*", "blogs_ID=" . $_GET['view_blog'] . " and users_LOGIN='******'s_login'] . "'"); if (sizeof($creator) > 0) { $smarty->assign("T_BLOGS_ISBLOGCREATOR", 1); } $blogPosts = eF_getTableData("module_blogs_articles", "*", "blogs_ID=" . $_GET['view_blog'], "timestamp desc"); //pr($blogPosts); $indexing = array(); foreach ($blogPosts as $key => $value) { $indexing[date('Y', $blogPosts[$key]['timestamp'])][date('F', $blogPosts[$key]['timestamp'])][$value['id']] = $value['title']; $blogComments = eF_getTableData("module_blogs_comments", "*", "blogs_articles_ID=" . $value['id'], "timestamp desc"); $blogPosts[$key]['last_comment'] = $blogComments[0]; $blogPosts[$key]['comments'] = sizeof($blogComments); } //pr($indexing); //pr($blogPosts); $lastComments = eF_getTableData("module_blogs_comments as com,module_blogs_articles as art", "com.id as comment_id,com.data,com.timestamp,art.id as article_id,art.title,com.users_LOGIN", "com.blogs_articles_ID=art.id and art.blogs_ID=" . $_GET['view_blog'], "com.timestamp desc"); $smarty->assign("T_BLOGS_INDEXING", $indexing); $smarty->assign("T_BLOGS_LASTCOMMENTS", $lastComments); $smarty->assign("T_BLOGS_BLOG", $blog[0]); $smarty->assign("T_BLOGS_POSTS", $blogPosts); } elseif (isset($_GET['view_article'])) { $article = eF_getTableData("module_blogs_articles", "*", "id=" . $_GET['view_article']); $blogComments = eF_getTableData("module_blogs_comments", "*", "blogs_articles_ID=" . $_GET['view_article'], "timestamp asc"); $article[0]['comments'] = sizeof($blogComments); $blog = eF_getTableData("module_blogs", "*", "id=" . $article[0]['blogs_ID']); $creator = eF_getTableData("module_blogs_users", "*", "blogs_ID=" . $article[0]['blogs_ID'] . " and users_LOGIN='******'s_login'] . "'"); if (sizeof($creator) > 0) { $smarty->assign("T_BLOGS_ISBLOGCREATOR", 1); } $smarty->assign("T_BLOGS_BLOG", $blog[0]); $smarty->assign("T_BLOGS_ARTICLE", $article[0]); $smarty->assign("T_BLOGS_COMMENTS", $blogComments); } else { $lessonBlogs = eF_getTableData("module_blogs", "*", "lessons_ID=" . $currentLesson->lesson['id']); foreach ($lessonBlogs as $key => $value) { //echo $value['id']; $res = eF_getTableData("module_blogs_articles", "*", "blogs_ID=" . $value['id'], "timestamp desc"); $lessonBlogs[$key]['last_article'] = $res[0]; /* $creators = eF_getTableData("module_blogs_users","*","blogs_ID=".$value['id']." and users_LOGIN='******'s_login']."'"); if (sizeof($creators) > 0) { $lessonBlogs[$key]['is_creator'] = 1; } else{ $lessonBlogs[$key]['is_creator'] = 0; } */ } //pr($lessonBlogs); //$smarty -> assign("T_BLOGS_LASTARTICLE", $lastArticle); $smarty->assign("T_BLOGS_LESSONBLOGS", $lessonBlogs); $smarty->assign("T_BLOGS_CLESSON", $currentLesson); $smarty->assign("T_BLOGS_CUSER", $currentUser); $smarty->assign("T_BLOGS_ROLE", $role); return true; } }