Example #1
0
 /**
  * (non-PHPdoc)
  * @see libraries/EfrontEntity#handleForm($form)
  */
 public function handleForm($form)
 {
     formatLogin();
     $flippedLogins = array_flip($GLOBALS['_usernames']);
     $timestamp = mktime($_POST['payment_Hour'], $_POST['payment_Minute'], 0, $_POST['payment_Month'], $_POST['payment_Day'], $_POST['payment_Year']);
     $values = $form->exportValues();
     $fields = array("amount" => $values['amount'], "comments" => $values['comments'], "timestamp" => $timestamp, "txn_id" => $values['txn_id'], "method" => "manual", "users_LOGIN" => $flippedLogins[$_POST['user']]);
     $payments = self::create($fields);
     $this->payments = $payments;
 }
Example #2
0
function getConnectedUsers()
{
    $usersOnline = array();
    //A user may have multiple active entries on the user_times table, one for system, one for unit etc. Pick the most recent
    $result = eF_getTableData("user_times,users,module_chat_users", "users_LOGIN, users.name, users.surname, users.user_type, timestamp_now, session_timestamp", "users.login=user_times.users_LOGIN and users.login=module_chat_users.username and session_expired=0", "timestamp_now desc");
    foreach ($result as $value) {
        if (!isset($parsedUsers[$value['users_LOGIN']])) {
            $value['login'] = $value['users_LOGIN'];
            $usersOnline[] = array('login' => $value['users_LOGIN'], 'formattedLogin' => formatLogin($value['login'], $value), 'user_type' => $value['user_type'], 'timestamp_now' => $value['timestamp_now'], 'time' => eF_convertIntervalToTime(time() - $value['session_timestamp']));
            $parsedUsers[$value['users_LOGIN']] = true;
        }
    }
    return $usersOnline;
}
                foreach ($assignedProjects[$id][$infoUser->user['login']] as $project) {
                    $workSheet->write($row, 0, $project['title'], $fieldCenterFormat);
                    $workSheet->write($row++, 1, formatScore($project['grade']) . "%", $fieldCenterFormat);
                    $avgScore += $project['grade'];
                }
                $workSheet->write($row, 0, _AVERAGESCORE, $titleCenterFormat);
                $workSheet->write($row++, 1, formatScore($avgScore / sizeof($assignedProjects[$id][$infoUser->user['login']])) . "%", $titleCenterFormat);
            }
        }
    }
    $workBook->send('export_' . $infoUser->user['login'] . '.xls');
    $workBook->close();
    exit;
} else {
    if (isset($_GET['pdf']) && $_GET['pdf'] == 'user') {
        $pdf = new EfrontPdf(_REPORT . ": " . formatLogin($infoUser->user['login']));
        try {
            $avatarFile = new EfrontFile($infoUser->user['avatar']);
        } catch (Exception $e) {
            $avatarFile = new EfrontFile(G_SYSTEMAVATARSPATH . "unknown_small.png");
        }
        $info = array(array(_USERNAME, $userInfo['general']['fullname']), array(_USERTYPE, $userInfo['general']['user_types_ID'] ? $userInfo['general']['user_types_ID'] : $roles[$userInfo['general']['user_type']]), array(_ACTIVE, $userInfo['general']['active'] ? _YES : _NO), array(_JOINED, $userInfo['general']['joined_str']), array(_TOTALLOGINTIME, $userInfo['general']['total_login_time']['time_string']));
        $pdf->printInformationSection(_GENERALUSERINFO, $info, $avatarFile);
        $info = array(array(_FORUMPOSTS, sizeof($userInfo['communication']['forum_messages'])), array(_FORUMLASTMESSAGE, formatTimestamp($userInfo['communication']['last_message']['timestamp'])), array(_PERSONALMESSAGES, sizeof($userInfo['communication']['personal_messages'])), array(_MESSAGESFOLDERS, sizeof($userInfo['communication']['personal_folders'])), array(_FILES, sizeof($userInfo['communication']['files'])), array(_FOLDERS, sizeof($userInfo['communication']['folders'])), array(_TOTALSIZE, $userInfo['communication']['total_size'] . _KB), array(_COMMENTS, sizeof($userInfo['communication']['comments'])));
        if (!EfrontUser::isOptionVisible('forum')) {
            unset($info[_FORUMPOSTS]);
            unset($info[_FORUMLASTMESSAGE]);
        }
        if (!EfrontUser::isOptionVisible('messages')) {
            unset($info[_PERSONALMESSAGES]);
            unset($info[_MESSAGESFOLDERS]);
Example #4
0
                    $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');
                exit;
            }
        }
    }
} catch (Exception $e) {
    handleNormalFlowExceptions($e);
}
 public function getSmartyTpl()
 {
     $smarty = $this->getSmartyVar();
     $currentUser = $this->getCurrentUser();
     $currentLesson = $this->getCurrentLesson();
     $currentLessonID = $currentLesson->lesson['id'];
     if ($currentUser->getRole($this->getCurrentLesson()) == 'professor' || $currentUser->getRole($this->getCurrentLesson()) == 'student') {
         // XXX
         $workbookLessonName = _WORKBOOK_NAME . ' [' . $this->getWorkbookLessonName($currentLessonID) . ']';
         $smarty->assign("T_WORKBOOK_LESSON_NAME", $workbookLessonName);
         $lessonQuestions = $this->getLessonQuestions($currentLessonID);
         $workbookLessons = $this->isWorkbookInstalledByUser($currentUser, $currentUser->getRole($this->getCurrentLesson()), $currentLessonID);
         $workbookItems = $this->getWorkbookItems($currentLessonID);
         $nonOptionalQuestionsNr = $this->getNonOptionalQuestionsNr($workbookItems);
         if ($nonOptionalQuestionsNr != 0) {
             $questionPercentage = (double) (100 / $nonOptionalQuestionsNr);
             $questionPercentage = round($questionPercentage, 2);
         }
         $isWorkbookPublished = $this->isWorkbookPublished($currentLessonID);
     }
     if ($currentUser->getRole($this->getCurrentLesson()) == 'student') {
         $workbookSettings = $this->getWorkbookSettings($currentLessonID);
         $smarty->assign("T_WORKBOOK_SETTINGS", $workbookSettings);
     }
     $smarty->assign("T_WORKBOOK_BASEURL", $this->moduleBaseUrl);
     $smarty->assign("T_WORKBOOK_BASELINK", $this->moduleBaseLink);
     global $popup;
     isset($popup) && $popup == 1 ? $popup_ = '&popup=1' : ($popup_ = '');
     if (isset($_REQUEST['question_preview']) && $_REQUEST['question_preview'] == '1' && isset($_REQUEST['question_id']) && eF_checkParameter($_REQUEST['question_id'], 'id')) {
         $id = $_REQUEST['question_id'];
         if (!in_array($id, array_keys($lessonQuestions))) {
             // reused item
             $reusedQuestion = $this->getReusedQuestionDetails($id);
             $type = $reusedQuestion['type'];
         } else {
             $type = $lessonQuestions[$id]['type'];
         }
         echo $this->questionToHtml($id, $type);
         exit;
     }
     if (isset($_REQUEST['get_progress']) && $_REQUEST['get_progress'] == '1') {
         $isWorkbookCompleted = $this->isWorkbookCompleted($currentUser->user['login'], $currentLessonID, array_keys($workbookItems), $nonOptionalQuestionsNr);
         $studentProgress = $this->getStudentProgress($currentUser->user['login'], $currentLessonID);
         if ($isWorkbookCompleted['is_completed'] == 1) {
             $unitToComplete = $workbookSettings['unit_to_complete'];
             $result = eF_updateTableData('module_workbook_progress', array('completion_date' => time()), "lessons_ID='" . $currentLessonID . "' AND users_LOGIN='******'login'] . "'");
             if ($unitToComplete != -1) {
                 $currentUser->setSeenUnit($unitToComplete, $currentLessonID, true);
             }
         }
         echo $studentProgress . '-' . $isWorkbookCompleted['id'];
         exit;
     }
     if (isset($_GET['edit_settings']) && $_GET['edit_settings'] == '1') {
         if ($_SESSION['s_type'] != 'professor') {
             $message = _WORKBOOK_NOACCESS;
             $message_type = 'failure';
             $this->setMessageVar(urlencode($message), $message_type);
         }
         $content = new EfrontContentTree($currentLessonID);
         $iterator = new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($content->tree), RecursiveIteratorIterator::SELF_FIRST), array('ctg_type' => 'theory'));
         $contentOptions = $content->toHTMLSelectOptions($iterator);
         $contentOptions = array(-1 => '-------------') + $contentOptions;
         $workbookSettings = $this->getWorkbookSettings($currentLessonID);
         if ($isWorkbookPublished == 1) {
             $contentOptions[$workbookSettings['unit_to_complete']] = str_replace(' ', '', $contentOptions[$workbookSettings['unit_to_complete']]);
             $contentOptions[$workbookSettings['unit_to_complete']] = str_replace('»', '', $contentOptions[$workbookSettings['unit_to_complete']]);
         }
         $form = new HTML_QuickForm("edit_settings_form", "post", $this->moduleBaseUrl . "&edit_settings=1", "", null, true);
         $form->addElement('text', 'lesson_name', _WORKBOOK_LESSON_NAME, 'class="inputText"');
         $form->addRule('lesson_name', _THEFIELD . ' "' . _WORKBOOK_LESSON_NAME . '" ' . _ISMANDATORY, 'required', null, 'client');
         $form->addElement('advcheckbox', 'allow_print', _WORKBOOK_ALLOW_PRINT, null, 'class="inputCheckBox"', array(0, 1));
         $form->addElement('advcheckbox', 'allow_export', _WORKBOOK_ALLOW_EXPORT, null, 'class="inputCheckBox"', array(0, 1));
         $form->addElement('advcheckbox', 'edit_answers', _WORKBOOK_EDIT_ANSWERS, null, 'class="inputCheckBox"', array(0, 1));
         $form->addElement('select', 'unit_to_complete', _WORKBOOK_UNIT_TO_COMPLETE, $contentOptions);
         $form->addElement('submit', 'submit', _UPDATE, 'class="flatButton"');
         if ($isWorkbookPublished == 1) {
             $form->freeze('unit_to_complete');
         }
         $form->setDefaults($workbookSettings);
         if ($form->isSubmitted() && $form->validate()) {
             $values = $form->exportValues();
             $fields = array("lesson_name" => $values['lesson_name'], "allow_print" => $values['allow_print'], "allow_export" => $values['allow_export'], "edit_answers" => $values['edit_answers'], "unit_to_complete" => $values['unit_to_complete']);
             if (eF_updateTableData("module_workbook_settings", $fields, "id=" . $workbookSettings['id'])) {
                 $smarty->assign("T_WORKBOOK_MESSAGE", _WORKBOOK_SETTINGS_SUCCESSFULLY_EDITED);
                 $smarty->assign("T_WORKBOOK_MESSAGE_TYPE", 'success');
             } else {
                 $smarty->assign("T_WORKBOOK_MESSAGE", _WORKBOOK_SETTINGS_EDIT_PROBLEM);
                 $smarty->assign("T_WORKBOOK_MESSAGE_TYPE", 'failure');
             }
         }
         $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
         $renderer->setRequiredTemplate('{$html}{if $required}&nbsp;<span class="formRequired">*</span>{/if}');
         $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
         $form->setRequiredNote(_REQUIREDNOTE);
         $form->accept($renderer);
         $smarty->assign('T_WORKBOOK_EDIT_SETTINGS_FORM', $renderer->toArray());
     }
     if (isset($_GET['reuse_item']) && $_GET['reuse_item'] == '1') {
         if ($_SESSION['s_type'] != 'professor') {
             $message = _WORKBOOK_NOACCESS;
             $message_type = 'failure';
             $this->setMessageVar(urlencode($message), $message_type);
         }
         $form = new HTML_QuickForm("reuse_item_form", "post", $this->moduleBaseUrl . "&reuse_item=1", "", null, true);
         $form->addElement('text', 'item_id', _WORKBOOK_ITEM_ID, 'class="inputText"');
         $form->addRule('item_id', _THEFIELD . ' "' . _WORKBOOK_ITEM_ID . '" ' . _ISMANDATORY, 'required', null, 'client');
         $form->addElement('submit', 'submit', _WORKBOOK_REUSE_ITEM, 'class="flatButton"');
         if ($form->isSubmitted() && $form->validate()) {
             $values = $form->exportValues();
             $existingIDs = $this->getItemsUniqueIDs();
             if (!in_array($values['item_id'], $existingIDs)) {
                 $message = _WORKBOOK_INVALID_UNIQUE_ID;
                 $message_type = 'failure';
                 $this->setMessageVar(urlencode($message), $message_type);
             } else {
                 $item = $this->getItemByUniqueID($values['item_id']);
                 $fields = array("item_title" => $item['item_title'], "item_text" => $item['item_text'], "item_question" => $item['item_question'], "question_text" => $item['question_text'], "check_answer" => $item['check_answer'], "lessons_ID" => $currentLessonID, "unique_ID" => $this->generateItemID(), "position" => $this->itemPosition($currentLessonID));
                 if (eF_insertTableData("module_workbook_items", $fields)) {
                     $smarty->assign("T_WORKBOOK_MESSAGE", urlencode(_WORKBOOK_ITEM_SUCCESSFULLY_ADDED));
                     $smarty->assign("T_WORKBOOK_MESSAGE_TYPE", 'success');
                 } else {
                     $smarty->assign("T_WORKBOOK_MESSAGE", _WORKBOOK_ITEM_ADD_PROBLEM);
                     $smarty->assign("T_WORKBOOK_MESSAGE_TYPE", 'failure');
                 }
             }
         }
         $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
         $renderer->setRequiredTemplate('{$html}{if $required}&nbsp;<span class="formRequired">*</span>{/if}');
         $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
         $form->setRequiredNote(_REQUIREDNOTE);
         $form->accept($renderer);
         $smarty->assign('T_WORKBOOK_REUSE_ITEM_FORM', $renderer->toArray());
     }
     if (isset($_GET['move_item']) && eF_checkParameter($_GET['move_item'], 'id') && in_array($_GET['move_item'], array_keys($workbookItems))) {
         if ($_SESSION['s_type'] != 'professor') {
             $message = _WORKBOOK_NOACCESS;
             $message_type = 'failure';
             $this->setMessageVar(urlencode($message), $message_type);
         }
         $smarty->assign("T_WORKBOOK_ITEMS_COUNT", count($workbookItems));
         $itemPosition = $workbookItems[$_GET['move_item']]['position'];
         $availablePositions = array();
         foreach ($workbookItems as $key => $value) {
             if ($value['position'] != $itemPosition) {
                 $availablePositions[$value['position']] = $value['position'];
             }
         }
         $form = new HTML_QuickForm("move_item_form", "post", $this->moduleBaseUrl . "&move_item=" . $_GET['move_item'], "", null, true);
         $form->addElement('select', 'item_position', _WORKBOOK_ITEM_NEW_POSITION, $availablePositions, '');
         $form->addElement('submit', 'submit', _WORKBOOK_MOVE_ITEM, 'class="flatButton"');
         if ($form->isSubmitted() && $form->validate()) {
             $values = $form->exportValues();
             $newPosition = $values['item_position'];
             if ($newPosition > $itemPosition) {
                 foreach ($workbookItems as $key => $value) {
                     if ($value['position'] > $itemPosition && $value['position'] <= $newPosition) {
                         eF_updateTableData("module_workbook_items", array('position' => $value['position'] - 1), "id=" . $key);
                     }
                 }
             } else {
                 foreach ($workbookItems as $key => $value) {
                     if ($value['position'] < $itemPosition && $value['position'] >= $newPosition) {
                         eF_updateTableData("module_workbook_items", array('position' => $value['position'] + 1), "id=" . $key);
                     }
                 }
             }
             eF_updateTableData("module_workbook_items", array('position' => $newPosition), "id=" . $_GET['move_item']);
             $smarty->assign("T_WORKBOOK_MESSAGE", _WORKBOOK_ITEM_SUCCESSFULLY_MOVED);
             $smarty->assign("T_WORKBOOK_MESSAGE_TYPE", 'success');
         }
         $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
         $renderer->setRequiredTemplate('{$html}{if $required}&nbsp;<span class="formRequired">*</span>{/if}');
         $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
         $form->setRequiredNote(_REQUIREDNOTE);
         $form->accept($renderer);
         $smarty->assign('T_WORKBOOK_MOVE_ITEM_FORM', $renderer->toArray());
     }
     if (isset($_GET['delete_item']) && eF_checkParameter($_GET['delete_item'], 'id') && in_array($_GET['delete_item'], array_keys($workbookItems))) {
         $item_id = $_GET['delete_item'];
         $itemPosition = $workbookItems[$item_id]['position'];
         foreach ($workbookItems as $key => $value) {
             if ($value['position'] > $itemPosition) {
                 eF_updateTableData("module_workbook_items", array('position' => $value['position'] - 1), "id=" . $key);
             }
         }
         eF_deleteTableData("module_workbook_items", "id=" . $item_id);
     }
     if (isset($_GET['switch_lesson']) && eF_checkParameter($_GET['switch_lesson'], 'id') && in_array($_GET['switch_lesson'], array_keys($workbookLessons))) {
         $lessonID = $_GET['switch_lesson'];
         eF_redirect("location:" . $this->moduleBaseUrl . "&lessons_ID=" . $lessonID . $popup_);
     }
     if (isset($_GET['add_item']) && $_GET['add_item'] == '1' || isset($_GET['edit_item']) && eF_checkParameter($_GET['edit_item'], 'id') && in_array($_GET['edit_item'], array_keys($workbookItems))) {
         if ($_SESSION['s_type'] != "professor") {
             eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_WORKBOOK_NOACCESS) . $popup_);
         }
         global $load_editor;
         $load_editor = true;
         $questionsText = array();
         $questionsText[-1] = "-----------------------";
         foreach ($lessonQuestions as $key => $value) {
             $questionsText[$key] = $this->truncateText(strip_tags($value['text']), 70);
         }
         if (isset($_GET['edit_item'])) {
             $editItemID = $_GET['edit_item'];
             $editItemQuestion = $workbookItems[$editItemID]['item_question'];
             if ($editItemQuestion != '-1' && !in_array($editItemQuestion, array_keys($questionsText))) {
                 // reused item
                 $reusedQuestion = $this->getReusedQuestionDetails($editItemQuestion);
                 $questionsText[$editItemQuestion] = $this->truncateText(strip_tags($reusedQuestion['text']), 70);
             }
         }
         isset($_GET['add_item']) ? $postTarget = "&add_item=1" : ($postTarget = "&edit_item=" . $_GET['edit_item']);
         $form = new HTML_QuickForm("add_edit_item_form", "post", $this->moduleBaseUrl . $postTarget, "", null, true);
         $form->addElement('text', 'item_title', _WORKBOOK_ITEM_TITLE, 'class="inputText" style="width:500px;"');
         $form->addElement('textarea', 'item_text', _WORKBOOK_ITEM_TEXT, 'class="mceEditor" style="width:99%;height:300px;" id="editor_content_data"');
         $form->addElement('select', 'item_question', _WORKBOOK_ITEM_QUESTION, $questionsText, 'onchange="questionPreview(this)"');
         $form->addElement('advcheckbox', 'check_answer', _WORKBOOK_ITEM_GRADE_ANSWER, null, 'class="inputCheckBox"', array(0, 1));
         if (isset($_GET['add_item'])) {
             $form->addElement('submit', 'submit', _WORKBOOK_ADD_ITEM, 'class="flatButton"');
         } else {
             $form->addElement('submit', 'submit', _WORKBOOK_UPDATE_ITEM, 'class="flatButton"');
         }
         if (isset($_GET['edit_item'])) {
             $editItem = $workbookItems[$_GET['edit_item']];
             $form->setDefaults($editItem);
             if ($isWorkbookPublished == '1') {
                 $editItem['question_title'] = $questionsText[$editItem['item_question']];
                 if ($editItem['check_answer'] == '1') {
                     $editItem['check_answer_text'] = _YES;
                 } else {
                     $editItem['check_answer_text'] = _NO;
                 }
             }
             $smarty->assign('T_WORKBOOK_EDIT_ITEM_DETAILS', $editItem);
         }
         if ($form->isSubmitted() && $form->validate()) {
             $values = $form->exportValues();
             isset($_GET['add_item']) ? $lessonID = $currentLessonID : ($lessonID = $editItem['lessons_ID']);
             isset($_GET['add_item']) ? $uniqueID = $this->generateItemID() : ($uniqueID = $editItem['unique_ID']);
             isset($_GET['add_item']) ? $position = $this->itemPosition($currentLessonID) : ($position = $editItem['position']);
             if ($values['item_question'] != '-1') {
                 $id = $values['item_question'];
                 if (!in_array($id, array_keys($lessonQuestions))) {
                     // edit reused item
                     $reusedQuestion = $this->getReusedQuestionDetails($id);
                     $type = $reusedQuestion['type'];
                 } else {
                     $type = $lessonQuestions[$id]['type'];
                 }
                 $questionText = $this->questionToHtml($id, $type);
             } else {
                 $questionText = '';
             }
             $fields = array("item_title" => $values['item_title'], "item_text" => $values['item_text'], "item_question" => $values['item_question'], "question_text" => $questionText, "check_answer" => $values['check_answer'], "lessons_ID" => $lessonID, "unique_ID" => $uniqueID, "position" => $position);
             if ($values['item_title'] == '' && $values['item_text'] == '' && $values['item_question'] == '-1') {
                 $message = _WORKBOOK_ITEM_EMPTY_FIELDS;
                 if (isset($_GET['add_item'])) {
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=failure&add_item=1" . $popup_);
                 } else {
                     $itemID = $_GET['edit_item'];
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=failure&edit_item=" . $itemID . $popup_);
                 }
             }
             if (isset($_GET['add_item'])) {
                 if (eF_insertTableData("module_workbook_items", $fields)) {
                     $message = _WORKBOOK_ITEM_SUCCESSFULLY_ADDED;
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=success" . $popup_);
                 } else {
                     $message = _WORKBOOK_ITEM_ADD_PROBLEM;
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=failure" . $popup_);
                 }
             } else {
                 if (eF_updateTableData("module_workbook_items", $fields, "id=" . $_GET['edit_item'])) {
                     $message = _WORKBOOK_ITEM_SUCCESSFULLY_EDITED;
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=success" . $popup_);
                 } else {
                     $message = _WORKBOOK_ITEM_EDIT_PROBLEM;
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=failure" . $popup_);
                 }
             }
         }
         $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
         $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
         $form->setRequiredNote(_REQUIREDNOTE);
         $form->accept($renderer);
         $smarty->assign('T_WORKBOOK_ADD_EDIT_ITEM_FORM', $renderer->toArray());
         $basedir = $currentLesson->getDirectory();
         $options = array('lessons_ID' => $currentLessonID, 'metadata' => 0);
         $url = $_SERVER['REQUEST_URI'];
         $extraFileTools = array(array('image' => 'images/16x16/arrow_right.png', 'title' => _INSERTEDITOR, 'action' => 'insert_editor'));
         include "file_manager.php";
     }
     if (isset($_GET['publish_workbook']) && $_GET['publish_workbook'] == '1') {
         $result = eF_getTableData("module_workbook_publish", "publish", "lessons_ID=" . $currentLessonID);
         if (count($result) == 0) {
             if (eF_insertTableData("module_workbook_publish", array('lessons_ID' => $currentLessonID, 'publish' => 1))) {
                 $message = _WORKBOOK_SUCCESSFULLY_PUBLISHED;
                 eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=success" . $popup_);
             } else {
                 $message = _WORKBOOK_PUBLISH_PROBLEM;
                 eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=failure" . $popup_);
             }
         } else {
             if (eF_updateTableData("module_workbook_publish", array('publish' => 1), "lessons_ID=" . $currentLessonID)) {
                 $message = _WORKBOOK_SUCCESSFULLY_PUBLISHED;
                 eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=success" . $popup_);
             } else {
                 $message = _WORKBOOK_PUBLISH_PROBLEM;
                 eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=failure" . $popup_);
             }
         }
     }
     if (isset($_GET['reset_workbook_professor']) && $_GET['reset_workbook_professor'] == '1') {
         eF_updateTableData("module_workbook_publish", array('publish' => 0), "lessons_ID=" . $currentLessonID);
         foreach ($workbookItems as $key => $value) {
             eF_deleteTableData("module_workbook_answers", "item_id=" . $key);
             eF_deleteTableData("module_workbook_autosave", "item_id=" . $key);
             eF_deleteTableData("module_workbook_progress", "lessons_ID=" . $currentLessonID);
         }
     }
     if (isset($_GET['reset_workbook_student']) && eF_checkParameter($_GET['reset_workbook_student'], 'id')) {
         $id = $_GET['reset_workbook_student'];
         $result = eF_getTableData("module_workbook_progress", "users_LOGIN", "id=" . $id);
         if ($result[0]['users_LOGIN'] != $currentUser->user['login']) {
             eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_WORKBOOK_NOACCESS) . $popup_);
         }
         eF_deleteTableData("module_workbook_progress", "id=" . $id);
         foreach ($workbookItems as $key => $value) {
             eF_deleteTableData("module_workbook_answers", "item_id=" . $key . " AND users_LOGIN='******'login'] . "'");
         }
         $unitToComplete = $workbookSettings['unit_to_complete'];
         if ($unitToComplete != -1) {
             $currentUser->setSeenUnit($unitToComplete, $currentLessonID, false);
         }
     }
     if (isset($_GET['download_as']) && $_GET['download_as'] == 'doc') {
         include dirname(__FILE__) . "/classes/html_to_doc.inc.php";
         $workbookAnswers = $this->getWorkbookAnswers($currentUser->user['login'], array_keys($workbookItems));
         $workbookHTML = '';
         foreach ($workbookItems as $key => $value) {
             $workbookHTML .= '<div style="width:98%;float:left;border:1px dotted #808080;padding: 5px 10px;">';
             $workbookHTML .= '<div style="background-color: #EAEAEA;border: 1px solid #AAAAAA;padding: 2px;font-weight: bold;">';
             $workbookHTML .= _WORKBOOK_ITEMS_COUNT . $value['position'];
             if ($value['item_title'] != '') {
                 $workbookHTML .= '&nbsp;-&nbsp;' . $value['item_title'];
             }
             $workbookHTML .= '</div><br/>';
             if ($value['item_text'] != '') {
                 $workbookHTML .= '<div>' . $value['item_text'] . '</div><br/>';
             }
             if ($value['item_question'] != '-1') {
                 $questionType = $lessonQuestions[$value['item_question']]['type'];
                 if ($workbookAnswers[$value['id']] == '') {
                     if ($questionType == 'drag_drop') {
                         $dragDrop = eF_getTableData("questions", "options, answer, text", "id=" . $value['item_question']);
                         $options = unserialize($dragDrop[0]['options']);
                         $answer = unserialize($dragDrop[0]['answer']);
                         shuffle($options);
                         shuffle($answer);
                         $workbookHTML .= $dragDrop[0]['text'];
                         for ($i = 0; $i < count($options); $i++) {
                             $workbookHTML .= '<div>' . $options[$i] . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                             $workbookHTML .= $answer[$i] . '</div>';
                         }
                     } else {
                         $workbookHTML .= '<div>' . $value['question_text'] . '</div>';
                     }
                 } else {
                     $workbookHTML .= '<div>' . $workbookAnswers[$value['id']] . '</div>';
                 }
             }
             $workbookHTML .= '</div><br/>';
         }
         $workbookHTML = preg_replace('/<script\\b[^>]*>(.*?)<\\/script>/is', "", $workbookHTML);
         $fileName = _WORKBOOK_NAME . '_' . $this->getWorkbookLessonName($currentLessonID);
         $fileName = preg_replace('/[\\s]+/', '_', $fileName);
         $htmltodoc = new HTML_TO_DOC();
         $htmltodoc->createDoc($workbookHTML, $fileName, true);
         exit(0);
     }
     if (isset($_GET['download_as']) && $_GET['download_as'] == 'pdf') {
         $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
         $pdf->SetCreator(PDF_CREATOR);
         $pdf->SetAuthor(PDF_AUTHOR);
         $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
         $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
         $pdf->setFontSubsetting(false);
         $pdf->AddPage();
         $completion_date = '';
         $resutlt = eF_getTableData('module_workbook_progress', 'completion_date', "users_LOGIN='******'login'] . "' and lessons_ID='" . $currentLessonID . "'");
         if ($resutlt) {
             $completion_date = $resutlt[0]['completion_date'];
         }
         $workbookHTML = '';
         $workbookHTML .= '<table>';
         $workbookHTML .= '<tr>';
         $workbookHTML .= '<td colspan="2">';
         $workbookHTML .= formatLogin($currentUser->user['login']);
         $workbookHTML .= '</td>';
         $workbookHTML .= '</tr>';
         $workbookHTML .= '<tr>';
         $workbookHTML .= '<td>';
         $workbookHTML .= $workbookLessonName;
         $workbookHTML .= '</td>';
         $workbookHTML .= '<td>';
         $workbookHTML .= formatTimestamp($completion_date);
         $workbookHTML .= '</td>';
         $workbookHTML .= '</tr>';
         $workbookHTML .= '</table>';
         $pdf->writeHTML($workbookHTML, true, false, true, false, '');
         $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
         $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
         $pdf->setHeaderFont(array('Freeserif', 'I', 11));
         $pdf->setFooterFont(array('Freeserif', '', 8));
         $pdf->setHeaderData('', '', '', $workbookLessonName);
         $pdf->AliasNbPages();
         $pdf->SetFont('Freeserif', '', 10);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('Freeserif', '', 10);
         $pdf->SetTextColor(0, 0, 0);
         $workbookAnswers = $this->getWorkbookAnswers($currentUser->user['login'], array_keys($workbookItems));
         $pdf->AddPage();
         $workbookHTML .= '';
         $itemLogo = new EfrontFile(G_DEFAULTIMAGESPATH . "32x32/unit.png");
         $itemLogoUrl = $itemLogo['path'];
         foreach ($workbookItems as $key => $value) {
             $workbookHTML .= '<div id="pdf-block" style="width:98%;float:left;border:1px dotted #808080;page-break-after:always;">';
             $workbookHTML .= '<div style="background-color: #EAEAEA;font-weight: bold;">';
             $workbookHTML .= '<img src="' . $itemLogoUrl . '"/>&nbsp;' . _WORKBOOK_ITEMS_COUNT . $value['position'];
             if ($value['item_title'] != '') {
                 $workbookHTML .= '&nbsp;-&nbsp;' . $value['item_title'];
             }
             $workbookHTML .= '</div>';
             if ($value['item_text'] != '') {
                 $workbookHTML .= '<div>' . $value['item_text'] . '</div>';
             }
             if ($value['item_question'] != '-1') {
                 $questionType = $lessonQuestions[$value['item_question']]['type'];
                 if ($workbookAnswers[$value['id']] == '') {
                     if ($questionType == 'drag_drop') {
                         $dragDrop = eF_getTableData("questions", "options, answer, text", "id=" . $value['item_question']);
                         $options = unserialize($dragDrop[0]['options']);
                         $answer = unserialize($dragDrop[0]['answer']);
                         shuffle($options);
                         shuffle($answer);
                         $workbookHTML .= $dragDrop[0]['text'];
                         for ($i = 0; $i < count($options); $i++) {
                             $workbookHTML .= '<div>' . $options[$i] . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                             $workbookHTML .= $answer[$i] . '</div>';
                         }
                     } else {
                         $workbookHTML .= '<div>' . $value['question_text'] . '</div>';
                     }
                 } else {
                     $workbookHTML .= '<div>' . $workbookAnswers[$value['id']] . '</div>';
                 }
             }
             $workbookHTML .= '</div><br/>';
         }
         $workbookHTML = preg_replace('/<script\\b[^>]*>(.*?)<\\/script>/is', "", $workbookHTML);
         $pdf->writeHTML($workbookHTML, true, false, true, false, '');
         $fileName = _WORKBOOK_NAME . '_' . str_replace(' ', '_', $this->getWorkbookLessonName($currentLessonID)) . '.pdf';
         header("Content-type: application/pdf");
         header("Content-disposition: attachment; filename=" . $fileName);
         echo $pdf->Output('', 'S');
         exit(0);
     }
     if (isset($_GET['check_workbook_progress']) && $_GET['check_workbook_progress'] == '1') {
         $lessonStudents = $currentLesson->getUsers('student');
         $workbookStudents = array();
         foreach ($lessonStudents as $userLogin => $value) {
             if ($nonOptionalQuestionsNr != 0) {
                 $studentProgress = $this->getStudentProgress($userLogin, $currentLessonID);
                 $studentProgress .= '%';
             } else {
                 $studentProgress = '-';
             }
             $workbookStudents[$userLogin] = array('login' => $userLogin, 'progress' => $studentProgress);
         }
         $smarty->assign("T_WORKBOOK_STUDENTS", $workbookStudents);
     }
     if (isset($_GET['preview_workbook']) && $_GET['preview_workbook'] == '1' && isset($_GET['student']) && eF_checkParameter($_GET['student'], 'login')) {
         $userLogin = $_GET['student'];
         $studentProgress = $this->getStudentProgress($userLogin, $currentLessonID);
         $smarty->assign("T_WORKBOOK_PREVIEW_STUDENT_PROGRESS", $studentProgress);
         $workbookAnswers = $this->getWorkbookAnswers($userLogin, array_keys($workbookItems));
         $smarty->assign("T_WORKBOOK_PREVIEW_ANSWERS", $workbookAnswers);
     }
     if (isset($_GET['get_reset_message']) && $_GET['get_reset_message'] == '1') {
         echo $this->getResetMessage(array_keys($workbookItems));
         exit;
     }
     if (isset($_POST['item_submitted'])) {
         $itemID = $_POST['item_submitted'];
         $questionID = $workbookItems[$itemID]['item_question'];
         $checkAnswer = $workbookItems[$itemID]['check_answer'];
         if (!in_array($questionID, array_keys($lessonQuestions))) {
             // reused item
             $reusedQuestion = $this->getReusedQuestionDetails($questionID);
             $questionType = $reusedQuestion['type'];
         } else {
             $questionType = $lessonQuestions[$questionID]['type'];
         }
         $question = QuestionFactory::factory($questionID);
         $question->setDone($_POST['question'][$questionID]);
         $results = $question->correct();
         if ($questionType != 'raw_text' && !ef_compare_float($results['score'], 1)) {
             print '-1';
         } else {
             $form = new HTML_QuickForm("questionForm", "post", "", "", null, true);
             $fields = array('item_id' => $itemID, 'html_solved' => $question->toHTMLSolved($form), 'users_LOGIN' => $currentUser->user['login']);
             eF_insertTableData("module_workbook_answers", $fields);
             if ($checkAnswer == '1') {
                 $this->updateStudentProgress($currentUser->user['login'], $currentLessonID, $questionPercentage, $nonOptionalQuestionsNr);
             }
             echo $question->toHTMLSolved($form);
         }
         eF_deleteTableData("module_workbook_autosave", "item_id=" . $itemID . " AND users_LOGIN='******'login'] . "'");
         exit(0);
     }
     if (isset($_POST['item_submitted_autosave'])) {
         $itemID = $_POST['item_submitted_autosave'];
         $questionID = $workbookItems[$itemID]['item_question'];
         $question = QuestionFactory::factory($questionID);
         $form = new HTML_QuickForm("questionForm", "post", "", "", null, true);
         $form->setDefaults($_POST);
         $fields = array('item_id' => $itemID, 'autosave_text' => $question->toHTML($form), 'users_LOGIN' => $currentUser->user['login']);
         eF_deleteTableData("module_workbook_autosave", "item_id=" . $itemID . " AND users_LOGIN='******'login'] . "'");
         eF_insertTableData("module_workbook_autosave", $fields);
         exit(0);
     }
     if (isset($_POST['item_to_update'])) {
         $itemID = $_POST['item_to_update'];
         $questionID = $workbookItems[$itemID]['item_question'];
         $question = QuestionFactory::factory($questionID);
         $question->userAnswer = urldecode($_POST['ans']);
         $form = new HTML_QuickForm("questionForm", "post", "", "", null, true);
         $form->setDefaults($_POST);
         print $question->toHTML($form);
         exit(0);
     }
     if (isset($_POST['item_updated'])) {
         $itemID = $_POST['item_updated'];
         $questionID = $workbookItems[$itemID]['item_question'];
         $question = QuestionFactory::factory($questionID);
         $question->setDone($_POST['question'][$questionID]);
         $form = new HTML_QuickForm("questionForm", "post", "", "", null, true);
         $answerToUpdate = eF_getTableData("module_workbook_answers", "id", "item_id=" . $itemID . " AND users_LOGIN='******'login'] . "'");
         eF_updateTableData("module_workbook_answers", array('html_solved' => $question->toHTMLSolved($form)), "id=" . $answerToUpdate[0]['id']);
         echo $question->toHTMLSolved($form);
         eF_deleteTableData("module_workbook_autosave", "item_id=" . $itemID . " AND users_LOGIN='******'login'] . "'");
         exit(0);
     } else {
         if ($currentUser->getRole($this->getCurrentLesson()) == 'professor' || $currentUser->getRole($this->getCurrentLesson()) == 'student') {
             $workbookItems = $this->getWorkbookItems($currentLessonID);
             $smarty->assign("T_WORKBOOK_ITEMS", $workbookItems);
             $smarty->assign("T_WORKBOOK_LESSONS", $workbookLessons);
             $isWorkbookPublished = $this->isWorkbookPublished($currentLessonID);
             $smarty->assign("T_WORKBOOK_IS_PUBLISHED", $isWorkbookPublished);
             $smarty->assign("T_WORKBOOK_NON_OPTIONAL_QUESTIONS_NR", $nonOptionalQuestionsNr);
         }
         if ($currentUser->getRole($this->getCurrentLesson()) == 'professor') {
             $workbookOptions[] = array('text' => _SETTINGS, 'image' => $this->moduleBaseLink . 'images/settings.png', 'href' => $this->moduleBaseUrl . '&edit_settings=1&popup=1', 'onClick' => "eF_js_showDivPopup(event, '" . _SETTINGS . "', 0)", 'target' => 'POPUP_FRAME', 'id' => 'edit_settings');
             $workbookOptions[] = array('text' => _WORKBOOK_POPUP_INFO, 'image' => $this->moduleBaseLink . 'images/info.png', 'href' => $this->moduleBaseUrl . '&popup_info=1&popup=1', 'onClick' => "eF_js_showDivPopup(event, '" . _WORKBOOK_POPUP_INFO . "', 2)", 'target' => 'POPUP_FRAME', 'id' => 'popup_info');
             $smarty->assign("T_WORKBOOK_OPTIONS", $workbookOptions);
         } else {
             if ($currentUser->getRole($this->getCurrentLesson()) == 'student') {
                 $workbookAnswers = $this->getWorkbookAnswers($currentUser->user['login'], array_keys($workbookItems));
                 $smarty->assign("T_WORKBOOK_ANSWERS", $workbookAnswers);
                 $autoSaveAnswers = $this->getAutoSaveAnswers($currentUser->user['login'], array_keys($workbookItems));
                 $smarty->assign("T_WORKBOOK_AUTOSAVE_ANSWERS", $autoSaveAnswers);
                 $studentProgress = $this->getStudentProgress($currentUser->user['login'], $currentLessonID);
                 $smarty->assign("T_WORKBOOK_STUDENT_PROGRESS", $studentProgress);
                 $isWorkbookCompleted = $this->isWorkbookCompleted($currentUser->user['login'], $currentLessonID, array_keys($workbookItems), $nonOptionalQuestionsNr);
                 $smarty->assign("T_WORKBOOK_IS_COMPLETED", $isWorkbookCompleted);
             }
         }
     }
     if ($currentUser->getRole($this->getCurrentLesson()) == 'professor') {
         return $this->moduleBaseDir . "module_workbook_professor.tpl";
     } else {
         if ($currentUser->getRole($this->getCurrentLesson()) == 'student') {
             return $this->moduleBaseDir . "module_workbook_student.tpl";
         }
     }
 }
            foreach ($result as $value) {
                $userBranches[$value['users_login']][] = $value['name'];
            }
            foreach ($userBranches as $login => $value) {
                $userBranches[$login] = implode(",", $value);
            }
            $formatting = array(_USER => array('width' => '16%', 'fill' => false), _COURSEROLE => array('width' => '16%', 'fill' => false), _BRANCH => array('width' => '16%', 'fill' => false), _PERCENTAGE => array('width' => '16%', 'fill' => false), _ENROLLEDON => array('width' => '10%', 'fill' => false), _COMPLETED => array('width' => '11%', 'fill' => false), _SCORE => array('width' => '11%', 'fill' => false, 'align' => 'R'));
        }
        #cpp#endif
        foreach ($users as $login => $info) {
            if ($info['completed'] && $info['to_timestamp']) {
                $completedString = _YES . ', ' . _ON . ' ' . formatTimestamp($info['to_timestamp']);
            } elseif ($info['completed']) {
                $completedString = _YES;
            } else {
                $completedString = _NO;
            }
            if (G_VERSIONTYPE == 'enterprise') {
                #cpp#ifdef ENTERPRISE
                $data[] = array(_USER => formatLogin($info['login']), _COURSEROLE => $roles[$info['role']], _BRANCH => $userBranches[$login], _PERCENTAGE => $rolesBasic[$info['user_type']] == 'student' ? $info['lesson_percentage'] . "%" : "", _ENROLLEDON => formatTimestamp($info['enrolled_on']), _COMPLETED => $completedString, _SCORE => formatScore($info['score']) . "%");
            } else {
                #cpp#else
                $data[] = array(_USER => formatLogin($info['login']), _COURSEROLE => $roles[$info['role']], _PERCENTAGE => $rolesBasic[$info['user_type']] == 'student' ? $info['lesson_percentage'] . "%" : "", _ENROLLEDON => formatTimestamp($info['enrolled_on']), _COMPLETED => $completedString, _SCORE => formatScore($info['score']) . "%");
            }
            #cpp#endif
        }
        $pdf->printDataSection(_USERSINFO, $data, $formatting);
        $pdf->OutputPdf('course_form_' . $infoCourse->course['name'] . '.pdf');
        exit;
    }
}
 /**
  * Create course metadata
  *
  * @param array $fields Course properties
  * @return string Serialized representation of metadata array
  * @since 3.6.1
  * @access private
  */
 private static function createCourseMetadata($fields)
 {
     $languages = EfrontSystem::getLanguages(true);
     $courseMetadata = array('title' => $fields['name'], 'creator' => formatLogin($GLOBALS['currentUser']->user['login']), 'publisher' => formatLogin($GLOBALS['currentUser']->user['login']), 'contributor' => formatLogin($GLOBALS['currentUser']->user['login']), 'date' => date("Y/m/d", time()), 'language' => $languages[$fields['languages_NAME']], 'type' => 'course');
     $metadata = serialize($courseMetadata);
     return $metadata;
 }
 private function doCategoryReports()
 {
     $smarty = $this->getSmartyVar();
     $currentUser = $this->getCurrentUser();
     $directionsTree = new EfrontDirectionsTree();
     $directionPaths = $directionsTree->toPathString();
     $form = new HTML_QuickForm("category_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=module&op=module_administrator_tools&tab=category_reports&do=enterprise", "", null, true);
     $form->addElement('select', 'category', _CATEGORY, $directionPaths);
     $form->addElement('checkbox', 'incomplete', _MODULE_ADMINISTRATOR_TOOLS_SHOWINCOMPLETE);
     $form->addElement('checkbox', 'inactive', _MODULE_ADMINISTRATOR_TOOLS_SHOWINACTIVECOURSES);
     $form->addElement('date', 'from_timestamp', _MODULE_ADMINISTRATOR_TOOLS_COMPLETEDFROM, array('minYear' => 1970, 'maxYear' => date("Y")));
     $form->addElement('date', 'to_timestamp', _MODULE_ADMINISTRATOR_TOOLS_COMPLETEDTO, array('minYear' => 1970, 'maxYear' => date("Y")));
     $form->addElement("submit", "submit", _SUBMIT, 'class = "flatButton"');
     $form->setDefaults(array("from_timestamp" => mktime(0, 0, 0, date("m") - 1, date("d"), date("Y")), "to_timestamp" => time()));
     if ($form->isSubmitted() && $form->validate()) {
         $values = $form->exportValues();
         $_SESSION['from_timestamp'] = mktime(0, 0, 0, $_POST['from_timestamp']['M'], $_POST['from_timestamp']['d'], $_POST['from_timestamp']['Y']);
         $_SESSION['to_timestamp'] = mktime(23, 59, 59, $_POST['to_timestamp']['M'], $_POST['to_timestamp']['d'], $_POST['to_timestamp']['Y']);
         $_SESSION['category'] = $values['category'];
         $_SESSION['incomplete'] = $values['incomplete'];
         $_SESSION['inactive'] = $values['inactive'];
         $smarty->assign("T_SHOW_TABLE", true);
     }
     if (isset($_GET['ajax']) && $_GET['ajax'] == 'categoryUsersTable' || $_GET['ajax'] == 'xls' || $_GET['ajax'] == 'show_xls') {
         $smarty->assign("T_SHOW_TABLE", true);
         $smarty->assign("T_DIRECTIONS_TREE", $directionPaths);
         $branchesTree = new EfrontBranchesTree();
         $branchesPaths = $branchesTree->toPathString();
         $category = new EfrontDirection($_SESSION['category']);
         $directionsTree = new EfrontDirectionsTree();
         $children = $directionsTree->getNodeChildren($_SESSION['category']);
         foreach (new EfrontAttributeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($children)), array('id')) as $value) {
             $siblings[] = $value;
         }
         $result = eF_getTableDataFlat("courses", "id", "archive = 0 && directions_ID in (" . implode(",", $siblings) . ")");
         $categoryCourses = $result['id'];
         $resultCourses = eF_getTableDataFlat("users_to_courses uc, courses c", "distinct c.id", 'c.id=uc.courses_ID ' . (!$_SESSION['inactive'] ? 'and c.active=1' : '') . ' and uc.archive=0 and uc.completed=1 and uc.to_timestamp >= ' . $_SESSION['from_timestamp'] . ' and uc.to_timestamp <= ' . $_SESSION['to_timestamp']);
         $resultEvents = eF_getTableDataFlat("events e, courses c", "distinct c.id", 'c.id=e.lessons_ID ' . (!$_SESSION['inactive'] ? 'and c.active=1' : '') . ' and e.type=54 and e.timestamp >= ' . $_SESSION['from_timestamp'] . ' and e.timestamp <= ' . $_SESSION['to_timestamp']);
         if (empty($resultEvents)) {
             $resultEvents['id'] = array();
         }
         $result = array_unique(array_merge($resultCourses['id'], $resultEvents['id']));
         $categoryCourses = array_intersect(array_unique($categoryCourses), $result);
         //count only courses that have users completed them
         if ($_SESSION['incomplete']) {
             $constraints = array('archive' => false, 'condition' => '(to_timestamp is null OR to_timestamp = 0 OR (to_timestamp >= ' . $_SESSION['from_timestamp'] . ' and to_timestamp <= ' . $_SESSION['to_timestamp'] . '))');
         } else {
             $constraints = array('archive' => false, 'condition' => 'completed=1 and to_timestamp >= ' . $_SESSION['from_timestamp'] . ' and to_timestamp <= ' . $_SESSION['to_timestamp']);
         }
         foreach ($categoryCourses as $courseId) {
             $course = new EfrontCourse($courseId);
             foreach ($course->getCourseUsers($constraints) as $value) {
                 $userBranches = $value->aspects['hcd']->getBranches();
                 $userSupervisors = $value->aspects['hcd']->getSupervisors();
                 $userSupervisor = end($userSupervisors);
                 $value->user['course_active'] = $course->course['active'];
                 $value->user['course_id'] = $course->course['id'];
                 $value->user['category'] = $directionPaths[$course->course['directions_ID']];
                 $value->user['course'] = $course->course['name'];
                 $value->user['directions_ID'] = $course->course['directions_ID'];
                 $value->user['branch'] = $branchesPaths[current($userBranches['employee'])];
                 $value->user['branch_ID'] = current($userBranches['employee']);
                 $value->user['supervisor'] = $userSupervisor;
                 $value->user['historic'] = false;
                 $unique = md5($value->user['to_timestamp'] . $value->user['course_id'] . $value->user['login']);
                 $courseUsers[$unique] = $value->user;
             }
             $result = eF_getTableData("events", "*", 'type=54 and lessons_ID=' . $courseId . ' and timestamp >= ' . $_SESSION['from_timestamp'] . ' and timestamp <= ' . $_SESSION['to_timestamp']);
             //exit;
             foreach ($result as $entry) {
                 try {
                     $value = EfrontUserFactory::factory($entry['users_LOGIN']);
                     if (!$value->user['archive']) {
                         $userBranches = $value->aspects['hcd']->getBranches();
                         $userSupervisors = $value->aspects['hcd']->getSupervisors();
                         //pr($entry['users_LOGIN']);pr($userSupervisors);pr(current($userSupervisors));
                         $userSupervisor = current($userSupervisors);
                         $value->user['course_active'] = $course->course['active'];
                         $value->user['course_id'] = $course->course['id'];
                         $value->user['category'] = $directionPaths[$course->course['directions_ID']];
                         $value->user['course'] = $course->course['name'];
                         $value->user['directions_ID'] = $course->course['directions_ID'];
                         $value->user['branch'] = $branchesPaths[current($userBranches['employee'])];
                         $value->user['branch_ID'] = current($userBranches['employee']);
                         $value->user['supervisor'] = $userSupervisor;
                         $value->user['to_timestamp'] = $entry['timestamp'];
                         $value->user['completed'] = 1;
                         $value->user['score'] = '';
                         $value->user['historic'] = true;
                         $unique = md5($value->user['to_timestamp'] . $value->user['course_id'] . $value->user['login']);
                         if (!isset($courseUsers[$unique])) {
                             $courseUsers[$unique] = $value->user;
                         }
                     }
                 } catch (Exception $e) {
                     /*Bypass non-existing users*/
                 }
             }
         }
         if ($_GET['ajax'] == 'xls') {
             $xlsFilePath = $currentUser->getDirectory() . 'category_report.xls';
             unlink($xlsFilePath);
             $_GET['limit'] = sizeof($courseUsers);
             $_GET['sort'] = 'category';
             list($tableSize, $courseUsers) = filterSortPage($courseUsers);
             $header = array('category' => _CATEGORY, 'course' => _NAME, 'login' => _USER, 'to_timestamp' => _COMPLETED, 'score' => _SCORE, 'supervisor' => _SUPERVISOR, 'branch' => _BRANCH, 'historic' => _MODULE_ADMINISTRATOR_TOOLS_HISTORICENTRY);
             foreach ($courseUsers as $value) {
                 $rows[] = array(_CATEGORY => str_replace("&nbsp;&rarr;&nbsp;", " -> ", $value['category']), _COURSE => $value['course'], _USER => formatLogin($value['login']), _COMPLETED => formatTimestamp($value['to_timestamp']), _SCORE => $value['historic'] ? '' : formatScore($value['score']) . '%', _SUPERVISOR => formatLogin($value['supervisor']), _BRANCH => str_replace("&nbsp;&rarr;&nbsp;", " -> ", $value['branch']), _MODULE_ADMINISTRATOR_TOOLS_HISTORICENTRY => $value['historic'] ? _YES : _NO);
             }
             EfrontSystem::exportToXls($rows, $xlsFilePath);
             exit;
         } else {
             if ($_GET['ajax'] == 'show_xls') {
                 $xlsFilePath = $currentUser->getDirectory() . 'category_report.xls';
                 $file = new EfrontFile($xlsFilePath);
                 $file->sendFile(true);
                 exit;
             } else {
                 list($tableSize, $courseUsers) = filterSortPage($courseUsers);
                 $smarty->assign("T_SORTED_TABLE", $_GET['ajax']);
                 $smarty->assign("T_TABLE_SIZE", $tableSize);
                 $smarty->assign("T_DATA_SOURCE", $courseUsers);
             }
         }
     }
     $smarty->assign("T_CATEGORY_FORM", $form->toArray());
 }
 /**
  * (non-PHPdoc)
  * @see libraries/EfrontModule#onResetProgressInCourse($login)
  */
 public function onResetProgressInAllCourses($login)
 {
     $courseName = eF_getTableData("courses", "name", "id={$courseId}");
     eF_insertTableData("module_vLab_data", array("timestamp" => time(), "data" => str_replace('%login%', formatLogin($login), _MODULE_VLAB_RESETALLCOURSE)));
 }
 private function printPdfHeader($title)
 {
     $this->pdf->SetCreator(formatLogin($_SESSION['s_login']));
     $this->pdf->SetAuthor(formatLogin($_SESSION['s_login']));
     $this->pdf->SetTitle($title);
     //$this->pdf->SetSubject($title);
     //$this->pdf->SetKeywords('pdf, '._EMPLOYEEFORM);
     $this->pdf->setPrintHeader(false);
     $this->pdf->setPrintFooter(false);
     $this->pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     $this->pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     $this->pdf->setFontSubsetting(false);
     $this->pdf->AddPage();
     $logoFile = EfrontSystem::getSystemLogo();
     $imgDetails = getimagesize($logoFile['path']);
     if ($imgDetails[0] > 170) {
         $resized_file = $logoFile['directory'] . '/resized-logo.png';
         $this->smartResizeImage($logoFile['path'], null, '170', '52', true, $resized_file, false, false, 100);
         $resized = true;
     }
     if (extension_loaded('gd')) {
         if ($resized) {
             $this->pdf->Image($resized_file, '', '', 0, 0, '', '', 'T');
         } else {
             $this->pdf->Image($logoFile['path'], '', '', 0, 0, '', '', 'T');
         }
     }
     $this->pdf->SetFont($this->defaultSettings['default_font']);
     $this->printLargeTitle($GLOBALS['configuration']['site_name']);
     $this->printSmallTitle($GLOBALS['configuration']['site_motto']);
     $this->printSeparatorHeader($title);
 }
 /**
  * The main functionality
  *
  * (non-PHPdoc)
  * @see libraries/EfrontModule#getModule()
  */
 public function getModule()
 {
     $smarty = $this->getSmartyVar();
     $smarty->assign("T_MODULE_BASEDIR", $this->moduleBaseDir);
     $smarty->assign("T_MODULE_BASELINK", $this->moduleBaseLink);
     $smarty->assign("T_MODULE_BASEURL", $this->moduleBaseUrl);
     $currentUser = $this->getCurrentUser();
     if ($currentUser->user['user_type'] != 'administrator') {
         $currentEmployee = $this->getCurrentUser()->aspects['hcd'];
         if (!$currentEmployee || !$currentEmployee->isSupervisor()) {
             throw new Exception("You cannot access this module");
         }
     }
     $form = new HTML_QuickForm("user_activity_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=module&op=module_idle_users&tab=user_activity", "", null, true);
     $form->addElement('date', 'idle_from_timestamp', _MODULE_IDLE_USERS_SHOWINACTIVEUSERSSINCE, array('minYear' => 2005, 'maxYear' => date("Y")));
     $form->addElement("static", "", '<a href = "javascript:void(0)" onclick = "setFormDate(' . date("Y") . ',' . date("m") . ',' . (date("d") - 7) . ')">' . _LASTWEEK . '</a> - <a href = "javascript:void(0)" onclick = "setFormDate(' . date("Y") . ',' . (date("m") - 1) . ',' . date("d") . ')">' . _LASTMONTH . '</a> - <a href = "javascript:void(0)" onclick = "setFormDate(' . date("Y") . ',' . (date("m") - 3) . ',' . date("d") . ')">' . _MODULE_IDLE_USERS_LAST3MONTHS . '</a>');
     $form->addElement("submit", "submit", _SUBMIT, 'class = "flatButton"');
     if (!isset($_SESSION['timestamp_from'])) {
         $_SESSION['timestamp_from'] = time() - 86400 * 30;
     }
     $form->setDefaults(array("idle_from_timestamp" => $_SESSION['timestamp_from']));
     if ($form->isSubmitted() && $form->validate()) {
         $values = $form->exportValues();
         $_SESSION['timestamp_from'] = mktime(0, 0, 0, $values['idle_from_timestamp']['M'], $values['idle_from_timestamp']['d'], $values['idle_from_timestamp']['Y']);
     }
     $smarty->assign("T_IDLE_USER_FORM", $form->toArray());
     try {
         if ($currentEmployee) {
             if ($_SESSION['s_current_branch'] && in_array($_SESSION['s_current_branch'], $currentEmployee->supervisesBranches)) {
                 $currentBranch = new EfrontBranch($_SESSION['s_current_branch']);
                 $subbranches = $currentBranch->getSubbranches();
                 foreach ($subbranches as $subbranch) {
                     $branches[$subbranch['branch_ID']] = $subbranch['branch_ID'];
                 }
                 $branches[$_SESSION['s_current_branch']] = $_SESSION['s_current_branch'];
                 $result = eF_getTableData("users u JOIN module_hcd_employee_works_at_branch ewb on ewb.users_login=u.login", "u.login,u.name,u.surname,u.active,u.last_login as last_action", "ewb.branch_ID in (" . implode(',', $branches) . ") and u.last_login is null or u.last_login <= " . $_SESSION['timestamp_from']);
                 //$result = eF_getTableData("(select login,name,surname,active,max(l.timestamp) as last_action from users u left outer join logs l on u.login=l.users_LOGIN where u.archive=0 group by login) r join module_hcd_employee_works_at_branch ewb on ewb.users_login=r.login", "*", "ewb.branch_ID in (".implode(',', $branches) .") and (r.last_action is null or r.last_action <= ".$_SESSION['timestamp_from'].")");
             } else {
                 $result = eF_getTableData("users u JOIN module_hcd_employee_works_at_branch ewb on ewb.users_login=u.login", "u.login,u.name,u.surname,u.active,u.last_login as last_action", "ewb.branch_ID in (" . implode(',', $currentEmployee->supervisesBranches) . ") and u.last_login is null or u.last_login <= " . $_SESSION['timestamp_from']);
                 //$result = eF_getTableData("(select login,name,surname,active,max(l.timestamp) as last_action from users u left outer join logs l on u.login=l.users_LOGIN where u.archive=0 group by login) r join module_hcd_employee_works_at_branch ewb on ewb.users_login=r.login", "*", "ewb.branch_ID in (".implode(',', $currentEmployee->supervisesBranches).") and (r.last_action is null or r.last_action <= ".$_SESSION['timestamp_from'].")");
             }
         } else {
             $result = eF_getTableData("users", "login,name,surname,active,last_login as last_action", "last_login is null or last_login <= " . $_SESSION['timestamp_from']);
         }
         $users = array();
         foreach ($result as $value) {
             if ($value['last_action']) {
                 $value['last_action_since'] = eF_convertIntervalToTime(time() - $value['last_action'], true);
             } else {
                 $value['last_action_since'] = null;
             }
             $users[$value['login']] = $value;
         }
         foreach ($users as $key => $value) {
             if (isset($_COOKIE['toggle_active'])) {
                 if ($_COOKIE['toggle_active'] == 1 && !$value['active'] || $_COOKIE['toggle_active'] == -1 && $value['active']) {
                     unset($users[$key]);
                 }
             }
         }
         if (isset($_GET['excel'])) {
             $export_users[] = array(_USER, _MODULE_IDLE_USERS_LASTACTION, _STATUS);
             foreach ($users as $key => $value) {
                 $value['last_action'] ? $last_action = formatTimestamp($value['last_action']) : ($last_action = _NEVER);
                 $value['active'] ? $status = _ACTIVE : ($status = _INACTIVE);
                 $export_users[] = array(formatLogin($value['login']), $last_action, $status);
             }
             EfrontSystem::exportToCsv($export_users, true);
             exit;
         }
         if ($_GET['ajax'] == 'idleUsersTable') {
             list($tableSize, $users) = filterSortPage($users);
             $smarty->assign("T_SORTED_TABLE", $_GET['ajax']);
             $smarty->assign("T_TABLE_SIZE", $tableSize);
             $smarty->assign("T_DATA_SOURCE", $users);
         }
         if (isset($_GET['ajax']) && isset($_GET['archive_user'])) {
             if (isset($users[$_GET['archive_user']])) {
                 $user = EfrontUserFactory::factory($_GET['archive_user']);
                 $user->archive();
             }
             exit;
         } else {
             if (isset($_GET['ajax']) && isset($_GET['archive_all_users'])) {
                 //eF_updateTableData("users", array("archive" => 1, "active" => 0), "login in (select login from (select login,max(l.timestamp) as last_action from users u left outer join logs l on u.login=l.users_LOGIN where u.archive=0 and u.login != '".$_SESSION['s_login']."' group by login) r where r.last_action <= ".$_SESSION['timestamp_from']." or r.last_action is null)");
                 foreach ($users as $value) {
                     eF_updateTableData("users", array("archive" => 1, "active" => 0), "login='******'login'] . "'");
                 }
                 exit;
             } else {
                 if (isset($_GET['ajax']) && isset($_GET['toggle_user'])) {
                     if (isset($users[$_GET['toggle_user']])) {
                         $user = EfrontUserFactory::factory($_GET['toggle_user']);
                         if ($user->user['active']) {
                             $user->deactivate();
                         } else {
                             $user->activate();
                         }
                         echo json_encode(array('status' => 1, 'active' => $user->user['active']));
                     }
                     exit;
                 } else {
                     if (isset($_GET['ajax']) && isset($_GET['deactivate_all_users'])) {
                         //eF_updateTableData("users", array("active" => 0), "login in (select login from (select login,max(l.timestamp) as last_action from users u left outer join logs l on u.login=l.users_LOGIN where u.archive=0 and u.login != '".$_SESSION['s_login']."' group by login) r where r.last_action <= ".$_SESSION['timestamp_from']." or r.last_action is null)");
                         foreach ($users as $value) {
                             eF_updateTableData("users", array("active" => 0), "login='******'login'] . "'");
                         }
                         exit;
                     }
                 }
             }
         }
     } catch (Exception $e) {
         handleAjaxExceptions($e);
     }
     return true;
 }
 /**
  * (non-PHPdoc)
  * @see libraries/EfrontEntity#handleForm($form)
  */
 public function handleForm($form)
 {
     $values = $form->exportValues();
     $forumUser = EfrontUserFactory::factory($_SESSION['s_login']);
     $forumAttachmentDirectory = $forumUser->getDirectory() . 'forum';
     if (!is_dir($forumAttachmentDirectory)) {
         mkdir($forumAttachmentDirectory, 0755);
     }
     $filesystem = new FileSystemTree($forumAttachmentDirectory);
     $attachmentBody = '';
     foreach ($_FILES['attachment_upload']['error'] as $key => $value) {
         if ($value != UPLOAD_ERR_NO_FILE) {
             $uploadedFile = $filesystem->uploadFile('attachment_upload', $certificateDirectory, $key);
             $attachmentid = $uploadedFile['id'];
             $attachmentBody .= '<p style="font-style:italic"><a href="view_file.php?action=download&file=' . $attachmentid . '">' . $uploadedFile['name'] . '</a></p>';
         }
     }
     if (isset($_GET['edit'])) {
         $fields = array("title" => $values['title'], "body" => $values['body'] . $attachmentBody);
         if ($this->{$this->entity}['users_LOGIN'] != $_SESSION['s_login'] && strstr($fields['body'], _FORUMMESSAGEEDITEDBY . " " . formatLogin($_SESSION['s_login'])) === false) {
             $fields['body'] .= " " . _FORUMMESSAGEEDITEDBY . " " . formatLogin($_SESSION['s_login']) . " (" . formatTimestamp(time()) . ")";
         }
         $this->{$this->entity} = array_merge($this->{$this->entity}, $fields);
         $this->persist();
     } else {
         $fields = array("title" => $values['title'], "body" => $values['body'] . $attachmentBody, "f_topics_ID" => $_GET['topic_id'], "users_LOGIN" => $_SESSION['s_login'], "timestamp" => time(), "replyto" => $values['replyto'] ? $values['replyto'] : 0);
         self::create($fields);
     }
 }
    /**
     * 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_owner']) ? $options['show_owner'] = false : 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['delete_folder']) ? $options['delete_folder'] = false : 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
            try {
                $subtree = $this->seekNode($currentDir['path']);
                //If the folder is leaf and empty, this will throw an exception
            } catch (Exception $e) {
            }
            foreach ($innerFileSystem->tree as $key => $value) {
                !empty($subtree[$key]) or $subtree[$key] = $value;
                $currentDir[$key] = $subtree[$key];
            }
            //$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.'/'.eFront_basename($file['path']));
                    $file->copy($currentDirectory . '/' . eFront_basename($file['path']), false);
                }
            }
        } 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() . ') &nbsp;<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);
            }
            if ($options['extra_filter']) {
                $filt = array_keys($options['extra_filter']);
                $filt = $filt[0];
                $arg0 = $options['extra_filter'][$filt][0];
                $arg1 = $options['extra_filter'][$filt][1];
                $code = ' $iterator = new $filt($iterator, $arg0, $arg1);';
                eval($code);
            }
            if ($options['extra_filter']) {
                $filt = array_keys($options['extra_filter']);
                $filt = $filt[0];
                $arg0 = $options['extra_filter'][$filt][0];
                $arg1 = $options['extra_filter'][$filt][1];
                $code = ' $iterator = new $filt($iterator, $arg0, $arg1);';
                eval($code);
            }
            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);
            }
            if ($options['extra_filter']) {
                $filt = array_keys($options['extra_filter']);
                $filt = $filt[0];
                $arg0 = $options['extra_filter'][$filt][0];
                $arg1 = $options['extra_filter'][$filt][1];
                $code = ' $iterator = new $filt($iterator, $arg0, $arg1);';
                eval($code);
            }
        }
        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_owner'] ? '<td class = "topTitle centerAlign" name = "extension">' . _USER . '</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'] || $options['copy'] || $_SESSION['s_lessons_ID'] && $options['share'] ? '<td class = "topTitle centerAlign">' . _SELECT . '</td>' : '') . '
                    		</tr>';
        if (isset($parentDir)) {
            if ($parentDir['path'] == $this->dir['path']) {
                $parentDir['path'] = '';
            }
            //Create links for currently browsing folder section
            $path_parts = explode('/', str_replace($this->dir['path'] . '/', '', $currentDir['path']));
            $path_string = '<a class="editLink" href = "javascript:void(0)" onclick = "eF_js_rebuildTable($(\'filename_' . $tableId . '\').down().getAttribute(\'tableIndex\'), 0, \'\', \'desc\', \'' . urlencode($this->dir['path']) . '\');">../</a>';
            $concat_part = '';
            //pr($this -> dir['path']);
            foreach ($path_parts as $path_part) {
                $concat_part = $concat_part . '/' . $path_part;
                $path_string .= '<a class="editLink" href = "javascript:void(0)" onclick = "eF_js_rebuildTable($(\'filename_' . $tableId . '\').down().getAttribute(\'tableIndex\'), 0, \'\', \'desc\', \'' . urlencode($this->dir['path'] . $concat_part) . '\');">' . EfrontFile::decode($path_part) . '/</a>';
            }
            //vd($concat_part);
            $filesCode .= '
            			<tr class = "defaultRowHeight eventRowColor"><td class = "centerAlign" colspan = "100%">' . _CURRENTLYBROWSINGFOLDER . ': ' . $path_string . '</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>&nbsp;';
                    if ($tool['mode'] == 'custom' && (!isset($tool['hide']) || !$value['hide_' . $tool['hide']])) {
                        $toolsString .= '<span>                   					
                    					<a href = "' . (isset($tool['href']) ? $tool['href'] . '&file_identifier=' . $identifier : 'javascript:void(0)') . '" ' . (isset($tool['popup']) ? ' target = "POPUP_FRAME" ' : null) . 'onclick = "' . $tool['action'] . '"><img src = "' . $tool['image'] . '" alt = "' . $tool['title'] . '" title = "' . $tool['title'] . '"></a>&nbsp;
                    					</span>';
                    } else {
                        if (!isset($tool['hide']) || !$value['hide_' . $tool['hide']]) {
                            $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>&nbsp;';
                        }
                    }
                }
                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>&nbsp;';
                }
                if ($options['download']) {
                    $toolsString .= '<a href = "' . $url . '&download=' . urlencode($identifier) . '"><img src = "images/16x16/import.png" alt = "' . _DOWNLOADFILE . '" title = "' . _DOWNLOADFILE . '" border = "0"/></a>&nbsp;';
                }
                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>&nbsp;';
                }
                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 = "' . _RENAME . '" title = "' . _RENAME . '" onclick = "toggleEditBox(this, \'' . urlencode($identifier) . '\')"/>&nbsp;';
                }
                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>&nbsp;';
                }
            } else {
                if (is_dir($value['path'])) {
                    $filterValue = $value;
                    $identifier = $value['path'];
                    $value = new EfrontDirectory($value['path']);
                    $link = $url . '&view_dir=' . urlencode($identifier);
                    foreach ($extraDirectoryTools as $tool) {
                        if ($tool['mode'] == 'custom' && (!isset($tool['hide']) || !$filterValue['hide_' . $tool['hide']])) {
                            $toolsString .= '<span>
                    	<a href = "' . (isset($tool['href']) ? $tool['href'] . '&file_identifier=' . urlencode($identifier) : 'javascript:void(0)') . '" ' . (isset($tool['popup']) ? ' target = "POPUP_FRAME" ' : null) . 'onclick = "' . $tool['action'] . '"><img src = "' . $tool['image'] . '" alt = "' . $tool['title'] . '" title = "' . $tool['title'] . '"></a>&nbsp;
                    	</span>';
                        } else {
                            if (!isset($tool['hide']) || !$filterValue['hide_' . $tool['hide']]) {
                                $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>&nbsp;';
                            }
                        }
                    }
                    if ($options['edit']) {
                        $toolsString .= '<img class = "ajaxHandle edit" src = "images/16x16/edit.png" alt = "' . _RENAME . '" title = "' . _RENAME . '" onclick = "toggleEditBox(this, \'' . urlencode($identifier) . '\')"/>&nbsp;';
                    }
                    if ($options['delete'] || $options['delete_folder']) {
                        $toolsString .= '<img class = "ajaxHandle" src = "images/16x16/error_delete.png" alt = "' . _DELETE . '" title = "' . _DELETE . '" onclick = "if (confirm(\'' . _IRREVERSIBLEACTIONAREYOUSURE . '\')) {deleteFolder(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)}" />&nbsp;';
                    }
                }
            }
            $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 = "javascript:void(0);" onclick = "eF_js_showDivPopup(event, \'' . _PREVIEW . '\', 2, \'preview_table_' . $tableId . '\');$(\'preview_frame\').src = \'' . $link . '\';" >' . $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;}"/>&nbsp;<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>';
            }
            if ($options['show_owner']) {
                $filesCode .= '<td class = "centerAlign"><span>' . (isset($value['users_LOGIN']) ? formatLogin($value['users_LOGIN']) : '') . '</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'] || $options['copy'] || $_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'] || $options['copy'] || $_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 . '\');">&nbsp;';
                }
                $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>&nbsp;
        		</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>&nbsp;
        		</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)') . '" ' . (isset($option['popup']) ? ' target = "POPUP_FRAME" ' : null) . 'onclick = "' . $option['action'] . '">' . $option['title'] . '</a>&nbsp;
    	    	</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;
    }
Example #14
0
 /**
  * Get event message
  *
  * This function creates the message string for this event
  * according to its type and its information
  *
  * <br/>Example:
  * <code>
  * $event = new EfrontEvent(5);       //create object for event with id 5
  * $event -> createMessage();
  * echo $event -> event['message'];
  * </code>
  *
  * @param array with all modules to optimize module message printing
  * @returns the message value also set to the $this -> event['message'] field
  * @since 3.6.0
  * @access public
  */
 public function createMessage($modulesArray = false)
 {
     global $currentUser;
     // Module related code
     if ($this->event['type'] >= EfrontEvent::MODULE_BASE_TYPE_CODE) {
         $className = $this->event['entity_ID'];
         if (isset($modulesArray[$className])) {
             $data = array();
             if ($this->event['entity_name'] != '') {
                 $data = unserialize($this->event['entity_name']);
             }
             foreach ($this->event as $field => $value) {
                 $data[$field] = $value;
             }
             $this->event['message'] = $modulesArray[$className]->getEventMessage((int) $this->event['type'] - EfrontEvent::MODULE_BASE_TYPE_CODE, $data);
         }
         if (!$this->event['message']) {
             $this->event['message'] = _UNREGISTEREDEVENT . " " . _FORTHEMODULE . " '" . $className . "'";
         }
     } else {
         // Basic system event codes
         // All excluded events are not of the form: The user did sth. For example: Project X expired
         if ($this->event['type'] != EfrontEvent::PROJECT_EXPIRY && $this->event['type'] != EfrontEvent::LESSON_PROGRAMMED_EXPIRY && $this->event['type'] != EfrontEvent::LESSON_PROGRAMMED_START) {
             //changed to $_SESSION['s_type'] to work for different roles between lessons
             formatLogin($this->event['users_LOGIN']) ? $formattedLogin = formatLogin($this->event['users_LOGIN']) : ($formattedLogin = $this->event['users_name'] . ' ' . $this->event['users_surname'] . ' (' . $this->event['users_LOGIN'] . ')');
             $this->event['message'] = _NAMEARTICLE . " <b><a  href = \"" . $_SESSION['s_type'] . ".php?ctg=social&op=show_profile&user="******"&popup=1\" onclick = \"eF_js_showDivPopup(event, '" . _USERPROFILE . "', 1)\"  target = \"POPUP_FRAME\"> " . $formattedLogin . "</a></b> ";
         }
         if ($this->event['type'] == EfrontEvent::SYSTEM_JOIN) {
             $this->event['message'] .= _HASJOINEDTHESYSTEM;
         } else {
             if ($this->event['type'] == EfrontEvent::SYSTEM_VISITED) {
                 $this->event['message'] .= _VISITEDTHESYSTEM;
             } else {
                 if ($this->event['type'] == EfrontEvent::SYSTEM_FORGOTTEN_PASSWORD) {
                     $this->event['message'] .= _HASFORGOTTENHISPASSWORD;
                 } else {
                     if ($this->event['type'] == EfrontEvent::SYSTEM_REMOVAL) {
                         $this->event['message'] .= _HASBEENREMOVEDFROMTHESYSTEM;
                     } else {
                         if ($this->event['type'] == EfrontEvent::LESSON_ACQUISITION_AS_STUDENT) {
                             $this->event['message'] .= _WASASSIGNEDTHELESSON . " <b>" . $this->event['lessons_name'] . "</b>";
                         } else {
                             if ($this->event['type'] == EfrontEvent::LESSON_ACQUISITION_AS_PROFESSOR) {
                                 $this->event['message'] .= _WILLBETEACHINGLESSON . " <b>" . $this->event['lessons_name'] . "</b>";
                             } else {
                                 if ($this->event['type'] == EfrontEvent::LESSON_VISITED) {
                                     $this->event['message'] .= _VISITEDLESSON . " <b>" . $this->event['lessons_name'] . "</b>";
                                 } else {
                                     if ($this->event['type'] == EfrontEvent::LESSON_REMOVAL) {
                                         $this->event['message'] .= _NOLONGERATTENDSLESSON . " <b>" . $this->event['lessons_name'] . "</b>";
                                     } else {
                                         if ($this->event['type'] == EfrontEvent::LESSON_COMPLETION) {
                                             $this->event['message'] .= _HASCOMPLETEDLESSON . " <b>" . $this->event['lessons_name'] . "</b>";
                                         } else {
                                             if ($this->event['type'] == EfrontEvent::LESSON_PROGRESS_RESET) {
                                                 $this->event['message'] .= _WASBEINGRESETLESSONPROGRESS . " <b>" . $this->event['lessons_name'] . "</b>";
                                             } else {
                                                 if ($this->event['type'] == EfrontEvent::PROJECT_SUBMISSION) {
                                                     $this->event['message'] .= _SUBMITTEDPROJECT . " <b>" . $this->event['entity_name'] . "</b> " . _OFTHELESSON . " <b>" . $this->event['lessons_name'] . "</b>";
                                                 } else {
                                                     if ($this->event['type'] == EfrontEvent::PROJECT_CREATION) {
                                                         $this->event['message'] .= _HASCREATEDPROJECT . " <b>" . $this->event['entity_name'] . "</b> " . _FORTHELESSON . " <b>" . $this->event['lessons_name'] . "</b>";
                                                     } else {
                                                         if ($this->event['type'] == EfrontEvent::LESSON_PROGRAMMED_START) {
                                                             $this->event['message'] .= _SCHEDULEDSTARTOFLESSON . " <b>" . $this->event['lessons_name'] . "</b>";
                                                         } else {
                                                             if ($this->event['type'] == EfrontEvent::LESSON_PROGRAMMED_EXPIRY) {
                                                                 $this->event['message'] .= _SCHEDULEDEXPIRYOFLESSON . " <b>" . $this->event['lessons_name'] . "</b>";
                                                             } else {
                                                                 if ($this->event['type'] == EfrontEvent::PROJECT_EXPIRY) {
                                                                     $this->event['message'] .= _THEPROJECT . " <b>" . $this->event['entity_name'] . "</b> " . _OFTHELESSON . " <b>" . $this->event['lessons_name'] . "</b> " . _HASEXPIRED;
                                                                 } else {
                                                                     if ($this->event['type'] == EfrontEvent::PROJECT_ASSIGNMENT) {
                                                                         $this->event['message'] .= _THEPROJECT . " <b>" . $this->event['entity_name'] . "</b> " . _OFTHELESSON . " <b>" . $this->event['lessons_name'] . "</b> " . _WASASSIGNEDTO . " " . $this->event['users_LOGIN'];
                                                                     } else {
                                                                         if ($this->event['type'] == EfrontEvent::NEW_LESSON_ANNOUNCEMENT) {
                                                                             $this->event['message'] .= _HASPUBLISHEDTHEANNOUNCEMENT . " <b>" . $this->event['entity_name'] . "</b> " . _OFTHELESSON . " <b>" . $this->event['lessons_name'] . "</b> ";
                                                                         } else {
                                                                             if ($this->event['type'] == EfrontEvent::SYSTEM_NEW_PASSWORD_REQUEST) {
                                                                                 $this->event['message'] .= _HASASKEDFORANEWPASSWORD;
                                                                             } else {
                                                                                 if ($this->event['type'] == EfrontEvent::SYSTEM_REGISTER) {
                                                                                     $this->event['message'] .= _WASREGISTEREDINTOTHESYSTEM;
                                                                                 } else {
                                                                                     if ($this->event['type'] == EfrontEvent::SYSTEM_ON_EMAIL_ACTIVATION) {
                                                                                         $this->event['message'] .= _ACTIVATEDHISACCOUNTWITHEACTIVATIONMAIL;
                                                                                     } else {
                                                                                         if ($this->event['type'] == EfrontEvent::SYSTEM_ON_ADMIN_ACTIVATION) {
                                                                                             $this->event['message'] .= _ACTIVATEDACCOUNTFROMSUPERVISOR;
                                                                                         } else {
                                                                                             if ($this->event['type'] == EfrontEvent::SYSTEM_USER_DEACTIVATE) {
                                                                                                 $this->event['message'] .= _WASDEACTIVATEDFROMTHESYSTEM;
                                                                                                 // For courses we have lessons_name -> courses_name
                                                                                             } else {
                                                                                                 if ($this->event['type'] == EfrontEvent::COURSE_ACQUISITION_AS_STUDENT) {
                                                                                                     $this->event['message'] .= _WASASSIGNEDTHECOURSE . " <b>" . $this->event['lessons_name'] . "</b>";
                                                                                                 } else {
                                                                                                     if ($this->event['type'] == EfrontEvent::COURSE_ACQUISITION_AS_PROFESSOR) {
                                                                                                         $this->event['message'] .= _WILLBETEACHINGCOURSE . " <b>" . $this->event['lessons_name'] . "</b>";
                                                                                                     } else {
                                                                                                         if ($this->event['type'] == EfrontEvent::COURSE_COMPLETION) {
                                                                                                             $this->event['message'] .= _HASCOMPLETEDCOURSE . " <b>" . $this->event['lessons_name'] . "</b>";
                                                                                                         } else {
                                                                                                             if ($this->event['type'] == EfrontEvent::COURSE_REMOVAL) {
                                                                                                                 $this->event['message'] .= _NOLONGERATTENDSCOURSE . " <b>" . $this->event['lessons_name'] . "</b>";
                                                                                                             } else {
                                                                                                                 if ($this->event['type'] == EfrontEvent::COURSE_PROGRAMMED_START) {
                                                                                                                     $this->event['message'] .= _SCHEDULEDSTARTOFCOURSE . " <b>" . $this->event['lessons_name'] . "</b>";
                                                                                                                 } else {
                                                                                                                     if ($this->event['type'] == EfrontEvent::COURSE_PROGRAMMED_EXPIRY) {
                                                                                                                         $this->event['message'] .= _SCHEDULEDEXPIRYOFCOURSE . " <b>" . $this->event['lessons_name'] . "</b>";
                                                                                                                     } else {
                                                                                                                         if ($this->event['type'] == EfrontEvent::COURSE_PROGRESS_RESET) {
                                                                                                                             $this->event['message'] .= _WASBEINGRESETCOURSEPROGRESS . " <b>" . $this->event['lessons_name'] . "</b>";
                                                                                                                         } else {
                                                                                                                             if ($this->event['type'] == EfrontEvent::TEST_CREATION) {
                                                                                                                                 $this->event['message'] .= _CREATEDTHETEST . " <b>" . $this->event['entity_name'] . "</b> " . _FORTHELESSON . " <b>" . $this->event['lessons_name'] . "</b>";
                                                                                                                             } else {
                                                                                                                                 if ($this->event['type'] == EfrontEvent::CONTENT_MODIFICATION) {
                                                                                                                                     $this->event['message'] .= _HASMODIFIEDUNIT . " <b>" . $this->event['entity_name'] . "</b> " . _OFTHELESSON . " <b>" . $this->event['lessons_name'] . "</b>";
                                                                                                                                 } else {
                                                                                                                                     if ($this->event['type'] == EfrontEvent::CONTENT_CREATION) {
                                                                                                                                         $this->event['message'] .= _HASCREATEDUNIT . " <b>" . $this->event['entity_name'] . "</b> " . _FORTHELESSON . " <b>" . $this->event['lessons_name'] . "</b>";
                                                                                                                                     } else {
                                                                                                                                         if ($this->event['type'] == EfrontEvent::CONTENT_COMPLETION) {
                                                                                                                                             $this->event['message'] .= _HASCOMPLETEDUNIT . " <b>" . $this->event['entity_name'] . "</b> " . _OFTHELESSON . " <b>" . $this->event['lessons_name'] . "</b>";
                                                                                                                                         } else {
                                                                                                                                             if ($this->event['type'] == EfrontEvent::NEW_SYSTEM_ANNOUNCEMENT) {
                                                                                                                                                 $this->event['message'] .= _HASPUBLISHEDTHEANNOUNCEMENT . " <b>" . $this->event['entity_name'] . "</b>";
                                                                                                                                             } else {
                                                                                                                                                 if ($this->event['type'] == EfrontEvent::NEW_SURVEY) {
                                                                                                                                                     $this->event['message'] .= _HASPUBLISHEDSURVEY . " <b>" . str_replace("</p>", "", str_replace("<p>", "", $this->event['entity_name'])) . "</b> " . _FORTHELESSON . " <b>" . $this->event['lessons_name'] . "</b>";
                                                                                                                                                 } else {
                                                                                                                                                     if ($this->event['type'] == EfrontEvent::NEW_COMMENT_WRITING) {
                                                                                                                                                         $this->event['message'] .= _WROTEACOMMENTFORUNIT . " <b>" . $this->event['entity_name'] . "</b> " . _OFTHELESSON . " <b>" . $this->event['lessons_name'] . "</b>";
                                                                                                                                                     } else {
                                                                                                                                                         if ($this->event['type'] == EfrontEvent::TEST_START) {
                                                                                                                                                             $this->event['message'] .= _STARTEDTEST . " <b>" . $this->event['entity_name'] . "</b> " . _OFTHELESSON . " <b>" . $this->event['lessons_name'] . "</b>";
                                                                                                                                                         } else {
                                                                                                                                                             if ($this->event['type'] == EfrontEvent::TEST_COMPLETION) {
                                                                                                                                                                 $this->event['message'] .= _COMPLETEDTEST . " <b>" . $this->event['entity_name'] . "</b> " . _OFTHELESSON . " <b>" . $this->event['lessons_name'] . "</b>";
                                                                                                                                                             } else {
                                                                                                                                                                 if ($this->event['type'] == EfrontEvent::TEST_FAILURE) {
                                                                                                                                                                     $this->event['message'] .= _FAILEDTEST . " <b>" . $this->event['entity_name'] . "</b> " . _OFTHELESSON . " <b>" . $this->event['lessons_name'] . "</b>";
                                                                                                                                                                 } else {
                                                                                                                                                                     if ($this->event['type'] == EfrontEvent::TEST_MARKED) {
                                                                                                                                                                         $this->event['message'] .= _MARKEDTEST . " <b>" . $this->event['entity_name'] . "</b> " . _OFTHELESSON . " <b>" . $this->event['lessons_name'] . "</b>";
                                                                                                                                                                     } else {
                                                                                                                                                                         if ($this->event['type'] == EfrontEvent::NEW_FORUM) {
                                                                                                                                                                             $this->event['message'] .= _CREATEDTHENEWFORUM . " <b>" . $this->event['entity_name'] . "</b> " . _FORTHELESSON . " <b>" . $this->event['lessons_name'] . "</b>";
                                                                                                                                                                         } else {
                                                                                                                                                                             if ($this->event['type'] == EfrontEvent::NEW_TOPIC) {
                                                                                                                                                                                 $this->event['message'] .= _CREATEDTHENEWTOPIC . " <b>" . $this->event['entity_name'] . "</b> " . _FORTHELESSON . " <b>" . $this->event['lessons_name'] . "</b>";
                                                                                                                                                                             } else {
                                                                                                                                                                                 if ($this->event['type'] == EfrontEvent::NEW_POLL) {
                                                                                                                                                                                     $this->event['message'] .= _CREATEDTHENEWPOLL . " <b>" . $this->event['entity_name'] . "</b> " . _FORTHELESSON . " <b>" . $this->event['lessons_name'] . "</b>";
                                                                                                                                                                                 } else {
                                                                                                                                                                                     if ($this->event['type'] == EfrontEvent::NEW_FORUM_MESSAGE_POST) {
                                                                                                                                                                                         $this->event['message'] .= _POSTEDTHENEWMESSAGE . " <b>" . $this->event['entity_name'] . "</b> " . _INTHEFORUMOFTHELESSON . " <b>" . $this->event['lessons_name'] . "</b>";
                                                                                                                                                                                     } else {
                                                                                                                                                                                         if ($this->event['type'] == EfrontEvent::STATUS_CHANGE) {
                                                                                                                                                                                             $this->event['message'] .= _CHANGEDHISHERPROFILE;
                                                                                                                                                                                         } else {
                                                                                                                                                                                             if ($this->event['type'] == EfrontEvent::AVATAR_CHANGE) {
                                                                                                                                                                                                 $this->event['message'] .= _CHANGEDHISHERAVATARPICTURE;
                                                                                                                                                                                             } else {
                                                                                                                                                                                                 if ($this->event['type'] == EfrontEvent::PROFILE_CHANGE) {
                                                                                                                                                                                                     $this->event['message'] .= _CHANGEDHISHERPROFILE;
                                                                                                                                                                                                 } else {
                                                                                                                                                                                                     if ($this->event['type'] == EfrontEvent::NEW_PROFILE_COMMENT_FOR_OTHER) {
                                                                                                                                                                                                         $this->event['message'] .= _COMMENTEDONTHEPROFILEOF;
                                                                                                                                                                                                         // Here check whether this is your own profile or not
                                                                                                                                                                                                         if ($this->event['entity_ID'] != $currentUser->user['login']) {
                                                                                                                                                                                                             $this->event['message'] .= " <b><a  href = \"" . $currentUser->getType() . ".php?ctg=social&op=show_profile&user="******"&popup=1\" onclick = \"eF_js_showDivPopup(event, '" . _USERPROFILE . "', 1)\"  target = \"POPUP_FRAME\"> " . $this->event['entity_name'] . "</a></b> ";
                                                                                                                                                                                                         } else {
                                                                                                                                                                                                             $this->event['message'] .= " <b>" . $this->event['entity_name'] . "</b>";
                                                                                                                                                                                                         }
                                                                                                                                                                                                     } else {
                                                                                                                                                                                                         if ($this->event['type'] == EfrontEvent::NEW_PROFILE_COMMENT_FOR_SELF) {
                                                                                                                                                                                                             $this->event['message'] .= _COMMENTEDONHISHEROWNPROFILE;
                                                                                                                                                                                                         } else {
                                                                                                                                                                                                             if ($this->event['type'] == EfrontEvent::DELETE_PROFILE_COMMENT_FOR_SELF) {
                                                                                                                                                                                                                 $this->event['message'] .= _DELETEDACOMMENTFROMHISHEROWNPROFILE;
                                                                                                                                                                                                             } else {
                                                                                                                                                                                                                 if ($this->event['type'] == EfrontEvent::NEW_POST_FOR_LESSON_TIMELINE_TOPIC) {
                                                                                                                                                                                                                     $topic_post = unserialize($this->event['entity_name']);
                                                                                                                                                                                                                     $this->event['message'] .= _POSTEDFORLESSONTOPIC . " <b>" . $topic_post['topic_title'] . "</b> " . _THEPOST . ": " . $topic_post['data'];
                                                                                                                                                                                                                     if ($this->event['users_LOGIN'] == $GLOBALS['currentUser']->user['login']) {
                                                                                                                                                                                                                         $this->event['editlink'] = "<a href='" . $_SESSION['s_type'] . ".php?ctg=social&op=timeline&lessons_ID=" . $this->event['lessons_ID'] . "&post_topic=" . $this->event['entity_ID'] . "&action=change&popup=1&id=" . $topic_post['post_id'] . "' onclick = 'eF_js_showDivPopup(event, \"" . _EDITMESSAGEFORLESSONTIMELINETOPIC . "\", 1)'  target = 'POPUP_FRAME'><img src='images/16x16/edit.png' border='0' alt = '" . _EDITMESSAGEFORLESSONTIMELINETOPIC . "' title='" . _EDITMESSAGEFORLESSONTIMELINETOPIC . "' /></a>";
                                                                                                                                                                                                                         $this->event['deletelink'] = "<a href='" . $_SESSION['s_type'] . ".php?ctg=social&op=timeline&lessons_ID=" . $this->event['lessons_ID'] . "&post_topic=" . $this->event['entity_ID'] . "&action=delete&id=" . $topic_post['post_id'] . "'><img src='images/16x16/error_delete.png' border='0' alt = '" . _DELETEMESSAGEFORLESSONTIMELINETOPIC . "' title='" . _DELETEMESSAGEFORLESSONTIMELINETOPIC . "' /></a>";
                                                                                                                                                                                                                     }
                                                                                                                                                                                                                 } else {
                                                                                                                                                                                                                     if ($this->event['type'] == EfrontEvent::DELETE_POST_FROM_LESSON_TIMELINE) {
                                                                                                                                                                                                                         $this->event['message'] .= _DELETEDAPOSTFORLESSONTOPIC . " " . $this->event['entity_name'];
                                                                                                                                                                                                                     } else {
                                                                                                                                                                                                                         if ($this->event['type'] == EfrontEvent::HCD_NEW_BRANCH) {
                                                                                                                                                                                                                             $this->event['message'] .= _CREATEDTHEBRANCH . " <b>" . $this->event['lessons_name'] . "</b>";
                                                                                                                                                                                                                         } else {
                                                                                                                                                                                                                             if ($this->event['type'] == EfrontEvent::HCD_REMOVE_BRANCH) {
                                                                                                                                                                                                                                 $this->event['message'] .= _DELETEDTHEBRANCH . " <b>" . $this->event['lessons_name'] . "</b>";
                                                                                                                                                                                                                             } else {
                                                                                                                                                                                                                                 if ($this->event['type'] == EfrontEvent::HCD_NEW_JOB_ASSIGNMENT) {
                                                                                                                                                                                                                                     $this->event['message'] .= _WASASSIGNEDTHEJOB . " <b>" . $this->event['entity_name'] . "</b>" . _ATBRANCH . " <b>" . $this->event['lessons_name'] . "</b>";
                                                                                                                                                                                                                                 } else {
                                                                                                                                                                                                                                     if ($this->event['type'] == EfrontEvent::HCD_REMOVE_JOB_ASSIGNMENT) {
                                                                                                                                                                                                                                         $this->event['message'] .= _WASREMOVEDFROMJOB . " <b>" . $this->event['entity_name'] . "</b>" . _ATBRANCH . " <b>" . $this->event['lessons_name'] . "</b>";
                                                                                                                                                                                                                                     } else {
                                                                                                                                                                                                                                         if ($this->event['type'] == EfrontEvent::HCD_FIRED) {
                                                                                                                                                                                                                                             $this->event['message'] .= _WASFIRED;
                                                                                                                                                                                                                                         } else {
                                                                                                                                                                                                                                             if ($this->event['type'] == EfrontEvent::NEW_ASSIGNMENT_TO_GROUP) {
                                                                                                                                                                                                                                                 $this->event['message'] .= _WASASSIGNEDTOGROUP . " <b>" . $this->event['entity_name'] . "</b>";
                                                                                                                                                                                                                                             } else {
                                                                                                                                                                                                                                                 if ($this->event['type'] == EfrontEvent::REMOVAL_FROM_GROUP) {
                                                                                                                                                                                                                                                     $this->event['message'] .= _WASREMOVEDFROMGROUP . " <b>" . $this->event['entity_name'] . "</b>";
                                                                                                                                                                                                                                                 } else {
                                                                                                                                                                                                                                                     if ($this->event['type'] == EfrontEvent::NEW_PAYPAL_PAYMENT) {
                                                                                                                                                                                                                                                         $this->event['message'] .= _PAYEDWITHPAYPAL . " <b>" . $this->event['entity_name'] . "</b>";
                                                                                                                                                                                                                                                     } else {
                                                                                                                                                                                                                                                         if ($this->event['type'] == EfrontEvent::NEW_BALANCE_PAYMENT) {
                                                                                                                                                                                                                                                             $this->event['message'] .= _PAYEDWITHBALANCE . " <b>" . $this->event['entity_name'] . "</b>";
                                                                                                                                                                                                                                                         } else {
                                                                                                                                                                                                                                                             if ($this->event['type'] == EfrontEvent::NEW_MANUAL_PAYMENT) {
                                                                                                                                                                                                                                                                 $this->event['message'] .= _PAYEDMANUALLY . " <b>" . $this->event['entity_name'] . "</b>";
                                                                                                                                                                                                                                                             } else {
                                                                                                                                                                                                                                                                 if ($this->event['type'] == EfrontEvent::COUPON_USAGE) {
                                                                                                                                                                                                                                                                     $this->event['message'] .= _USEDCOUPON . " <b>" . $this->event['entity_name'] . "</b>";
                                                                                                                                                                                                                                                                 } else {
                                                                                                                                                                                                                                                                     if ($this->event['type'] == EfrontEvent::HCD_NEW_SKILL) {
                                                                                                                                                                                                                                                                         $this->event['message'] .= _WASASSIGNEDSKILL . " <b>" . $this->event['entity_name'] . "</b>";
                                                                                                                                                                                                                                                                     } else {
                                                                                                                                                                                                                                                                         if ($this->event['type'] == EfrontEvent::HCD_REMOVE_SKILL) {
                                                                                                                                                                                                                                                                             $this->event['message'] .= _DOESNOTHAVEANYMORESKILL . " <b>" . $this->event['entity_name'] . "</b>";
                                                                                                                                                                                                                                                                         } else {
                                                                                                                                                                                                                                                                             if ($this->event['type'] == EfrontEvent::HCD_SKILL_EDIT) {
                                                                                                                                                                                                                                                                                 $this->event['message'] .= _HADHISSKILLEDITEDTO . " <b>" . $this->event['entity_name'] . "</b>";
                                                                                                                                                                                                                                                                             } else {
                                                                                                                                                                                                                                                                                 if ($this->event['type'] == EfrontEvent::HCD_HIRED) {
                                                                                                                                                                                                                                                                                     $this->event['message'] .= _WASHIRED;
                                                                                                                                                                                                                                                                                 } else {
                                                                                                                                                                                                                                                                                     if ($this->event['type'] == EfrontEvent::HCD_LEFT) {
                                                                                                                                                                                                                                                                                         $this->event['message'] .= _HASLEFTHECOMPANY;
                                                                                                                                                                                                                                                                                     } else {
                                                                                                                                                                                                                                                                                         if ($this->event['type'] == EfrontEvent::HCD_WAGE_CHANGE) {
                                                                                                                                                                                                                                                                                             $this->event['message'] .= _HASHADHISWAGECHANGETO . " <b>" . $this->event['entity_name'] . "</b>";
                                                                                                                                                                                                                                                                                         } else {
                                                                                                                                                                                                                                                                                             if ($this->event['type'] == EfrontEvent::COURSE_CERTIFICATE_ISSUE) {
                                                                                                                                                                                                                                                                                                 $this->event['message'] .= _HASCERTIFICATED . " <b>" . $this->event['lessons_name'] . "</b> " . _WITHGRADE . " <b>" . $this->event['entity_name'] . "</b> " . _WITHKEY . " <b> " . $this->event['entity_ID'] . "</b>";
                                                                                                                                                                                                                                                                                             } else {
                                                                                                                                                                                                                                                                                                 if ($this->event['type'] == EfrontEvent::COURSE_CERTIFICATE_REVOKE) {
                                                                                                                                                                                                                                                                                                     $this->event['message'] .= _HASLOSTCERTIFICATE . " <b>" . $this->event['lessons_name'] . "</b>";
                                                                                                                                                                                                                                                                                                 } else {
                                                                                                                                                                                                                                                                                                     if ($this->event['type'] == EfrontEvent::COURSE_CERTIFICATE_EXPIRY) {
                                                                                                                                                                                                                                                                                                         $this->event['message'] .= _CERTIFICATEEXPIRY . " <b>" . $this->event['lessons_name'] . "</b>";
                                                                                                                                                                                                                                                                                                     } else {
                                                                                                                                                                                                                                                                                                         return false;
                                                                                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                                                                                 }
                                                                                                                                                                                                                                                                                             }
                                                                                                                                                                                                                                                                                         }
                                                                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                                                                 }
                                                                                                                                                                                                                                                                             }
                                                                                                                                                                                                                                                                         }
                                                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                                                 }
                                                                                                                                                                                                                                                             }
                                                                                                                                                                                                                                                         }
                                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                                 }
                                                                                                                                                                                                                                             }
                                                                                                                                                                                                                                         }
                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                 }
                                                                                                                                                                                                                             }
                                                                                                                                                                                                                         }
                                                                                                                                                                                                                     }
                                                                                                                                                                                                                 }
                                                                                                                                                                                                             }
                                                                                                                                                                                                         }
                                                                                                                                                                                                     }
                                                                                                                                                                                                 }
                                                                                                                                                                                             }
                                                                                                                                                                                         }
                                                                                                                                                                                     }
                                                                                                                                                                                 }
                                                                                                                                                                             }
                                                                                                                                                                         }
                                                                                                                                                                     }
                                                                                                                                                                 }
                                                                                                                                                             }
                                                                                                                                                         }
                                                                                                                                                     }
                                                                                                                                                 }
                                                                                                                                             }
                                                                                                                                         }
                                                                                                                                     }
                                                                                                                                 }
                                                                                                                             }
                                                                                                                         }
                                                                                                                     }
                                                                                                                 }
                                                                                                             }
                                                                                                         }
                                                                                                     }
                                                                                                 }
                                                                                             }
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $this->event['time'] = eF_convertIntervalToTime(time() - $this->event['timestamp'], true) . ' ' . _AGO;
     return $this->event['message'];
 }
Example #15
0
    foreach ($users as $login => $value) {
        $workSheet->write($row, 1, formatLogin($login), $fieldLeftFormat);
        $workSheet->write($row, 2, $value['accesses'], $fieldCenterFormat);
        $time = EfrontTimes::formatTimeForReporting($value['seconds']);
        $workSheet->write($row++, 3, $time['time_string'], $fieldCenterFormat);
    }
    $workSheet =& $workBook->addWorkSheet("Analytic log");
    $workSheet->setInputEncoding('utf-8');
    $workSheet->setColumn(0, 0, 5);
    $workSheet->write(1, 1, _ANALYTICLOG, $headerFormat);
    $workSheet->mergeCells(1, 1, 1, 7);
    $workSheet->setColumn(1, 6, 30);
    $workSheet->write(2, 1, _LOGIN, $fieldLeftFormat);
    $workSheet->write(2, 2, _LESSON, $fieldLeftFormat);
    $workSheet->write(2, 3, _UNIT, $fieldLeftFormat);
    $workSheet->write(2, 4, _ACTION, $fieldLeftFormat);
    $workSheet->write(2, 5, _TIME, $fieldLeftFormat);
    $workSheet->write(2, 6, _IPADDRESS, $fieldLeftFormat);
    $row = 3;
    foreach ($analytic_log as $value) {
        $workSheet->write($row, 1, formatLogin($value['users_LOGIN']), $fieldLeftFormat);
        $workSheet->write($row, 2, $value['lesson_name'], $fieldCenterFormat);
        $workSheet->write($row, 3, $value['content_name'], $fieldLeftFormat);
        $workSheet->write($row, 4, $actions[$value['action']], $fieldLeftFormat);
        $workSheet->write($row, 5, formatTimestamp($value['timestamp'], 'time'), $fieldLeftFormat);
        $workSheet->write($row++, 6, eF_decodeIP($value['session_ip']), $fieldLeftFormat);
    }
    $workBook->send('system_reports.xls');
    $workBook->close();
    exit(0);
}
Example #16
0
function askUsers()
{
    if (G_VERSIONTYPE == 'enterprise') {
        #cpp#ifdef ENTERPRISE
        if (!isset($_SESSION['supervises_branches'])) {
            include_once $path . "module_hcd_tools.php";
            //Automatically fix missing branch assignments for supervisors
            eF_assignSupervisorMissingSubBranchesRecursive();
            //discover employee role in the hierarchy
            eF_getRights();
        }
    }
    #cpp#endif
    //	$_POST['preffix'] = "%";	// Useful for debugging
    if (isset($_POST['preffix'])) {
        if (mb_strpos($_POST['preffix'], ";") === false) {
            $user = $_POST['preffix'];
        } else {
            $user = trim(mb_substr(strrchr($_POST['preffix'], ";"), 1));
        }
    }
    //pr($_SESSION);
    $users = array();
    if (isset($user) && $user) {
        $preffix = $user;
        // Return active users for statistics:
        // - admins: all
        // - supervisors: all supervised (in Enterprise)
        // - professors: students
        if (isset($_GET['supervisors'])) {
            $users = eF_getTableData("users u, module_hcd_employee_works_at_branch wb", "distinct u.login,u.name,u.surname,u.user_type,u.user_types_ID", "u.login=wb.users_LOGIN and wb.supervisor=1 and u.active = 1 and (login like '{$preffix}%' OR name like '{$preffix}%' OR surname like '{$preffix}%' OR user_type like '{$preffix}%')", "login");
        } elseif (!isset($_GET['messaging'])) {
            if ($_SESSION['s_type'] == "administrator") {
                $users = eF_getTableData("users", "login,name,surname,user_type,user_types_ID", "active = 1 and (login like '{$preffix}%' OR name like '{$preffix}%' OR surname like '{$preffix}%' OR user_type like '{$preffix}%')", "login");
            } else {
                // Get students of professor
                $user = EfrontUserFactory::factory($_SESSION['s_login']);
                $students = $user->getProfessorStudents();
                $logins = array();
                $size = sizeof($students);
                for ($i = 0; $i < $size; $i++) {
                    if (!isset($logins[$students[$i]])) {
                        $logins[$students[$i]] = $students[$i];
                    }
                }
                $logins[] = $_SESSION['s_login'];
                if (G_VERSIONTYPE == 'enterprise') {
                    #cpp#ifdef ENTERPRISE
                    // Append to logins array the employees of supervisor
                    if (isset($user->aspects['hcd']) && $user->aspects['hcd']->isSupervisor()) {
                        include_once $path . "module_hcd_tools.php";
                        $supervised_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.login", "(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'))) AND active = 1 GROUP BY login", "login");
                        foreach ($supervised_employees as $employee) {
                            if (!isset($logins[$employee['login']])) {
                                $logins[$employee['login']] = $employee['login'];
                            }
                        }
                    }
                }
                #cpp#endif
                $students_list = "'" . implode("','", $logins) . "'";
                if (sizeof($logins) > 100) {
                    // for performance reason
                    $users = eF_getTableData("users", "login,name,surname,user_type,user_types_ID", "login like '{$preffix}%' OR name like '{$preffix}%' OR surname like '{$preffix}%' OR user_type like '{$preffix}%'", "login");
                    $logins2 = array();
                    foreach ($users as $value) {
                        $logins2[$value['login']] = $value;
                    }
                    $users = array_values(array_intersect_key($logins2, $logins));
                } else {
                    $users = eF_getTableData("users", "login,name,surname,user_type,user_types_ID", "login IN ({$students_list}) AND (login like '{$preffix}%' OR name like '{$preffix}%' OR surname like '{$preffix}%' OR user_type like '{$preffix}%')", "login");
                }
            }
            // Return active users for messaging:
            // - admins: all
            // - supervisors: all
            // - users: other users with common group, lesson, course (or branch in Enterprise)
        } else {
            if ($_SESSION['s_type'] == "administrator") {
                $users = eF_getTableData("users", "login,name,surname,user_type,user_types_ID", "active = 1 and (login like '{$preffix}%' OR name like '{$preffix}%' OR surname like '{$preffix}%')", "login");
                $users[] = array('login' => "[*]", 'name' => _ALLUSERS, 'surname' => _ALLUSERS);
            } else {
                $currentUser = EfrontUserFactory::factory($_SESSION['s_login']);
                $grant_full_access = false;
                if (G_VERSIONTYPE == 'enterprise') {
                    #cpp#ifdef ENTERPRISE
                    $currentEmployee = $currentUser->aspects['hcd'];
                    if ($currentEmployee->isSupervisor()) {
                        $grant_full_access = true;
                    }
                }
                #cpp#endif
                if (!$grant_full_access) {
                    // Used for correct handling in Enterprise and non-Enterprise editions
                    $myGroupsIds = array_keys($currentUser->getGroups());
                    //echo "Groups<BR><BR><BR>";pr($myGroupsIds);
                    if (!empty($myGroupsIds)) {
                        $result = eF_getTableDataFlat("users JOIN users_to_groups", "distinct users_LOGIN", "users.active = 1 and users.login = users_to_groups.users_LOGIN AND groups_ID IN ('" . implode("','", $myGroupsIds) . "')");
                        $logins = $result['users_LOGIN'];
                    }
                    $myLessonsIds = array_keys($currentUser->getLessons());
                    //pr($result);echo "Lessons<BR><BR><BR>";pr($myLessonsIds);
                    if (!empty($myLessonsIds)) {
                        $result = eF_getTableDataFlat("users JOIN users_to_lessons", "distinct users_LOGIN", "users.active = 1 and users.archive=0 and users_to_lessons.archive=0 and users.login = users_to_lessons.users_LOGIN AND lessons_ID IN ('" . implode("','", $myLessonsIds) . "')");
                        $logins = array();
                        foreach ($result['users_LOGIN'] as $login) {
                            if (!isset($logins[$login])) {
                                $logins[$login] = $login;
                            }
                        }
                    }
                    $myCoursesIds = eF_getTableDataFlat("users_to_courses", "courses_ID", "archive = 0 and users_LOGIN = '******'login'] . "'");
                    $myCoursesIds = $myCoursesIds['courses_ID'];
                    //echo "Courses<BR><BR><BR>";pr($myCoursesIds);
                    if (!empty($myCoursesIds)) {
                        $result = eF_getTableDataFlat("users JOIN users_to_courses", "distinct users_LOGIN", "users.active = 1 and users.login = users_to_courses.users_LOGIN AND  users.archive=0 and users_to_courses.archive=0 AND courses_ID IN ('" . implode("','", $myCoursesIds) . "')");
                        foreach ($result['users_LOGIN'] as $login) {
                            if (!isset($logins[$login])) {
                                $logins[$login] = $login;
                            }
                        }
                    }
                    if (G_VERSIONTYPE == 'enterprise') {
                        #cpp#ifdef ENTERPRISE
                        $branches = $currentEmployee->getBranches(true);
                        //						pr($branches);
                        if (!empty($branches)) {
                            $result = eF_getTableDataFlat("users JOIN module_hcd_employee_works_at_branch", "users_LOGIN", "users.login = module_hcd_employee_works_at_branch.users_LOGIN AND branch_ID IN ('" . implode("','", $branches) . "')");
                            foreach ($result['users_LOGIN'] as $login) {
                                if (!isset($logins[$login])) {
                                    $logins[$login] = $login;
                                }
                            }
                        }
                    }
                    #cpp#endif
                    $related_users_list = "'" . implode("','", $logins) . "'";
                    $users = eF_getTableData("users", "distinct login,name,surname,user_type,user_types_ID", "login IN (" . $related_users_list . ") AND (login like '{$preffix}%' OR name like '{$preffix}%' OR surname like '{$preffix}%')", "login");
                } else {
                    $users = eF_getTableData("users", "distinct login,name,surname,user_type,user_types_ID", "login like '{$preffix}%' OR name like '{$preffix}%' OR surname like '{$preffix}%'", "login");
                }
            }
            if ($_SESSION['s_type'] == "professor") {
                $users[] = array('login' => "[*]", 'name' => _MYSTUDENTS, 'surname' => _MYSTUDENTS, 'user_type' => '[*]');
            }
            //pr($users);
        }
    }
    if (G_VERSIONTYPE == 'enterprise' && $_SESSION['s_current_branch'] && $_SESSION['s_type'] != 'administrator') {
        $currentBranch = new EfrontBranch($_SESSION['s_current_branch']);
        $branchTreeUsers = array_keys($currentBranch->getBranchTreeUsers());
        foreach ($users as $key => $value) {
            if (!in_array($value['login'], $branchTreeUsers)) {
                unset($users[$key]);
            }
        }
        $users = array_values($users);
    }
    for ($k = 0; $k < sizeof($users); $k++) {
        /*$hilogin = highlightSearch($users[$k]['login'], $preffix);
        	 $hiname = highlightSearch($users[$k]['name'], $preffix);
        	 $hisurname = highlightSearch($users[$k]['surname'], $preffix);  */
        $hilogin = $users[$k]['login'];
        $hiname = $users[$k]['name'];
        $hisurname = $users[$k]['surname'];
        $hiusertype = $users[$k]['user_types_ID'] ? $users[$k]['user_types_ID'] : $users[$k]['user_type'];
        if ($users[$k]['login'] == '[*]') {
            $formattedLogins[$users[$k]['login']] = $hiname;
        } else {
            $formattedLogins[$users[$k]['login']] = formatLogin($hilogin, array('login' => $hilogin, 'name' => $hiname, 'surname' => $hisurname, 'user_type' => $hiusertype));
        }
        //$str = $str.'<li id='.$users[$k]['login'].'>'.$formattedLogin.'</li>';
    }
    //changed for case that two users (without common appearance) returned  but one of them have common appearance with a third user (#1741)
    if ($GLOBALS['configuration']['username_format_resolve']) {
        formatLogin($_SESSION['s_login']);
        foreach ($formattedLogins as $key => $value) {
            if (isset($GLOBALS['_usernames'][$key])) {
                $formattedLogins[$key] = $GLOBALS['_usernames'][$key];
            }
        }
    }
    $strs = array();
    $strs[] = '<ul>';
    for ($k = 0; $k < sizeof($users); $k++) {
        $strs[] = '<li id="' . htmlentities($users[$k]['login'], ENT_COMPAT | ENT_HTML401, 'UTF-8') . '">' . htmlentities($formattedLogins[$users[$k]['login']], ENT_COMPAT | ENT_HTML401, 'UTF-8') . '</li>';
    }
    $strs[] = '</ul>';
    echo implode("", $strs);
}
Example #17
0
 $pdf = new EfrontPdf(_EMPLOYEEFORM . ": " . formatLogin($editedUser->user['login']));
 try {
     $avatarFile = new EfrontFile($infoUser->user['avatar']);
 } catch (Exception $e) {
     $avatarFile = new EfrontFile(G_SYSTEMAVATARSPATH . "unknown_small.png");
 }
 $info = array(array(_NAME, formatLogin($editedUser->user['login'])), array(_BIRTHDAY, formatTimestamp($editedEmployee->employee['birthday'])), array(_ADDRESS, $editedEmployee->employee['address']), array(_CITY, $editedEmployee->employee['city']), array(_HIREDON, formatTimestamp($editedEmployee->employee['hired_on'])), array(_LEFTON, formatTimestamp($editedEmployee->employee['left_on'])));
 $pdf->printInformationSection(_GENERALUSERINFO, $info, $avatarFile);
 $info = array();
 foreach ($jobs as $value) {
     $info[] = array($value['name'], strip_tags($value['description']) . ($value['supervisor'] ? _SUPERVISOR : ''));
 }
 $pdf->printInformationSection(_PLACEMENTS, $info);
 $info = array();
 foreach ($evaluations as $value) {
     $info[] = array(formatLogin($value['author']) . ' ' . formatTimestamp($value['timestamp']), strip_tags($value['specification']));
 }
 $pdf->printInformationSection(_EVALUATIONS, $info);
 $info = array();
 foreach ($skills_sorted as $cat_id => $skills) {
     $info[] = array('category' => $skill_categories[$cat_id]);
     foreach ($skills as $value) {
         $info[] = array($value['description'] . ' ', $value['specification'] . ' ' . ($value['score'] ? "({$value['score']}%)" : ''));
         //Append space, in order to always appear
     }
     $info[] = array('category' => '');
 }
 $pdf->printInformationSection(_SKILLS, $info);
 if ($editedUser->user['user_type'] != 'administrator' && (!empty($userCourses) || !empty($userLessons))) {
     $formatting = array(_NAME => array('width' => '37%', 'fill' => false), _CATEGORY => array('width' => '25%', 'fill' => false), _REGISTRATIONDATE => array('width' => '12%', 'fill' => false), _COMPLETED => array('width' => '12%', 'fill' => false, 'align' => 'C'), _SCORE => array('width' => '8%', 'fill' => false, 'align' => 'R'), _CEUS => array('width' => '8%', 'fill' => false, 'align' => 'R'));
     $data = array();
Example #18
0
                                                 if (isset($sending_queue_msg['send_conditions']['users_login']) && isset($sending_queue_msg['send_conditions']['immediate_supervisor'])) {
                                                     $sending_queue_msgs[$key]['recipients'] = _USERIMMEDIATESUPERVISORS;
                                                 } else {
                                                     $sending_queue_msgs[$key]['recipients'] = _ALLUSERS;
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         } else {
             $sending_queue_msgs[$key]['recipients'] = formatLogin($sending_queue_msgs[$key]['recipient']);
         }
     }
 }
 $smarty->assign("T_MESSAGE_QUEUE_SIZE", $sending_queue_size[0]['count']);
 // This is almost buggy - cannot filter according to recipients count - significant optimization however
 foreach ($sending_queue_msgs as $key => $message) {
     $notification = new EfrontNotification($message);
     if ($notification->notification['recipient'] == "") {
         $sending_queue_msgs[$key]['recipients_count'] = sizeof($notification->getRecipients());
     }
 }
 if (!empty($sending_queue_msgs)) {
     $smarty->assign("T_QUEUE_MSGS", $sending_queue_msgs);
 }
 $smarty->display('administrator.tpl');
Example #19
0
         $editCourse = new EfrontCourse($_GET['edit_course']);
         $result = eF_getTableDataFlat("module_hcd_course_to_branch mb, module_hcd_branch b", "mb.branches_ID, b.name", "b.branch_ID=mb.branches_ID and mb.courses_ID=" . $editCourse->course['id']);
         if (sizeof($result['branches_ID']) > 0) {
             $form->setDefaults(array("branches_ID" => $result['branches_ID'][0], "branches_ID_autoselect" => $result['name'][0]));
             if (sizeof($result['branches_ID']) > 1) {
                 $smarty->assign("T_MORE_LOCATIONS", implode(", ", $result['name']));
                 $branchSelect = $form->addElement('text', 'branches_ID_autoselect', _LOCATIONBRANCH, 'class = "inputText" id = "autocomplete" disabled');
                 //$branchSelect = HTML_QuickForm :: createElement('select', 'branches_ID', _LOCATIONBRANCH, eF_createBranchesTreeSelect($branches,$only_existing), 'class = "inputText" disabled = "true"');
             }
         }
     }
     $form->addElement($branchSelect);
     $result = eF_getTableData("module_hcd_employee_works_at_branch ewb, users u", "u.login", "u.archive=0 and ewb.users_LOGIN=u.login and ewb.supervisor=1");
     $supervisors = array('' => '');
     foreach ($result as $value) {
         $supervisors[$value['login']] = formatLogin($value['login']);
     }
     if (sizeof($supervisors) > 1) {
         $form->addElement('select', 'supervisor_LOGIN', _ASSIGNMENTAPPROVEDBY, $supervisors, 'class = "inputText"');
     }
     //$smarty -> assign("T_BRANCHES_FILTER", eF_createBranchesFilterSelect());
     $smarty->assign("T_JOBS_FILTER", eF_createJobFilterSelect());
 }
 #cpp#endif
 $form->addElement('text', 'calendar_event', _CALENDAREVENT, 'class = "inputText"');
 $form->addElement('text', 'max_users', _MAXIMUMUSERS, 'class = "inputText" style = "width:50px"');
 $form->addElement('text', 'duration', _AVAILABLEFOR, 'style = "width:50px;"');
 $form->addRule('duration', _THEFIELD . ' "' . _AVAILABLEFOR . '" ' . _MUSTBENUMERIC, 'numeric', null, 'client');
 if (isset($_GET['edit_course'])) {
     $editCourse = new EfrontCourse($_GET['edit_course']);
     $smarty->assign('T_EDIT_COURSE', $editCourse);
                        #cpp#ifdef ENTERPRISE
                        $branchesTree = new EfrontBranchesTree();
                        $pathStrings = $branchesTree->toPathString();
                        $jobs = $user->aspects['hcd']->getJobs();
                        $branches = $user->aspects['hcd']->getBranches();
                        foreach ($jobs as $value) {
                            $tooltipInfo[] = '
	            		<div class = "infoEntry">
	            			<span>' . _JOBDESCRIPTION . '</span><span>: ' . $value['description'] . ' <b>(' . (isset($branches['supervisor'][$value['branch_ID']]) ? _SUPERVISOR : _USER) . ')</b></span>
	            			<span> ' . _ATBRANCH . ': </span><span style = "font-weight:bold">' . $pathStrings[$value['branch_ID']] . '</span>
	            		</div>
	            		';
                        }
                        $supervisors = array();
                        foreach ($user->aspects['hcd']->getSupervisors() as $value) {
                            $supervisors[] = formatLogin($value);
                        }
                        if (!empty($supervisors)) {
                            $tooltipInfo[] = '<div class = "infoEntry"><span>' . _SUPERVISORS . "</span><span>: " . implode(", ", $supervisors) . "</span></div>";
                        }
                        $skills = $user->aspects['hcd']->getSkills();
                        foreach ($skills as $value) {
                            $tooltipInfo[] = '
	            		<div class = "infoEntry">
	            			<span>' . _SKILL . '</span><span>: ' . $value['description'] . ($value['specification'] ? ' <b>(' . $value['specification'] . ')</b>' : '') . '</span>
	            			<span> ' . _WITHSCORE . ': </span><span style = "font-weight:bold">' . formatScore($value['score']) . '%</span>
	            		</div>
	            		';
                        }
                    }
                    #cpp#endif
 //in case unit is simply an iframe,do not load the print it button
 $contentStripped = strip_tags($currentUnit['data'], '<img><applet><iframe><div><br><p><ul><li><ol><span><sub><sup><hr><h1><h2><h3><h4><h5><h6><table><tbody><tr><th><td><font><em><i><strong><u><b><blockquote><big><center><code>');
 if ($contentStripped == "<p></p>" || $contentStripped == "") {
     $smarty->assign("T_DISABLEPRINTUNIT", true);
 }
 foreach ($loadedModules as $module) {
     if (isset($currentLesson->options[$module->className]) && $currentLesson->options[$module->className] == 1) {
         $module->onBeforeShowContent($currentUnit);
     }
 }
 if ($currentUnit['ctg_type'] == 'tests') {
     $test_id = eF_getTableData("tests", "id", "content_ID=" . $currentUnit['id']);
     $smarty->assign("T_UNIT_TEST_ID", $test_id[0]['id']);
 }
 $smarty->assign("T_UNIT", $currentUnit);
 $info = array('student_name' => $currentUser->user['name'], 'student_surname' => $currentUser->user['surname'], 'student_login' => $currentUser->user['login'], 'student_email' => $currentUser->user['email'] . "'", 'student_formatted_login' => formatLogin($currentUser->user['login']), 'lesson_name' => $currentLesson->lesson['name'], 'lesson_id' => $currentLesson->lesson['id'], 'course_name' => $currentCourse->course['name'], 'course_id' => $currentCourse->course['id'], 'timestamp' => time(), 'date' => formatTimestamp(time()));
 array_walk($info, create_function('&$v', '$v=htmlentities($v, ENT_QUOTES);'));
 $smarty->assign("T_INFORMATION_JSON", json_encode($info));
 if ($currentUnit['options']['complete_unit_setting'] == EfrontUnit::COMPLETION_OPTIONS_COMPLETEAFTERSECONDS) {
     $smarty->assign("T_REQUIRED_TIME_IN_UNIT", $currentUnit['options']['complete_time']);
 }
 //Next and previous units are needed for navigation buttons
 //package_ID denotes that a SCORM 2004 unit is active.
 if (!isset($_GET['package_ID'])) {
     $nextUnit = $currentContent->getNextNode($currentUnit, $visitableIterator);
     $smarty->assign("T_NEXT_UNIT", $nextUnit);
     $previousUnit = $currentContent->getPreviousNode($currentUnit, $visitableIterator);
     $smarty->assign("T_PREVIOUS_UNIT", $previousUnit);
     //Parents are needed for printing the titles
     $smarty->assign("T_PARENT_LIST", $currentContent->getNodeAncestors($currentUnit));
 } else {
     }
     $data[] = array(_USER => formatLogin($user['login']), $tag => $val, _REGISTRATIONDATE => formatTimestamp($user['timestamp']), _CONTENT => formatScore($user['overall_progress']['percentage']) . "%", _TESTS => formatScore($user['test_status']['mean_score']) . "%", _PROJECTS => formatScore($user['project_status']['mean_score']) . "%", _COMPLETED => $user['completed'] ? _YES . ', ' . _ON . ' ' . formatTimestamp($user['timestamp_completed']) : _NO, _SCORE => formatScore($user['score']) . "%", _LASTLOGIN => formatTimestamp($user['last_login'], true));
 }
 $pdf->printDataSection(_USERSINFO, $data, $formatting);
 $data = array();
 foreach ($professors as $user) {
     $data[] = array(_USER => formatLogin($user['login']), _REGISTRATIONDATE => formatTimestamp($user['timestamp']));
 }
 $pdf->printDataSection(_PROFESSORSINFO, $data, $formatting);
 if (EfrontUser::isOptionVisible('tests')) {
     $formatting = array(_USER => array('width' => '25%', 'fill' => false), _SCORE => array('width' => '15%', 'fill' => false));
     foreach ($testsInfo as $id => $info) {
         $data = array();
         foreach ($info['done'] as $results) {
             $avgScore[] = $results['active_score'] ? $results['active_score'] : $results['score'];
             $data[] = array(_USER => formatLogin($results['users_LOGIN']), _SCORE => formatScore(round($results['active_score'] ? $results['active_score'] : $results['score'], 2)) . "%");
         }
         if (!empty($data)) {
             $data[] = array(_USER => _AVERAGESCORE, _SCORE => formatScore(round(array_sum($avgScore) / sizeof($avgScore), 2)) . "%");
         }
         $pdf->printDataSection(_TESTSINFORMATION . ': ' . $info['general']['name'], $data, $formatting);
     }
     if (sizeof($lessonQuestions) > 0) {
         $formatting = array(_QUESTION => array('width' => '50%', 'fill' => false), _QUESTIONTYPE => array('width' => '20%', 'fill' => false), _DIFFICULTY => array('width' => '10%', 'fill' => false, 'align' => 'C'), _TIMESDONE => array('width' => '10%', 'fill' => false, 'align' => 'C'), _AVERAGESCORE => array('width' => '10%', 'fill' => false, 'align' => 'C'));
         $data = array();
         foreach ($questionsInfo as $id => $questionInfo) {
             $data[] = array(_QUESTION => $questionInfo['text'], _QUESTIONTYPE => Question::$questionTypes[$questionInfo['type']], _DIFFICULTY => Question::$questionDifficulties[$questionInfo['difficulty']], _TIMESDONE => $questionInfo['times_done'], _AVERAGESCORE => formatScore($questionInfo['avg_score']) . "%");
         }
         $pdf->printDataSection(_QUESTIONSINFORMATION, $data, $formatting);
     }
 }
 /**
  * Get the list of users that are currently online
  *
  * This function is used to get a list of the users that are currently online
  * In addition, it logs out any inactive users, based on global setting
  * <br>Example:
  * <code>
  * $online = EfrontUser :: getUsersOnline();
  * </code>
  *
  * @param boolean $userType Return only users of the basic type $user_type
  * @param int $interval The idle interval above which a user is logged out. If it's not specified, no logging out takes place
  * @return array The list of online users
  * @since 3.5.0
  * @access public
  */
 public static function getUsersOnline($interval = false)
 {
     $usersOnline = array();
     //A user may have multiple active entries on the user_times table, one for system, one for unit etc. Pick the most recent
     $result = eF_getTableData("user_times,users", "users.login, users.name, users.surname, users.user_type, timestamp_now, session_timestamp, session_id", "users.login=user_times.users_LOGIN and session_expired=0", "timestamp_now desc");
     foreach ($result as $value) {
         if (!isset($parsedUsers[$value['login']])) {
             if (time() - $value['timestamp_now'] < $interval || !$interval) {
                 $usersOnline[] = array('login' => $value['login'], 'formattedLogin' => formatLogin($value['login'], $value), 'user_type' => $value['user_type'], 'timestamp_now' => $value['timestamp_now'], 'session_timestamp' => $value['session_timestamp'], 'time' => EfrontTimes::formatTimeForReporting(time() - $value['session_timestamp']));
             } else {
                 //pr($result);
                 //pr("interval: $interval, time: ".time().", timestamp_now:".$value['timestamp_now']);
                 EfrontUserFactory::factory($value['login'])->logout($value['session_id']);
                 //exit;
             }
             $parsedUsers[$value['login']] = true;
         }
     }
     $online_users = sizeof($result);
     if (G_VERSIONTYPE != 'community') {
         #cpp#ifndef COMMUNITY
         if (G_VERSIONTYPE != 'standard') {
             #cpp#ifndef STANDARD
             $threshold = $GLOBALS['configuration']['max_online_users_threshold'];
             if ($threshold > 0 && $online_users > $threshold && time() > $GLOBALS['configuration']['max_online_users_threshold_timestamp'] + 24 * 60 * 60) {
                 $admin = EfrontSystem::getAdministrator();
                 eF_mail($GLOBALS['configuration']['system_email'], $admin->user['email'], _ONLINEUSERSMAIL, str_replace(array('%w', '%x', '%y', '%z'), array($admin->user['name'], $threshold, $GLOBALS['configuration']['site_name'], G_SERVERNAME), _ONLINEUSERSMAILBODY));
                 EfrontConfiguration::setValue('max_online_users_threshold_timestamp', time());
             }
         }
         #cpp#endif
     }
     #cpp#endif
     if ($GLOBALS['configuration']['max_online_users'] < $online_users) {
         EfrontConfiguration::setValue('max_online_users', $online_users);
         EfrontConfiguration::setValue('max_online_users_timestamp', time());
     }
     if (G_VERSIONTYPE == 'enterprise' && defined("G_BRANCH_URL") && G_BRANCH_URL && $_SESSION['s_current_branch']) {
         $branch = new EfrontBranch($_SESSION['s_current_branch']);
         $branchUsers = $branch->getBranchTreeUsers();
         foreach ($usersOnline as $key => $value) {
             if (!isset($branchUsers[$value['login']]) && $value['user_type'] != 'administrator') {
                 unset($usersOnline[$key]);
             }
         }
     }
     return $usersOnline;
 }
Example #24
0
 private function printPdfHeader($title)
 {
     $this->pdf->SetCreator(formatLogin($_SESSION['s_login']));
     $this->pdf->SetAuthor(formatLogin($_SESSION['s_login']));
     $this->pdf->SetTitle($title);
     //$this->pdf->SetSubject($title);
     //$this->pdf->SetKeywords('pdf, '._EMPLOYEEFORM);
     $this->pdf->setPrintHeader(false);
     $this->pdf->setPrintFooter(false);
     $this->pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     $this->pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     $this->pdf->setFontSubsetting(false);
     $this->pdf->AddPage();
     $logoFile = EfrontSystem::getSystemLogo();
     if (extension_loaded('gd')) {
         $this->pdf->Image($logoFile['path'], '', '', 0, 0, '', '', 'T');
     }
     $this->pdf->SetFont($this->defaultSettings['default_font']);
     $this->printLargeTitle($GLOBALS['configuration']['site_name']);
     $this->printSmallTitle($GLOBALS['configuration']['site_motto']);
     $this->printSeparatorHeader($title);
 }