public static function getChildIDs($objective_id)
 {
     global $db;
     $objective_ids = array();
     $query = "SELECT `objective_id` FROM `global_lu_objectives` WHERE `objective_parent` = " . $db->qstr($objective_id);
     $child_ids = $db->GetAll($query);
     if ($child_ids) {
         foreach ($child_ids as $child_id) {
             $objective_ids[] = $child_id["objective_id"];
             $grandchild_ids = Models_Objective::getChildIDs($child_id["objective_id"]);
             if ($grandchild_ids) {
                 foreach ($grandchild_ids as $grandchild_id) {
                     $objective_ids[] = $grandchild_id;
                 }
             }
         }
     }
     return $objective_ids;
 }
Exemple #2
0
 public function addObjective($objective_id, $participation_level)
 {
     global $ENTRADA_USER;
     if (!$this->attachedObjectiveIsDuplicate($objective_id)) {
         $objective = Models_Objective::fetchRow($objective_id);
         if ($objective) {
             $objective_array = array();
             $objective_array["objective"] = $objective;
             $objective_array["objective_id"] = $objective_id;
             $objective_array["lentry_id"] = $this->getID();
             $objective_array["participation_level"] = $participation_level;
             $objective_array["updated_date"] = time();
             $objective_array["updated_by"] = $ENTRADA_USER->getID();
             $objective_array["objective_active"] = 1;
             $entry_objective = new Models_Logbook_Entry_Objective();
             $this->objectives[] = $entry_objective->fromArray($objective_array);
             return $entry_objective;
         }
     }
     return false;
 }
 }
 /**
  * Non-required field "comments" / Comments.
  */
 if (isset($_POST["comments"]) && ($comments = clean_input($_POST["comments"], array("trim", "notags")))) {
     $PROCESSED["comments"] = $comments;
 } else {
     $PROCESSED["comments"] = "";
 }
 $PROCESSED["objectives"] = array();
 /**
  * Non-required field "objectives" / objectives
  */
 if (is_array($_POST["objectives"]) && count($_POST["objectives"]) && @count($_POST["objectives"]) == @count($_POST["obj_participation_level"])) {
     foreach ($_POST["objectives"] as $objective_id) {
         $objective = Models_Objective::fetchRow($objective_id);
         if ($objective) {
             $objective_array = array();
             $objective_array["objective"] = $objective;
             $objective_array["objective_id"] = $objective_id;
             $objective_array["lentry_id"] = isset($entry_id) && $entry_id ? $entry_id : NULL;
             $objective_array["participation_level"] = isset($_POST["obj_participation_level"][$objective_id]) && $_POST["obj_participation_level"][$objective_id] ? $_POST["obj_participation_level"][$objective_id] : 3;
             $objective_array["updated_date"] = time();
             $objective_array["updated_by"] = $ENTRADA_USER->getID();
             $objective_array["objective_active"] = 1;
             $entry_objective = new Models_Logbook_Entry_Objective();
             $PROCESSED["objectives"][$objective_id] = $entry_objective->fromArray($objective_array);
         }
     }
 }
 if (!$ERROR) {
 public function getAllRequiredObjectivesMobile($course_id = false)
 {
     global $db;
     if (!$course_id) {
         $course_id = $this->getCourseID();
     }
     $objectives = array();
     $query = "SELECT `objective_id` FROM `course_objectives`\n                    " . ($course_id ? "WHERE `course_id` = " . $db->qstr($course_id) : "");
     $objective_ids = $db->GetAll($query);
     if ($objective_ids) {
         $objective_ids_array = $objective_ids;
         foreach ($objective_ids as $objective_id) {
             $objective = Models_Objective::fetchRow($objective_id["objective_id"]);
             if ($objective) {
                 $descendant_ids = Models_Objective::getChildIDs($objective_id["objective_id"]);
                 foreach ($descendant_ids as $descendant_id) {
                     $descendant = Models_Objective::fetchRow($descendant_id);
                     if ($descendant && $descendant->getLoggable() && !Models_Objective::getChildIDs($descendant_id)) {
                         $objectives[$descendant->getID()] = $descendant->toArray();
                     }
                 }
                 if (!$descendant_ids && $objective->getLoggable()) {
                     $objectives[$objective->getID()] = $objective->toArray();
                 }
             }
         }
     }
     return $objectives;
 }
 public static function fetchRow($leobjective_id = 0)
 {
     global $db;
     $entry_objective = false;
     $query = "SELECT * FROM `logbook_entry_objectives` WHERE `leobjective_id` = ?";
     $result = $db->GetRow($query, array($leobjective_id));
     if ($result) {
         if ($result["objective_id"]) {
             $result["objective"] = Models_Objective::fetchRow($result["objective_id"]);
         }
         $leo = new self();
         $entry_objective = $ao->fromArray($result);
     }
     return $entry_objective;
 }