Пример #1
0
 }
 $form->addElement('text', 'price', _PRICE, 'class = "inputText" style = "width:50px"');
 //Add the price, active and submit button to the form
 $form->addElement('advcheckbox', 'active', _ACTIVENEUTRAL, null, null, array(0, 1));
 $form->addElement('advcheckbox', 'show_catalog', _SHOWLESSONINCATALOG, null, null, array(0, 1));
 $courseOnly = $form->addElement('radio', 'course_only', _LESSONAVAILABLE, _COURSEONLY, 1, 'onclick = "$$(\'tr.only_lesson\').each(function(s) {s.hide()})"');
 $directAccess = $form->addElement('radio', 'course_only', _LESSONAVAILABLE, _DIRECTLY, 0, 'onclick = "$$(\'tr.only_lesson\').each(function(s) {s.show()});if ($(\'recurring\').options[$(\'recurring\').selectedIndex].value == 0) {$(\'duration_row\').hide();}"');
 $recurringOptions = array(0 => _NO, 'D' => _DAILY, 'W' => _WEEKLY, 'M' => _MONTHLY, 'Y' => _YEARLY);
 $recurringDurations = array('D' => array_combine(range(1, 90), range(1, 90)), 'W' => array_combine(range(1, 52), range(1, 52)), 'M' => array_combine(range(1, 24), range(1, 24)), 'Y' => array_combine(range(1, 5), range(1, 5)));
 //Imposed by paypal interface
 $form->addElement('select', 'recurring', _SUBSCRIPTION, $recurringOptions, 'id = "recurring" onchange = "$(\'duration_row\').show();$$(\'span\').each(function (s) {if (s.id.match(\'_duration\')) {s.hide();}});if (this.selectedIndex) {$(this.options[this.selectedIndex].value+\'_duration\').show();} else {$(\'duration_row\').hide();}"');
 $form->addElement('select', 'D_duration', _DAYSCONDITIONAL, $recurringDurations['D']);
 $form->addElement('select', 'W_duration', _WEEKSCONDITIONAL, $recurringDurations['W']);
 $form->addElement('select', 'M_duration', _MONTHSCONDITIONAL, $recurringDurations['M']);
 $form->addElement('select', 'Y_duration', _YEARSCONDITIONAL, $recurringDurations['Y']);
 $lessons = EfrontLesson::getLessons();
 $lessonsList = array(0 => _SELECTLESSON, -1 => '---------------');
 foreach ($lessons as $value) {
     $lessonsList[$value['id']] = $value['name'];
 }
 unset($lessonsList[$_GET['edit_lesson']]);
 $form->addElement('text', 'max_users', _MAXIMUMUSERS, 'class = "inputText" style = "width:50px"');
 $form->addElement('hidden', 'copy_properties', null, 'id="copy_properties"');
 //Convert to autocomplete input fields to show categories
 //$form -> addElement('select', 'share_folder', _SHAREFOLDERWITH, $lessonsList, 'id = "share_folder" onchange = "$(\'clone_lesson\').options.selectedIndex=0;this.options.selectedIndex ? $(\'clone_lesson\').disabled = \'disabled\' : $(\'clone_lesson\').disabled = \'\'"');
 //$form -> addElement('select', 'clone_lesson', _CLONELESSON, $lessonsList, 'id = "clone_lesson" onchange = "$(\'share_folder\').options.selectedIndex=0;this.options.selectedIndex ? $(\'share_folder\').disabled = \'disabled\' : $(\'share_folder\').disabled = \'\'"');
 $form->addElement('hidden', 'share_folder', null, 'id = "share_folder" onchange = "$(\'clone_lesson\').options.selectedIndex=0;this.options.selectedIndex ? $(\'clone_lesson\').disabled = \'disabled\' : $(\'clone_lesson\').disabled = \'\'"');
 $form->addElement('hidden', 'clone_lesson', null, 'id = "clone_lesson" onchange = "$(\'share_folder\').options.selectedIndex=0;this.options.selectedIndex ? $(\'share_folder\').disabled = \'disabled\' : $(\'share_folder\').disabled = \'\'"');
 $form->addElement('text', 'duration', _AVAILABLEFOR, 'style = "width:50px;"');
 $form->addRule('duration', _THEFIELD . ' "' . _AVAILABLEFOR . '" ' . _MUSTBENUMERIC, 'numeric', null, 'client');
 $form->addElement('text', 'access_limit', _AVAILABLEFOR, 'style = "width:50px;"');
Пример #2
0
<?php

if (str_replace(DIRECTORY_SEPARATOR, "/", __FILE__) == $_SERVER['SCRIPT_FILENAME']) {
    exit;
}
try {
    if (!isset($lessons) || !$lessons && !is_array($lessons)) {
        $lessons = EfrontLesson::getLessons(true);
        foreach ($lessons as $key => $lesson) {
            if ($lesson->lesson['archive'] || !$lesson->lesson['active']) {
                unset($lessons[$key]);
            }
        }
    }
    if (!isset($courses) || !$courses && !is_array($courses)) {
        //$courses = EfrontCourse :: getCourses(true);
        $constraints = array('active' => true, 'archive' => false, 'instance' => false, 'sort' => 'name');
        $constraints['required_fields'] = array('has_instances');
        $courses = EfrontCourse::getAllCourses($constraints);
        if ($_SESSION['s_current_branch']) {
            //filter out courses that don't belong to the current branch url
            $stats_filters = array();
            $branches = array($_SESSION['s_current_branch']);
            $branchesTree = new EfrontBranchesTree();
            $iterator = new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($branchesTree->getNodeChildren($_SESSION['s_current_branch'])), RecursiveIteratorIterator::SELF_FIRST));
            foreach ($iterator as $key => $value) {
                $branches[] = $key;
            }
            $result = eF_getTableDataFlat("module_hcd_course_to_branch", "courses_ID", "branches_ID in (" . implode(",", $branches) . ")");
            foreach ($courses as $key => $value) {
                if (!in_array($key, $result['courses_ID'])) {
Пример #3
0
 public function getSmartyTpl()
 {
     $smarty = $this->getSmartyVar();
     $smarty->assign("T_RSS_MODULE_BASEURL", $this->moduleBaseUrl);
     $smarty->assign("T_RSS_MODULE_BASELINK", $this->moduleBaseLink);
     $smarty->assign("T_RSS_PROVIDED_FEEDS_MODES", $this->feedProviderModes);
     $smarty->assign("T_RSS_PROVIDED_FEEDS_TYPES", $this->providedFeeds);
     $smarty->assign("T_RSS_PROVIDED_FEEDS_LESSON_TYPES", $this->lessonProvidedFeeds);
     if (isset($_GET['delete_feed']) && eF_checkParameter($_GET['delete_feed'], 'id')) {
         try {
             if ($_GET['type'] == 'provider') {
                 eF_deleteTableData("module_rss_provider", "id=" . $_GET['delete_feed']);
             } else {
                 eF_deleteTableData("module_rss_feeds", "id=" . $_GET['delete_feed']);
             }
         } catch (Exception $e) {
             handleAjaxExceptions($e);
         }
         exit;
     } elseif (isset($_GET['deactivate_feed']) && eF_checkParameter($_GET['deactivate_feed'], 'id')) {
         try {
             if ($_GET['type'] == 'provider') {
                 eF_updateTableData("module_rss_provider", array("active" => 0), "id=" . $_GET['deactivate_feed']);
             } else {
                 eF_updateTableData("module_rss_feeds", array("active" => 0), "id=" . $_GET['deactivate_feed']);
             }
             echo 0;
         } catch (Exception $e) {
             handleAjaxExceptions($e);
         }
         exit;
     } elseif (isset($_GET['activate_feed']) && eF_checkParameter($_GET['activate_feed'], 'file')) {
         //Although db operations do not support exceptions (yet), we leave this here for future support
         try {
             if ($_GET['type'] == 'provider') {
                 eF_updateTableData("module_rss_provider", array("active" => 1), "id=" . $_GET['activate_feed']);
             } else {
                 eF_updateTableData("module_rss_feeds", array("active" => 1), "id=" . $_GET['activate_feed']);
             }
             echo 1;
         } catch (Exception $e) {
             handleAjaxExceptions($e);
         }
         exit;
     } else {
         if (isset($_GET['add_feed']) || isset($_GET['edit_feed']) && eF_checkParameter($_GET['edit_feed'], 'id')) {
             if ($_SESSION['s_lesson_user_type']) {
                 $type = $_SESSION['s_lesson_user_type'];
             } else {
                 $type = $this->getCurrentUser()->getType();
             }
             $smarty->assign("T_RSS_USERTYPE", $type);
             $feeds = $this->getFeeds();
             $lessons = array(-1 => _RSS_NONE, 0 => _ALLLESSONS);
             $result = EfrontLesson::getLessons();
             foreach ($result as $key => $lesson) {
                 $lessons[$key] = $lesson['name'];
             }
             isset($_GET['add_feed']) ? $postTarget = "&add_feed=1" : ($postTarget = "&edit_feed=" . $_GET['edit_feed']);
             $form = new HTML_QuickForm("add_feed_form", "post", $this->moduleBaseUrl . $postTarget, "", null, true);
             $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
             $form->addElement('text', 'title', _RSS_FEEDTITLE, 'class = "inputText"');
             $form->addElement('text', 'url', _RSS_FEEDURL, 'class = "inputText"');
             $form->addElement('select', 'lessons_ID', _LESSON, $lessons);
             if ($type != 'administrator' && $_SESSION['s_lessons_ID']) {
                 $form->setDefaults(array('lessons_ID' => $_SESSION['s_lessons_ID']));
                 $form->freeze(array('lessons_ID'));
             }
             $form->addElement("advcheckbox", "active", _RSS_ACTIVE, null, 'class = "inputCheckBox"', array(0, 1));
             $form->setDefaults(array('active' => 1));
             $form->addElement("advcheckbox", "only_summary", _RSS_ONLYSUMMARY, null, 'class = "inputCheckBox"', array(0, 1));
             $form->addRule('title', _THEFIELD . ' "' . _RSS_FEEDTITLE . '" ' . _ISMANDATORY, 'required', null, 'client');
             $form->addRule('url', _THEFIELD . ' "' . _RSS_FEEDURL . '" ' . _ISMANDATORY, 'required', null, 'client');
             $form->addRule('title', _INVALIDFIELDDATA, 'checkParameter', 'text');
             $form->addElement('submit', 'submit', _SUBMIT, 'class = "flatButton"');
             if (isset($_GET['edit_feed'])) {
                 $editFeed = $feeds[$_GET['edit_feed']];
                 $form->setDefaults($editFeed);
             }
             if ($form->isSubmitted() && $form->validate()) {
                 //If the form is submitted and validated
                 $values = $form->exportValues();
                 $fields = array("title" => $values['title'], "url" => $values['url'], "active" => $values['active'], "only_summary" => $values['only_summary'], "lessons_ID" => $values['lessons_ID']);
                 if (isset($_GET['add_feed'])) {
                     eF_insertTableData("module_rss_feeds", $fields);
                     $smarty->assign("T_RSS_RSS_MESSAGE", _RSS_SUCCESSFULLYADDEDFEED);
                 } else {
                     eF_updateTableData("module_rss_feeds", $fields, "id=" . $_GET['edit_feed']);
                     $smarty->assign("T_RSS_RSS_MESSAGE", _RSS_SUCCESSFULLYEDITEDFEED);
                     EfrontCache::getInstance()->deleteCache('rss_cache:' . $_GET['edit_feed']);
                 }
             }
             $smarty->assign("T_RSS_ADD_RSS_FORM", $form->toArray());
         } else {
             if (isset($_GET['add_feed_provider']) || isset($_GET['edit_feed_provider']) && eF_checkParameter($_GET['edit_feed_provider'], 'id')) {
                 if ($_SESSION['s_lesson_user_type']) {
                     $type = $_SESSION['s_lesson_user_type'];
                 } else {
                     $type = $this->getCurrentUser()->getType();
                 }
                 $smarty->assign("T_RSS_USERTYPE", $type);
                 $feeds = $this->getProvidedFeeds();
                 isset($_GET['add_feed_provider']) ? $postTarget = "&add_feed_provider=1" : ($postTarget = "&edit_feed_provider=" . $_GET['edit_feed_provider']);
                 !isset($_GET['lesson']) or $postTarget .= '&lesson=1';
                 $form = new HTML_QuickForm("add_feed_provider_form", "post", $this->moduleBaseUrl . $postTarget . '&tab=rss_provider', "", null, true);
                 $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
                 if ($_GET['lesson']) {
                     $lessons = array(0 => _ALLLESSONS);
                     $result = EfrontLesson::getLessons();
                     foreach ($result as $key => $lesson) {
                         $lessons[$key] = $lesson['name'];
                     }
                     $form->addElement('select', 'feeds_provided', _RSS_PROVIDEDFEEDS, $this->lessonProvidedFeeds);
                     $form->addElement('select', 'lessons_ID', _LESSON, $lessons);
                     if ($type != 'administrator' && $_SESSION['s_lessons_ID']) {
                         $form->setDefaults(array('lessons_ID' => $_SESSION['s_lessons_ID']));
                         $form->freeze(array('lessons_ID'));
                     }
                 } else {
                     $form->addElement('select', 'feeds_provided', _RSS_PROVIDEDFEEDS, $this->providedFeeds);
                 }
                 $form->addElement("advcheckbox", "active", _RSS_ACTIVE, null, 'class = "inputCheckBox"', array(0, 1));
                 $form->setDefaults(array('active' => 1));
                 $form->addElement('submit', 'submit', _SUBMIT, 'class = "flatButton"');
                 if (isset($_GET['edit_feed_provider'])) {
                     $editFeed = $feeds[$_GET['edit_feed_provider']];
                     $form->setDefaults($editFeed);
                 }
                 try {
                     if ($form->isSubmitted() && $form->validate()) {
                         //If the form is submitted and validated
                         $values = $form->exportValues();
                         $fields = array("mode" => $_GET['lesson'] ? 'lesson' : 'system', "type" => $values['feeds_provided'], "active" => $values['active'], "lessons_ID" => $values['lessons_ID']);
                         foreach ($feeds as $feed) {
                             if ($feed['type'] == $fields['type'] && $feed['mode'] == $fields['mode'] && $feed['lessons_ID'] == $fields['lessons_ID']) {
                                 throw new Exception(_FEEDALREADYEXISTS);
                             }
                         }
                         if (isset($_GET['add_feed_provider'])) {
                             eF_insertTableData("module_rss_provider", $fields);
                             $smarty->assign("T_RSS_RSS_MESSAGE", _RSS_SUCCESSFULLYADDEDFEED);
                         } else {
                             eF_updateTableData("module_rss_provider", $fields, "id=" . $_GET['edit_feed_provider']);
                             $smarty->assign("T_RSS_RSS_MESSAGE", _RSS_SUCCESSFULLYEDITEDFEED);
                         }
                     }
                 } catch (Exception $e) {
                     $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
                     $message = $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
                     $message_type = 'failure';
                 }
                 $smarty->assign("T_RSS_PROVIDE_RSS_FORM", $form->toArray());
             } else {
                 if (isset($_GET['ajax'])) {
                     echo $this->getRssFeeds($_GET['refresh']);
                     //echo $this -> getRssFeeds(true);
                     exit;
                 } else {
                     $lessons = array(0 => _ALLLESSONS);
                     $result = EfrontLesson::getLessons();
                     foreach ($result as $key => $lesson) {
                         $lessons[$key] = $lesson['name'];
                     }
                     $smarty->assign("T_LESSON_NAMES", $lessons);
                     if ($_SESSION['s_lesson_user_type']) {
                         $type = $_SESSION['s_lesson_user_type'];
                         $smarty->assign("T_RSS_PROVIDED_FEEDS", $this->getProvidedFeeds($_SESSION['s_lessons_ID']));
                         $smarty->assign("T_RSS_FEEDS", $this->getFeeds(false, $_SESSION['s_lessons_ID']));
                     } else {
                         $type = $this->getCurrentUser()->getType();
                         $smarty->assign("T_RSS_PROVIDED_FEEDS", $this->getProvidedFeeds());
                         $smarty->assign("T_RSS_FEEDS", $this->getFeeds());
                     }
                     $smarty->assign("T_RSS_USERTYPE", $type);
                 }
             }
         }
     }
     if ($message) {
         $this->setMessageVar($message, $message_type);
     }
     return $this->moduleBaseDir . "module_rss.tpl";
 }
Пример #4
0
 foreach ($result as $key => $value) {
     $value['lessons_ID'] ? $result[$key]['lesson_name'] = $lessonNames[$value['lessons_ID']] : null;
     if ($value['action'] == 'content') {
         $result[$key]['content_name'] = $contentNames[$value['comments']];
     } else {
         if ($value['action'] == 'tests' || $value['action'] == 'test_begin') {
             $result[$key]['content_name'] = $testNames[$value['comments']];
         }
     }
 }
 $smarty->assign("T_USER_LOG", $result);
 $traffic = array();
 $traffic['lessons'] = array();
 $allStats = EfrontStats::getUsersTimeAll();
 //$allStats = EfrontStats :: getUsersTimeAll($from, $to);
 $result = EfrontLesson::getLessons();
 $probed_lessons = array();
 foreach ($result as $value) {
     $probed_lessons[$value['id']] = array("lessons_ID" => $value['id'], "lessons_name" => $value['name'], "active" => $value['active']);
 }
 foreach ($probed_lessons as $id => $lesson) {
     $userTraffic = $allStats[$id];
     //$userTraffic = EfrontStats :: getUsersTime($id, $user_logins, $from, $to);
     foreach ($user_logins as $user => $login) {
         if ($userTraffic[$login]['accesses']) {
             if (!isset($traffic['lessons'][$id])) {
                 $traffic['lessons'][$id] = $userTraffic[$login];
                 $traffic['lessons'][$id]['name'] = $lesson['lessons_name'];
                 $traffic['lessons'][$id]['active'] = $lesson['active'];
             } else {
                 $traffic['lessons'][$id]['accesses'] += $userTraffic[$login]['accesses'];