Ejemplo n.º 1
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.º 2
0
 $smarty->assign("T_SKILLGAP_TEST", $skillgap_tests);
 //If we asked to edit the test using the Unit id, then convert to Test id and assign to $_GET['edit_test']
 if (isset($_GET['edit']) && in_array($_GET['edit'], $legalUnits)) {
     $unit = new EfrontUnit($_GET['edit']);
     if ($unit->isTest()) {
         $test = new EfrontTest($_GET['edit'], true);
         $_GET['edit_test'] = $test->test['id'];
     }
 }
 if (isset($_GET['delete_test']) && in_array($_GET['delete_test'], $legalValues) && eF_checkParameter($_GET['delete_test'], 'id')) {
     try {
         if (!$_change_) {
             throw new EfrontUserException(_UNAUTHORIZEDACCESS, EfrontUserException::RESTRICTED_USER_TYPE);
         }
         $currentTest = new EfrontTest($_GET['delete_test']);
         $currentTest->delete();
     } catch (Exception $e) {
         header("HTTP/1.0 500 ");
         echo $e->getMessage() . ' (' . $e->getCode() . ')';
     }
     exit;
 } elseif (isset($_GET['publish_test']) && in_array($_GET['publish_test'], $legalValues) && eF_checkParameter($_GET['publish_test'], 'id')) {
     try {
         if (!$_change_) {
             throw new EfrontUserException(_UNAUTHORIZEDACCESS, EfrontUserException::RESTRICTED_USER_TYPE);
         }
         $currentTest = new EfrontTest($_GET['publish_test']);
         $currentTest->test['publish'] == true ? $currentTest->test['publish'] = 0 : ($currentTest->test['publish'] = 1);
         $currentTest->persist();
         echo $currentTest->test['publish'];
     } catch (Exception $e) {