Exemple #1
0
 /**
  * Create comments
  * 
  * This function is used to create comments
  * <br>Example:
  * <code>
  * $comments = comments :: create($fields));			//$fields is an array of data for the comment
  * </code>
  * 
  * @param $fields An array of data
  * @return comments The new object
  * @since 3.6.0
  * @access public
  * @static
  */
 public static function create($fields = array())
 {
     $fields = array("data" => $fields['data'], "users_LOGIN" => $fields['users_LOGIN'], "content_ID" => $fields['content_ID'], "private" => $fields['private'], "timestamp" => isset($fields['timestamp']) && $fields['timestamp'] ? $fields['timestamp'] : time(), "active" => !isset($fields['active']) || $fields['active'] ? 1 : 0);
     $newId = eF_insertTableData("comments", $fields);
     $comments = new comments($newId);
     $sourceUnit = new EfrontUnit($fields['content_ID']);
     EfrontEvent::triggerEvent(array("type" => EfrontEvent::NEW_COMMENT_WRITING, "lessons_ID" => $sourceUnit['lessons_ID'], "entity_ID" => $fields['content_ID'], "entity_name" => $sourceUnit['name']));
     return $comments;
 }
 /**
  * Create calendar
  *
  * This function is used to create calendar
  *
  * @param $fields An array of data
  * @return calendar The new object
  * @since 3.6.7
  * @access public
  * @static
  */
 public static function create($fields = array())
 {
     $fields = array('data' => $fields['data'], 'timestamp' => $fields['timestamp'] ? $fields['timestamp'] : time(), 'active' => isset($fields['active']) && $fields['active'] ? 1 : 0, 'type' => $fields['type'], 'foreign_ID' => $fields['foreign_ID'], 'users_LOGIN' => $fields['users_LOGIN']);
     $newId = eF_insertTableData("calendar", $fields);
     $result = eF_getTableData("calendar", "*", "id=" . $newId);
     //We perform an extra step/query for retrieving data, sinve this way we make sure that the array fields will be in correct order (forst id, then name, etc)
     $calendar = new calendar($result[0]['id']);
     return $calendar;
 }
 /**
  * Function insertText()
  *
  * This function registers a new keyword to the search table. Input arguments are:
  * - The keyword to be commited
  * - The id of the database entry in the keyword original table
  * - This table's name.
  * - Whether the keyword lies on the title or the body of the containing text
  *
  * @param string $text The search keyword
  * @param int $foreignID The keyword's original entry id
  * @param string $tableName The keyword's original table name
  * @param string $position The keyword's original text position, either 'title' or 'data'.
  * @since 3.5.0
  * @access public
  */
 public static function insertText($text, $foreignID, $tableName, $position)
 {
     $fields['foreign_ID'] = $foreignID;
     $fields['table_name'] = EfrontSearch::$tableAssoc[$tableName];
     //from 3.6 there is a corespondence between tables and numbers
     $position == "title" ? $fields['position'] = 0 : ($fields['position'] = 1);
     //from 3.6  1 means 'data' and 0 means 'title'
     //todo : remove also some special chars like [ ] & * etc
     if ($text == "") {
         return true;
     }
     $replace = array("&nbsp;", "(", "{", "}", ")", "]", "[", "@", "#", "\$", "%", "^", "&", "*", ".", ",", "'", "\"", "/", "\\");
     $querywords = mb_strtolower(strip_tags(str_replace($replace, " ", $text)));
     $eachword = explode(" ", $querywords);
     $eachword = array_unique($eachword);
     //Remove duplicate values from search table
     $terms = array();
     foreach ($eachword as $key => $value) {
         $len = mb_strlen($value);
         if ($len > 3 and $len < 100) {
             //Only words with length more than 3 and less than 100 characters long.
             $terms[] = $value;
         } else {
         }
     }
     //Querying for all values may be very slow; this is why we added this 20 values limit
     if (sizeof($terms) > 20) {
         $result = eF_getTableDataFlat("search_invertedindex", "id,keyword");
     } else {
         $terms = array_map(create_function('$x', 'return htmlspecialchars($x, ENT_QUOTES, "utf-8");'), $terms);
         $result = eF_getTableDataFlat("search_invertedindex", "*", "keyword IN ('" . implode("','", $terms) . "')");
     }
     isset($result["keyword"]) && $result["keyword"] ? $allTerms = $result["keyword"] : ($allTerms = array());
     if (!empty($terms)) {
         foreach ($terms as $key => $value) {
             $position = array_search($value, $allTerms);
             //array_search may also return null!
             if ($position === false && !is_null($position)) {
                 $newId = eF_insertTableData("search_invertedindex", array("keyword" => $value));
                 //$fields['keyword'] = $newId;
                 $allFields[] = $fields + array('keyword' => $newId);
                 //$rows[] = "('".implode("','",$fields)."')";
             } else {
                 //$fields['keyword'] = $result["id"][$position];
                 $allFields[] = $fields + array('keyword' => $result["id"][$position]);
                 //$rows[] = "('".implode("','",$fields)."')";
             }
         }
         $allFields = array_map('unserialize', array_unique(array_map('serialize', $allFields)));
         //$res = eF_executeNew("insert into search_keywords (".implode(",", array_keys($fields)).") values ".implode(",",$rows)."");
         eF_insertTableDataMultiple("search_keywords", $allFields);
     }
     return true;
 }
Exemple #4
0
 /**
  * Create glossary
  *
  * This function is used to create glossary
  * <br>Example:
  * <code>
  * $fields = array("title"       => $form -> exportValue('title'),
  *       "data"        => $form -> exportValue('data'),
  *       "timestamp"   => $from_timestamp,
  *		 "expire"      => $to_timestamp,
  *       "lessons_ID"  => isset($_SESSION['s_lessons_ID']) && $_SESSION['s_lessons_ID'] ? $_SESSION['s_lessons_ID'] : 0,
  *       "users_LOGIN" => $_SESSION['s_login']);
  *
  * $glossary = glossary :: create($fields, 0));
  *
  * </code>
  *
  * @param $fields An array of data
  * @return glossary The new object
  * @since 3.6.0
  * @access public
  * @static
  */
 public static function create($fields = array())
 {
     // added to fix http://forum.efrontlearning.net/viewtopic.php?f=5&t=2851&p=14715
     if (mb_substr($fields['info'], 0, 3) == "<p>") {
         $fields['info'] = mb_substr($fields['info'], 3);
         if (mb_substr($fields['info'], -4, 4) == "</p>") {
             $fields['info'] = mb_substr($fields['info'], 0, -4);
         }
     }
     $fields = array("name" => $fields['name'], "info" => $fields['info'], "lessons_ID" => $fields['lessons_ID'], "type" => isset($fields['type']) && $fields['type'] ? $fields['type'] : "general");
     //    "active"     => isset($fields['active'])&& $fields['active'] ? 1 : 0);  //not implemented yet
     $newId = eF_insertTableData("glossary", $fields);
     $glossary = new glossary($newId);
     //pr($glossary);exit;
     EfrontSearch::insertText($glossary->glossary['name'], $glossary->glossary['id'], "glossary", "title");
     EfrontSearch::insertText($glossary->glossary['info'], $glossary->glossary['id'], "glossary", "data");
     return $glossary;
 }
 /**
  * Create news
  *
  * This function is used to create news
  * <br>Example:
  * <code>
  * $fields = array("title"       => $form -> exportValue('title'),
  *       "data"        => $form -> exportValue('data'),
  *       "timestamp"   => $from_timestamp,
  *		 "expire"      => $to_timestamp,
  *       "lessons_ID"  => isset($_SESSION['s_lessons_ID']) && $_SESSION['s_lessons_ID'] ? $_SESSION['s_lessons_ID'] : 0,
  *       "users_LOGIN" => $_SESSION['s_login']);
  *
  * $news = news :: create($fields, 0));
  *
  * </code>
  *
  * @param $fields An array of data
  * @param $sendEmail Whether to send the announcement as an email as well
  * @return news The new object
  * @since 3.6.0
  * @access public
  * @static
  */
 public static function create($fields = array(), $sendEmail = false)
 {
     $fields = array('title' => $fields['title'], 'data' => $fields['data'], 'timestamp' => $fields['timestamp'] ? $fields['timestamp'] : time(), 'expire' => $fields['expire'] ? $fields['expire'] : null, 'lessons_ID' => $fields['lessons_ID'], 'users_LOGIN' => $fields['users_LOGIN']);
     $newId = eF_insertTableData("news", $fields);
     $result = eF_getTableData("news", "*", "id=" . $newId);
     //We perform an extra step/query for retrieving data, sinve this way we make sure that the array fields will be in correct order (forst id, then name, etc)
     $news = new news($result[0]['id']);
     if ($news->news['lessons_ID']) {
         //EfrontEvent::triggerEvent(array("type" => EfrontEvent::NEW_LESSON_ANNOUNCEMENT, "users_LOGIN" => $fields['users_LOGIN'], "users_name" => $currentUser -> user['name'], "users_surname" => $currentUser -> user['surname'], "lessons_ID" => $fields['lessons_ID'], "entity_ID" => $id, "entity_name" => $news_content['title']), isset($_POST['email']));
         EfrontEvent::triggerEvent(array("type" => EfrontEvent::NEW_LESSON_ANNOUNCEMENT, "users_LOGIN" => $GLOBALS['currentUser']->user['login'], "users_name" => $GLOBALS['currentUser']->user['name'], "users_surname" => $GLOBALS['currentUser']->user['surname'], "lessons_ID" => $GLOBALS['currentLesson']->lesson['id'], "lessons_name" => $GLOBALS['currentLesson']->lesson['name'], "entity_name" => $fields['title'], "entity_ID" => $newId), $sendEmail);
     } else {
         //EfrontEvent::triggerEvent(array("type" => EfrontEvent::NEW_SYSTEM_ANNOUNCEMENT, "users_LOGIN" => $fields['users_LOGIN'], "users_name" => $currentUser -> user['name'], "users_surname" => $currentUser -> user['surname'], "entity_ID" => $id, "entity_name" => $news_content['title']), isset($_POST['email']));
         EfrontEvent::triggerEvent(array("type" => EfrontEvent::NEW_SYSTEM_ANNOUNCEMENT, "users_LOGIN" => $GLOBALS['currentUser']->user['login'], "users_name" => $GLOBALS['currentUser']->user['name'], "users_surname" => $GLOBALS['currentUser']->user['surname'], "lessons_name" => $GLOBALS['currentLesson']->lesson['name'], "entity_name" => $fields['title'], "entity_ID" => $newId), $sendEmail);
     }
     EfrontSearch::insertText($news->news['title'], $news->news['id'], "news", "title");
     EfrontSearch::insertText($news->news['data'], $news->news['id'], "news", "data");
     return $news;
 }
Exemple #6
0
         echo "<xml>";
         echo "<status>error</status>";
         echo "<message>Invalid token</message>";
         echo "</xml>";
     }
     break;
 case 'lesson_to_user':
     if (isset($_GET['token']) && checkToken($_GET['token'])) {
         if (isset($_GET['login']) && isset($_GET['lesson'])) {
             $insert['users_LOGIN'] = $_GET['login'];
             $insert['lessons_ID'] = $_GET['lesson'];
             $insert['active'] = '1';
             $insert['from_timestamp'] = time();
             $res = eF_getTableData("users_to_lessons", "*", "users_LOGIN='******'login'] . "' and lessons_ID=" . $_GET['lesson']);
             if (sizeof($res) == 0) {
                 eF_insertTableData("users_to_lessons", $insert);
                 echo "<xml>";
                 echo "<status>ok</status>";
                 echo "</xml>";
             } else {
                 echo "<xml>";
                 echo "<status>error</status>";
                 echo "<message>Assignment already exists</message>";
                 echo "</xml>";
             }
         } else {
             echo "<xml>";
             echo "<status>error</status>";
             echo "<message>Incomplete arguments</message>";
             echo "</xml>";
         }
 protected function importData($line, $type, $data)
 {
     //pr($line);exit;
     try {
         switch ($type) {
             case "users":
                 $newUser = EfrontUser::createUser($data);
                 $this->log["success"][] = _LINE . " {$line}: " . _IMPORTEDUSER . " " . $newUser->login;
                 break;
             case "users_to_courses":
                 //Check if a user exists and whether it has the same case
                 $userFound = false;
                 if (!in_array($data['users_login'], $this->allUserLogins)) {
                     //For case-insensitive matches
                     foreach ($this->allUserLogins as $login) {
                         if (mb_strtolower($data['users_login']) == mb_strtolower($login)) {
                             $data['users_login'] = $login;
                             $userFound = true;
                         }
                     }
                 } else {
                     $userFound = true;
                 }
                 if ($userFound) {
                     $courses_name = trim($data['course_name']);
                     $courses_ID = $this->getCourseByName($courses_name);
                     unset($data['course_name']);
                     if ($courses_ID) {
                         foreach ($courses_ID as $course_ID) {
                             $data['courses_ID'] = $course_ID;
                             $course = new EfrontCourse($course_ID);
                             if (is_null($this->course_users[$course_ID])) {
                                 $result = eF_getTableDataFlat("users_to_courses", "users_LOGIN", "courses_ID={$course_ID} AND archive=0");
                                 $this->course_users[$course_ID] = array_combine($result['users_LOGIN'], $result['users_LOGIN']);
                             }
                             if (isset($this->course_users[$course_ID][$data['users_login']])) {
                                 throw new Exception("User is already assigned to the course", self::USER_TO_COURSE_EXISTS);
                             }
                             //$course -> addUsers($data['users_login'], (isset($data['user_type']) && $data['user_type']?$data['user_type']:"student"));
                             $course->addUsers($data['users_login'], isset($data['user_type']) ? $data['user_type'] : "student");
                             $where = "users_login = '******'users_login'] . "' AND courses_ID = " . $data['courses_ID'];
                             $data['completed'] ? $data['completed'] = 1 : ($data['completed'] = 0);
                             EfrontCourse::persistCourseUsers($data, $where, $data['courses_ID'], $data['users_login']);
                             if ($data['active']) {
                                 $course->confirm($data['users_login']);
                             } else {
                                 $course->unconfirm($data['users_login']);
                             }
                             $this->course_users[$course_ID][$data['users_login']] = $data['users_login'];
                             $this->log["success"][] = _LINE . " {$line}: " . _NEWCOURSEASSIGNMENT . " " . $courses_name . " - " . $data['users_login'];
                         }
                     } else {
                         if ($courses_name != "") {
                             $course = EfrontCourse::createCourse(array("name" => $courses_name));
                             $this->log["success"][] = _LINE . " {$line}: " . _NEWCOURSE . " " . $courses_name;
                             $course->addUsers($data['users_login'], isset($data['user_type']) ? $data['user_type'] : "student");
                             $courses_ID = $course->course['id'];
                             $this->courseNamesToIds[$courses_name] = array($courses_ID);
                             $where = "users_login = '******'users_login'] . "' AND courses_ID = " . $courses_ID;
                             EfrontCourse::persistCourseUsers($data, $where, $courses_ID, $data['users_login']);
                             if ($data['active']) {
                                 $course->confirm($data['users_login']);
                             } else {
                                 $course->unconfirm($data['users_login']);
                             }
                             $this->log["success"][] = _LINE . " {$line}: " . _NEWCOURSEASSIGNMENT . " " . $courses_name . " - " . $data['users_login'];
                         } else {
                             $this->log["failure"][] = _LINE . " {$line}: " . _COULDNOTFINDCOURSE . " " . $courses_name;
                         }
                     }
                 } else {
                     $this->log["failure"][] = _LINE . " {$line}: " . _USERDOESNOTEXIST . ": " . $data['users_login'];
                 }
                 break;
             case "users_to_lessons":
                 //Check if a user exists and whether it has the same case
                 $userFound = false;
                 if (!in_array($data['users_login'], $this->allUserLogins)) {
                     //For case-insensitive matches
                     foreach ($this->allUserLogins as $login) {
                         if (mb_strtolower($data['users_login']) == mb_strtolower($login)) {
                             $data['users_login'] = $login;
                             $userFound = true;
                         }
                     }
                 } else {
                     $userFound = true;
                 }
                 if ($userFound) {
                     $lessons_name = trim($data['lesson_name']);
                     $lessons_ID = $this->getLessonByName($lessons_name);
                     unset($data['lesson_name']);
                     if ($lessons_ID) {
                         foreach ($lessons_ID as $lesson_ID) {
                             $data['lessons_ID'] = $lesson_ID;
                             $lesson = new EfrontLesson($lesson_ID);
                             if (is_null($this->lesson_users[$lesson_ID])) {
                                 $result = eF_getTableDataFlat("users_to_lessons", "users_LOGIN", "lessons_ID={$lesson_ID} AND archive=0");
                                 $this->lesson_users[$lesson_ID] = array_combine($result['users_LOGIN'], $result['users_LOGIN']);
                             }
                             if (isset($this->lesson_users[$lesson_ID][$data['users_login']])) {
                                 throw new Exception("User is already assigned to the lesson", self::USER_TO_LESSON_EXISTS);
                             }
                             if (!$lesson->lesson['course_only']) {
                                 $lesson->addUsers($data['users_login'], isset($data['user_type']) ? $data['user_type'] : "student");
                             }
                             $data['completed'] ? $data['completed'] = 1 : ($data['completed'] = 0);
                             eF_updateTableData("users_to_lessons", $data, "users_login = '******'users_login'] . "' AND lessons_ID = " . $data['lessons_ID']);
                             if (!$lesson->lesson['course_only']) {
                                 if ($data['active']) {
                                     $lesson->confirm($data['users_login']);
                                 } else {
                                     $lesson->unconfirm($data['users_login']);
                                 }
                             }
                             $this->log["success"][] = _LINE . " {$line}: " . _NEWLESSONASSIGNMENT . " " . $lessons_name . " - " . $data['users_login'];
                         }
                     } else {
                         if ($lessons_name != "") {
                             $lesson = EfrontLesson::createLesson(array("name" => $lessons_name, 'course_only' => false));
                             $this->log["success"][] = _LINE . " {$line}: " . _NEWLESSON . " " . $lessons_name;
                             $lesson->addUsers($data['users_login'], isset($data['user_type']) ? $data['user_type'] : "student");
                             $lessons_ID = $lesson->lesson['id'];
                             $this->lessonNamesToIds[$lessons_name] = array($lessons_ID);
                             eF_updateTableData("users_to_lessons", $data, "users_login = '******'users_login'] . "' AND lessons_ID = " . $lessons_ID);
                             if ($data['active']) {
                                 $lesson->confirm($data['users_login']);
                             } else {
                                 $lesson->unconfirm($data['users_login']);
                             }
                             $this->log["success"][] = _LINE . " {$line}: " . _NEWLESSONASSIGNMENT . " " . $lessons_name . " - " . $data['users_login'];
                         } else {
                             $this->log["failure"][] = _LINE . " {$line}: " . _COULDNOTFINDLESSON . " " . $lessons_name;
                         }
                     }
                 } else {
                     $this->log["failure"][] = _LINE . " {$line}: " . _USERDOESNOTEXIST . ": " . $data['users_login'];
                 }
                 break;
             case "users_to_groups":
                 //debug();
                 $groups_ID = $this->getGroupByName($data['groups.name']);
                 $group_name = $data['groups.name'];
                 unset($data['groups.name']);
                 foreach ($groups_ID as $group_ID) {
                     $data['groups_ID'] = $group_ID;
                     $group = new EfrontGroup($group_ID);
                     $group->addUsers(array($data['users_login']));
                     $this->log["success"][] = _LINE . " {$line}: " . _NEWGROUPASSIGNMENT . " " . $group_name . " - " . $data['users_login'];
                 }
                 break;
                 //debug(false);
                 #cpp#ifdef ENTERPRISE
             //debug(false);
             #cpp#ifdef ENTERPRISE
             case "employees":
                 $this->cleanUpEmptyValues($data);
                 // a bit customized here, based on the fact that employees are always created together AFTER users (so the object should exist)
                 eF_updateTableData("module_hcd_employees", $data, "users_login='******'users_login'] . "'");
                 break;
             case "branches":
                 // If no father defined - root, else we may need to create the father first
                 $data['father_branch_ID'] = $this->getFatherBranchId($data['father_branch_name']);
                 $father_name = $data['father_branch_name'];
                 $branch_ID = $this->getBranchByName($data['name']);
                 $branch_name = $data['name'];
                 if (sizeof($branch_ID) > 0 && $data['name'] != $data['father_branch_name']) {
                     //TODO
                     unset($data['father_branch_name']);
                     $data['branch_ID'] = $branch_ID[0];
                     throw new EfrontBranchException(_BRANCHALREADYEXISTS, EfrontBranchException::BRANCH_EXISTS);
                 } else {
                     unset($data['father_branch_name']);
                     $data['url'] = EfrontBranch::getBranchUrl($data['name']);
                     $branch = EfrontBranch::createBranch($data);
                     $this->setBranchByName($branch_name, $branch->branch['branch_ID']);
                 }
                 $this->log["success"][] = _LINE . " {$line}: " . _NEWBRANCH . " " . $branch_name;
                 break;
             case "job_descriptions":
                 if ($data['branch_name'] == "") {
                     $data['branch_ID'] = "all";
                     // this denotes to the createJob class to put the job in all branches
                 } else {
                     $data['branch_ID'] = $this->getBranchByName($data['branch_name']);
                     if (sizeof($data['branch_ID']) > 0) {
                         //TODO: maybe different handling when multiple branches are found
                         $data['branch_ID'] = $data['branch_ID'][0];
                     } else {
                         throw new EfrontJobException(_BRANCHDESIGNATEDFORTHISJOBDESCRIPTIONDOESNOTEXIST, EfrontJobException::BRANCH_NOT_EXISTS);
                     }
                 }
                 unset($data['branch_name']);
                 if ($data['description'] != "") {
                     $job_ID = $this->getJobByName($data['description']);
                     if (sizeof($job_ID) > 0) {
                         $data['job_description_ID'] = $job_ID[0];
                         throw new EfrontJobException(_JOBDESCRIPTIONEXISTSALREADY, EfrontJobException::JOB_ALREADY_EXISTS);
                     } else {
                         EfrontJob::createJob($data);
                         $this->log["success"][] = _LINE . " {$line}: " . _NEWJOB . " " . $data['description'];
                     }
                 } else {
                     $this->log["failure"][] = _LINE . " {$line}: " . _NOTITLEPROVIDEDFORNEWJOB;
                 }
                 break;
             case "skills":
                 if ($data['skill_category'] == "") {
                     throw new EfrontSkillException(_MISSINGSKILLCATEGORY, EfrontSkillException::INVALID_SKILL_CATEGORY);
                 } else {
                     $data['categories_ID'] = $this->getSkillCategoryByName($data['skill_category']);
                     if ($data['categories_ID'][0] != "") {
                         $data['categories_ID'] = $data['categories_ID'][0];
                     } else {
                         // create skill category
                         $data['categories_ID'] = eF_insertTableData("module_hcd_skill_categories", array('description' => $data['skill_category']));
                         $this->setSkillCategoryByName($data['skill_category'], $data['categories_ID']);
                     }
                 }
                 unset($data['skill_category']);
                 $skill_ID = $this->getSkillByName($data['description']);
                 if ($skill_ID) {
                     //TODO: another double issue
                     $data['skill_ID'] = $skill_ID[0];
                     throw new EfrontSkillException(_SKILLALREADYEXISTS, EfrontSkillException::SKILL_EXISTS);
                 } else {
                     EfrontSkill::createSkill($data);
                     $this->log["success"][] = _LINE . " {$line}: " . _NEWSKILL . " " . $data['description'];
                 }
                 break;
             case "users_to_jobs":
                 // Get user
                 $user = EfrontUserFactory::factory($data["users_login"]);
                 // Get branch id
                 $branch_ID = $this->getBranchByName($data['branch_name']);
                 $branch_name = $data['branch_name'];
                 if ($branch_ID[0] != "") {
                     if (sizeof($branch_ID) == 1) {
                         $branch_ID = $branch_ID[0];
                     } else {
                         throw new EfrontBranchException(_BRANCHNAMEAMBIGUOUS, EfrontBranchException::BRANCH_AMBIGUOUS);
                     }
                 } else {
                     throw new EfrontBranchException(_BRANCHDOESNOTEXIST, EfrontBranchException::BRANCH_NOT_EXISTS);
                 }
                 // Get job id
                 $job_name = $data['description'];
                 if ($job_name != "") {
                     $new_job_description_ID = eF_getJobDescriptionId($job_name, $branch_ID);
                 } else {
                     throw new EfrontJobException(_MISSING_JOB_DESCRIPTION, EfrontJobException::MISSING_JOB_DESCRIPTION);
                 }
                 // Get hcd employee object
                 if ($data['supervisor']) {
                     $employee = new EfrontSupervisor(array("users_login" => $data["users_login"]));
                     $position = 1;
                 } else {
                     $employee = new EfrontEmployee(array("users_login" => $data["users_login"]));
                     $position = 0;
                 }
                 // Assign job
                 try {
                     $employee->addJob($user, $new_job_description_ID, $branch_ID, $position);
                     $this->log["success"][] = _LINE . " {$line}: " . _NEWJOBASSIGNMENT . " " . $data["users_login"] . " - (" . $branch_name . " - " . $job_name . ") ";
                 } catch (Exception $e) {
                     if ($this->options['replace_existing']) {
                         $employee->removeJob($new_job_description_ID);
                         $employee->addJob($user, $new_job_description_ID, $branch_ID, $position);
                         $this->log["success"][] = _LINE . " {$line}: " . _NEWJOBASSIGNMENT . " " . $data["users_login"] . " - (" . $branch_name . " - " . $job_name . ") ";
                     }
                 }
                 break;
             case "users_to_skills":
                 $skill_ID = $this->getSkillByName($data['description']);
                 $skill_name = $data['description'];
                 if ($skill_ID[0] != "") {
                     if (sizeof($skill_ID) == 1) {
                         $skill_ID = $skill_ID[0];
                     } else {
                         throw new EfrontSkillException(_SKILLNAMEAMBIGUOUS, EfrontSkillException::SKILL_AMBIGUOUS);
                     }
                 } else {
                     throw new EfrontSkillException(_SKILLDOESNOTEXIST, EfrontSkillException::SKILL_NOT_EXISTS);
                 }
                 $skill = new EfrontSkill($skill_ID);
                 $skill->assignToEmployee($data['users_login'], $data['specification']);
                 $this->log["success"][] = _LINE . " {$line}: " . _NEWSKILLASSIGNMENT . " " . $data["users_login"] . " - " . $skill_name;
                 break;
             case "courses_to_branches":
                 $branchId = $this->getBranchByName($data['branch_name']);
                 if (!$branchId[0]) {
                     $fields = array('name' => $data['branch_name'], 'url' => EfrontBranch::getBranchUrl($data['branch_name']));
                     $branch = EfrontBranch::createBranch($fields);
                 } else {
                     $branch = new EfrontBranch($branchId[0]);
                 }
                 $courseId = $this->getCourseByName($data['course_name']);
                 if ($courseId[0]) {
                     $branch->addCoursesToBranch($courseId[0]);
                 }
                 $this->log["success"][] = _LINE . " {$line}: " . _NEWCOURSETOBRANCHASSIGNMENT . " " . $data['course_name'] . " - " . $data['branch_name'];
                 break;
                 #cpp#endif
         }
     } catch (Exception $e) {
         if ($this->options['replace_existing']) {
             if ($this->isAlreadyExistsException($e->getCode(), $type)) {
                 $this->updateExistingData($line, $type, $data);
             } else {
                 $this->log["failure"][] = _LINE . " {$line}: " . $e->getMessage();
                 // ." ". str_replace("\n", "<BR>", $e->getTraceAsString());
             }
         } else {
             $this->log["failure"][] = _LINE . " {$line}: " . $e->getMessage();
             // ." ". str_replace("\n", "<BR>", $e->getTraceAsString());
         }
     }
 }
Exemple #8
0
                                    }
                                    $form->setDefaults(array('previous_url' => $previous_url));
                                    $form->addElement('submit', 'submit_topic_details', _SUBMIT, 'class = "flatButton" tabindex="2"');
                                    if (isset($_GET['edit_topic'])) {
                                        $form->setDefaults(array('topic_description' => $topic[0]['title']));
                                    }
                                    $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
                                    $renderer->setRequiredTemplate('{$html}{if $required}
							&nbsp;<span class = "formRequired">*</span>
						{/if}');
                                    //LESSONTIMELINE DATA SUBMISSION
                                    if ($form->isSubmitted()) {
                                        if ($form->validate()) {
                                            $topic_content = array('title' => $form->exportValue('topic_description'), 'lessons_ID' => $currentLesson->lesson['id']);
                                            if (isset($_GET['add_topic'])) {
                                                eF_insertTableData("lessons_timeline_topics", $topic_content);
                                                $message = _SUCCESSFULLYCREATEDLESSONTIMELINETOPIC;
                                                $message_type = 'success';
                                            } elseif (isset($_GET['edit_topic'])) {
                                                eF_updateTableData("lessons_timeline_topics", $topic_content, "id = '" . $_GET['edit_topic'] . "'");
                                                $message = _LESSONTIMELINETOPICDATAUPDATED;
                                                $message_type = 'success';
                                            }
                                            // Return to previous url stored in a hidden - that way, after the insertion we can immediately return to where we were
                                            echo "<script>!/\\?/.test(parent.location) ? parent.location = '" . basename($form->exportValue('previous_url')) . "&message=" . urlencode($message) . "&message_type=" . $message_type . "' : parent.location = '" . basename($form->exportValue('previous_url')) . "&message=" . urlencode($message) . "&message_type=" . $message_type . "';</script>";
                                            //eF_redirect("".$form->exportValue('previous_url')."&message=". $message . "&message_type=" . $message_type . "&tab=skills");
                                            exit;
                                        }
                                    }
                                    $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
                                    $form->setRequiredNote(_REQUIREDNOTE);
 /**
  * (non-PHPdoc)
  * @see libraries/EfrontModule#onDeleteTheme()
  */
 public function onDeleteTheme($theme)
 {
     eF_insertTableData("module_vLab_data", array("timestamp" => time(), "data" => str_replace('%theme%', $theme, _MODULE_VLAB_DELETETHEME)));
 }
             $redirectUrl .= "&message_type=" . $message_type . "&reset_popup=1";
             $smarty->assign('T_CLONE_CERTIFICATE_TEMPLATE_REDIRECT', $redirectUrl);
         }
         $tid = $_GET['template_id'];
         $postTarget = basename($_SERVER['PHP_SELF']) . '?' . $baseUrl . '&op=clone_certificate_template&template_id=' . $tid;
         $form = new HTML_QuickForm("clone_certificate_template_form", "post", $postTarget, "", null, true);
         $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
         // Register this rule for checking user input with eF_checkParameter
         $form->addElement('text', 'certificate_name', _CERTIFICATENAME, 'class="inputText"');
         $form->addRule('certificate_name', _THEFIELD . ' "' . _CERTIFICATENAME . '" ' . _ISMANDATORY, 'required', null, 'client');
         $form->addElement('submit', 'clone_certificate_template', _SAVE, 'class="flatButton"');
         if ($form->isSubmitted() && $form->validate()) {
             $cloneTemplate = eF_getTableData("certificate_templates", "certificate_xml", "id=" . $tid);
             $formValues = $form->exportValues();
             $dbFields = array("certificate_name" => $formValues['certificate_name'], "certificate_xml" => $cloneTemplate[0]['certificate_xml'], "certificate_type" => "course", "users_LOGIN" => $GLOBALS['currentUser']->user['login']);
             if ($cloned = eF_insertTableData("certificate_templates", $dbFields)) {
                 $message = _SUCCESSFULLYCLONECERTIFICATETEMPLATE;
                 $message_type = 'success';
             } else {
                 $message = _PROBLEMCLONECERTIFICATETEMPLATE;
                 $message_type = 'failure';
             }
             $redirectUrl = "" . basename($_SERVER['PHP_SELF']) . "?" . $baseUrl . "&op=format_certificate&message=" . urlencode($message);
             $redirectUrl .= "&message_type=" . $message_type . "&reset_popup=1&tid=" . $cloned;
             $smarty->assign('T_CLONE_CERTIFICATE_TEMPLATE_REDIRECT', $redirectUrl);
         }
         $renderer = prepareFormRenderer($form);
         $smarty->assign('T_CLONE_CERTIFICATE_TEMPLATE_FORM', $renderer->toArray());
     }
     #cpp#endif
 } else {
 /**
  * Set configuration value
  *
  * This function is used to set a configuration value. Given a name/value pair,
  * this function first checks if it exists in the 'configuration' database table.
  * If so, it updates the variable with the new value, otherwise it inserts a new
  * entry.
  * <br/>Example:
  * <code>
  * $defaultConfig = EfrontConfiguration :: setValue('smtp_host', 'localhost');			//Set the configuration parameter 'smtp_host' to 'localhost'
  * </code>
  *
  * @param string $name The variable name
  * @param string $value The variable value
  * @return boolean The query result
  * @access public
  * @since 3.0
  * @static
  */
 public static function setValue($name, $value)
 {
     $value = trim($value);
     try {
         eF_insertTableData("configuration", array('name' => $name, 'value' => $value));
     } catch (Exception $e) {
         //If exists, update it
         eF_updateTableData("configuration", array('value' => $value), "name = '{$name}'");
     }
     $GLOBALS['configuration'][$name] = $value;
     EfrontCache::getInstance()->deleteCache('configuration');
     return true;
 }
 /**
  * Assign a branch to this course
  *
  * This function is used to correlate a branch to the course
  * All users of the branch should be assigned to this course
  *
  * <br/>Example:
  * <code>
  * $course -> assignBranch(2);   // The course will be assigned to branch with id 2
  * </code>
  *
  * @param $branch_ID the id of the branch to be assigned
  * @return boolean true/false
  * @since 3.6.0
  * @access public
  */
 public function assignBranch($branch_ID)
 {
     $this->getBranches();
     // Check if the branch is not assigned as offered by this course
     if ($this->branches[$branch_ID]['courses_ID'] == "") {
         eF_insertTableData("module_hcd_course_to_branch", array("branches_ID" => $branch_ID, "courses_ID" => $this->course['id']));
         $this->branches[$branch_ID]['courses_ID'] = $this->course['id'];
         $newBranch = new EfrontBranch($branch_ID);
         $employees = $newBranch->getEmployees(false, true);
         //get data flat
         $this->addUsers($employees['login'], $employees['user_type']);
     }
     return true;
 }
Exemple #13
0
             $message = _PERMITTEDROLESMODULEERROR;
             $message_type = 'failure';
             $roles_failure = 1;
         }
     }
 }
 if ($roles_failure) {
     $dir = new EfrontDirectory(G_MODULESPATH . $module_folder . '/');
     $dir->delete();
 } else {
     $fields = array('className' => $className, 'db_file' => $database_file, 'name' => $className, 'active' => 1, 'title' => (string) $xml->title ? (string) $xml->title : " ", 'author' => (string) $xml->author, 'version' => (string) $xml->version, 'description' => (string) $xml->description, 'position' => $module_position, 'permissions' => implode(",", $module->getPermittedRoles()));
     if (!isset($_GET['upgrade'])) {
         // Install module database
         try {
             if ($module->onInstall()) {
                 eF_insertTableData("modules", $fields);
                 $message = _MODULESUCCESFULLYINSTALLED;
                 $message_type = 'success';
                 eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=modules&message=" . urlencode($message) . "&message_type=" . $message_type . "&refresh_side=1");
             } else {
                 $message = _MODULEDBERRORONINSTALL;
                 $message_type = 'failure';
                 $dir = new EfrontDirectory(G_MODULESPATH . $module_folder . '/');
                 $dir->delete();
                 //eF_deleteFolder(G_MODULESPATH.$module_folder.'/');
             }
         } catch (Exception $e) {
             $module->onUninstall();
             $message = _PROBLEMINSERTINGPARSEDXMLVALUESORMODULEEXISTS;
             $message_type = 'failure';
             //$dir = new EfrontDirectory(G_MODULESPATH.$module_folder.'/');
 /**
  * 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;
 }
 /**
  * Copy a simple scorm unit or test
  *
  * This function copies a scorm unit/test (NOT its children) into the current content tree
  * <br/>Example:
  * <code>
  * $currentContent = new EfrontContentTree(5);           //Initialize content for lesson with id 5
  * $currentContent -> copySimpleUnit(3, false);   //Copy the scorm unit with id = 3 into the content tree (at its end)
  * </code>
  *
  * @param int The id of the scorm unit/test (in the scorm_data table)
  * @param EfrontUnit $sourceUnit The unit object to be copied
  * @param mixed $targetUnit The id of the parent unit (or the parent EfrontUnit)in which the new unit will be copied, or false (the unit will be appended at the end)
  * @return EfrontUnit The newly created unit object
  * @since 3.5.0
  * @access public
  */
 public function copyScorm($sid, $sourceUnit, $targetUnit, $copyFiles = true)
 {
     $newUnit = $this->copySimpleUnit($sourceUnit, $targetUnit, false, $copyFiles);
     if ($sid) {
         $data = eF_getTableData("scorm_data", "*", "id = " . $sid);
         $scorm_array = $data[0];
         unset($scorm_array['id']);
         $scorm_array['content_ID'] = $newUnit->offsetGet('id');
         eF_insertTableData("scorm_data", $scorm_array);
     }
     return $newUnit;
 }
Exemple #16
0
         unset($editCourse->options['recurring']);
     }
     //$editCourse -> course['instance_source'] OR $editCourse -> options['course_code'] = $form -> exportValue('course_code');	//Instances don't have a code of their own
     $editCourse->options['training_hours'] = $form->exportValue('training_hours');
     $editCourse->options['duration'] = $form->exportValue('duration') ? $form->exportValue('duration') : null;
     //$editCourse -> options['course_code'] 	 = $form -> exportValue('course_code') ? $form -> exportValue('course_code') : null;
     //$editCourse -> options['duration'] = $form -> exportValue('duration');
     //$start_date = mktime(0, 0, 0, $_POST['date_Month'], $_POST['date_Day'], $_POST['date_Year']);
     $editCourse->persist();
     if (isset($updateCourseInstancesCategory) && $updateCourseInstancesCategory) {
         eF_updateTableData("courses", array("directions_ID" => $editCourse->course['directions_ID']), "instance_source=" . $editCourse->course['id']);
     }
     if ($form->exportValue('branches_ID') && eF_checkParameter($form->exportValue('branches_ID'), 'id')) {
         $result = eF_getTableDataFlat("module_hcd_course_to_branch", "branches_ID", "courses_ID=" . $editCourse->course['id']);
         if (sizeof($result['branches_ID']) == 0) {
             eF_insertTableData("module_hcd_course_to_branch", array("branches_ID" => $form->exportValue('branches_ID'), "courses_ID" => $editCourse->course['id']));
         } elseif (sizeof($result['branches_ID']) == 1) {
             //Only one branch associated with this course, as a 'location'
             eF_updateTableData("module_hcd_course_to_branch", array("branches_ID" => $form->exportValue('branches_ID')), "courses_ID=" . $editCourse->course['id']);
         }
     } else {
         if (G_VERSIONTYPE == 'enterprise') {
             #cpp#ifdef ENTERPRISE
             eF_deleteTableData("module_hcd_course_to_branch", "courses_ID=" . $editCourse->course['id']);
         }
         #cpp#endif
     }
     !isset($redirect) or eF_redirect($redirect);
 } catch (Exception $e) {
     handleNormalFlowExceptions($e);
 }
Exemple #17
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";
 }
 public function setCache($key, $data, $timeout = null)
 {
     $key = self::_encode($parameters);
     $values = array("cache_key" => $key, "value" => serialize($data), "timestamp" => time());
     if ($timeout && eF_checkParameter($timeout, 'int')) {
         $values['timeout'] = $timeout;
     }
     if (sizeof(eF_getTableData("cache", "value", "cache_key='" . $key . "'")) > 0) {
         $result = eF_updateTableData("cache", $values, "cache_key='{$key}'");
     } else {
         $result = eF_insertTableData("cache", $values);
     }
     return $result;
 }
 /**
  * Create direction
  *
  * This function is used to create a new direction
  * <br/>Example:
  * <code>
  * $fields = array('name' => 'new direction');
  * EfrontDirection :: createDirection($fields);
  * </code>
  *
  * @param array $fields The new direction's fields
  * @return EfrontDirection The new direction
  * @since 3.5.0
  * @access public
  * @static
  */
 public static function createDirection($fields = array())
 {
     !isset($fields['name']) ? $fields['name'] = 'Default direction' : null;
     $newId = eF_insertTableData("directions", $fields);
     $result = eF_getTableData("directions", "*", "id=" . $newId);
     //We perform an extra step/query for retrieving data, sinve this way we make sure that the array fields will be in correct order (forst id, then name, etc)
     $direction = new EfrontDirection($result[0]);
     return $direction;
 }
 /**
  *
  * @param $fields
  * @return unknown_type
  */
 public static function create($fields = array())
 {
     !isset($fields['users_LOGIN']) || !eF_checkParameter($fields['users_LOGIN'], 'login') ? $fields['users_LOGIN'] = $_SESSION['s_login'] : null;
     $directory = G_UPLOADPATH . $fields['users_LOGIN'] . '/message_attachments/' . $fields['name'];
     if (!mkdir($directory, 0755)) {
         throw new EfrontFileException(_COULDNOTCREATEDIRECTORY . ': ' . $directory, EfrontFileException::GENERAL_ERROR);
     }
     eF_insertTableData("f_folders", $fields);
 }
Exemple #21
0
                 $newLesson->options['recurring_duration'] = $form->exportValue($newLesson->options['recurring'] . '_duration');
             }
             $newLesson->persist();
         }
         //Import file, if any specified
         if ($values['clone_lesson']) {
             $cloneLesson = new EfrontLesson($values['clone_lesson']);
             $file = $cloneLesson->export();
             $exportedFile = $file->copy($newLesson->getDirectory() . '/' . $exportedFile['name']);
         }
         if (isset($exportedFile)) {
             $newLesson->import($exportedFile);
         } else {
             //There was no file imported, then it's safe to add a default completion condition
             $fields = array('lessons_ID' => $newLesson->lesson['id'], 'type' => 'all_units', 'relation' => 'and');
             eF_insertTableData('lesson_conditions', $fields);
         }
         if ($newLesson->lesson['course_only']) {
             //For course-only lessons, redirect to lessons list, not to "edit lesson" page
             eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=lessons&message=" . urlencode(_SUCCESSFULLYCREATEDLESSON) . "&message_type=success");
         } else {
             eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=lessons&edit_lesson=" . $newLesson->lesson['id'] . "&tab=users&message=" . urlencode(_SUCCESSFULLYCREATEDLESSON) . "&message_type=success");
         }
     } 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';
     }
 } elseif (isset($_GET['edit_lesson'])) {
     //The first case is when the administrator is editing a lesson
     $fields_update = array('name' => $values['name'], 'directions_ID' => $values['directions_ID'], 'languages_NAME' => $languages_NAME, 'active' => $values['active'], 'duration' => $values['duration'] ? $values['duration'] : 0, 'access_limit' => $values['access_limit'] ? $values['access_limit'] : 0, 'share_folder' => $values['share_folder'] ? $values['share_folder'] : 0, 'max_users' => $values['max_users'] ? $values['max_users'] : null, 'show_catalog' => $values['show_catalog'], 'course_only' => $values['course_only'], 'price' => str_replace($localeSettings['decimal_point'], '.', $values['price']));
 }
 $form->addGroup($group, 'options', '', '<br/>');
 $form->addRule('options', _PLEASEPICKANOPTION, 'required', null, 'client');
 $form->addElement('submit', 'submit_poll', _VOTE, 'class = "flatButton"');
 if ($form->isSubmitted() && $form->validate()) {
     $values = $form->exportValues();
     //pr($values);
     //debug();
     $res = eF_getTableData("f_users_to_polls", "*", "f_poll_ID=" . $values['options']['vote'] . " and users_LOGIN='******'login'] . "'");
     //debug(false);
     if (sizeof($res) > 0) {
         $message = _YOUHAVEALREADYVOTED;
         $message_type = 'failure';
     } else {
         $fields = array('f_poll_ID' => $_GET['poll'], 'users_LOGIN' => $_SESSION['s_login'], 'vote' => $values['options']['vote'], 'timestamp' => time());
         if (eF_insertTableData("f_users_to_polls", $fields)) {
             $message = _SUCCESFULLYVOTED;
             $message_type = 'success';
             eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=forum&poll=" . $_GET['poll']);
         } else {
             $message = _SOMEPROBLEMEMERGED;
             $message_type = 'failure';
         }
     }
 }
 $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
 //Create a smarty renderer
 $form->accept($renderer);
 //Assign this form to the renderer, so that corresponding template code is created
 $smarty->assign('T_POLL_FORM', $renderer->toArray());
 //Assign the form to the template
Exemple #23
0
 $form->addElement('text', 'email', _YOUREMAIL, 'class = "inputText"');
 $form->addRule('email', _THEFIELD . ' "' . _EMAIL . '" ' . _ISMANDATORY, 'required');
 $form->addRule('email', _INVALIDFIELDDATA, 'checkParameter', 'email');
 $form->addElement('text', 'message_subject', _MESSAGESUBJECT, 'class = "inputText"');
 //$form -> addRule('message_subject', _INVALIDFIELDDATA, 'checkParameter', 'text');
 $form->addElement('textarea', 'message_body', _TEXT, 'class = "inputText" id = "contact"');
 $form->addElement('submit', 'submit_contact', _SUBMIT, 'class = "flatButton"');
 if ($_GET['limit_reached']) {
     $form->setDefaults(array('message_subject' => _IWANTTOSIGNUPBUTMAXIMUMUSERSLIMITREACHED, 'message_body' => _IWANTTOSIGNUPBUTMAXIMUMUSERSLIMITREACHEDBODY));
 }
 if ($_SESSION['s_login']) {
     $form->setDefaults(array('email' => $currentUser->user['email']));
 }
 if ($form->isSubmitted()) {
     $fields_insert = array('users_LOGIN' => 'visitor', 'timestamp' => time(), 'action' => 'forms', 'comments' => 'contact', 'session_ip' => eF_encodeIP(eF_getRemoteAddress()));
     eF_insertTableData("logs", $fields_insert);
     if ($form->validate()) {
         $to = $form->exportValue("email");
         $subject = $form->exportValue("message_subject");
         $body = $form->exportValue("message_body") . "\r\n\r\n(" . $subject . " [" . _FROM . ": " . $to . "])";
         if (eF_mail($to, $GLOBALS['configuration']['system_email'], $subject . " [" . _FROM . ": " . $to . "]", $body, false, true)) {
             $copied_body = _THANKYOUFORCONTACTINGUSBODY . "<br/><hr/><br/>" . $form->exportValue("message_body");
             eF_mail($GLOBALS['configuration']['system_email'], $to, _THANKYOUFORCONTACTINGUS, $copied_body, false, false);
             $message = _SENDSUCCESS;
             $message_type = 'success';
             eF_redirect(basename($_SERVER['PHP_SELF']) . '?message=' . urlencode($message) . '&message_type=' . $message_type);
         } else {
             $message = _SENDFAILURE;
             $message_type = 'failure';
         }
     }
     $scoUser->setSeenUnit($scoUnit, $scoLesson, true);
 }
 $remaining_times = -1;
 if ($credit) {
     if ($seenUnit || strtolower($fields['completion_status']) == 'failed' || strtolower($fields['lesson_status']) == 'failed') {
         $result = eF_getTableData("users_to_content", "visits, attempt_identifier", "content_ID={$unit['id']} and users_LOGIN='******'login']}'");
         if (!empty($result)) {
             // 				vd($_SESSION['attempt_identifier']);
             // 				vd($result[0]['attempt_identifier']);
             $visits = $result[0]['visits'];
             if ($_SESSION['attempt_identifier'] != $result[0]['attempt_identifier']) {
                 eF_updateTableData("users_to_content", array("visits" => $result[0]['visits'] + 1, "attempt_identifier" => $_SESSION['attempt_identifier']), "content_ID={$unit['id']} and users_LOGIN='******'login']}'");
                 $visits = $result[0]['visits'] + 1;
             }
         } else {
             eF_insertTableData("users_to_content", array("attempt_identifier" => $_SESSION['attempt_identifier'], "visits" => 1, "content_ID" => $unit['id'], "lessons_ID" => $unit['lessons_ID'], "users_LOGIN" => $scoUser->user['login']));
             $visits = 1;
         }
         $remaining_times = $unit['options']['scorm_times'] - $visits;
     }
 }
 $newUserProgress = EfrontStats::getUsersLessonStatus($scoLesson, $scoUser->user['login']);
 $newPercentage = $newUserProgress[$scoLesson->lesson['id']][$scoUser->user['login']]['overall_progress'];
 $newConditionsPassed = $newUserProgress[$scoLesson->lesson['id']][$scoUser->user['login']]['conditions_passed'];
 $newLessonPassed = $newUserProgress[$scoLesson->lesson['id']][$scoUser->user['login']]['lesson_passed'];
 if ($scoLesson->lesson['course_only'] && $_SESSION['s_courses_ID']) {
     $res = eF_getTableData("users_to_courses", "issued_certificate", "courses_ID=" . $_SESSION['s_courses_ID'] . " and users_LOGIN='******'s_login'] . "'");
     if ($res[0]['issued_certificate'] != "") {
         $courseCertified = true;
     }
 }
 /**
  *
  * @param $fields
  * @return unknown_type
  */
 public static function create($fields = array())
 {
     if (is_file(G_THEMESPATH . $fields['path'] . 'images/logo.png')) {
         $fields['options']['logo'] = $fields['path'] . 'images/logo.png';
     }
     if (is_file(G_THEMESPATH . $fields['path'] . 'images/favicon.png')) {
         $fields['options']['favicon'] = $fields['path'] . 'images/favicon.png';
     }
     $fields = self::validateFields($fields);
     $result = eF_getTableDataFlat("themes", "name");
     if (!in_array($fields['name'], $result['name'])) {
         $id = eF_insertTableData("themes", $fields);
     } else {
         $idx = array_search($fields['name'], $result['name']);
         $id = $result['name'][$idx];
     }
     EfrontCache::getInstance()->deleteCache('themes');
     $newTheme = new themes($id);
     return $newTheme;
 }
 /**
  * Login user
  *
  * This function logs the user in the system, using the specified password
  * <br/>Example:
  * <code>
  * $user = EfrontUserFactory :: factory('jdoe');
  * $user -> login('mypass');
  * </code>
  *
  * @param string $password The password to login with
  * @param boolean $encrypted Whether the password is already encrypted
  * @return boolean True if the user logged in successfully
  * @since 3.5.0
  * @access public
  */
 public function login($password, $encrypted = false)
 {
     //If the user is already logged in, log him out
     if ($this->isLoggedIn()) {
         //If the user is logged in right now on the same pc with the same session, return true (nothing to do)
         if ($this->isLoggedIn(session_id())) {
             if (!$encrypted && EfrontUser::createPassword($password) != $this->user['password']) {
                 throw new EfrontUserException(_INVALIDPASSWORD, EfrontUserException::INVALID_PASSWORD);
             } else {
                 if ($encrypted && $password != $this->user['password']) {
                     throw new EfrontUserException(_INVALIDPASSWORD, EfrontUserException::INVALID_PASSWORD);
                 }
             }
             return true;
         } elseif (!$this->allowMultipleLogin()) {
             $this->logout();
         }
     }
     //If we are logged in as another user, log him out
     if (isset($_SESSION['s_login']) && $_SESSION['s_login'] != $this->user['login']) {
         try {
             EfrontUserFactory::factory($_SESSION['s_login'])->logout(session_id());
         } catch (Exception $e) {
         }
     }
     //Empty session without destroying it
     foreach ($_SESSION as $key => $value) {
         if ($key != 'login_mode' && strpos($key, "facebook") === false) {
             //'login_mode' is used to facilitate lesson registrations
             unset($_SESSION[$key]);
         }
     }
     if ($this->user['pending']) {
         throw new EfrontUserException(_USERPENDING, EfrontUserException::USER_PENDING);
     }
     if (!$this->user['active']) {
         throw new EfrontUserException(_USERINACTIVE, EfrontUserException::USER_INACTIVE);
     }
     if ($this->isLdapUser) {
         //Authenticate LDAP user
         if (!eF_checkUserLdap($this->user['login'], $password)) {
             throw new EfrontUserException(_INVALIDPASSWORD, EfrontUserException::INVALID_PASSWORD);
         }
     } else {
         if (!$encrypted) {
             $password = EfrontUser::createPassword($password);
         }
         if ($password != $this->user['password']) {
             throw new EfrontUserException(_INVALIDPASSWORD, EfrontUserException::INVALID_PASSWORD);
         }
     }
     //if user language is deactivated or deleted, login user with system default language
     if ($GLOBALS['configuration']['onelanguage']) {
         $loginLanguage = $GLOBALS['configuration']['default_language'];
     } else {
         $activeLanguages = array_keys(EfrontSystem::getLanguages(true, true));
         if (in_array($this->user['languages_NAME'], $activeLanguages)) {
             $loginLanguage = $this->user['languages_NAME'];
         } else {
             $loginLanguage = $GLOBALS['configuration']['default_language'];
         }
     }
     //Assign session variables
     $_SESSION['s_login'] = $this->user['login'];
     $_SESSION['s_password'] = $this->user['password'];
     $_SESSION['s_type'] = $this->user['user_type'];
     $_SESSION['s_language'] = $loginLanguage;
     $_SESSION['s_custom_identifier'] = sha1(microtime() . $this->user['login']);
     $_SESSION['s_time_target'] = array(0 => 'system');
     //'s_time_target' is used to signify which of the system's area the user is currently accessing. It is a id => entity pair
     //$_SESSION['last_action_timestamp'] = time();	//Initialize first action
     //Insert log entry
     $fields_insert = array('users_LOGIN' => $this->user['login'], 'timestamp' => time(), 'action' => 'login', 'comments' => session_id(), 'session_ip' => eF_encodeIP($_SERVER['REMOTE_ADDR']));
     eF_insertTableData("logs", $fields_insert);
     eF_updateTableData("users", array('last_login' => time()), "login='******'login']}'");
     if ($GLOBALS['configuration']['ban_failed_logins']) {
         eF_deleteTableData("logs", "users_LOGIN='******'login'] . "' and action='failed_login'");
     }
     //Insert user times entry
     $fields = array("session_timestamp" => time(), "session_id" => session_id(), "session_custom_identifier" => $_SESSION['s_custom_identifier'], "session_expired" => 0, "users_LOGIN" => $_SESSION['s_login'], "timestamp_now" => time(), "time" => 0, "entity" => 'system', "entity_id" => 0);
     eF_insertTableData("user_times", $fields);
     return true;
 }
Exemple #27
0
 public function getModule()
 {
     $currentLesson = $this->getCurrentLesson();
     $smarty = $this->getSmartyVar();
     $smarty->assign("T_LESSON_ID", $currentLesson->lesson['id']);
     if (isset($_GET['delete_link']) && eF_checkParameter($_GET['delete_link'], 'id')) {
         eF_deleteTableData("module_links", "id=" . $_GET['delete_link']);
         $this->setMessageVar(_LINKS_SUCCESFULLYDELETEDLINK, 'success');
         eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type={$message_type}");
     } else {
         if (isset($_GET['add_link']) || isset($_GET['edit_link']) && eF_checkParameter($_GET['edit_link'], 'id')) {
             $form = new HTML_QuickForm("link_entry_form", "POST", $_SERVER['REQUEST_URI'], "");
             $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
             //Register this rule for checking user input with our function, eF_checkParameter
             $form->addElement('text', 'display', null);
             $form->addElement('text', 'link', null);
             $form->addElement('textarea', 'description', null);
             $form->addElement('submit', 'submit_link', _SUBMIT, 'class = "flatButton"');
             $element =& $form->getElement('display');
             $element->setSize(50);
             $element =& $form->getElement('link');
             $element->setSize(50);
             $element =& $form->getElement('description');
             $element->setCols(50);
             if (isset($_GET['edit_link'])) {
                 $link_entry = eF_getTableData("module_links", "*", "id=" . $_GET['edit_link']);
                 $form->setDefaults(array('display' => $link_entry[0]['display'], 'link' => $link_entry[0]['link'], 'description' => $link_entry[0]['description']));
             } else {
                 $form->setDefaults(array('link' => "http://"));
             }
             if ($form->isSubmitted() && $form->validate()) {
                 $fields = array('lessons_ID' => $_SESSION['s_lessons_ID'], 'display' => $form->exportValue('display'), 'link' => $form->exportValue('link'), 'description' => $form->exportValue('description'));
                 if (isset($_GET['edit_link'])) {
                     if (eF_updateTableData("module_links", $fields, "id=" . $_GET['edit_link'])) {
                         $message = _LINKS_SUCCESFULLYUPDATEDLINKENTRY;
                         $message_type = 'success';
                         eF_redirect("" . $_SERVER['PHP_SELF'] . "?ctg=module&op=module_links&message=" . urlencode($message) . "&message_type={$message_type}");
                     } else {
                         $message = _LINKS_PROBLEMUPDATINGLINKENTRY;
                         $message_type = 'failure';
                         eF_redirect("" . $_SERVER['PHP_SELF'] . "?ctg=module&op=module_links&message=" . urlencode($message) . "&message_type={$message_type}");
                     }
                 } else {
                     if (eF_insertTableData("module_links", $fields)) {
                         $message = _LINKS_SUCCESFULLYINSERTEDLINKENTRY;
                         $message_type = 'success';
                         eF_redirect("" . $_SERVER['PHP_SELF'] . "?ctg=module&op=module_links&message=" . urlencode($message) . "&message_type={$message_type}");
                     } else {
                         $message = _LINKS_PROBLEMINSERTINGLINKENTRY;
                         $message_type = 'failure';
                         eF_redirect("" . $_SERVER['PHP_SELF'] . "?ctg=module&op=module_links&message=" . urlencode($message) . "&message_type={$message_type}");
                     }
                 }
             }
             $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
             $form->accept($renderer);
             $smarty->assign('T_LINKS_FORM', $renderer->toArray());
         } else {
             $links = eF_getTableDataFlat("module_links", "*", "lessons_ID = " . $_SESSION['s_lessons_ID']);
             $smarty->assign("T_LINKS", $links);
         }
     }
     return true;
 }
Exemple #28
0
 /**
  * Add courses to group
  *
  * This function is used to add courses to the current group
  * <br>Example:
  * <code>
  * $group = new EfrontGroup(2);
  * $group -> addCourse(3, 'professor'); // will add course with id 3 and role 'professor' to the group's courses
  * </code>
  *
  * @param $courses_ID and $user_type
  * @return boolean True if everything is ok
  * @since 3.5.2
  * @access public
  */
 public function addCourse($courses_ID, $user_type = "student")
 {
     // Check if the course exists in the group's list
     $courses = $this->getCourses();
     if (in_array($courses_ID, array_keys($courses))) {
         // If the course is already assigned check if you need
         // to update the user type for this course
         if ($courses[$courses_ID]['user_type'] != $user_type) {
             $ok = eF_updateTableData("courses_to_groups", array("user_type" => $user_type), "courses_ID = " . $courses_ID);
             $this->courses[$courses_ID]['user_type'] = $user_type;
             return $ok;
         }
     } else {
         $fields = array('courses_ID' => $courses_ID, 'user_type' => $user_type, 'groups_ID' => $this->group['id']);
         if ($ok = eF_insertTableData("courses_to_groups", $fields)) {
             $newCourse = new EfrontCourse($courses_ID);
             $this->courses[$courses_ID] = array('courses_ID' => $courses_ID, 'courses_name' => $newCourse->course['name'], 'user_type' => $user_type);
         }
         return $ok;
     }
     // if control flow reaches here then the course was already assigned and with the same user_type
     return false;
 }
 }
 if ($currentUnit['options']['complete_unit_setting'] == EfrontUnit::COMPLETION_OPTIONS_ACCEPTTERMSCOMPLETION) {
     $accept_term_message = _ACCEPTTERMCOMPLETIONMESSAGE;
     if ($accept_term_message) {
         $smarty->assign("T_ACCEPT_TERM_COMPLETION_MESSAGE", $accept_term_message);
         $res = eF_getTableData("users_to_content", "pending", "users_LOGIN='******'login'] . "' and content_ID=" . $currentUnit['id']);
         if (sizeof($_POST) > 0) {
             try {
                 if ($_POST['accept_terms'] === 'true') {
                     $currentUser->setSeenUnit($currentUnit, $currentLesson, true);
                     echo 'accept';
                 } elseif ($_POST['accept_terms'] === 'false') {
                     if (sizeof($res) > 0) {
                         eF_updateTableData("users_to_content", array('pending' => 1), "users_LOGIN='******'login'] . "' and content_ID=" . $currentUnit['id']);
                     } else {
                         eF_insertTableData("users_to_content", array("pending" => 1, "users_LOGIN" => $currentUser->user['login'], "content_ID" => $currentUnit['id'], "lessons_ID" => $currentLesson->lesson['id']));
                     }
                 }
             } catch (Exception $e) {
                 //handleAjaxExceptions($e);
             }
             exit;
         } elseif (in_array($currentUnit['id'], array_keys($seenContent))) {
             $smarty->assign("T_ACCEPT_TERM_COMPLETION_CHECKED", 'accepted');
         } elseif ($res[0]['pending']) {
             $smarty->assign("T_ACCEPT_TERM_COMPLETION_CHECKED", 'rejected');
         }
     }
 }
 if (isset($_GET['set_seen']) && $ruleCheck) {
     try {
 /**
  * Assign a branch to this lesson
  *
  * This function is used to correlate a branch to the lesson
  * All users of the branch should be assigned to this lesson
  *
  * <br/>Example:
  * <code>
  * $lesson -> assignBranch(2);   // The lesson will be assigned to branch with id 2
  * </code>
  *
  * @param $branch_ID the id of the branch to be assigned
  * @return boolean true/false
  * @since 3.6.0
  * @access public
  */
 public function assignBranch($branch_ID)
 {
     $this->getBranches();
     // Check if the branch is not assigned as offered by this lesson
     if ($this->branches[$branch_ID]['lessons_ID'] == "") {
         if ($ok = eF_insertTableData("module_hcd_lesson_to_branch", array("branches_ID" => $branch_ID, "lessons_ID" => $this->lesson['id']))) {
             $this->branches[$branch_ID]['lessons_ID'] = $this->lesson['id'];
             $newBranch = new EfrontBranch($branch_ID);
             $employees = $newBranch->getEmployees(false, true);
             //get data flat
             $this->addUsers($employees['login'], $employees['user_type']);
         } else {
             throw new EfrontLessonException(_EMPLOYEESRECORDCOULDNOTBEUPDATED, EfrontLessonException::DATABASE_ERROR);
         }
     }
     return true;
 }