Ejemplo n.º 1
0
 /**
  * Delete course
  *
  * This function is used to delete the current course. It also
  * removes the course from the succession information of other
  * courses
  * <br/>Example:
  * <code>
  * $course -> delete();
  * </code>
  *
  * @since 3.5.0
  * @access public
  * @todo remove from other courses succession
  */
 public function delete()
 {
     $this->removeLessons(array_keys($this->getCourseLessons()));
     $courseUsers = eF_getTableDataFlat("users_to_courses", "users_LOGIN", "courses_ID=" . $this->course['id']);
     $this->removeUsers($courseUsers["users_LOGIN"]);
     $this->deleteCourseInstances();
     $this->removeCourseSkills();
     $this->deleteUniqueLessons();
     calendar::deleteCourseCalendarEvents($this);
     eF_deleteTableData("courses", "id=" . $this->course['id']);
     if (G_VERSIONTYPE == 'enterprise') {
         #cpp#ifdef ENTERPRISE
         eF_deleteTableData("module_hcd_course_to_job_description", "courses_ID =" . $this->course['id']);
         eF_deleteTableData("module_hcd_course_to_branch", "courses_ID =" . $this->course['id']);
     }
     #cpp#endif
     eF_updateTableData("courses", array("depends_on" => 0), "depends_on = " . $this->course['id']);
     $modules = eF_loadAllModules();
     foreach ($modules as $module) {
         $module->onDeleteCourse($this->course['id']);
     }
     EfrontSearch::removeText('courses', $this->course['id'], '');
 }
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");
 }
Ejemplo n.º 4
0
 /**
  * Delete unit
  *
  * This function is used to delete the current unit.
  * <br/>Example:
  * <code>
  * $unit -> delete();
  * </code>
  *
  * @return boolean true if everything is ok
  * @since 3.5.0
  * @access public
  */
 public function delete()
 {
     if ($this['ctg_type'] == 'tests' || $this['ctg_type'] == 'feedback') {
         $result = eF_getTableData("tests", "id, content_ID", "content_ID=" . $this['id']);
         if (sizeof($result) > 0) {
             $test = new EfrontTest($result[0]);
             $test->delete();
         }
     }
     $result = eF_getTableData("lesson_conditions", "*", "lessons_ID=" . $this['lessons_ID']);
     foreach ($result as $value) {
         $conditionOptions = unserialize($value['options']);
         if (($value['type'] == 'specific_unit' || $condition['type'] == 'specific_test') && $conditionOptions[0] == $this['id']) {
             eF_deleteTableData("lesson_conditions", "id=" . $value['id']);
         }
     }
     eF_deleteTableData("content", "id=" . $this['id']);
     //Delete Unit from database
     EfrontCache::getInstance()->deleteCache("content_tree:{$this['lessons_ID']}");
     eF_deleteTableData("scorm_data", "content_ID=" . $this['id']);
     //Delete Unit from scorm_data
     eF_deleteTableData("comments", "content_ID=" . $this['id']);
     //Delete comments of this unit
     eF_deleteTableData("users_to_content", "content_ID=" . $this['id']);
     //Delete time data for the unit
     eF_deleteTableData("rules", "content_ID=" . $this['id'] . " OR rule_content_ID=" . $this['id']);
     //Delete rules associated with this unit
     eF_updateTableData("questions", array("content_ID" => 0), "content_ID=" . $this['id']);
     //Remove association of questions with this unit but not delete them
     EfrontSearch::removeText('content', $this['id'], '');
     //Delete keywords
     //Delete scorm data related to the unit
     if (G_VERSIONTYPE != 'community') {
         #cpp#ifndef COMMUNITY
         if (G_VERSIONTYPE != 'standard') {
             #cpp#ifndef STANDARD
             EfrontContentTreeSCORM::deleteSCORMContentOrganization($this['id']);
         }
         #cpp#endif
     }
     #cpp#endif
 }
Ejemplo n.º 5
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.º 6
0
 /**
  * Persist file values
  *
  * This function is used to persist any changed values
  * of the file.
  * <br/>Example:
  * <code>
  * $file = new EfrontFile(43);                                  //Instantiate file object
  * $file -> file['description'] = 'New description';            //Change a file's property
  * $file -> persist();                                          //Persist changes
  * </code>
  *
  * @return boolean true if everything is ok
  * @since 3.5.0
  * @access public
  */
 public function persist()
 {
     $fields = array('path' => str_replace(G_ROOTPATH, '', $this['path']), 'description' => $this['description'], 'groups_ID' => $this['groups_ID'], 'access' => $this['access'], 'shared' => $this['shared'], 'metadata' => $this['metadata']);
     $ok = eF_updateTableData("files", $fields, "id=" . $this['id']);
     EfrontSearch::removeText('files', $this['id'], 'data');
     $fileMetadataArray = unserialize($this['metadata']);
     foreach ($fileMetadataArray as $key => $value) {
         EfrontSearch::insertText($value, $this['id'], "files", "data");
     }
     return $ok;
 }
Ejemplo n.º 7
0
 /**
  * (non-PHPdoc)
  * @see libraries/EfrontEntity#persist()
  */
 public function persist()
 {
     parent::persist();
     EfrontSearch::removeText('f_poll', $this->{$this->entity}['id'], 'title');
     EfrontSearch::insertText($fields['title'], $this->{$this->entity}['id'], "f_poll", "title");
 }