Пример #1
0
        throw new EfrontFileException(_ILLEGALPATH . ': ' . $file['path'], EfrontFileException::ILLEGAL_PATH);
    }
    if (strpos($file['path'], G_ROOTPATH . 'backups') !== false && $_SESSION['s_type'] != 'administrator') {
        throw new EfrontFileException(_YOUCANNOTACCESSTHEREQUESTEDRESOURCE, EfrontFileException::UNAUTHORIZED_ACTION);
    }
    if (isset($_GET['action']) && $_GET['action'] == 'download') {
        $file->sendFile(true);
    } else {
        cacheHeaders(lastModificationTime(filemtime($file['path'])));
        $file->sendFile(false);
    }
} catch (EfrontFileException $e) {
    if ($e->getCode() == EfrontFileException::FILE_NOT_EXIST) {
        header("HTTP/1.0 404");
    }
    echo EfrontSystem::printErrorMessage($e->getMessage());
}
function cacheHeaders($lastModifiedDate)
{
    if ($lastModifiedDate) {
        if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $lastModifiedDate) {
            if (php_sapi_name() == 'CGI') {
                Header("Status: 304 Not Modified");
            } else {
                Header("HTTP/1.0 304 Not Modified");
            }
            exit;
        } else {
            $gmtDate = gmdate("D, d M Y H:i:s \\G\\M\\T", $lastModifiedDate);
            header('Last-Modified: ' . $gmtDate);
        }
Пример #2
0
    }
}
$smarty->assign("T_GENERAL_SECURITY_FORM", $generalSecurityForm->toArray());
$generalLocaleForm = new HTML_QuickForm("general_locale", "post", basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=general&tab=locale", "", null, true);
$generalLocaleForm->registerRule('checkParameter', 'callback', 'eF_checkParameter');
$defaultEncodings = array_combine(mb_list_encodings(), mb_list_encodings());
$encodings['UTF7-IMAP'] = 'UTF7-IMAP';
/*
if (in_array(_CHARSET, $defaultEncodings)) {
	$encodings[_CHARSET] = _CHARSET;
}
*/
$encodings['UTF-8'] = 'UTF-8';
$encodings = array_merge($encodings, $defaultEncodings);
// Hard-coded cities per time zone - hopefully all are DST aware
$generalLocaleForm->addElement("select", "default_language", _DEFAULTLANGUAGE, EfrontSystem::getLanguages(true, true), 'class = "inputSelect"');
$generalLocaleForm->addElement("advcheckbox", "onelanguage", _ONLYONELANGUAGE, null, 'class = "inputCheckBox"', array(0, 1));
$generalLocaleForm->addElement("select", "date_format", _DATEFORMAT, array("DD/MM/YYYY" => "DD/MM/YYYY", "MM/DD/YYYY" => "MM/DD/YYYY", "YYYY/MM/DD" => "YYYY/MM/DD"));
$generalLocaleForm->addElement("select", "time_zone", _TIMEZONE, eF_getTimezones(), 'class = "inputText" style="width:40em"');
$generalLocaleForm->addElement("select", "currency", _CURRENCY, $CURRENCYNAMES);
$generalLocaleForm->addElement("select", "currency_order", _SHOWCURRENCYSYMBOL, array(1 => _BEFOREPRICE, 0 => _AFTERPRICE));
//$generalLocaleForm -> addElement("text", "decimal_point", _DECIMALPOINT,	   'class = "inputText" style = "width:50px"');
//$generalLocaleForm -> addElement("text", "thousands_sep", _THOUSANDSSEPARATOR, 'class = "inputText" style = "width:50px"');
$generalLocaleForm->addElement("select", "file_encoding", _TRANSLATEFILESYSTEM, $encodings, 'class = "inputSelect"');
$generalLocaleForm->setDefaults($GLOBALS['configuration']);
if (isset($currentUser->coreAccess['configuration']) && $currentUser->coreAccess['configuration'] != 'change') {
    $generalLocaleForm->freeze();
} else {
    $generalLocaleForm->addElement("submit", "submit", _SAVE, 'class = "flatButton"');
    if ($generalLocaleForm->isSubmitted() && $generalLocaleForm->validate()) {
        //If the form is submitted and validated
Пример #3
0
 *	   Typically, you store transaction IDs in a database so that you know you are only processing unique transactions.
 *	 - Validate that the receiver's email address is registered to you.
 *	   This check provides additional protection against fraud.
 *	 - Verify that the price, item description, and so on, match the transaction on your website.
 *	   This check provides additional protection against fraud.
 * 6. If the verified response passes the checks, take action based on the value of the txn_type variable if it exists; otherwise, take action based on the value of the reason_code variable.
 * 7. If the response is INVALID, save the message for further investigation.
 *
 */
$path = "../libraries/";
require_once $path . "configuration.php";
$GLOBALS['configuration']['paypalmode'] == 'sandbox' ? $paypalUrl = "www.sandbox.paypal.com" : ($paypalUrl = "www.paypal.com");
//Toggle sandbox/normal use
try {
    //Get the directory where the log file will be stored
    $admin = EfrontSystem::getAdministrator();
    $logFolder = $admin->user['directory'] . '/';
    new EfrontDirectory($logFolder);
    //This way if the $logFolder is not a valid directory, we will go to the catch{} block below
} catch (Exception $e) {
    $logFolder = '';
    //Use the current directory for storing the log
}
$logFile = $logFolder . 'ipn.log';
file_put_contents($logFile, "\n======================Start of communication====================\n", FILE_APPEND);
try {
    $result = eF_getTableData("payments", "*");
    $processedPayments = array();
    foreach ($result as $value) {
        if ($value['txn_id']) {
            $processedPayments[$value['txn_id']] = $value['status'];
Пример #4
0
 if (isset($_GET['add_lesson'])) {
     $post_target = 'add_lesson=1';
 } else {
     $post_target = 'edit_lesson=' . $_GET['edit_lesson'];
     $smarty->assign("T_LESSON_OPTIONS", array(array('text' => _LESSONSETTINGS, 'image' => "16x16/generic.png", 'href' => basename($_SERVER['PHP_SELF']) . "?ctg=lessons&lesson_settings=" . $_GET['edit_lesson'])));
 }
 $form = new HTML_QuickForm("add_lessons_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=lessons&" . $post_target, "", null, true);
 //Build the form
 $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
 //Register our custom input check function
 $form->addElement('text', 'name', _LESSONNAME, 'class = "inputText"');
 //The lesson name, it is required and of type 'text'
 $form->addRule('name', _THEFIELD . ' "' . _LESSONNAME . '" ' . _ISMANDATORY, 'required', null, 'client');
 $form->addRule('name', _INVALIDFIELDDATA, 'checkParameter', 'noscript');
 if ($GLOBALS['configuration']['onelanguage'] != true) {
     $form->addElement('select', 'languages_NAME', _LANGUAGE, EfrontSystem::getLanguages(true, true));
     //Add a language select box to the form
 }
 try {
     //If there are no direction set, redirect to add direction page
     $directionsTree = new EfrontDirectionsTree();
     if (sizeof($directionsTree->tree) == 0) {
         eF_redirect(basename($_SERVER['PHP_SELF']) . '?ctg=directions&add_direction=1&message=' . urlencode(_YOUMUSTFIRSTCREATEDIRECTION) . '&message_type=failure');
         exit;
     }
     $form->addElement('select', 'directions_ID', _DIRECTION, $directionsTree->toPathString());
     //Append a directions select box to the form
 } catch (Exception $e) {
     $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
     $message = _SOMEPROBLEMOCCURED . ': ' . $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
     $message_type = 'failure';
Пример #5
0
     }
 }
 #cpp#endif
 $lessons = $course->getCourseLessons();
 foreach ($lessons as $key => $lesson) {
     $content = new EfrontContentTree($lesson);
     if (sizeof($content->tree) > 0) {
         $contentTree[$key] = $content->toHTML(false, 'dhtml_content_tree_' . $lesson->lesson['id'], array('noclick' => 1));
     }
     $lessonInfo[$key] = new LearningObjectInformation(unserialize($lesson->lesson['info']));
     $additionalInfo[$key] = $lesson->getInformation();
 }
 $smarty->assign("T_ADDITIONAL_LESSON_INFO", $additionalInfo);
 $smarty->assign("T_COURSE_LESSON_INFO", $lessonInfo);
 $smarty->assign("T_CONTENT_TREE", $contentTree);
 $smarty->assign("T_LANGUAGES", EfrontSystem::getLanguages(true));
 $smarty->assign("T_COURSE_LESSONS", $lessons);
 $constraints = array('archive' => false, 'active' => true, 'sort' => 'name', 'condition' => 'show_catalog=1');
 if ($course->course['instance_source']) {
     $parentCourse = new EfrontCourse($course->course['instance_source']);
     $instances = $parentCourse->getInstances($constraints);
     $instances[$parentCourse->course['id']] = $parentCourse;
 } else {
     $instances = $course->getInstances($constraints);
     $instances[$course->course['id']] = $course;
 }
 $smarty->assign("T_COURSE_INSTANCES", $instances);
 $courseInfo = new LearningObjectInformation(unserialize($course->course['info']));
 $smarty->assign("T_COURSE_INFO", $courseInfo);
 $additionalInfo = $course->getInformation();
 $smarty->assign("T_ADDITIONAL_COURSE_INFO", $additionalInfo);
 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());
 }
Пример #7
0
 /**
  * Get lesson statisticsinformation
  *
  * This function returns the lesson information in an array
  * with attributes: 'general_description', 'assessment',
  * 'objectives', 'lesson_topics', 'resources', 'other_info',
  * as well as other information, including professors, projects
  * etc.
  * If a user is specified, the information is customized on this
  * user.
  *
  * <br/>Example:
  * <code>
  * $info = $lesson -> getInformation();         //Get lesson information
  * $info = $lesson -> getInformation('jdoe');   //Get lesson information, customizable for user 'jdoe'
  * </code>
  *
  * @param string $user The user login to customize lesson information for
  * @return array The lesson information
  * @since 3.5.0
  * @access public
  */
 public function getStatisticInformation($user = false)
 {
     $lessonContent = new EFrontContentTree($this->lesson['id']);
     $testIds = array();
     foreach (new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($lessonContent->tree), RecursiveIteratorIterator::SELF_FIRST), array('active' => 1, 'publish' => 1, 'ctg_type' => 'tests')) as $key => $value) {
         $testIds[$key] = $key;
         //Count tests
     }
     foreach (new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($lessonContent->tree), RecursiveIteratorIterator::SELF_FIRST), array('active' => 1, 'ctg_type' => 'scorm_test')) as $key => $value) {
         $testIds[$key] = $key;
         //Count scorm tests
     }
     $theoryIds = array();
     foreach (new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($lessonContent->tree), RecursiveIteratorIterator::SELF_FIRST), array('ctg_type' => 'theory', 'active' => 1)) as $key => $value) {
         $theoryIds[$key] = $key;
         //Count theory
     }
     foreach (new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($lessonContent->tree), RecursiveIteratorIterator::SELF_FIRST), array('ctg_type' => 'scorm', 'active' => 1)) as $key => $value) {
         $theoryIds[$key] = $key;
         //Count scorm content
     }
     $exampleIds = array();
     foreach (new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($lessonContent->tree), RecursiveIteratorIterator::SELF_FIRST), array('ctg_type' => 'examples', 'active' => 1)) as $key => $value) {
         $exampleIds[$key] = $key;
         //Count examples
     }
     if (!$user) {
         $projects = $this->getProjects();
         $lessonComments = eF_getTableData("comments, content", "comments.*", "comments.content_ID = content.id and content.lessons_ID=" . $this->lesson['id']);
         $lessonMessages = eF_getTableData("f_messages, f_topics, f_forums", "f_messages.*", "f_messages.f_topics_ID = f_topics.id and f_topics.f_forums_ID = f_forums.id and f_forums.lessons_ID=" . $this->lesson['id']);
     } else {
         $projects = $this->getProjects(false, $user, false);
         $lessonComments = eF_getTableData("comments, content", "comments.*", "comments.users_LOGIN='******' and comments.content_ID = content.id and content.lessons_ID=" . $this->lesson['id']);
         $lessonMessages = eF_getTableData("f_messages, f_topics, f_forums", "f_messages.*", "f_messages.users_LOGIN='******' and f_messages.f_topics_ID = f_topics.id and f_topics.f_forums_ID = f_forums.id and f_forums.lessons_ID=" . $this->lesson['id']);
     }
     $direction = $this->getDirection();
     $languages = EfrontSystem::getLanguages(true);
     $info['students'] = $this->getUsers('student');
     $info['professors'] = $this->getUsers('professor');
     $info['tests'] = sizeof($testIds);
     $info['theory'] = sizeof($theoryIds);
     $info['examples'] = sizeof($exampleIds);
     $info['content'] = $info['examples'] + $info['theory'];
     $info['projects'] = sizeof($projects);
     $info['comments'] = sizeof($lessonComments);
     $info['messages'] = sizeof($lessonMessages);
     $info['direction'] = $direction['name'];
     $info['active'] = $this->lesson['active'];
     $info['active_string'] = $this->lesson['active'] == 1 ? _YES : _NO;
     $info['price'] = $this->lesson['price'];
     $info['price_string'] = $this->lesson['price_string'];
     $info['language'] = $languages[$this->lesson['languages_NAME']];
     $info['created'] = $languages[$this->lesson['created']];
     if ($this->lesson['info']) {
         if (unserialize($this->lesson['info']) !== false) {
             $storedInfo = unserialize($this->lesson['info']);
             unset($storedInfo['professors']);
             //Due to an old bug, serialized information may contain professors as well. So, we must remove them
             $info = array_merge($info, $storedInfo);
         } else {
             if (is_array($this->lesson['info'])) {
                 $info = array_merge($info, $this->lesson['info']);
             }
         }
     }
     return $info;
 }
Пример #8
0
     $logoDirectory = new EfrontDirectory(G_LOGOPATH);
     $filesystem = new FileSystemTree(G_LOGOPATH);
     try {
         $logoFile = $filesystem->uploadFile('site_logo', $logoDirectory);
         if (strpos($logoFile['mime_type'], 'image') === false) {
             throw new EfrontFileException(_NOTANIMAGEFILE, EfrontFileException::NOT_APPROPRIATE_TYPE);
         }
         EfrontConfiguration::setValue('site_logo', $logoFile['id']);
     } catch (EfrontFileException $e) {
         if ($e->getCode() != UPLOAD_ERR_NO_FILE) {
             throw $e;
         }
         //Don't halt if no file was uploaded (errcode = 4). Otherwise, throw the exception
     }
     if (empty($logoFile)) {
         $logoFile = new EfrontFile(EfrontSystem::setLogoFile($currentTheme));
     }
     // Normalize avatar picture to the dimensions set in the System Configuration menu. NOTE: the picture will be modified to match existing settings. Future higher settings will be disregarded, while lower ones might affect the quality of the displayed image
     if ($values["normalize_dimensions"] == 1) {
         eF_normalizeImage(G_LOGOPATH . $logoFile['name'], $logoFile['extension'], $values["logo_max_width"], $values["logo_max_height"]);
     } else {
         list($width, $height) = getimagesize(G_LOGOPATH . $logoFile['name']);
         eF_createImage(G_LOGOPATH . $logoFile['name'], $logoFile['extension'], $width, $height, $values["logo_max_width"], $values["logo_max_height"]);
     }
     EfrontConfiguration::setValue('logo_timestamp', time());
     // to avoid browser caching when changing logo dimensions
     EfrontCache::getInstance()->deleteCache('logo');
     eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=appearance&tab=logo&message=" . urlencode(_SUCCESFULLYUPDATECONFIGURATION) . "&message_type=success");
 } catch (Exception $e) {
     handleNormalFlowExceptions($e);
 }
 public function sendTo($recipient)
 {
     if (is_array($recipient)) {
         if (isset($recipient['login'])) {
             if (!(isset($recipient['email']) && isset($recipient['name']) && isset($recipient['surname']) && isset($recipient['user_type']))) {
                 $recipient = $recipient['login'];
             } else {
                 $defined = 1;
             }
         } else {
             throw new EfrontNotificationException(_UNKNOWNRECIPIENT, EfrontNotificationException::NORECIPIENTLOGIN_DEFINED);
         }
     }
     if (!$defined) {
         $recipient = eF_getTableData("users", "*", "login = '******'");
         if (!empty($recipient)) {
             $recipient = $recipient[0];
         } else {
             throw new EfrontNotificationException(_UNKNOWNRECIPIENT, EfrontNotificationException::NORECIPIENTLOGIN_DEFINED);
         }
     }
     // create the array of substitutions for this particular user and replace them in the subject/message texts
     $hostname = G_SERVERNAME;
     if ($hostname[strlen($hostname) - 1] == "/") {
         $hostname = substr($hostname, 0, strlen($hostname) - 1);
     }
     $language = eF_getTableData("languages", "translation", "name = '" . $recipient['languages_NAME'] . "'");
     if (!empty($language)) {
         $language = $language[0]['translation'];
     }
     $template_formulations = array("users_name" => $recipient['name'], "users_surname" => $recipient['surname'], "users_login" => $recipient['login'], "users_email" => $recipient['email'], "users_comments" => $recipient['comments'], "users_language" => $language, "date" => formatTimestamp(time()), "date_time" => formatTimestamp(time(), 'time'), "timestamp" => time(), "user_type" => $recipient['user_type'], "host_name" => $hostname, "site_name" => $GLOBALS['configuration']['site_name'], "site_motto" => $GLOBALS['configuration']['site_motto']);
     $header = array('From' => $GLOBALS['configuration']['system_email'], 'To' => $recipient['email'], 'Subject' => eF_formulateTemplateMessage($this->notification['subject'], $template_formulations), 'Content-Transfer-Encoding' => '7bit', 'Date' => date("r"));
     if ($this->notification['html_message'] == 1) {
         $header['Content-type'] = 'text/html;charset="UTF-8"';
         // if content-type is text/html, the message cannot be received by mail clients for Registration content
     } else {
         $header['Content-type'] = 'text/plain;charset="UTF-8"';
     }
     $smtp = Mail::factory('smtp', array('auth' => $GLOBALS['configuration']['smtp_auth'] ? true : false, 'host' => $GLOBALS['configuration']['smtp_host'], 'password' => $GLOBALS['configuration']['smtp_pass'], 'port' => $GLOBALS['configuration']['smtp_port'], 'username' => $GLOBALS['configuration']['smtp_user'], 'timeout' => $GLOBALS['configuration']['smtp_timeout']));
     // force url change for html messages
     $message = eF_getCorrectLanguageMessage($this->notification['message'], $recipient['languages_NAME']);
     // Local paths names should become urls
     if ($this->notification['html_message'] == 1) {
         $message = str_replace('="content', '="###host_name###/content', $message);
         /*
          * //Commented-out Feb 2013 (periklis) because it's no longer needed (probably)        	
         			if ($configuration['math_images']) {
         				$message = "<html><body><script type = \"text/javascript\" src = \"###host_name###/js/ASCIIMath2Tex.js\"> </script>".$message."</body></html>";
         			} else {
         				$message = "<html><body><script type = \"text/javascript\" src = \"###host_name###/js/ASCIIMathML.js\"> </script>".$message."</body></html>";
         			}
         */
     } else {
         $message = str_replace("<br />", "\r\n", $message);
         $message = str_replace("<br>", "\r\n", $message);
         $message = str_replace("<p>", "\r\n", $message);
         $message = str_replace("</p>", "\r\n", $message);
         $message = str_replace("&amp;", "&", $message);
         $message = strip_tags($message);
     }
     $message = eF_formulateTemplateMessage($message, $template_formulations);
     $message = eF_replaceMD5($message);
     if ($GLOBALS['configuration']['notifications_send_mode'] == 0) {
         //email only
         if (!empty($recipient['email'])) {
             $result = $smtp->send($recipient['email'], $header, $message);
         }
     } else {
         if ($GLOBALS['configuration']['notifications_send_mode'] == 1) {
             //pm only
             $pm = new eF_PersonalMessage($recipient['login'], $recipient['login'], $header['Subject'], $message);
             $result = $pm->send();
         } else {
             if ($GLOBALS['configuration']['notifications_send_mode'] == 2) {
                 //email and pm
                 $pm = new eF_PersonalMessage($recipient['login'], $recipient['login'], $header['Subject'], $message);
                 $pm->send();
                 if (!empty($recipient['email'])) {
                     $result = $smtp->send($recipient['email'], $header, $message);
                 }
             }
         }
     }
     if (PEAR::isError($result)) {
         $admin = EfrontSystem::getAdministrator();
         eF_mail($GLOBALS['configuration']['system_email'], $admin->user['email'], _AUTOMATEDEMAILSENTFROM . $admin->user['email'], $result->getMessage());
         throw new EfrontNotificationException($result->getMessage(), EfrontNotificationException::GENERAL_ERROR);
     }
     if ($result === true) {
         // put into sent_notifications table
         eF_insertTableData("sent_notifications", array("timestamp" => time(), "recipient" => $recipient['email'] . " (" . $recipient['name'] . " " . $recipient['surname'] . ")", "subject" => $header['Subject'], "body" => $message, "html_message" => $this->notification['html_message']));
         return true;
     } else {
         return false;
     }
 }
Пример #10
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();
     $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);
 }
Пример #11
0
 public function showLogo($pdf)
 {
     $logo = $this->active_certificate->logo;
     if ($logo) {
         $start = substr($logo['file'], 0, 7);
         if ($start == 'http://') {
             $logoUrl = $logo['file'];
         } else {
             /*try{
             			try{
             				$configuration = EfrontConfiguration::getValues();
             				$logoFile = new EfrontFile($configuration['logo']);
             				$logoUrl = G_SERVERNAME.'themes/default/images/logo/'.$logoFile['physical_name'];
             			}
             			catch(EfrontFileException $e){
             				$currentTheme = new themes(G_CURRENTTHEME);
             				$logoFile = new EfrontFile($currentTheme->options['logo']);
             				$logoUrl = G_SERVERNAME.'themes/default/images/'.$logoFile['physical_name'];
             			}
             		}
             		catch(EfrontFileException $e){
             			$logoUrl = G_SERVERNAME.'themes/default/images/logo.png';
             		}*/
             $logoFile = EfrontSystem::getSystemLogo();
             $logoUrl = $logoFile['path'];
         }
         $this->showImage($pdf, $logoUrl, $logo['x'], $logo['y']);
     }
 }
Пример #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;
 }
Пример #13
0
<?php

//This file cannot be called directly, only included.
if (str_replace(DIRECTORY_SEPARATOR, "/", __FILE__) == $_SERVER['SCRIPT_FILENAME']) {
    exit;
}
//pr($languages);
$loadScripts[] = 'includes/languages';
if (!EfrontUser::isOptionVisible('languages')) {
    eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=control_panel&message=" . urlencode(_UNAUTHORIZEDACCESS) . "&message_type=failure");
}
$languages = EfrontSystem::getLanguages();
if (isset($_GET['delete_language']) && eF_checkParameter($_GET['delete_language'], 'file') && in_array($_GET['delete_language'], array_keys($languages)) && $_GET['delete_language'] != 'english') {
    if (isset($currentUser->coreAccess['languages']) && $currentUser->coreAccess['languages'] != 'change') {
        eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=control_panel&message=" . urlencode(_UNAUTHORIZEDACCESS) . "&message_type=failure");
    }
    try {
        $file = new EfrontFile(G_ROOTPATH . '/libraries/language/lang-' . $_GET['delete_language'] . '.php.inc');
        $file->delete();
        eF_deleteTableData("languages", "name='" . $_GET['delete_language'] . "'");
    } catch (Exception $e) {
        header("HTTP/1.0 500 ");
        echo $e->getMessage() . ' (' . $e->getCode() . ')';
    }
    exit;
} elseif (isset($_GET['deactivate_language']) && eF_checkParameter($_GET['deactivate_language'], 'file') && in_array($_GET['deactivate_language'], array_keys($languages))) {
    if (isset($currentUser->coreAccess['languages']) && $currentUser->coreAccess['languages'] != 'change') {
        echo urlencode(_UNAUTHORIZEDACCESS);
        exit;
    }
    //Although db operations do not support exceptions (yet), we leave this here for future support
Пример #14
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);
 }
Пример #15
0
     }
 }
 $totalUserAccesses = $totalUserTime = 0;
 foreach ($users as $key => $user) {
     $users[$key]['time'] = eF_convertIntervalToTime($user['seconds']);
     $totalUserAccesses += $user['accesses'];
     $totalUserTime += $user['seconds'];
 }
 if (!isset($_GET['showusers'])) {
     $users = array_slice($users, 0, 20, true);
 }
 $smarty->assign("T_ACTIVE_USERS", $users);
 $smarty->assign("T_TOTAL_USER_ACCESSES", $totalUserAccesses);
 $smarty->assign("T_TOTAL_USER_TIME", eF_convertIntervalToTime($totalUserTime));
 if ($_GET['calculate_space']) {
     $smarty->assign("T_SPACE_USED", EfrontSystem::getSpaceUsage());
 }
 $smarty->assign("T_USER_TIMES", array('logins' => implode(",", array_keys($userTimes)), 'times' => implode(",", $userTimes)));
 //Needed only for chart
 /*
 //Commented out until we convert old log-based stats to time-based
 
     $directionsTree = new EfrontDirectionsTree();
     $directionsTreePaths = $directionsTree -> toPathString();
 
     $result       = eF_getTableDataFlat("lessons", "id, name, active, directions_ID");
     $lessonNames  = array_combine($result['id'], $result['name']);
     $lessonActive = array_combine($result['id'], $result['active']);
     $lessonCategory = array_combine($result['id'], $result['directions_ID']);
 
     $lessonTimes = $timesReport -> getSystemSessionTimesForLessons();
Пример #16
0
/**
 * Shutdown function
 * This function gets executed whenever the script ends, normally or unexpectedly.
 * We implement this in order to catch fatal errors (E_ERROR) level and display
 * an appropriate message
 *
 * @since 3.6.6
 */
function shutDownFunction()
{
    session_write_close();
    if (function_exists('error_get_last')) {
        $error = error_get_last();
        if ($error['type'] == E_ERROR || $error['type'] == E_COMPILE_ERROR || $error['type'] == E_CORE_ERROR) {
            echo EfrontSystem::printErrorMessage($error['message'] . ' in ' . $error['file'] . ' line ' . $error['line']);
        }
    }
}
Пример #17
0
 $form->addElement('text', 'name', _COURSENAME, 'class = "inputText"');
 $form->addRule('name', _THEFIELD . ' "' . _COURSENAME . '" ' . _ISMANDATORY, 'required', null, 'client');
 //$form -> addRule('name', _INVALIDFIELDDATA, 'checkParameter', 'text');
 try {
     $directionsTree = new EfrontDirectionsTree();
     if (sizeof($directionsTree->tree) == 0) {
         eF_redirect(basename($_SERVER['PHP_SELF']) . '?ctg=directions&add_direction=1&message=' . urlencode(_TOCREATECOURSEYOUMUSTFIRSTCREATECATEGORY) . '&message_type=failure');
     }
     $directions = $directionsTree->toPathString();
 } catch (Exception $e) {
     handleNormalFlowExceptions($e);
 }
 $form->addElement('select', 'directions_ID', _DIRECTION, $directions);
 //Append a directions select box to the form
 if ($GLOBALS['configuration']['onelanguage'] != true) {
     $languages = EfrontSystem::getLanguages(true, true);
     $form->addElement('select', 'languages_NAME', _LANGUAGE, $languages);
 }
 $form->addElement('advcheckbox', 'active', _ACTIVEFEM, null, null, array(0, 1));
 $form->addElement('advcheckbox', 'show_catalog', _SHOWCOURSEINCATALOG, null, null, array(0, 1));
 $form->addElement('text', 'price', _PRICE, 'class = "inputText" style = "width:100px"');
 //$form -> addElement('text', 'course_code', _COURSECODE, 'class = "inputText" style = "width:50px"');
 $form->addElement('text', 'training_hours', _TRAININGHOURS, 'class = "inputText" style = "width:50px"');
 $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, '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']);
Пример #18
0
 $lockdown_form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
 //Register our custom input check function
 $lockdown_form->addElement('textarea', 'lock_message', _LOCKDOWNMESSAGE, 'class = "inputContentTextarea mceEditor" style = "width:100%;height:20em;"');
 $lockdown_form->addElement('checkbox', 'logout_users', null, null, 'class = "inputCheckBox"');
 $lockdown_form->setDefaults(array("lock_message" => $GLOBALS['configuration']['lock_message'] ? $GLOBALS['configuration']['lock_message'] : _SYSTEMDOWNFORMAINTENANCE, "logout_users" => true));
 $lockdown_form->addElement('submit', 'submit_lockdown', _LOCKDOWN, 'class = "flatButton"');
 $lockdown_form->addElement('submit', 'submit_message', _SAVECHANGES, 'class = "flatButton"');
 $lockdown_form->addElement('submit', 'submit_unlock', _UNLOCK, 'class = "flatButton"');
 //Check here, whether the system is already locked, and present unlock button
 if ($lockdown_form->isSubmitted() && $lockdown_form->validate()) {
     //If the form is submitted and validated
     $values = $lockdown_form->exportValues();
     if ($GLOBALS['configuration']['lock_down'] && isset($values['submit_unlock'])) {
         EfrontSystem::unlockSystem();
     } elseif (isset($values['submit_lockdown'])) {
         EfrontSystem::lockSystem($values['lock_message'], $values['logout_users']);
     } elseif (isset($values['submit_message'])) {
         EfrontConfiguration::setValue('lock_message', $values['lock_message']);
     }
     eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=maintenance&tab=lock_down");
 }
 $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
 //Create a smarty renderer
 $lockdown_form->accept($renderer);
 //Assign this form to the renderer, so that corresponding template code is created
 $smarty->assign('T_LOCKDOWN_FORM', $renderer->toArray());
 //Assign the form to the template
 if ($_GET['check_cleanup'] || isset($_GET['cleanup'])) {
     //User check
     $users = eF_getTableDataFlat("users", "login");
     //$users_dir = eF_getDirContents(G_ROOTPATH.'upload/', '', false, false);
Пример #19
0
}
$backup_form = new HTML_QuickForm("backup_form", "post", basename($_SERVER['PHP_SELF']) . '?ctg=backup', "", null, true);
$backup_form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
//Register this rule for checking user input with our function, eF_checkParameter
$backup_form->addElement('text', 'backupname', null, 'class = "inputText"');
$backup_form->addRule('backupname', _THEFIELD . ' ' . _FILENAME . ' ' . _ISMANDATORY, 'required', null, 'client');
$backup_form->setDefaults(array("backupname" => "backup_" . date('Y_m_d_h.i.s', time())));
if ($GLOBALS['configuration']['version_hosted']) {
    $backupTypes = array("0" => _DATABASEONLY);
} else {
    $backupTypes = array("0" => _DATABASEONLY, "1" => _ALLDATABACKUP);
    if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
        $backupTypes[3] = _ALLDATASYSTEMBACKUP;
    }
}
$backup_form->addElement('select', 'backuptype', null, $backupTypes);
$backup_form->addElement('submit', 'submit_backup', _TAKEBACKUP, 'class = "flatButton" onclick = "$(\'backup_image\').show();"');
if ($backup_form->isSubmitted() && $backup_form->validate()) {
    $values = $backup_form->exportValues();
    try {
        $backupFile = EfrontSystem::backup($values['backupname'] . '.zip', $values['backuptype']);
        eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=backup&message=" . urlencode(_SUCCESFULLYBACKEDUP) . "&message_type=success");
    } catch (EfrontFileException $e) {
        $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
        $message = $e->getMessage() . ' &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
        $message_type = failure;
    }
}
$renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
$backup_form->accept($renderer);
$smarty->assign('T_BACKUP_FORM', $renderer->toArray());
Пример #20
0
function askInformation()
{
    try {
        if (isset($_GET['lessons_ID']) && eF_checkParameter($_GET['lessons_ID'], 'id')) {
            $lesson = new EfrontLesson($_GET['lessons_ID']);
            $lessonInformation = $lesson->getInformation();
            $languages = EfrontSystem::getLanguages(true);
            //$lessonInformation['language'] = $languages[$lesson -> lesson['languages_NAME']];
            if ($lessonInformation['professors']) {
                foreach ($lessonInformation['professors'] as $value) {
                    $professorsString[] = $value['name'] . ' ' . $value['surname'];
                }
                $lessonInformation['professors'] = implode(", ", $professorsString);
            }
            $lesson->lesson['price'] ? $priceString = formatPrice($lesson->lesson['price'], array($lesson->options['recurring'], $lesson->options['recurring_duration']), true) : ($priceString = false);
            $lessonInformation['price_string'] = $priceString;
            //    if (!$lessonInformation['price']) {
            //        unset($lessonInformation['price_string']);
            //    }
            try {
                if ($_GET['from_course']) {
                    $course = new EfrontCourse($_GET['from_course']);
                    $schedule = $course->getLessonScheduleInCourse($lesson);
                    if ($schedule['start_date'] || $schedule['end_date']) {
                        $lessonInformation['from_timestamp'] = $schedule['start_date'];
                        $lessonInformation['to_timestamp'] = $schedule['end_date'];
                    } else {
                        $lessonInformation['from_timestamp'] = $schedule['active_in_lesson'] + 24 * 60 * 60 * $schedule['start_period'];
                        $lessonInformation['to_timestamp'] = $lessonInformation['from_timestamp'] + 24 * 60 * 60 * $schedule['end_period'];
                    }
                }
            } catch (Exception $e) {
            }
            foreach ($lessonInformation as $key => $value) {
                if ($value) {
                    switch ($key) {
                        case 'language':
                            $GLOBALS['configuration']['onelanguage'] or $tooltipInfo[] = '<div class = "infoEntry"><span>' . _LANGUAGE . "</span><span>: {$languages[$value]}</span></div>";
                            break;
                        case 'professors':
                            $tooltipInfo[] = '<div class = "infoEntry"><span>' . _PROFESSORS . "</span><span>: {$value}</span></div>";
                            break;
                        case 'content':
                            $tooltipInfo[] = '<div class = "infoEntry"><span>' . _CONTENTUNITS . "</span><span>: {$value}</span></div>";
                            break;
                        case 'tests':
                            EfrontUser::isOptionVisible('tests') ? $tooltipInfo[] = '<div class = "infoEntry"><span>' . _TESTS . "</span><span>: {$value}</span></div>" : null;
                            break;
                        case 'projects':
                            EfrontUser::isOptionVisible('projects') ? $tooltipInfo[] = '<div class = "infoEntry"><span>' . _PROJECTS . "</span><span>: {$value}</span></div>" : null;
                            break;
                        case 'course_dependency':
                            $tooltipInfo[] = '<div class = "infoEntry"><span>' . _DEPENDSON . "</span><span>: {$value}</span></div>";
                            break;
                        case 'from_timestamp':
                            $tooltipInfo[] = '<div class = "infoEntry"><span>' . _AVAILABLEFROM . "</span><span>: " . formatTimestamp($value, 'time_nosec') . "</span></div>";
                            break;
                        case 'to_timestamp':
                            $tooltipInfo[] = '<div class = "infoEntry"><span>' . _AVAILABLEUNTIL . "</span><span>: " . formatTimestamp($value, 'time_nosec') . "</span></div>";
                            break;
                        case 'general_description':
                            $tooltipInfo[] = '<div class = "infoEntry"><span>' . _DESCRIPTION . "</span><span>: {$value}</span></div>";
                            break;
                        case 'assessment':
                            $tooltipInfo[] = '<div class = "infoEntry"><span>' . _ASSESSMENT . "</span><span>: {$value}</span></div>";
                            break;
                        case 'objectives':
                            $tooltipInfo[] = '<div class = "infoEntry"><span>' . _OBJECTIVES . "</span><span>: {$value}</span></div>";
                            break;
                        case 'lesson_topics':
                            $tooltipInfo[] = '<div class = "infoEntry"><span>' . _LESSONTOPICS . "</span><span>: {$value}</span></div>";
                            break;
                        case 'resources':
                            $tooltipInfo[] = '<div class = "infoEntry"><span>' . _RESOURCES . "</span><span>: {$value}</span></div>";
                            break;
                        case 'other_info':
                            $tooltipInfo[] = '<div class = "infoEntry"><span>' . _OTHERINFO . "</span><span>: {$value}</span></div>";
                            break;
                        case 'price_string':
                            !$lesson->lesson['course_only'] ? $tooltipInfo[] = '<div class = "infoEntry"><span>' . _PRICE . "</span><span>: {$value}</span></div>" : null;
                            break;
                        default:
                            break;
                    }
                }
            }
            if ($string = implode("", $tooltipInfo)) {
                echo $string;
            } else {
                echo _NODATAFOUND;
            }
        }
        if (isset($_GET['courses_ID']) && eF_checkParameter($_GET['courses_ID'], 'id')) {
            $course = new EfrontCourse($_GET['courses_ID']);
            $courseInformation = $course->getInformation();
            $languages = EfrontSystem::getLanguages(true);
            if ($courseInformation['professors']) {
                foreach ($courseInformation['professors'] as $value) {
                    $professorsString[] = $value['name'] . ' ' . $value['surname'];
                }
                $courseInformation['professors'] = implode(", ", $professorsString);
            }
            $course->course['price'] ? $priceString = formatPrice($course->course['price'], array($course->options['recurring'], $course->options['recurring_duration']), true) : ($priceString = false);
            $courseInformation['price_string'] = $priceString;
            foreach ($courseInformation as $key => $value) {
                if ($value) {
                    switch ($key) {
                        case 'language':
                            $tooltipInfo[] = '<div class = "infoEntry"><span>' . _LANGUAGE . "</span><span>: {$languages[$value]}</span></div>";
                            break;
                        case 'professors':
                            $tooltipInfo[] = '<div class = "infoEntry"><span>' . _PROFESSORS . "</span><span>: {$value}</span></div>";
                            break;
                        case 'lessons_number':
                            $tooltipInfo[] = '<div class = "infoEntry"><span>' . _LESSONS . "</span><span>: {$value}</span></div>";
                            break;
                        case 'instances':
                            $tooltipInfo[] = '<div class = "infoEntry"><span>' . _COURSEINSTANCES . "</span><span>: {$value}</span></div>";
                            break;
                        case 'general_description':
                            $tooltipInfo[] = '<div class = "infoEntry"><span>' . _DESCRIPTION . "</span><span>: {$value}</span></div>";
                            break;
                        case 'assessment':
                            $tooltipInfo[] = '<div class = "infoEntry"><span>' . _ASSESSMENT . "</span><span>: {$value}</span></div>";
                            break;
                        case 'objectives':
                            $tooltipInfo[] = '<div class = "infoEntry"><span>' . _OBJECTIVES . "</span><span>: {$value}</span></div>";
                            break;
                        case 'lesson_topics':
                            $tooltipInfo[] = '<div class = "infoEntry"><span>' . _COURSETOPICS . "</span><span>: {$value}</span></div>";
                            break;
                        case 'resources':
                            $tooltipInfo[] = '<div class = "infoEntry"><span>' . _RESOURCES . "</span><span>: {$value}</span></div>";
                            break;
                        case 'other_info':
                            $tooltipInfo[] = '<div class = "infoEntry"><span>' . _OTHERINFO . "</span><span>: {$value}</span></div>";
                            break;
                        case 'price_string':
                            $tooltipInfo[] = '<div class = "infoEntry"><span>' . _PRICE . "</span><span>: {$value}</span></div>";
                            break;
                        default:
                            break;
                    }
                }
            }
            if ($string = implode("", $tooltipInfo)) {
                echo $string;
            } else {
                echo _NODATAFOUND;
            }
        }
        // For eFront social
        if (isset($_GET['common_lessons']) && isset($_GET['user1']) && isset($_GET['user2'])) {
            $user1 = EfrontUserFactory::factory($_GET['user1']);
            if ($user1->getType() != "administrator") {
                $common_lessons = $user1->getCommonLessons($_GET['user2']);
                // pr($common_lessons);
                foreach ($common_lessons as $id => $lesson) {
                    if (strlen($lesson['name']) > 25) {
                        $lesson['name'] = substr($lesson['name'], 0, 22) . "...";
                    }
                    $tooltipInfo[] = '<div class = "infoEntry"><span>' . $lesson['name'] . "</span><span></span></div>";
                }
                if ($string = implode("", $tooltipInfo)) {
                    echo $string;
                } else {
                    echo _NODATAFOUND;
                }
            } else {
                echo _NODATAFOUND;
            }
        }
    } catch (Exception $e) {
        handleAjaxExceptions($e);
    }
}
Пример #21
0
 protected function importDataMultiple($type, $data)
 {
     try {
         switch ($type) {
             case "users_to_groups":
                 foreach ($data as $value) {
                     $groups_ID = current($this->getGroupByName($value['groups.name']));
                     $groups[$groups_ID][] = $value['users_login'];
                 }
                 foreach ($groups as $id => $groupUsers) {
                     try {
                         $group = new EfrontGroup($id);
                         $this->log["success"][] = _NEWGROUPASSIGNMENT . " " . $group->group['name'];
                         $group->addUsers($groupUsers);
                     } catch (Exception $e) {
                         $this->log["failure"][] = _LINE . " " . ($key + 2) . ": " . $e->getMessage();
                         // ." ". str_replace("\n", "<BR>", $e->getTraceAsString());
                     }
                 }
                 break;
             case "users":
                 $existingUsers = eF_getTableDataFlat("users", "login, active, archive");
                 $roles = EfrontUser::getRoles();
                 foreach (EfrontUser::getRoles(true) as $key => $value) {
                     $rolesTypes[$key] = mb_strtolower($value);
                 }
                 $languages = EfrontSystem::getLanguages();
                 $addedUsers = array();
                 foreach ($data as $key => $value) {
                     try {
                         $newUser = EfrontUser::createUser($value, $existingUsers, false);
                         $existingUsers['login'][] = $newUser->user['login'];
                         $existingUsers['active'][] = $newUser->user['active'];
                         $existingUsers['archive'][] = $newUser->user['archive'];
                         $addedUsers[] = $newUser->user['login'];
                         $this->log["success"][] = _IMPORTEDUSER . " " . $newUser->user['login'];
                     } catch (Exception $e) {
                         if ($this->options['replace_existing']) {
                             if ($this->isAlreadyExistsException($e->getCode(), $type)) {
                                 if (!in_array($value['login'], $existingUsers['login'], true)) {
                                     //For case-insensitive matches
                                     foreach ($existingUsers['login'] as $login) {
                                         if (mb_strtolower($value['login']) == mb_strtolower($login)) {
                                             $value['login'] = $login;
                                         }
                                     }
                                 }
                                 if (!isset($value['user_type'])) {
                                     $value['user_type'] = 'student';
                                 } else {
                                     if (in_array(mb_strtolower($value['user_type']), $roles)) {
                                         $value['user_type'] = mb_strtolower($value['user_type']);
                                     } else {
                                         if ($k = array_search(mb_strtolower($value['user_type']), $rolesTypes)) {
                                             $value['user_types_ID'] = $k;
                                             $value['user_type'] = $roles[$k];
                                         } else {
                                             $value['user_type'] = 'student';
                                         }
                                     }
                                 }
                                 if (!in_array($value['user_type'], EFrontUser::$basicUserTypes)) {
                                     $value['user_type'] = 'student';
                                     $value['user_types_ID'] = 0;
                                 }
                                 if ($value['languages_NAME'] == "") {
                                     unset($value['languages_NAME']);
                                 } elseif (in_array($value['languages_NAME'], array_keys($languages)) === false) {
                                     $value['languages_NAME'] = $GLOBALS['configuration']['default_language'];
                                 }
                                 $this->updateExistingData($key + 2, $type, $value);
                             } else {
                                 $this->log["failure"][] = _LINE . " " . ($key + 2) . ": " . $e->getMessage();
                                 // ." ". str_replace("\n", "<BR>", $e->getTraceAsString());
                             }
                         } else {
                             $this->log["failure"][] = _LINE . " " . ($key + 2) . ": " . $e->getMessage();
                             // ." ". str_replace("\n", "<BR>", $e->getTraceAsString());
                         }
                     }
                 }
                 $defaultGroup = eF_getTableData("groups", "id", "is_default = 1 AND active = 1");
                 if (!empty($defaultGroup) && !empty($addedUsers)) {
                     $defaultGroup = new EfrontGroup($defaultGroup[0]['id']);
                     $defaultGroup->addUsers($addedUsers);
                 }
                 break;
             case "users_to_jobs":
                 $jobDescriptions = $userJobs = $userBranchesAssigned = $userBranchesUnassigned = array();
                 $result = eF_getTableData("module_hcd_job_description", "job_description_ID, branch_ID, description");
                 foreach ($result as $value) {
                     $jobDescriptions[$value['job_description_ID']] = $value;
                 }
                 $result = eF_getTableData("module_hcd_employee_has_job_description", "*");
                 foreach ($result as $value) {
                     $userJobs[$value['users_login']][$value['job_description_ID']] = $value['job_description_ID'];
                 }
                 $result = eF_getTableData("module_hcd_employee_works_at_branch", "*");
                 foreach ($result as $value) {
                     if ($value['assigned']) {
                         $userBranchesAssigned[$value['users_login']][$value['branch_ID']] = $value;
                     } else {
                         $userBranchesUnassigned[$value['users_login']][$value['branch_ID']] = $value;
                     }
                 }
                 $allBranches = eF_getTableData("module_hcd_branch", "branch_ID, father_branch_ID", "");
                 $addedJobs = $addedBranches = array();
                 foreach ($data as $key => $value) {
                     try {
                         if (!$value['description']) {
                             throw new EfrontJobException(_MISSING_JOB_DESCRIPTION, EfrontJobException::MISSING_JOB_DESCRIPTION);
                         }
                         $branchId = $this->getBranchByName($value['branch_name']);
                         //Executes only once
                         if ($branchId[0]) {
                             if (sizeof($branchId) == 1) {
                                 $branchId = $branchId[0];
                             } else {
                                 throw new EfrontBranchException(_BRANCHNAMEAMBIGUOUS . ': ' . $value['branch_name'], EfrontBranchException::BRANCH_AMBIGUOUS);
                             }
                         } else {
                             throw new EfrontBranchException(_BRANCHDOESNOTEXIST . ': ' . $value['branch_name'], EfrontBranchException::BRANCH_NOT_EXISTS);
                         }
                         $jobId = false;
                         foreach ($jobDescriptions as $job) {
                             if ($job['description'] == $value['description'] && $job['branch_ID'] == $branchId) {
                                 $jobId = $job['job_description_ID'];
                             }
                         }
                         if (!$jobId) {
                             $jobId = eF_insertTableData("module_hcd_job_description", array('description' => $value['description'], 'branch_ID' => $branchId));
                             $jobDescriptions[$jobId] = array('job_description_ID' => $jobId, 'description' => $value['description'], 'branch_ID' => $branchId);
                         }
                         $user = EfrontUserFactory::factory($value["users_login"]);
                         $value['users_login'] = $user->user['login'];
                         if (isset($userJobs[$value['users_login']]) && $this->options['replace_assignments']) {
                             $unset = false;
                             foreach ($userJobs[$value['users_login']] as $key => $v) {
                                 if (!isset($addedJobs[$v][$value['users_login']])) {
                                     $user->aspects['hcd']->removeJob($v);
                                     unset($userJobs[$value['users_login']][$v]);
                                     $unset = true;
                                 }
                             }
                             if ($unset) {
                                 unset($userBranchesAssigned[$value['users_login']]);
                             }
                         }
                         if (isset($userJobs[$value['users_login']][$jobId]) && $this->options['replace_existing']) {
                             eF_deleteTableData("module_hcd_employee_has_job_description", "users_login='******'users_login'] . "' AND job_description_ID ='" . $jobId . "'");
                             unset($userJobs[$value['users_login']][$jobId]);
                         }
                         // Check if this job description is already assigned
                         if (!isset($userJobs[$value['users_login']][$jobId])) {
                             if (!isset($userBranchesAssigned[$value['users_login']][$branchId])) {
                                 // Write to the database the new branch assignment: employee to branch (if such an assignment is not already true)
                                 if (isset($userBranchesUnassigned[$value['users_login']][$branchId])) {
                                     eF_updateTableData("module_hcd_employee_works_at_branch", array("assigned" => 1), "users_login='******'users_login'] . "' and branch_ID={$branchId}");
                                     unset($userBranchesUnassigned[$value['users_login']][$branchId]);
                                 } else {
                                     $fields = array('users_login' => $value['users_login'], 'supervisor' => $value['supervisor'], 'assigned' => '1', 'branch_ID' => $branchId);
                                     eF_insertTableData("module_hcd_employee_works_at_branch", $fields);
                                     if ($value['supervisor']) {
                                         //Iterate through sub branches
                                         foreach (eF_subBranches($branchId, $allBranches) as $subBranchId) {
                                             //If this subranch is not associated with the user, associate it
                                             if (!isset($userBranchesAssigned[$value['users_login']][$subBranchId]) && !isset($userBranchesUnassigned[$value['users_login']][$subBranchId])) {
                                                 $fields = array('users_login' => $value['users_login'], 'supervisor' => 1, 'assigned' => '0', 'branch_ID' => $subBranchId);
                                                 eF_insertTableData("module_hcd_employee_works_at_branch", $fields);
                                                 $userBranchesUnassigned[$value['users_login']][$branchId] = array('branch_ID' => $branchId, 'supervisor' => $value['supervisor'], 'assigned' => 0);
                                             } elseif (isset($userBranchesAssigned[$value['users_login']][$subBranchId]) && $userBranchesAssigned[$value['users_login']][$subBranchId]['supervisor'] == 0) {
                                                 eF_updateTableData("module_hcd_employee_works_at_branch", array("supervisor" => 1), "users_login='******'users_login'] . "' and branch_ID={$subBranchId}");
                                                 $userBranchesAssigned[$value['users_login']][$subBranchId]['supervisor'] = 1;
                                             } elseif (isset($userBranchesUnassigned[$value['users_login']][$subBranchId]) && $userBranchesUnassigned[$value['users_login']][$subBranchId]['supervisor'] == 0) {
                                                 eF_updateTableData("module_hcd_employee_works_at_branch", array("supervisor" => 1), "users_login='******'users_login'] . "' and branch_ID={$subBranchId}");
                                                 $userBranchesUnassigned[$value['users_login']][$subBranchId]['supervisor'] = 1;
                                             }
                                         }
                                     }
                                 }
                                 $userBranchesAssigned[$value['users_login']][$branchId] = array('branch_ID' => $branchId, 'supervisor' => $value['supervisor'], 'assigned' => 1);
                                 $addedBranches[$branchId][$value['users_login']] = $value['users_login'];
                             } elseif (!$userBranchesAssigned[$value['users_login']][$branchId]['supervisor'] && $value['supervisor']) {
                                 eF_updateTableData("module_hcd_employee_works_at_branch", array("supervisor" => 1), "users_login='******'users_login'] . "' and branch_ID={$branchId}");
                                 //Iterate through sub branches
                                 foreach (eF_subBranches($branchId, $allBranches) as $subBranchId) {
                                     //If this subranch is not associated with the user, associate it
                                     if (!isset($userBranchesAssigned[$value['users_login']][$subBranchId]) && !isset($userBranchesUnassigned[$value['users_login']][$subBranchId])) {
                                         $fields = array('users_login' => $value['users_login'], 'supervisor' => 1, 'assigned' => '0', 'branch_ID' => $subBranchId);
                                         eF_insertTableData("module_hcd_employee_works_at_branch", $fields);
                                         $userBranchesUnassigned[$value['users_login']][$branchId] = array('branch_ID' => $branchId, 'supervisor' => $value['supervisor'], 'assigned' => 0);
                                     } elseif (isset($userBranchesAssigned[$value['users_login']][$subBranchId]) && $userBranchesAssigned[$value['users_login']][$subBranchId]['supervisor'] == 0) {
                                         eF_updateTableData("module_hcd_employee_works_at_branch", array("supervisor" => 1), "users_login='******'users_login'] . "' and branch_ID={$subBranchId}");
                                         $userBranchesAssigned[$value['users_login']][$subBranchId]['supervisor'] = 1;
                                     } elseif (isset($userBranchesUnassigned[$value['users_login']][$subBranchId]) && $userBranchesUnassigned[$value['users_login']][$subBranchId]['supervisor'] == 0) {
                                         eF_updateTableData("module_hcd_employee_works_at_branch", array("supervisor" => 1), "users_login='******'users_login'] . "' and branch_ID={$subBranchId}");
                                         $userBranchesUnassigned[$value['users_login']][$subBranchId]['supervisor'] = 1;
                                     }
                                 }
                             } elseif ($userBranchesAssigned[$value['users_login']][$branchId]['supervisor'] && !$value['supervisor']) {
                                 eF_updateTableData("module_hcd_employee_works_at_branch", array("supervisor" => 0), "users_login='******'users_login'] . "' and branch_ID={$branchId}");
                             }
                             // Write to database the new job assignment: employee to job description
                             $fields = array('users_login' => $value['users_login'], 'job_description_ID' => $jobId);
                             eF_insertTableData("module_hcd_employee_has_job_description", $fields);
                             $userJobs[$value['users_login']][$jobId] = $jobId;
                             $addedJobs[$jobId][$value['users_login']] = $value['users_login'];
                             /*
                             									if ($event_info) {
                             										EfrontEvent::triggerEvent(array("type" => EfrontEvent::HCD_NEW_JOB_ASSIGNMENT, "users_LOGIN" => $this -> login, "lessons_ID" => $branchID, "lessons_name" => $bname[0]['name'], "entity_ID" => $jobID, "entity_name" => $job_description, "timestamp" => $event_info['timestamp'], "explicitly_selected" => $event_info['manager']));
                             									} else {
                             										EfrontEvent::triggerEvent(array("type" => EfrontEvent::HCD_NEW_JOB_ASSIGNMENT, "users_LOGIN" => $this -> login, "lessons_ID" => $branchID, "lessons_name" => $bname[0]['name'], "entity_ID" => $jobID, "entity_name" => $job_description));
                             									}
                             */
                         } else {
                             throw new EfrontUserException(_JOBALREADYASSIGNED . ": " . $value['users_login'], EfrontUserException::WRONG_INPUT_TYPE);
                         }
                         $this->log["success"][] = _LINE . " " . ($key + 2) . " : " . _NEWJOBASSIGNMENT . " " . $value["users_login"] . " - (" . $value['branch_name'] . " - " . $value['description'] . ") ";
                     } catch (Exception $e) {
                         $this->log["failure"][] = _LINE . " " . ($key + 2) . " : " . $e->getMessage() . ' (' . $e->getCode() . ')';
                     }
                 }
                 $courseAssignmentsToUsers = $lessonAssignmentsToUsers = array();
                 $result = eF_getTableData("module_hcd_course_to_job_description", "*");
                 foreach ($result as $value) {
                     foreach ($addedJobs[$value['job_description_ID']] as $user) {
                         $courseAssignmentsToUsers[$value['courses_ID']][] = $user;
                     }
                 }
                 $result = eF_getTableData("module_hcd_lesson_to_job_description", "*");
                 foreach ($result as $value) {
                     foreach ($addedJobs[$value['job_description_ID']] as $user) {
                         $lessonAssignmentsToUsers[$value['lessons_ID']][] = $user;
                     }
                 }
                 if ($GLOBALS['configuration']['mode_propagate_courses_to_branch_users']) {
                     $result = eF_getTableData("module_hcd_course_to_branch", "*");
                     foreach ($result as $value) {
                         foreach ($addedBranches[$value['branches_ID']] as $user) {
                             $courseAssignmentsToUsers[$value['courses_ID']][] = $user;
                         }
                     }
                 }
                 foreach ($courseAssignmentsToUsers as $courseId => $users) {
                     $course = new EfrontCourse($courseId);
                     $course->addUsers($users);
                 }
                 foreach ($lessonAssignmentsToUsers as $lessonId => $users) {
                     $course = new EfrontLesson($lessonId);
                     $course->addUsers($users);
                 }
                 break;
         }
     } catch (Exception $e) {
         $this->log["failure"][] = $e->getMessage() . ' (' . $e->getCode() . ')';
         // ." ". str_replace("\n", "<BR>", $e->getTraceAsString());
     }
 }
Пример #22
0
#cpp#endif
$userMainForm->setDefaults($GLOBALS['configuration']);
if (isset($currentUser->coreAccess['configuration']) && $currentUser->coreAccess['configuration'] != 'change') {
    $userMainForm->freeze();
} else {
    $userMainForm->addElement("submit", "submit", _SAVE, 'class = "flatButton"');
    if ($userMainForm->isSubmitted() && $userMainForm->validate()) {
        $values = $userMainForm->exportValues();
        if ($values['reset_license_note'] || $values['reset_license_note_always']) {
            eF_updateTableData("users", array("viewed_license" => 0), "viewed_license = 1");
        }
        if ($values['username_format']) {
            EfrontCache::getInstance()->deleteCache('usernames');
        }
        if ($values['time_reports'] != $GLOBALS['configuration']['time_reports']) {
            EfrontSystem::switchLessonReportingMode($values['time_reports']);
        }
        unset($values['reset_license_note']);
        //Unset it, since we don't need to store this value to the database
        unset($values['submit']);
        foreach ($values as $key => $value) {
            EfrontConfiguration::setValue($key, $value);
        }
        eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=user&tab=main&message=" . urlencode(_SUCCESFULLYUPDATECONFIGURATION) . "&message_type=success");
    }
}
$smarty->assign("T_USER_MAIN_FORM", $userMainForm->toArray());
$userMultipleLoginsForm = new HTML_QuickForm("user_multiple_logins_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=user&tab=multiple_logins", "", null, true);
$userMultipleLoginsForm->registerRule('checkParameter', 'callback', 'eF_checkParameter');
$groups = array();
foreach (EfrontGroup::getGroups() as $value) {
Пример #23
0
 /**
  * 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;
 }
Пример #24
0
         #cpp#ifdef ENTERPRISE
         if ($mode == "branch") {
             $basic_templates_array["branch_name"] = _BRANCHNAME;
         } else {
             if ($mode == "job") {
                 $basic_templates_array["job_description_name"] = _JOBDESCRIPTIONNAME;
             }
         }
     }
     #cpp#endif
 }
 $form->addElement('select', 'templ_add', _ADDTEMPLATIZEDTEXT, $basic_templates_array, "id = 'template_add' class = 'inputSelectMed' onChange= 'addTemplatizedText(this)'");
 if ($GLOBALS['configuration']['onelanguage']) {
     $form->addElement('hidden', 'languages_NAME', $GLOBALS['configuration']['default_language']);
 } else {
     $form->addElement('select', 'languages_NAME', _LANGUAGE, EfrontSystem::getLanguages(true), 'class = "inputSelectMed" onchange="addLanguageTag(this)"');
     // Set default values for new users
     $form->setDefaults(array('languages_NAME' => $GLOBALS['configuration']['default_language']));
 }
 $form->addElement('text', 'header', _SUBJECT, 'class = "inputText" id="messageSubject" onFocus="myActiveElement=\'messageSubject\';" ');
 $form->addRule('header', _THEFIELD . ' ' . _SUBJECT . ' ' . _ISMANDATORY, 'required', null, 'client');
 $form->addRule('header', _INVALIDFIELDDATA, 'checkParameter', 'text');
 $load_editor = true;
 $form->addElement('textarea', 'message', _BODY, 'class = "digestEditor" id="messageBody" onActivate="myActiveElement=\'\';" style = "width:100%;height:200px"');
 // Get available lessons
 $lessons = eF_getTableDataFlat("lessons", "id,name", "archive=0", "name");
 sizeof($lessons) > 0 ? $av_lessons = array_combine(array_merge(array("0"), $lessons['id']), array_merge(array(_ANYLESSON), $lessons['name'])) : ($av_lessons = array(0 => _ANYLESSON));
 sizeof($lessons) > 0 ? $lessons = array_combine($lessons['id'], $lessons['name']) : ($lessons = array());
 // Get available courses
 $courses = eF_getTableDataFlat("courses", "id,name", "archive=0", "name");
 //return only unarchived courses
Пример #25
0
 /**
  * Get user information
  *
  * This function returns the user information in an array
  *
  *
  * <br/>Example:
  * <code>
  * $info = $user -> getInformation();		 //Get lesson information
  * </code>
  *
  * @param string $user The user login to customize lesson information for
  * @return array The user information
  * @since 3.5.0
  * @access public
  */
 public function getInformation()
 {
     $languages = EfrontSystem::getLanguages(true);
     $info = array();
     $info['login'] = $this->user['login'];
     $info['name'] = $this->user['name'];
     $info['surname'] = $this->user['surname'];
     $info['fullname'] = $this->user['name'] . " " . $this->user['surname'];
     $info['user_type'] = $this->user['user_type'];
     $info['user_types_ID'] = $this->user['user_types_ID'];
     $info['student_lessons'] = $this->getLessons(true, 'student');
     $info['professor_lessons'] = $this->getLessons(true, 'professor');
     $info['total_lessons'] = sizeof($this->getUserLessons());
     $info['total_courses'] = sizeof($this->getUserCourses(array('active' => true, 'return_objects' => false)));
     $info['total_login_time'] = self::getLoginTime($this->user['login']);
     $info['language'] = $languages[$this->user['languages_NAME']];
     $info['active'] = $this->user['active'];
     $info['active_str'] = $this->user['active'] ? _YES : _NO;
     $info['joined'] = $this->user['timestamp'];
     $info['joined_str'] = formatTimestamp($this->user['timestamp'], 'time');
     $info['avatar'] = $this->user['avatar'];
     return $info;
 }
Пример #26
0
                echo Installation::printErrorMessage("You must have a valid configuration file for the emergency restore to work");
                exit;
            }
        } 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';
        }
        foreach ($it = new DirectoryIterator(G_BACKUPPATH) as $key => $value) {
            if (!$value->isDir() && pathinfo($value->getFileName(), PATHINFO_EXTENSION) == 'zip') {
                $files[] = basename($value);
            }
        }
        $smarty->assign("T_BACKUP_FILES", $files);
        if (isset($_GET['file']) && in_array($_GET['file'], $files)) {
            EfrontSystem::restore(G_BACKUPPATH . $_GET['file']);
            //Auto backup database
            $message = "The restoring procedure completed successfully";
            $message_type = "success";
        }
    } catch (Exception $e) {
        Installation::handleInstallationExceptions($e);
    }
}
$loadScripts = array('EfrontScripts', 'scriptaculous/prototype', 'scriptaculous/scriptaculous', 'scriptaculous/effects', 'efront_ajax');
$smarty->assign("T_HEADER_LOAD_SCRIPTS", implode(",", array_unique($loadScripts)));
//array_unique, so it doesn't send duplicate entries
$smarty->assign("T_MESSAGE", $message);
$smarty->assign("T_MESSAGE_TYPE", $message_type);
$smarty->load_filter('output', 'eF_template_applyImageMap');
$smarty->load_filter('output', 'eF_template_applyThemeToImages');