Ejemplo n.º 1
0
 /**
  * Create new course
  *
  * Create a new course based on the specified $fields
  * <br/>Example:
  * <code>
  * $fields = array('name' => 'new course', 'languages_NAME' => 'english');
  * $course = EfrontCourse :: createCourse($fields);
  * </code>
  *
  * @param array $fields The new fields
  * @return EfrontCourse the new course
  * @since 3.5.0
  * @access public
  */
 public static function createCourse($fields)
 {
     $fields['metadata'] = self::createCourseMetadata($fields);
     $fields = self::validateAndSanitizeCourseFields($fields);
     isset($fields['creator_LOGIN']) or $fields['creator_LOGIN'] = $_SESSION['s_login'];
     $newId = eF_insertTableData("courses", $fields);
     // Insert the corresponding lesson skill to the skill and lesson_offers_skill tables. Automatic skill generation only for the educational version
     if (G_VERSIONTYPE == 'educational') {
         #cpp#ifdef EDUCATIONAL
         $courseSkillId = eF_insertTableData("module_hcd_skills", array("description" => _KNOWLEDGEOFCOURSE . " " . $fields['name'], "categories_ID" => -1));
         eF_insertTableData("module_hcd_course_offers_skill", array("courses_ID" => $newId, "skill_ID" => $courseSkillId));
     }
     #cpp#endif
     EfrontSearch::insertText($fields['name'], $newId, "courses", "title");
     $course = new EfrontCourse($newId);
     self::notifyModuleListenersForCourseCreation($course);
     return $course;
 }
Ejemplo n.º 2
0
 /**
  * Persist glossary properties
  *
  * This function can be used to persist with the database
  * any changes made to the current glossary object.
  * <br/>Example:
  * <code>
  * $glossary -> glossary['name'] = 'new Title';              //Change the name
  * $glossary -> persist();                                   //Make the change permanent
  * </code>
  *
  * @since 3.6.0
  * @access public
  */
 public function persist()
 {
     // added to fix http://forum.efrontlearning.net/viewtopic.php?f=5&t=2851&p=14715
     if (mb_substr($this->glossary['info'], 0, 3) == "<p>") {
         $this->glossary['info'] = mb_substr($this->glossary['info'], 3);
         if (mb_substr($this->glossary['info'], -4, 4) == "</p>") {
             $this->glossary['info'] = mb_substr($this->glossary['info'], 0, -4);
         }
     }
     parent::persist();
     EfrontSearch::removeText('glossary', $this->glossary['id'], 'data');
     EfrontSearch::insertText($this->glossary['info'], $this->glossary['id'], "glossary", "data");
     EfrontSearch::removeText('glossary', $this->glossary['id'], 'title');
     EfrontSearch::insertText($this->glossary['title'], $this->glossary['id'], "glossary", "title");
 }
Ejemplo n.º 3
0
 /**
  * Store database values
  *
  * This function is used to store changed lesson properties
  * to the database.
  * <br/>Example:
  * <code>
  * $lesson = new EfrontLesson(4);           //Instantiate lesson with id 4
  * $lesson -> lesson['name'] = 'new name';  //Change a lesson's property, for example its name
  * $lesson -> persist();                    //Store any changed values to the database
  * </code>
  *
  * @since 3.5.0
  * @access public
  */
 public function persist()
 {
     $localeSettings = localeconv();
     $fields = array('name' => $this->lesson['name'], 'directions_ID' => $this->lesson['directions_ID'], 'info' => $this->lesson['info'], 'price' => str_replace($localeSettings['decimal_point'], '.', $this->lesson['price']), 'active' => $this->lesson['active'], 'duration' => $this->lesson['duration'] ? $this->lesson['duration'] : 0, 'access_limit' => $this->lesson['access_limit'] ? $this->lesson['access_limit'] : 0, 'share_folder' => $this->lesson['share_folder'] ? $this->lesson['share_folder'] : 0, 'show_catalog' => $this->lesson['course_only'] ? 1 : $this->lesson['show_catalog'], 'options' => serialize($this->options), 'languages_NAME' => $this->lesson['languages_NAME'], 'metadata' => $this->lesson['metadata'], 'course_only' => $this->lesson['course_only'], 'certificate' => $this->lesson['certificate'], 'publish' => $this->lesson['publish'] ? 1 : 0, 'max_users' => $this->lesson['max_users'] ? $this->lesson['max_users'] : null, 'from_timestamp' => $this->lesson['from_timestamp'] ? $this->lesson['from_timestamp'] : 0, 'to_timestamp' => $this->lesson['to_timestamp'] ? $this->lesson['to_timestamp'] : 0, 'shift' => $this->lesson['shift'], 'archive' => $this->lesson['archive'], 'created' => $this->lesson['created']);
     if (!eF_updateTableData("lessons", $fields, "id=" . $this->lesson['id'])) {
         throw new EfrontUserException(_DATABASEERROR, EfrontUserException::DATABASE_ERROR);
     }
     EfrontSearch::removeText('lessons', $this->lesson['id'], 'title');
     //Refresh the search keywords
     EfrontSearch::insertText($fields['name'], $this->lesson['id'], "lessons", "title");
 }
 /**
  * Send a personal message
  *
  * This function is used to send the personal message. If $email is specified,
  * the message is also emailed to the recipients
  * <br/>Example:
  * <code>
  * $pm = new eF_PersonalMessage("professor", array("professor", "student", "admin"), 'Test subject', 'Test personal message body');
  * $pm -> send();
  * </code>
  *
  * @param boolean If true, the personal message will be send as an email as well
  * @return true on success, false on error
  * @since 1.0
  * @access public
  */
 public function send($email = false)
 {
     if (sizeof($this->recipients) == 0) {
         $this->errorMessage = _INVALIDRECIPIENT;
         return false;
     }
     $timestamp = time();
     if ($email) {
         //Check if the messag should be sent as an email also. This will be sent no matter the user quotas
         $recipientsMail = array();
         foreach ($this->recipients as $recipient) {
             if ($this->userData[$recipient]['email'] != "") {
                 $recipientsMail[] = $this->userData[$recipient]['email'];
             } else {
                 $this->errorMessage .= $this->userData[$recipient]['login'] . ' ' . _HASNOTANEMAILADDRESS . '<br/>';
             }
         }
         $recipientsList = implode(",", $recipientsMail);
         $this->body = _THISISAPMFROMSITE . " <a href=" . G_SERVERNAME . ">" . G_SERVERNAME . "</a><br />" . $this->body;
         $emailBody = str_replace('##EFRONTINNERLINK##', 'student', $this->body);
         if (($result = eF_mail($this->userData[$this->sender]['email'], $recipientsList, $this->subject, $emailBody, $this->attachments, false, $this->bcc)) !== true) {
             $this->errorMessage .= _THEMESSAGEWASNOTSENTASEMAIL . '<br/>';
         }
     }
     foreach ($this->recipients as $recipient) {
         $fields_insert = array("users_LOGIN" => $recipient, "recipient" => implode(", ", $this->recipients), "sender" => $this->sender, "timestamp" => $timestamp, "title" => $this->subject, "body" => $this->body, "bcc" => $this->bcc ? 1 : 0, "f_folders_ID" => $this->userData[$recipient]['folders']['Incoming'], "viewed" => 0);
         //It is not viewed yet
         if (!empty($this->attachments) && $this->attachments[0]) {
             if ($this->checkUserQuota($recipient)) {
                 $attachment = new EfrontFile($this->sender_attachment_fileId);
                 $recipient_dir = G_UPLOADPATH . $recipient . '/message_attachments/Incoming/' . $timestamp . '/';
                 mkdir($recipient_dir, 0755);
                 $newFile = $attachment->copy($recipient_dir, false, true);
                 $fields_insert["attachments"] = $newFile['id'];
             } else {
                 $fields_insert["body"] .= '<br /><span class="failure">' . _THEREWASATTACHMENTCUTBECAUSEOFQUOTA . '</span>';
             }
         }
         $id = eF_insertTableData("f_personal_messages", $fields_insert);
         EfrontSearch::insertText($fields_insert['body'], $id, "f_personal_messages", "data");
         EfrontSearch::insertText($fields_insert['title'], $id, "f_personal_messages", "title");
     }
     //it should not come here if sender has reached maximum space limit
     //if ($this -> checkUserQuota($this -> sender)) {
     $fields_insert = array("users_LOGIN" => $this->sender, "recipient" => implode(", ", $this->recipients), "sender" => $this->sender, "timestamp" => $timestamp, "title" => $this->subject, "body" => $this->body, "bcc" => $this->bcc ? 1 : 0, "f_folders_ID" => $this->userData[$this->sender]['folders']['Sent'], "viewed" => 0);
     if (!empty($this->attachments) && $this->attachments[0]) {
         $attachment = new EfrontFile($this->sender_attachment_fileId);
         $fields_insert["attachments"] = $this->sender_attachment_fileId;
     }
     $id = eF_insertTableData("f_personal_messages", $fields_insert);
     EfrontSearch::insertText($fields_insert['body'], $id, "f_personal_messages", "data");
     EfrontSearch::insertText($fields_insert['title'], $id, "f_personal_messages", "title");
     //} else {
     //    $this -> errorMessage .= _COULDNOTBECOPIEDTOYOURSENTBOX.' '._BECAUSEYOURMESSAGEBOXISFULL.'<br />';
     //}
     if ($this->errorMessage) {
         return false;
     } else {
         return true;
     }
 }
Ejemplo n.º 5
0
 /**
  * Function reBuiltIndex()
  *
  * This function is used to built the keywords from scratch
  *
  * @since 3.5.0
  * @access public
  */
 public static function reBuiltIndex()
 {
     eF_deleteTableData("search_keywords");
     //Delete old search terms
     //		eF_deleteTableData("search");
     $GLOBALS['db']->Execute("truncate table search_invertedindex");
     //Courses Data
     $courses = eF_getTableData("courses", "id,name");
     for ($i = 0; $i < sizeof($courses); $i++) {
         EfrontSearch::insertText($courses[$i]['name'], $courses[$i]['id'], "courses", "title");
     }
     //Lesson Data
     $lessons = eF_getTableData("lessons", "id,name");
     for ($i = 0; $i < sizeof($lessons); $i++) {
         EfrontSearch::insertText($lessons[$i]['name'], $lessons[$i]['id'], "lessons", "title");
     }
     //Content Data
     $content = eF_getTableData("content", "id,name,data");
     for ($i = 0; $i < sizeof($content); $i++) {
         EfrontSearch::insertText($content[$i]['name'], $content[$i]['id'], "content", "title");
         EfrontSearch::insertText(strip_tags($content[$i]['data']), $content[$i]['id'], "content", "data");
     }
     //Forum Messages
     $forum_messages = eF_getTableData("f_messages", "id, title, body");
     for ($i = 0; $i < sizeof($forum_messages); $i++) {
         EfrontSearch::insertText(strip_tags($forum_messages[$i]['body']), $forum_messages[$i]['id'], "f_messages", "data");
         EfrontSearch::insertText($forum_messages[$i]['title'], $forum_messages[$i]['id'], "f_messages", "title");
     }
     //Forums
     $forums = eF_getTableData("f_forums", "id, title, comments");
     for ($i = 0; $i < sizeof($forums); $i++) {
         EfrontSearch::insertText($forums[$i]['title'], $forums[$i]['id'], "f_forums", "title");
         if (strlen($forums[$i]['comments']) > 3) {
             EfrontSearch::insertText(strip_tags($forums[$i]['comments']), $forums[$i]['id'], "f_forums", "data");
         }
     }
     //Forums Topics
     $f_topics = eF_getTableData("f_topics", "id, title, comments");
     for ($i = 0; $i < sizeof($f_topics); $i++) {
         EfrontSearch::insertText($f_topics[$i]['title'], $f_topics[$i]['id'], "f_topics", "title");
         if (strlen($f_topics[$i]['comments']) > 3) {
             EfrontSearch::insertText(strip_tags($f_topics[$i]['comments']), $f_topics[$i]['id'], "f_topics", "data");
         }
     }
     //Forums Polls
     $f_poll = eF_getTableData("f_poll", "id, title, question");
     for ($i = 0; $i < sizeof($f_poll); $i++) {
         EfrontSearch::insertText($f_poll[$i]['title'], $f_poll[$i]['id'], "f_poll", "title");
         if (strlen($f_poll[$i]['question']) > 3) {
             EfrontSearch::insertText(strip_tags($f_poll[$i]['question']), $f_poll[$i]['id'], "f_poll", "data");
         }
     }
     //Personal Messages
     $personal_messages = eF_getTableData("f_personal_messages", "id, title, body");
     //Get all the personal messages
     for ($i = 0; $i < sizeof($personal_messages); $i++) {
         EfrontSearch::insertText($personal_messages[$i]['body'], $personal_messages[$i]['id'], "f_personal_messages", "data");
         EfrontSearch::insertText($personal_messages[$i]['title'], $personal_messages[$i]['id'], "f_personal_messages", "title");
     }
     //Questions
     $questions = eF_getTableData("questions", "id, text");
     for ($i = 0; $i < sizeof($questions); $i++) {
         EfrontSearch::insertText(strip_tags($questions[$i]['data']), $questions[$i]['id'], "questions", "data");
     }
     //Glossary terms
     $glossary = eF_getTableData("glossary", "id, name, info");
     for ($i = 0; $i < sizeof($glossary); $i++) {
         EfrontSearch::insertText(strip_tags($glossary[$i]['info']), $glossary[$i]['id'], "glossary", "data");
         EfrontSearch::insertText($glossary[$i]['name'], $glossary[$i]['id'], "glossary", "title");
     }
 }
Ejemplo n.º 6
0
 private function importUnitFromXML($unitelement, $parentid)
 {
     $fields = array();
     $fields['name'] = (string) $unitelement->name;
     $fields['data'] = (string) $unitelement->data;
     $fields['ctg_type'] = (string) $unitelement->ctg_type;
     $fields['parent_content_ID'] = $parentid;
     $uid = ef_insertTableData("content", $fields);
     EfrontSearch::insertText($fields['name'], $uid, "content", "title");
     EfrontSearch::insertText($fields['data'], $uid, "content", "data");
     if ($fields['ctg_type'] == 'tests') {
         $testfields = array();
         $testfields['content_id'] = (string) $unitelement->id;
         $testfields['duration'] = (string) $unitelement->test[0]->duration;
         $testfields['redoable'] = (string) $unitelement->test[0]->redoable;
         $testfields['onebyone'] = (string) $unitelement->test[0]->onebyone;
         $testfields['answers'] = (string) $unitelement->test[0]->answers;
         $testfields['description'] = (string) $unitelement->test[0]->description;
         $testfields['shuffle_questions'] = (string) $unitelement->test[0]->shuffle_questions;
         $testfields['shuffle_answers'] = (string) $unitelement->test[0]->shuffle_answers;
         $testfields['given_answers'] = (string) $unitelement->test[0]->given_answers;
         $tid = ef_insertTableData("tests", $testfields);
     }
     //import the subunits
     for ($i = 0; $i < sizeof($unitelement->unit); $i++) {
         importUnitFromXML($unitelement->unit[$i]);
     }
 }
Ejemplo n.º 7
0
 $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
 $form->addElement("text", "events_size", null, 'class = "inputText" style = "width:60px"');
 $form->addElement("submit", "submit", _SUBMIT, 'class = "flatButton"');
 if ($form->isSubmitted() && $form->validate()) {
     $timestamp = mktime(0, 0, 0, $_POST['purge_Month'], $_POST['purge_Day'], $_POST['purge_Year']);
     if (eF_checkParameter($timestamp, 'int')) {
         eF_deleteTableData("events", "timestamp < {$timestamp}");
     }
     eF_redirect(basename($_SERVER['PHP_SELF'] . "?ctg=maintenance&tab=cleanup&message=" . urlencode(_OPERATIONCOMPLETEDSUCCESSFULLY) . "&message_type=success"));
 }
 $renderer = prepareFormRenderer($form);
 $smarty->assign("T_CLEANUP_EVENTS_FORM", $renderer->toArray());
 //Recreate search table
 if (isset($_GET['reindex']) && $_GET['ajax'] == 1) {
     try {
         EfrontSearch::reBuiltIndex();
     } catch (Exception $e) {
         handleAjaxExceptions($e);
     }
     exit;
 }
 if (isset($_GET['delete_tokens']) && $_GET['ajax'] == 1) {
     try {
         $one_month_ego = time() - 30 * 24 * 60 * 60;
         eF_deleteTableData("tokens", "create_timestamp < " . $one_month_ego);
     } catch (Exception $e) {
         handleAjaxExceptions($e);
     }
     exit;
 }
 if (isset($_GET['archive_tables']) && $_GET['ajax'] == 1) {
Ejemplo n.º 8
0
function askSuggestions()
{
    //header("Content-type: text/xml;charset=iso-8859-7");
    $ie = isset($_GET['ie']) ? true : false;
    $search_results_data = array();
    $search_results_forum = array();
    $search_results_pmsgs = array();
    $results = EfrontSearch::searchFull('');
    //$res     = eF_getTableData("users_to_lessons", "lessons_ID", "users_LOGIN='******'s_login']."'");
    $res = eF_getTableData("users_to_lessons,lessons", "lessons_ID", "users_to_lessons.archive=0 and lessons.archive=0 and users_LOGIN='******'s_login'] . "' and lessons.active=1 and lessons.id=users_to_lessons.lessons_ID");
    // na min emfanizontai ta deactivated lessons
    for ($i = 0; $i < sizeof($res); $i++) {
        $lessons_have[] = $res[$i]['lessons_ID'];
    }
    $have_results = false;
    if ($results) {
        for ($i = 0; $i < sizeof($results); $i++) {
            if ($results[$i]['table_name'] == "comments") {
                $res1 = eF_getTableData("content,comments", "content.name AS name,content.id AS id,content.lessons_ID AS lessons_ID", "comments.content_ID=content.id AND comments.id=" . $results[$i]['foreign_ID']);
                $type_str = _COMMENTS;
            } elseif ($results[$i]['table_name'] == "news") {
                $res1 = eF_getTableData($results[$i]['table_name'], "id,title AS name,lessons_ID", "id=" . $results[$i]['foreign_ID']);
                $type_str = _ANNOUNCEMENTS;
            } elseif ($results[$i]['table_name'] == "content") {
                $res1 = eF_getTableData($results[$i]['table_name'], "id,name,lessons_ID,ctg_type", "id=" . $results[$i]['foreign_ID']);
                $type_str = _LESSONCONTENT;
            } elseif ($results[$i]['table_name'] == "f_messages") {
                $res1 = eF_getTableData("f_messages, f_topics, f_forums", "f_forums.id as category_id, f_forums.lessons_ID, f_messages.id, f_messages.title, f_messages.f_topics_ID, f_topics.title as topic_title", "f_topics_ID = f_topics.id and f_forums.id = f_forums_ID and f_messages.id=" . $results[$i]['foreign_ID']);
                $type_str = _MESSAGESATFORUM;
            } elseif ($results[$i]['table_name'] == "f_personal_messages") {
                $res1 = eF_getTableData("f_personal_messages, f_folders", "f_personal_messages.id, f_personal_messages.title, f_personal_messages.users_LOGIN, f_folders.name, f_folders.id as folder_id", "f_personal_messages.f_folders_ID = f_folders.id and f_personal_messages.id=" . $results[$i]['foreign_ID']);
                $type_str = _MESSAGESATFORUM;
            } elseif ($results[$i]['table_name'] == "lessons") {
                $res1 = eF_getTableData($results[$i]['table_name'], "id as lessons_ID,name", "id=" . $results[$i]['foreign_ID'] . " and active=1");
                $type_str = _LESSON;
            } elseif ($results[$i]['table_name'] == "f_topics") {
                $res1 = $res1 = eF_getTableData("f_messages, f_topics, f_forums", "f_forums.id as category_id, f_forums.lessons_ID, f_messages.id, f_messages.title, f_messages.f_topics_ID, f_topics.title as topic_title", "f_topics_ID = f_topics.id and f_forums.id = f_forums_ID and f_topics.id=" . $results[$i]['foreign_ID']);
                $type_str = _MESSAGESATFORUM;
            }
            //print_r($res1);
            if (sizeof($res1) > 0) {
                $results[$i]['position'] == "title" ? $position_str = _TITLE : ($position_str = _TEXT);
                if (isset($res1[0]['lessons_ID']) && in_array($res1[0]['lessons_ID'], $lessons_have)) {
                    $lesson = eF_getTableData("lessons", "name", "id=" . $res1[0]['lessons_ID']);
                    if ($results[$i]['table_name'] != 'f_messages' && $results[$i]['table_name'] != 'f_topics') {
                        if ($results[$i]['table_name'] == "lessons") {
                            $search_results_data[] = array('id' => $res1[0]['id'], 'name' => $res1[0]['name'], 'table_name' => $results[$i]['table_name'], 'lessons_ID' => $res1[0]['lessons_ID'], 'lesson_name' => $lesson[0]['name'], 'score' => sprintf("%.0f %%", $results[$i]['score'] * 100), 'type' => $type_str, 'position' => $position_str);
                        } elseif ($results[$i]['table_name'] != "lessons") {
                            //echo $res1[0]['id']."->".eF_isDoneContent($res1[0]['id']);
                            $search_results_data[] = array('id' => $res1[0]['id'], 'name' => $res1[0]['name'], 'table_name' => $results[$i]['table_name'], 'lessons_ID' => $res1[0]['lessons_ID'], 'lesson_name' => $lesson[0]['name'], 'ctg_type' => $res1[0]['ctg_type'], 'score' => sprintf("%.0f %%", $results[$i]['score'] * 100), 'type' => $type_str, 'position' => $position_str);
                        }
                    } else {
                        $search_results_forum[] = array('category_id' => $res1[0]['category_id'], 'lesson_name' => $lesson[0]['name'], 'topic_subject' => $res1[0]['topic_title'], 'topic_id' => $res1[0]['f_topics_ID'], 'message_subject' => $res1[0]['title'], 'message_id' => $res1[0]['id'], 'position' => $position_str);
                    }
                } elseif ($results[$i]['table_name'] == 'f_personal_messages' && $_SESSION['s_login'] == $res1[0]['users_LOGIN']) {
                    $search_results_pmsgs[] = array('message_subject' => $res1[0]['title'], 'message_id' => $res1[0]['id'], 'folder_name' => $res1[0]['name'], 'folder_id' => $res1[0]['folder_id'], 'position' => $position_str);
                }
            }
        }
    }
    echo "<?xml version=\"1.0\" ?>";
    echo "<root>";
    echo "<search_results_data>";
    foreach ($search_results_data as $key => $value) {
        echo "<search_result_data>";
        echo "<id>" . $value['id'] . "</id>";
        echo "<name>" . $value['name'] . "</name>";
        echo "<table_name>" . $value['table_name'] . "</table_name>";
        echo "<lessons_ID>" . $value['lessons_ID'] . "</lessons_ID>";
        echo "<lesson_name>" . $value['lesson_name'] . "</lesson_name>";
        echo "<score>" . $value['score'] . "</score>";
        echo "<type>" . $value['type'] . "</type>";
        echo "<position>" . $value['position'] . "</position>";
        echo "</search_result_data>";
    }
    echo "</search_results_data>";
    /*
    for($i=0;$i<sizeof($result);$i++)
    {
    $name = str_replace("&","&amp;",$result[$i]['name']);
    $url = str_replace("&","&amp;",$result[$i]['url']);
    $id = $result[$i]['id'];
    echo "<bookmark>";
    if($ie)
    {
    echo "<name>".$name."</name>";
    echo "<url>".$url."</url>";
    echo "<id>".$id."</id>";
    }
    else
    {
    echo "<name>".iconv("UTF-8","ISO-8859-7",$name)."</name>";
    echo "<url>".iconv("UTF-8","ISO-8859-7",$url)."</url>";
    echo "<id>".$id."</id>";
    }
    echo "</bookmark>";
    }
    echo "</bookmarks>";
    }
    */
    echo "</root>";
}
Ejemplo n.º 9
0
 /**
  * Delete the news
  *
  * This function is used to delete the current news.
  * All related information is lost, as well as files associated
  * with the news.
  * <br/>Example:
  * <code>
  * $news = new news(12);                //Instantiate news with id 12
  * $news -> delete();                            //Delete news and all associated information
  * </code>
  *
  * @since 3.6.0
  * @access public
  */
 public function delete()
 {
     parent::delete();
     EfrontSearch::removeText('news', $this->news['id'], 'title');
     EfrontSearch::removeText('news', $this->news['id'], 'data');
 }
Ejemplo n.º 10
0
 /**
  * Import files to filesystem
  *
  * This function imports the specified files (in $list array) to the filesystem,
  * by creating a corresponding database representation. The $list
  * array should contain full paths to the files. The function returns an array
  * of the same size and contents as $list , but this time the file ids being the keys
  * <br/>Example:
  * <code>
  * $list = array('/var/www/text.txt', '/var/www/user.txt');
  * $newList = FileSystemTree :: importFiles($list);
  * </code>
  *
  * @param array $list The files list
  * @param array $options extra options to set for the files, such as whether they should be renamed, or the proper permissions
  * @return array An array with the new file ids
  * @access public
  * @since 3.0
  * @static
  */
 public static function importFiles($list, $options = array())
 {
     if (!is_array($list)) {
         $list = array($list);
     }
     $allFiles = eF_getTableDataFlat("files", "path");
     //Get all files, so that if a file already exists, a duplicate entry in the database won't be created
     for ($i = 0; $i < sizeof($list); $i++) {
         $list[$i] = EfrontFile::encode($list[$i]);
         if (!in_array($list[$i], $allFiles['path']) && strpos(dirname($list[$i]), rtrim(G_ROOTPATH, "/")) !== false) {
             $fileMetadata = array('title' => basename($list[$i]), 'creator' => $GLOBALS['currentUser']->user['name'] . ' ' . $GLOBALS['currentUser']->user['surname'], 'publisher' => $GLOBALS['currentUser']->user['name'] . ' ' . $GLOBALS['currentUser']->user['surname'], 'contributor' => $GLOBALS['currentUser']->user['name'] . ' ' . $GLOBALS['currentUser']->user['surname'], 'date' => date("Y/m/d", time()), 'type' => 'file');
             $fields = array('path' => str_replace(G_ROOTPATH, '', $list[$i]), 'users_LOGIN' => isset($_SESSION['s_login']) ? $_SESSION['s_login'] : '', 'timestamp' => time(), 'metadata' => serialize($fileMetadata));
             isset($options['access']) ? $fields['access'] = $options['access'] : null;
             $fileId = eF_insertTableData("files", $fields);
             if ($fileId) {
                 $newList[$fileId] = $list[$i];
                 foreach ($fileMetadata as $key => $value) {
                     EfrontSearch::insertText($value, $fileId, "files", "data");
                 }
             }
         }
     }
     return $newList;
 }
Ejemplo n.º 11
0
 /**
  * Create a new question
  *
  * This function is used to create a new question
  * <br/>Example:
  * <code>
  * $fields = array('text' => 'new questions', 'type' => 'multiple_one', 'content_ID' => 10);
  * $question = Question :: createQuestion($fields);
  * </code>
  *
  * @param array $question The new question attributes
  * @return Question the new question object or false
  * @since 3.5.0
  * @access public
  * @static
  */
 public static function createQuestion($question)
 {
     !isset($question['difficulty']) ? $question['difficulty'] = 'medium' : null;
     if ($newId = eF_insertTableData("questions", $question)) {
         EfrontSearch::insertText(eF_addSlashes($question['text']), $newId, "questions", "title");
         return QuestionFactory::factory($newId);
     } else {
         return false;
     }
 }
Ejemplo n.º 12
0
             }
         }
         foreach ($results_filesystem as $key => $value) {
             $keep = false;
             foreach ($paths as $path) {
                 if (strpos($value['path'], $path) !== false) {
                     $keep = true;
                 }
             }
             if (!$keep) {
                 unset($results_filesystem[$key]);
             }
         }
     }
     foreach ($results_filesystem as $key => $value) {
         $results_filesystem[$key]['content'] = EfrontSearch::resultsTextLimit($value['content'], $cr, 'resultsText', 500);
     }
 }
 //highlight_search(word_limiter(substr($text,strpos($text, "Breathing"),1000), 20), $cr);
 $smarty->assign("T_SEARCH_RESULTS_USERS", $results_users);
 $smarty->assign("T_SEARCH_RESULTS", $search_results_data);
 $smarty->assign("T_SEARCH_RESULTS_LESSONS", $search_results_lessons);
 $smarty->assign("T_LESSON_NAMES", $lesson_names);
 $smarty->assign("T_SEARCH_RESULTS_CURRENT_LESSON", $search_results_current_lesson);
 $smarty->assign("T_CURRENT_LESSON_NAME", $current_lesson_name);
 $smarty->assign("T_SEARCH_RESULTS_FORUM", $search_results_forum);
 $smarty->assign("T_SEARCH_RESULTS_PERSONAL_MESSAGES", $search_results_pmsgs);
 $smarty->assign("T_SEARCH_RESULTS_COURSES", $search_results_courses);
 $smarty->assign("T_SEARCH_RESULTS_FILES", $search_results_files);
 $smarty->assign("T_SEARCH_RESULTS_GLOSSARY", $search_results_glossary);
 $smarty->assign("T_SEARCH_RESULTS_FILESYSTEM", $results_filesystem);
Ejemplo n.º 13
0
 /**
  * 
  * @param $fields
  * @return unknown_type
  */
 public static function create($fields = array())
 {
     $new_id = eF_insertTableData("f_poll", $fields);
     EfrontSearch::insertText($fields['title'], $new_id, "f_poll", "title");
     if (mb_strlen($fields['question']) > 3) {
         EfrontSearch::insertText(strip_tags($fields['question']), $new_id, "f_poll", "data");
     }
     $post_lesson_id = $post_lesson_name = null;
     $result = eF_getTableData("lessons l, f_forums f", "l.id,l.name", "l.id=f.lessons_ID and f.id={$fields['f_forums_ID']}");
     if (!empty($result)) {
         $post_lesson_id = $result[0]['id'];
         $post_lesson_name = $result[0]['name'];
     }
     // Timelines add event
     EfrontEvent::triggerEvent(array("type" => EfrontEvent::NEW_POLL, "users_LOGIN" => $_SESSION['s_login'], "lessons_ID" => $post_lesson_id, "lessons_name" => $post_lesson_name, "entity_ID" => $new_id, "entity_name" => $fields['title']));
 }