Esempio n. 1
0
                        if ($_GET['edit_placement']) {
                            if ($_GET['edit_placement'] != $newJob) {
                                $editedEmployee->removeJob($_GET['edit_placement']);
                            } elseif (isset($userJobs[$newJob]) && $userJobs[$newJob]['supervisor'] != $_POST['position']) {
                                $editedEmployee->removeJob($_GET['edit_placement']);
                            }
                        }
                        $editedEmployee->addJob($editedUser, $newJob, $values['branch'], $_POST['position']);
                        $message = _OPERATIONCOMPLETEDSUCCESFULLY;
                        $message_type = 'success';
                    }
                }
            } catch (Exception $e) {
                handleNormalFlowExceptions($e);
            }
            $smarty->assign("T_FORM", $form->toArray());
        } else {
            $branchTree = new EfrontBranchesTree();
            $branches = $branchTree->toPathString();
            $smarty->assign("T_BRANCHES_PATH", $branches);
            $placements = $editedEmployee->getJobs();
            $smarty->assign("T_PLACEMENTS", $placements);
        }
    }
}
#cpp#endif
function eF_local_printBranchJobs($branch)
{
    $result = $branch->getJobDescriptions();
    $branchJobs = array("--- {$branch->branch['name']} ---");
    foreach ($result as $value) {
Esempio n. 2
0
                        $user->persist();
                        unset($_SESSION['s_index_comply']);
                        if ($GLOBALS['configuration']['show_license_note'] && $user->user['viewed_license'] == 0) {
                            eF_redirect("index.php?ctg=agreement");
                        } else {
                            EfrontEvent::triggerEvent(array("type" => EfrontEvent::SYSTEM_VISITED, "users_LOGIN" => $user->user['login'], "users_name" => $user->user['name'], "users_surname" => $user->user['surname']));
                            loginRedirect($user->user['user_type']);
                        }
                    }
                }
            }
            $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
            $changePasswordForm->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
            $changePasswordForm->setRequiredNote(_REQUIREDNOTE);
            $changePasswordForm->accept($renderer);
            $smarty->assign('T_CHANGE_PASSWORD_FORM', $changePasswordForm->toArray());
        } catch (Exception $e) {
            eF_redirect("index.php?message=" . urlencode($e->getMessage() . " (" . $e->getCode() . ")") . "&message_type=failure");
        }
    }
}
/* ---------------------------------------------------------Activation by email part--------------------------------------------------------- */
if (isset($_GET['account']) && isset($_GET['key']) && eF_checkParameter($_GET['account'], 'login') && eF_checkParameter($_GET['key'], 'timestamp')) {
    if ($configuration['activation'] == 0 && $configuration['mail_activation'] == 1 || $configuration['supervisor_mail_activation'] == 1) {
        $result = eF_getTableData("users", "timestamp, active", "login='******'account'] . "'");
        if ($result[0]['active'] == 0 && $result[0]['timestamp'] == $_GET['key']) {
            try {
                $user = EfrontUserFactory::factory($_GET['account']);
                //new EfrontUser($_GET['login']);
                $user->activate();
                if ($_GET['activatedBy']) {
 /**
  * The main functionality
  *
  * (non-PHPdoc)
  * @see libraries/EfrontModule#getModule()
  */
 public function getModule()
 {
     $smarty = $this->getSmartyVar();
     $currentUser = $this->getCurrentUser();
     $directionsTree = new EfrontDirectionsTree();
     $directionsPaths = $directionsTree->toPathString();
     $smarty->assign("T_MODULE_OUTLOOK_INVITATION_DIRECTION_PATHS", $directionsPaths);
     $temp = eF_getTableData("module_outlook_invitation as m,courses as c", "m.*,c.name,c.directions_ID", "m.courses_ID=c.id");
     $events = array();
     foreach ($temp as $value) {
         $events[$value['courses_ID']] = $value;
     }
     if (isset($_GET['delete_event']) && eF_checkParameter($_GET['delete_event'], 'id') && in_array($_GET['delete_event'], array_keys($events))) {
         try {
             $event = $events[$_GET['delete_event']];
             $course = new EfrontCourse($event['courses_ID']);
             $users = $course->getCourseUsers(array('active' => true, archive => false, 'return_objects' => false));
             $recipients = array();
             foreach ($users as $value) {
                 $recipients[] = $value['email'];
             }
             $this->cancelInvitation($course->course['id'], $recipients);
             eF_deleteTableData("module_outlook_invitation", "courses_ID=" . $_GET['delete_event']);
         } catch (Exception $e) {
             header("HTTP/1.0 500 ");
             echo $e->getMessage() . ' (' . $e->getCode() . ')';
         }
         exit;
     }
     if ($_SESSION['s_type'] != 'administrator') {
         $userCourses = $currentUser->getUserCourses(array('archive' => 0, 'active' => true, 'return_objects' => false));
         if (G_VERSIONTYPE == 'enterprise') {
             if ($_SESSION['s_current_branch']) {
                 $result = eF_getTableData("module_hcd_course_to_branch", "courses_ID", "branches_ID='{$_SESSION['s_current_branch']}'");
             } else {
                 if ($currentUser->aspects['hcd']->isSupervisor()) {
                     $result = eF_getTableData("module_hcd_course_to_branch", "courses_ID", "branches_ID in (select branches_ID from module_hcd_employee_works_at_branch where users_login='******'login']}' and supervisor=1)");
                 }
             }
             $branchCourses = array();
             foreach ($result as $value) {
                 $branchCourses[$value['courses_ID']] = $value['courses_ID'];
             }
             foreach ($events as $key => $value) {
                 if (!isset($branchCourses[$key]) && !isset($userCourses[$key])) {
                     unset($events[$key]);
                 }
             }
         } else {
             foreach ($events as $key => $value) {
                 if (!isset($userCourses[$key])) {
                     unset($events[$key]);
                 }
             }
         }
     }
     if (!isset($_GET['course'])) {
         $dataSource = $events;
         $tableName = 'outlookInvitationsTable';
         isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'uint') ? $limit = $_GET['limit'] : ($limit = G_DEFAULT_TABLE_SIZE);
         if (isset($_GET['sort']) && eF_checkParameter($_GET['sort'], 'text')) {
             $sort = $_GET['sort'];
             isset($_GET['order']) && $_GET['order'] == 'desc' ? $order = 'desc' : ($order = 'asc');
         } else {
             $sort = 'login';
         }
         $dataSource = eF_multiSort($dataSource, $sort, $order);
         $smarty->assign("T_TABLE_SIZE", sizeof($dataSource));
         if (isset($_GET['filter'])) {
             $dataSource = eF_filterData($dataSource, $_GET['filter']);
         }
         if (isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'int')) {
             isset($_GET['offset']) && eF_checkParameter($_GET['offset'], 'int') ? $offset = $_GET['offset'] : ($offset = 0);
             $dataSource = array_slice($dataSource, $offset, $limit);
         }
         $smarty->assign("T_DATA_SOURCE", $dataSource);
     } else {
         $course = new EfrontCourse($_GET['course']);
         $form = new HTML_QuickForm("import_outlook_invitation_form", "post", $this->moduleBaseUrl . "&course={$course->course['id']}&add_event=1" . (isset($_GET['popup']) ? '&popup=1' : ''), "", null, true);
         $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
         //Register this rule for checking user input with our function, eF_checkParameter
         $form->addElement('text', 'email', _SENDER, 'class = "inputText"');
         $form->addElement('text', 'location', _LOCATION, 'class = "inputText"');
         $form->addElement('text', 'subject', _SUBJECT, 'class = "inputText"');
         $form->addElement('textarea', 'description', _DESCRIPTION, 'class = "inputTestTextarea" style = "width:80%;height:6em;"');
         //$form -> addElement('checkbox', 'calendar', _MODULE_OUTLOOK_INVITATION_CREATE_CALENDAR);
         //$form -> addElement('static', 'static', _MODULE_OUTLOOK_INVITATION_INFO);
         $form->addElement('submit', 'submit_event_all', _MODULE_OUTLOOK_INVITATION_SENDALL, 'class=flatButton');
         $form->addElement('submit', 'submit_event_new', _MODULE_OUTLOOK_INVITATION_SENDNEW, 'class=flatButton');
         if (empty($events[$course->course['id']])) {
             //new invitation
             $currentEvent = null;
             $form->setDefaults(array('email' => $currentUser->user['email'], 'subject' => 'Invitation to attend training: ' . $course->course['name']));
         } else {
             //existing invitation
             $currentEvent = $events[$course->course['id']];
             $form->setDefaults(array('email' => $currentEvent['email'], 'description' => $currentEvent['description'], 'subject' => $currentEvent['subject'], 'location' => $currentEvent['location']));
         }
         if ($form->isSubmitted() && $form->validate()) {
             try {
                 $message = "";
                 // Set info to store into database
                 $permanent_info = array("courses_ID" => $course->course['id'], "email" => $form->exportValue('email') ? $form->exportValue('email') : $GLOBALS['configuration']['system_email'], "location" => $form->exportValue('location'), "subject" => $form->exportValue('subject'), "description" => $form->exportValue('description'));
                 if ($currentEvent) {
                     $permanent_info['sequence'] = $currentEvent['sequence'] + 1;
                     eF_updateTableData("module_outlook_invitation", $permanent_info, "courses_ID={$course->course['id']}");
                 } else {
                     eF_insertTableData("module_outlook_invitation", $permanent_info);
                 }
                 if ($form->exportValue('submit_event_all')) {
                     $users = $course->getCourseUsers(array('active' => true, archive => false, 'return_objects' => false));
                     $recipients = array();
                     foreach ($users as $value) {
                         $recipients[] = $value['email'];
                     }
                     $this->sendInvitation($course->course['id'], $recipients);
                 }
                 //					$smarty->assign('T_RELOAD', true);
                 if (isset($_GET['popup'])) {
                     $this->setMessageVar(_OPERATIONCOMPLETEDSUCCESSFULLY, 'success');
                 } else {
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_OPERATIONCOMPLETEDSUCCESSFULLY) . "&message_type=success");
                 }
             } catch (Exception $e) {
                 $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
                 $this->setMessageVar($e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>', 'failure');
             }
         }
         $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
         $form->setRequiredNote(_REQUIREDNOTE);
         $smarty->assign('T_MODULE_OUTLOOK_INVITATION_FORM', $form->toArray());
     }
     $smarty->assign("T_MODULE_BASEDIR", $this->moduleBaseDir);
     $smarty->assign("T_MODULE_BASELINK", $this->moduleBaseLink);
     $smarty->assign("T_MODULE_BASEURL", $this->moduleBaseUrl);
     return true;
 }
 private function doJobCourses()
 {
     $smarty = $this->getSmartyVar();
     $currentUser = $this->getCurrentUser();
     $result = eF_getTableData("module_hcd_job_description j left outer join module_hcd_course_to_job_description cj on cj.job_description_ID=j.job_description_ID", "j.job_description_ID,description,branch_ID,count(courses_ID) as total_courses", "", "", "j.job_description_ID");
     $branchesTree = new EfrontBranchesTree();
     $branchesTreePaths = $branchesTree->toPathString();
     $jobs = array();
     foreach ($result as $value) {
         $jobsArray[$value['job_description_ID']] = $value;
         $jobs[$value['job_description_ID']] = $branchesTreePaths[$value['branch_ID']] . "&nbsp;&rarr;&nbsp;" . $value['description'] . " (" . $value['total_courses'] . ")";
     }
     $form = new HTML_QuickForm("job_courses_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=module&op=module_administrator_tools&tab=job_courses&do=enterprise", "", null, true);
     $form->addElement('select', 'job', _JOBDESCRIPTION, $jobs);
     $form->addElement("submit", "submit", _MODULE_ADMINISTRATOR_TOOLS_COPYCOURSESELECTION, 'class = "flatButton"');
     $form->addElement("static", "", _MODULE_ADMINISTRATOR_TOOLS_COPYCOURSESELECTIONTOALLSIMILARJOBS);
     $form->setDefaults(array("idle_from_timestamp" => $_SESSION['timestamp_from']));
     if ($form->isSubmitted() && $form->validate()) {
         $GLOBALS['currentEmployee'] = $currentUser->aspects['hcd'];
         $job = new EfrontJob($form->exportValue('job'));
         $courses = $job->getJobCourses();
         foreach ($sameJobs = $job->getSameDescriptions() as $value) {
             eF_deleteTableData("module_hcd_course_to_job_description", "job_description_id = '" . $value . "'");
         }
         $job->associateCoursesToJob($courses, true);
         $message = str_replace(array("%x", "%y"), array(sizeof($sameJobs), sizeof($courses)), _MODULE_ADMINISTRATOR_TOOLS_SUCCESSFULLYASSIGNEDCOURSESTOJOBS);
         $message_type = 'success';
         $this->setMessageVar($message, $message_type);
     }
     $smarty->assign("T_JOB_COURSES_FORM", $form->toArray());
 }
 /**
  * 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);
     $dir = $this->moduleBaseDir . 'assets/';
     if (!is_dir($dir)) {
         mkdir($dir, 0755);
     }
     if ($_SESSION['s_type'] == 'administrator') {
         try {
             $form = new HTML_QuickForm("upload_files_form", "post", $this->moduleBaseUrl . '&tab=upload', "", null, true);
             $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
             //Register this rule for checking user input with our function, eF_checkParameter
             $form->addElement('file', 'file', _UPLOADFILE);
             if (G_VERSIONTYPE == 'enterprise') {
                 $tree = new EfrontBranchesTree();
                 $pathString = $tree->toPathString();
                 //$result = eF_getTableData("module_hcd_branch", "*", "url is not null and url !=''");
                 $handle = '<img id = "busy" src = "images/16x16/clock.png" style = "display:none;" alt = "{$smarty.const._LOADING}" title = "{$smarty.const._LOADING}"/><div id = "autocomplete_leaflet_branches" class = "autocomplete"></div>&nbsp;&nbsp;&nbsp;';
                 $form->addElement('static', 'sidenote', $handle);
                 $form->addElement('text', 'leaflet_branch_autoselect', _BRANCH, 'class = "autoCompleteTextBox" id = "autocomplete"');
                 $form->addElement('hidden', 'leaflet_branch', '', 'id = "leaflet_branch_value"');
             }
             $form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
             $form->addElement('submit', 'submit_upload', _UPLOAD, 'class = "flatButton"');
             if ($form->isSubmitted() && $form->validate()) {
                 $values = $form->exportValues();
                 try {
                     if ($values['leaflet_branch'] && eF_checkParameter($values['leaflet_branch'], 'id')) {
                         $branch = new EfrontBranch($values['leaflet_branch']);
                         if (!$branch->branch['url']) {
                             throw new Exception("You must assign a url to the selected branch to upload files for it");
                         }
                         $dir = $this->moduleBaseDir . 'assets/' . $branch->branch['url'];
                         mkdir($dir, 0755);
                     }
                     $filesystem = new FileSystemTree($dir);
                     $file = $filesystem->uploadFile("file", $dir);
                 } 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;
                     $this->setMessageVar($message, $message_type);
                 }
             }
             $smarty->assign('T_UPLOAD_FORM', $form->toArray());
             $url = $this->moduleBaseUrl;
             $basedir = $dir;
             $options = array('zip' => false, 'upload' => false, 'create_folder' => false, 'folders' => true);
             /**The file manager*/
             include "file_manager.php";
         } 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';
             $this->setMessageVar($message, $message_type);
         }
     } else {
         if (defined('G_BRANCH_URL') && G_BRANCH_URL) {
             try {
                 $assets_path = $root_path = $this->moduleBaseDir . 'assets/' . G_BRANCH_URL;
             } catch (Exception $e) {
                 //do nothing here if the directory doesn't exist
             }
         } else {
             $assets_path = $root_path = $this->moduleBaseDir . 'assets/';
         }
         $files = array();
         if (!empty($_GET['folder'])) {
             $folder = urldecode($_GET['folder']);
             if (is_dir($assets_path . $folder)) {
                 $folder = new EfrontDirectory($assets_path . $folder);
                 if (strpos(realpath($folder['path']), $root_path) === false) {
                     throw new Exception("Invalid folder");
                 }
                 $parent_folder = dirname($folder['path']);
                 $url = urlencode(str_replace($root_path, '', $folder['path']));
                 $assets_path = $folder['path'];
                 $parent_url = $this->moduleBaseUrl . "&folder=" . urlencode(str_replace($root_path, '', dirname($folder['path']) . '/'));
                 $parent_url or $parent_url = $this->moduleBaseUrl . 'assets/';
                 $files[] = array('text' => '.. (Up one level)', 'image' => $this->moduleBaseLink . 'ico/folders.png', 'href' => $parent_url);
             }
         }
         //pr($url);pr($parent_url);
         //
         $filesystem = new FileSystemTree($assets_path, true);
         foreach ($filesystem->tree as $key => $value) {
             if ($value instanceof EfrontDirectory) {
                 $files[] = array('text' => basename($key), 'image' => $this->moduleBaseLink . 'ico/folders.png', 'href' => $this->moduleBaseUrl . "&folder=" . urlencode(str_replace($root_path, '', $value['path'] . '/')));
             }
         }
         foreach ($filesystem->tree as $key => $value) {
             if ($value instanceof EfrontFile) {
                 if (is_file($this->moduleBaseDir . 'ico/' . pathinfo($key, PATHINFO_EXTENSION) . '.png')) {
                     $icon = $this->moduleBaseLink . 'ico/' . pathinfo($key, PATHINFO_EXTENSION) . '.png';
                 } else {
                     $icon = $this->moduleBaseLink . 'ico/unknown.png';
                 }
                 $files[] = array('text' => basename($key), 'image' => $icon, 'href' => $this->moduleBaseLink . str_replace($this->moduleBaseDir, '', $key));
             }
         }
         $smarty->assign("T_FILES", $files);
     }
     return true;
 }
Esempio n. 6
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";
 }
    /**
     * 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);
        $form = new HTML_QuickForm("bootstrap_form", "post", $this->moduleBaseUrl, "", null, true);
        $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
        $form->addElement('text', 'name', _NAME, 'class = "inputText"');
        $form->addElement('static', '', _MODULE_BOOTSTRAP_WITHOUTTHECLASS, 'class = "inputText"');
        $form->addRule('name', _THEFIELD . ' ' . _NAME . ' ' . _ISMANDATORY, 'required', null, 'client');
        $form->addRule('name', _INVALIDFIELDDATA, 'checkParameter', 'alnum');
        $form->addElement('text', 'title', _TITLE, 'class = "inputText"');
        $form->addElement('text', 'creator', _MODULE_BOOTSTRAP_CREATOR, 'class = "inputText"');
        $form->addElement('checkbox', 'administrator', _ADMINISTRATOR);
        $form->addElement('checkbox', 'professor', _PROFESSOR);
        $form->addElement('checkbox', 'student', _STUDENT);
        $form->addElement('checkbox', 'supervisor', _MODULE_BOOTSTRAP_SUPERVISORONLY);
        $form->addElement('checkbox', 'tabber', _MODULE_BOOTSTRAP_TABBER);
        $form->addElement('textarea', 'form', _MODULE_BOOTSTRAP_FORMFIELDS, 'class = "inputTextarea" style = "height:40px"');
        $form->addElement('static', '', _MODULE_BOOTSTRAP_FORMINSTRUCTIONS);
        $form->addElement('textarea', 'grid', _MODULE_BOOTSTRAP_GRIDFIELDS, 'class = "inputTextarea" style = "height:40px"');
        $form->addElement('static', '', _MODULE_BOOTSTRAP_GRIDINSTRUCTIONS);
        $form->addElement('checkbox', 'filemanager', _MODULE_BOOTSTRAP_FILEMANAGER);
        $form->addElement('textarea', 'description', _DESCRIPTION, 'class = "inputTextarea" style = "height:80px"');
        //$form -> addElement('placing', 'student', _MODULE_BOOTSTRAP_NAME);
        $form->addElement('checkbox', 'overwrite', _MODULE_BOOTSTRAP_OVERWRITEIFEXISTS);
        $form->addElement('submit', 'submit', _INSTALL, 'class = "flatButton"');
        $form->setDefaults(array('creator' => $this->getCurrentUser()->user['name'] . ' ' . $this->getCurrentUser()->user['surname']));
        if ($form->isSubmitted() && $form->validate()) {
            try {
                $values = $form->exportValues();
                if (!$values['administrator'] && !$values['student'] && !$values['professor']) {
                    throw new Exception(_MODULE_BOOTSTRAP_YOUMUSTSELECTATLEASTATYPE);
                }
                $module_name = $values['name'];
                $module_dir = $this->moduleBaseDir . 'module_' . $module_name;
                if (!is_dir($module_dir)) {
                    mkdir($module_dir, 0755);
                }
                if (!is_dir("{$module_dir}/img")) {
                    mkdir("{$module_dir}/img", 0755);
                }
                if (!is_dir("{$module_dir}/assets")) {
                    mkdir("{$module_dir}/assets", 0755);
                }
                if ($values['administrator']) {
                    $roles[] = 'administrator';
                }
                if ($values['professor']) {
                    $roles[] = 'professor';
                }
                if ($values['student']) {
                    $roles[] = 'student';
                }
                $roles = '"' . implode('","', $roles) . '"';
                $contents = $tabber = $block = $grid_content = $fields_content = '';
                $fields = array();
                if ($values['form']) {
                    foreach (explode(",", $values['form']) as $property) {
                        $property = explode(":", $property);
                        array_walk($property, create_function('&$v', '$v = trim($v);'));
                        $fields[] = array('type' => $property[0], 'name' => $property[1], 'title' => $property[2], 'extra' => $property[3]);
                    }
                    foreach ($fields as $value) {
                        $fields_content .= '$form -> addElement("' . $value["type"] . '", "' . $value["name"] . '", "' . $value["title"] . '", "' . $value["extra"] . '");';
                    }
                } else {
                    $fields = "return false;";
                }
                if ($values['filemanager']) {
                    $file_manager = "true";
                } else {
                    $file_manager = "false";
                }
                if ($values['grid']) {
                    $headers = $rows = $grid_contents = array();
                    $grid_content = "\$data = array(array(";
                    foreach (explode(",", $values['grid']) as $property) {
                        $property = trim($property);
                        if ($property) {
                            $property = explode(":", $property);
                            array_walk($property, create_function('&$v', '$v = trim($v);'));
                            $headers[] = "\r\n\t\t\t\t\t\t\t\t<td class = 'topTitle' name = '{$property[0]}'>{$property[1]}</td>";
                            $rows[] = "\r\n\t\t\t\t\t\t\t\t<td>{\$item.{$property[0]}}</td>";
                            $grid_content .= "'{$property[0]}' => 'sample value',";
                        }
                    }
                    $grid_content .= "));";
                    $headers = implode("\n", $headers);
                    $rows = implode("\n", $rows);
                    $contents .= <<<GRID
{capture name = "t_grid_code"}
<!--ajax:{$module_name}Table-->
\t\t\t\t\t<table style = "width:100%" class = "sortedTable" size = "{\$T_TABLE_SIZE}" sortBy = "0" id = "{$module_name}Table" useAjax = "1" rowsPerPage = "{\$smarty.const.G_DEFAULT_TABLE_SIZE}" url = "{\$T_MODULE_BASEURL}&">
\t\t\t\t\t\t<tr class = "topTitle">
\t\t\t\t\t\t\t{$headers}
\t\t\t\t\t\t</tr>
\t{foreach name = 'demo_data_list' key = 'key' item = 'item' from = \$T_DATA_SOURCE}
\t\t\t\t\t\t<tr class = "defaultRowHeight {cycle values = "oddRowColor, evenRowColor"}">
\t\t\t\t\t\t\t{$rows}
\t\t\t\t\t\t</tr>
\t{foreachelse}
\t\t\t\t\t<tr class = "defaultRowHeight oddRowColor"><td class = "emptyCategory" colspan = "100%">{\$smarty.const._NODATAFOUND}</td></tr>
\t{/foreach}
\t\t\t\t</table>

<!--/ajax:{$module_name}Table-->

{/capture}

GRID;
                    if ($values['tabber']) {
                        $tabber = "tabber = \"{$module_name}_grid\"";
                    }
                    $block .= '{eF_template_printBlock ' . $tabber . ' title = "' . _MODULE_BOOTSTRAP_DATA . '" data = $smarty.capture.t_grid_code}' . "\n";
                }
                if ($values['form']) {
                    $contents .= <<<FORM
{capture name = "t_form_block_code"}
\t{eF_template_printForm form = \$T_FORM}
{/capture}
FORM;
                    if ($values['tabber']) {
                        $tabber = "tabber = \"{$module_name}_form\"";
                    }
                    $block .= '{eF_template_printBlock ' . $tabber . ' title = "' . _MODULE_BOOTSTRAP_FORM . '" data = $smarty.capture.t_form_block_code}' . "\n";
                }
                if ($values['filemanager']) {
                    $contents .= <<<FILEMANAGER
{capture name = "t_block_code"}
\t{\$T_FILE_MANAGER}
{/capture}
FILEMANAGER;
                    if ($values['tabber']) {
                        $tabber = "tabber = \"{$module_name}_filemanager\"";
                    }
                    $block .= '{eF_template_printBlock ' . $tabber . ' title = "' . _MODULE_BOOTSTRAP_FILES . '" data = $smarty.capture.t_block_code}';
                }
                if ($values['empty_page']) {
                    $contents .= <<<EMPTY
{capture name = "t_block_code"}
\tCode here
{/capture}
EMPTY;
                    if ($values['tabber']) {
                        $tabber = "tabber = \"{$module_name}_page\"";
                    }
                    $block .= '{eF_template_printBlock ' . $tabber . ' title = "' . _MODULE_BOOTSTRAP_PAGE . '" data = $smarty.capture.t_block_code}';
                }
                if ($values['tabber']) {
                    $contents = <<<CONTENTS
{$contents}
{capture name = "t_code"}
<div class = "tabber">
{$block}
</div>
{/capture}
{eF_template_printBlock title = "{$values["title"]}" data = \$smarty.capture.t_code}
CONTENTS;
                } else {
                    $contents = $contents . $block;
                }
                file_put_contents("{$module_dir}/module.tpl", $contents);
                $search = array("###NAME###", "###TITLE###", "###ROLES###", "###FIELDS###", "###FILE_MANAGER###", "###GRID_DATA###");
                $replace = array($module_name, $values['title'], $roles, $fields_content, $file_manager, $grid_content);
                $contents = file_get_contents($this->moduleBaseDir . "template/module_.class.php");
                $contents = str_replace($search, $replace, $contents);
                file_put_contents("{$module_dir}/module_{$module_name}.class.php", $contents);
                $date = date("Y m d");
                $xml = <<<XML
<?xml version="1.0" ?>
<module>
\t<title>{$values['title']}</title>
\t<author>{$values['creator']}</author>
\t<date>{$date}</date>
\t<version>1.0</version>
\t<description>{$values['description']}</description>
\t<className>module_{$module_name}</className>
\t<requires>3.6.11</requires>
</module>
XML;
                file_put_contents("{$module_dir}/module.xml", $xml);
                copy($this->moduleBaseDir . "img/logo.png", "{$module_dir}/img/logo.png");
                copy($this->moduleBaseDir . "img/generic.png", "{$module_dir}/img/generic.png");
                $directory = new EfrontDirectory($module_dir);
                if (is_dir(G_MODULESPATH . basename($module_dir))) {
                    if ($values['overwrite']) {
                        $file = $directory->copy(G_MODULESPATH . basename($module_dir), true);
                    } else {
                        throw new Exception(_MODULE_BOOTSTRAP_MODULEEXISTS);
                    }
                } else {
                    $file = $directory->copy(G_MODULESPATH . basename($module_dir));
                }
                $this->setMessageVar(_MODULE_BOOTSTRAP_MODULEINSTALLED, 'success');
            } 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>';
                $this->setMessageVar($message, 'failure');
            }
        }
        $smarty->assign("T_FORM", $form->toArray());
        return true;
    }
Esempio n. 8
0
        }
        try {
            if ($form->isSubmitted() && $form->validate()) {
                $evaluation_content = array('specification' => $form->exportValue('specification'), 'event_code' => 10, 'users_login' => $editedUser->user['login'], 'author' => $currentUser->user['login'], 'timestamp' => time());
                if (isset($_GET['add_evaluation'])) {
                    eF_insertTableData("module_hcd_events", $evaluation_content);
                } elseif (isset($_GET['edit_evaluation'])) {
                    eF_updateTableData("module_hcd_events", $evaluation_content, "event_ID = '" . $_GET['edit_evaluation'] . "'");
                }
                $message = _OPERATIONCOMPLETEDSUCCESSFULLY;
                $message_type = 'success';
            }
        } catch (Exception $e) {
            handleNormalFlowExceptions($e);
        }
        $smarty->assign("T_EVALUATIONS_FORM", $form->toArray());
    } else {
        $evaluations = eF_getTableData("module_hcd_events", "*", "users_login = '******'login'] . "' AND event_code >=10", "timestamp");
        $smarty->assign("T_EVALUATIONS", $evaluations);
    }
}
#cpp#endif
/*** Evaluations are deleted either by administrators or by the users who wrote them ***/
/*
// Check if you are changing your own data - every HCD type is allowed to do that
if ($_GET['ctg'] != 'personal') {
if ($currentUser -> getType() != "administrator") {      // Administrators are allowed to do anything - no need to check further

// If you are a Supervisor...
if ($currentEmployee -> isSupervisor() ) {
$smarty -> assign("T_IS_SUPERVISOR", true);
Esempio n. 9
0
             $fields['self_enroll'] = $values['self_enroll'];
             $fields['key_max_usage'] = $values['key_max_usage'] ? $values['key_max_usage'] : 0;
             if (isset($_GET['edit_user_group'])) {
                 $values['key_max_usage'] or $fields['key_current_usage'] = 0;
                 $currentGroup->group = array_merge($currentGroup->group, $fields);
                 $currentGroup->persist();
             } else {
                 $currentGroup = EfrontGroup::create($fields);
             }
             eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=user_groups&edit_user_group=" . $currentGroup->group['id'] . "&message=" . urlencode(_OPERATIONCOMPLETEDSUCCESSFULLY) . "&message_type=success");
         } catch (Exception $e) {
             handleNormalFlowExceptions($e);
         }
     }
 }
 $smarty->assign('T_USERGROUPS_FORM', $form->toArray());
 if (isset($_GET['edit_user_group'])) {
     try {
         if (isset($_GET['ajax']) && $_GET['ajax'] == "usersTable") {
             $roles = EfrontUser::getRoles(true);
             $smarty->assign("T_ROLES", $roles);
             $constraints = array('archive' => false, 'return_objects' => false) + createConstraintsFromSortedTable();
             $users = $currentGroup->getGroupUsersIncludingUnassigned($constraints);
             $totalEntries = $currentGroup->countGroupUsersIncludingUnassigned($constraints);
             $dataSource = $users;
             $tableName = $_GET['ajax'];
             $alreadySorted = 1;
             $smarty->assign("T_TABLE_SIZE", $totalEntries);
             include "sorted_table.php";
         }
         if (isset($_GET['ajax']) && $_GET['ajax'] == "lessonsTable") {
Esempio n. 10
0
        EfrontConfiguration::setValue('multiple_logins', serialize($multipleLogins));
        eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=user&tab=multiple_logins&message=" . urlencode(_SUCCESFULLYUPDATECONFIGURATION) . "&message_type=success");
    }
}
$smarty->assign("T_USER_MULTIPLE_LOGINS_FORM", $userMultipleLoginsForm->toArray());
$userWebserverAuthenticationForm = new HTML_QuickForm("user_webserver_authentication_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=user&tab=webserver_authentication", "", null, true);
$userWebserverAuthenticationForm->registerRule('checkParameter', 'callback', 'eF_checkParameter');
$userWebserverAuthenticationForm->addElement("advcheckbox", "webserver_auth", _WEBSERVERAUTHENTICATION, null, 'class = "inputCheckBox"', array(0, 1));
$userWebserverAuthenticationForm->addElement("advcheckbox", "webserver_registration", _WEBSERVERREGISTRATION, null, 'class = "inputCheckBox"', array(0, 1));
$userWebserverAuthenticationForm->addElement("text", "error_page", _ERRORPAGEFORINVALIDLOGIN, 'class = "inputText"');
$userWebserverAuthenticationForm->addElement("text", "unauthorized_page", _ERRORPAGEFORUNAUTHORIZED, 'class = "inputText"');
$userWebserverAuthenticationForm->addElement("text", "username_variable", _VARIABLEFORUSERNAME, 'class = "inputText"');
$userWebserverAuthenticationForm->addElement("text", "registration_file", _INCLUDEFILETHATHANDLESUSERCREATION, 'class = "inputText"');
eval('$usernameVar=' . $GLOBALS['configuration']['username_variable'] . ';');
$userWebserverAuthenticationForm->addRule('webserver_auth', str_replace(array("%x", "%y"), array($GLOBALS['configuration']['username_variable'], $_SESSION['s_login']), _VARIABLEMUSTCONTAINLOGIN), 'callback', create_function('$checkbox', "if (\$GLOBALS['usernameVar'] == \$_SESSION['s_login']) {return true;}"));
$userWebserverAuthenticationForm->setDefaults($GLOBALS['configuration']);
if (isset($currentUser->coreAccess['configuration']) && $currentUser->coreAccess['configuration'] != 'change') {
    $userWebserverAuthenticationForm->freeze();
} else {
    $userWebserverAuthenticationForm->addElement("submit", "submit", _SAVE, 'class = "flatButton"');
    if ($userWebserverAuthenticationForm->isSubmitted() && $userWebserverAuthenticationForm->validate()) {
        $values = $userWebserverAuthenticationForm->exportValues();
        unset($values['submit']);
        foreach ($values as $key => $value) {
            EfrontConfiguration::setValue($key, $value);
        }
        eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=user&tab=webserver_authentication&message=" . urlencode(_SUCCESFULLYUPDATECONFIGURATION) . "&message_type=success");
    }
}
$smarty->assign("T_USER_WEBSERVER_AUTHENTICATION_FORM", $userWebserverAuthenticationForm->toArray());
Esempio n. 11
0
            EfrontConfiguration::setValue('facebook_api_key', $values['facebook_api_key']);
            unset($values['facebook_api_key']);
            EfrontConfiguration::setValue('facebook_secret', $values['facebook_secret']);
            unset($values['facebook_secret']);
            // Create the new binary map
            $socialModulesToBeActivated = 0;
            foreach ($values as $key => $value) {
                if ($value == 1) {
                    $socialModulesToBeActivated += intval(substr($key, 7));
                }
            }
            EfrontConfiguration::setValue('social_modules_activated', $socialModulesToBeActivated);
            eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=external&tab=facebook&message=" . urlencode(_SUCCESFULLYUPDATECONFIGURATION) . "&message_type=success");
        }
    }
    $smarty->assign("T_EXTERNAL_FACEBOOK_FORM", $externalFacebookForm->toArray());
}
#cpp#endif
$externalMathForm = new Html_QuickForm("external_math_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=external&tab=math", "", null, true);
$externalMathForm->registerRule('checkParameter', 'callback', 'eF_checkParameter');
$externalMathForm->addElement("advcheckbox", "math_content", _ENABLEMATHCONTENT, null, 'class = "inputCheckBox"', array(0, 1));
$externalMathForm->addElement("advcheckbox", "math_images", _LOADMATHTYPESASIMAGES, null, 'class = "inputCheckBox"', array(0, 1));
$externalMathForm->addElement("static", "", _MATHIMAGESINFO);
$externalMathForm->addElement("text", "math_server", _MATHSERVER, 'class = "inputText"');
$externalMathForm->addElement("static", "", _MATHSERVERINFO);
$externalMathForm->setDefaults($GLOBALS['configuration']);
if (isset($currentUser->coreAccess['configuration']) && $currentUser->coreAccess['configuration'] != 'change') {
    $externalMathForm->freeze();
} else {
    $externalMathForm->addElement("submit", "submit", _SAVE, 'class = "flatButton"');
    if ($externalMathForm->isSubmitted() && $externalMathForm->validate()) {
Esempio n. 12
0
 /**
  * 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;
 }
        		$socialModulesToBeActivated = 
        		EfrontUser::isOptionVisible('system_timeline') &
        		EfrontUser::isOptionVisible('lessons_timeline') &
        		EfrontUser::isOptionVisible('func_people') &
        		EfrontUser::isOptionVisible('func_comments') &
        		EfrontUser::isOptionVisible('func_userstatus');
        vd($socialModulesToBeActivated);
        */
        //EfrontConfiguration :: setValue('social_modules_activated', $socialModulesToBeActivated);
        // Create the new binary map
        $socialValues = array('mode_system_timeline', 'mode_lessons_timeline', 'mode_func_people', 'mode_func_comments', 'mode_func_userstatus');
        $socialModulesToBeActivated = '';
        foreach ($values as $key => $value) {
            if ($value == 1 && in_array($key, $socialValues) !== false) {
                $socialModulesToBeActivated = $socialModulesToBeActivated . strval($value);
            }
        }
        $socialModulesToBeActivated = intval($socialModulesToBeActivated, 2);
        EfrontConfiguration::setValue('social_modules_activated', $socialModulesToBeActivated);
        if ($values['mode_payments'] == 0) {
            eF_updateTableData("lessons", array('price' => 0), "id=id");
            eF_updateTableData("courses", array('price' => 0), "id=id");
        }
        if ($values['mode_simple_complete'] == 0) {
            eF_updateTableData("users", array('simple_mode' => 0));
        }
        eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=customization&tab=disable&message=" . urlencode(_SUCCESFULLYUPDATECONFIGURATION) . "&message_type=success");
    }
}
$smarty->assign("T_MODE_FORM", $modeForm->toArray());
Esempio n. 14
0
        } else {
            $user_mail = eF_getTableData("users", "email", "login='******'s_login'] . "'");
            $header = array('From' => $values['system_email'], 'To' => $user_mail[0]['email'], 'Subject' => 'Test email', 'Content-type' => 'text/plain;charset="UTF-8"', 'Content-Transfer-Encoding' => '7bit', 'Date' => date("r"));
            $smtp = Mail::factory('smtp', array('auth' => $values['smtp_auth'] ? true : false, 'host' => $values['smtp_host'], 'password' => $values['smtp_pass'], 'port' => $values['smtp_port'], 'username' => $values['smtp_user'], 'timeout' => $values['smtp_timeout'], 'localhost' => $_SERVER["HTTP_HOST"]));
            $result = $smtp->send($user_mail[0]['email'], $header, 'This is a test email sent from ' . G_SERVERNAME . ' to verify SMTP settings');
            if ($result === true) {
                $message = _EMAILSENDTOYOURADDRESS;
                $message_type = 'success';
            } else {
                $message = $result->getMessage();
                $message_type = 'failure';
            }
        }
    }
}
$smarty->assign("T_GENERAL_SMTP_FORM", $generalSMTPForm->toArray());
$generalPHPForm = new Html_QuickForm("general_php_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=general&tab=php", "", null, true);
$generalPHPForm->registerRule('checkParameter', 'callback', 'eF_checkParameter');
$generalPHPForm->addElement("static", "sidenote", 'M');
$generalPHPForm->addElement("text", "memory_limit", _MEMORYLIMIT, 'class = "inputText" style = "width:35px"');
$generalPHPForm->addElement("static", "sidenote", _SECONDS);
$generalPHPForm->addElement("text", "max_execution_time", _MAXEXECUTIONTIME, 'class = "inputText" style = "width:35px"');
$generalPHPForm->addElement("static", "", _LEAVEBLANKTOUSEPHPINI);
$generalPHPForm->addElement("advcheckbox", "gz_handler", _GZHANDLER, null, 'class = "inputCheckBox"', array(0, 1));
$generalPHPForm->addElement("advcheckbox", "compress_tests", _COMPRESSTESTS, null, 'class = "inputCheckBox"', array(0, 1));
$generalPHPForm->addElement("text", "max_file_size", _MAXFILESIZE, 'class = "inputText"');
$generalPHPForm->addElement("static", "", _MAXFILEISAFFECTEDANDIS . ' <b>' . FileSystemTree::getUploadMaxSize() . '</b> ' . _KB);
$generalPHPForm->addElement("text", "debug_mode", _DEBUGMODE, null, 'class = "inputText"');
$generalPHPForm->addElement("static", "", _COMMASEPARATEDLISTOFUSERSOR1FORALL);
$generalPHPForm->addRule('memory_limit', _INVALIDFIELDDATA, 'checkParameter', 'id');
$generalPHPForm->addRule('max_execution_time', _INVALIDFIELDDATA, 'checkParameter', 'id');
Esempio n. 15
0
/**
* Returns complete formatted date
* 
* @Args : formname -> name of the inputfield
*         content -> value of textfield
*         type_config -> array with values from the CMS:tag
*         cms_side['view'] -> the current view of the user, 'edit' or 'preview'
*                  ['edit'] -> 'true' if user set the mod in templateconfig as active
*                              if user set inactiv var is not set
* @Return String HTML fields
* @Access public 
*/
function type_form_date($formname, $content, $type_config, $cms_side)
{
    global $cfg_cms, $sess;
    include_once 'HTML/QuickForm.php';
    if (!_type_check_editable($cms_side['edit'], $type_config['editable'], $cms_side['view'])) {
        return _type_get_element_hidden($formname, $content);
    }
    if (empty($content)) {
        $content = time();
    }
    $optionfields = "";
    // Datumsangaben für Ausgabe formatieren
    if (!(empty($type_config['formdateformat']) || $type_config['formdateformat'] == '')) {
        if ($type_config['formdateformat'] == "default-cms-date-format") {
            $type_config['formdateformat'] = $cfg_cms['FormatDate'];
        }
        if ($type_config['formdateformat'] == "default-cms-time-format") {
            $type_config['formdateformat'] = $cfg_cms['FormatTime'];
        }
        if ($type_config['formdateformat'] == "default-cms-format") {
            $type_config['formdateformat'] = $cfg_cms['FormatDate'] . " " . $cfg_cms['FormatTime'];
        }
        $form = new HTML_QuickForm('');
        $form->setDefaults(array($formname => $content));
        $dateOptions = array('format' => $type_config['formdateformat'], 'language' => 'de', 'optionIncrement' => array('i' => 5));
        $contentYear = date("Y", $content);
        if (!empty($type_config['minyear'])) {
            $dateOptions['minYear'] = $type_config['minyear'];
        } else {
            $dateOptions['minYear'] = date("Y") - 5;
        }
        if ($dateOptions['minYear'] > $contentYear) {
            $dateOptions['minYear'] = $contentYear;
        }
        if (!empty($type_config['maxyear'])) {
            $dateOptions['maxYear'] = $type_config['maxyear'];
        } else {
            $dateOptions['maxYear'] = date("Y") + 5;
        }
        if ($dateOptions['maxYear'] < $contentYear) {
            $dateOptions['maxYear'] = $contentYear;
        }
        $form->addElement('date', $formname, 'Date2:', $dateOptions);
        $temp_fileds = $form->toArray();
        $optionfields .= $temp_fileds[elements][0][html];
        $optionfields .= '&nbsp;&nbsp;' . date($type_config['formdateformat'], $content);
    } else {
        $type_config['formdateformat'] = 'd.m.Y';
        $startdate = date($type_config['formdateformat'], $content);
        $content = getdate($content);
        // Datumsangaben für Ausgabe formatieren
        $optionfields .= _type_get_element_hidden($formname . '[0]', 'd.m.Y');
        $optionfields .= '<input type="text" id="' . $formname . '" name="' . $formname . '[1]" value="' . $startdate . '" size="10" maxlength="10" style="width: 85px;">';
        $optionfields .= '&nbsp;
    	<script language="JavaScript1.2">
        function callback_' . $formname . '(date, month, year)
        {
            if (String(month).length == 1) {
                month = "0" + month;
            }
        
            if (String(date).length == 1) {
                date = "0" + date;
            }    
            document.getElementById("' . $formname . '").value = date + "." + month + "." + year;
        }
    	  calendar' . $formname . ' = new dynCalendar("calendar' . $formname . '", "callback_' . $formname . '", "' . $cfg_cms['cms_html_path'] . '/tpl/standard/img/");
    	  calendar' . $formname . '.setMonthCombo(true);
    	  calendar' . $formname . '.setYearCombo(true);
    	</script>';
        $optionfields .= '&nbsp;&nbsp;dd.mm.yyyy';
        $optionfields .= '&nbsp;&nbsp;' . date($type_config['formdateformat']);
    }
    return '<td>
          ' . $optionfields . '
        </td>' . "\n";
}