Beispiel #1
0
 /**
  * @see ProjectInterface::get_all_status_array()
  * @return array
  */
 public function get_all_status_array()
 {
     global $runtime_data;
     if ($this->project_id and $this->project) {
         if ($runtime_data->is_object_data($this, "PROJECT_ALL_STATUS_ARRAY") == true) {
             return $runtime_data->read_object_data($this, "PROJECT_ALL_STATUS_ARRAY");
         } else {
             $return_array = array();
             $project_template = new ProjectTemplate($this->project->get_template_id());
             $all_status_array = $project_template->get_all_status();
             if (is_array($all_status_array) and count($all_status_array) >= 1) {
                 $project_canceled = false;
                 $status_found = false;
                 $datetime = null;
                 foreach ($all_status_array as $key => $value) {
                     $temp_array = array();
                     $project_has_status_array = ProjectHasProjectStatus_Access::list_entries_by_project_id($this->project_id);
                     if (is_array($project_has_status_array) and count($project_has_status_array) >= 1) {
                         foreach ($project_has_status_array as $status_key => $status_value) {
                             $project_has_project_status = new ProjectHasProjectStatus_Access($status_value);
                             if ($status_found == true and $datetime == null) {
                                 $datetime = $project_has_project_status->get_datetime();
                             }
                             if ($project_has_project_status->get_status_id() == $value) {
                                 $status_found = true;
                             }
                             if ($project_has_project_status->get_status_id() == 0) {
                                 $project_canceled = true;
                             }
                         }
                     }
                     $temp_array['id'] = $value;
                     $status_attribute_array = $project_template->get_status_attributes($value);
                     if ($status_attribute_array['requirement'] == "optional") {
                         $temp_array['optional'] = true;
                     } else {
                         $temp_array['optional'] = false;
                     }
                     if ($status_found == true) {
                         if ($datetime == null) {
                             $temp_array['datetime'] = date("Y-m-d H:i:s");
                         } else {
                             $temp_array['datetime'] = $datetime;
                             $datetime = null;
                         }
                         if ($project_canceled == true) {
                             $temp_array['status'] = 3;
                         } else {
                             $temp_array['status'] = 1;
                         }
                         if (($last_element = array_pop($return_array)) != null) {
                             $last_element['status'] = 2;
                             array_push($return_array, $last_element);
                         }
                         $status_found = false;
                         $datetime = null;
                     } else {
                         $temp_array['status'] = 0;
                     }
                     array_push($return_array, $temp_array);
                 }
                 if ($this->get_current_status_id() == 2) {
                     if (($last_element = array_pop($return_array)) != null) {
                         $last_element['status'] = 2;
                         array_push($return_array, $last_element);
                     }
                 }
                 $runtime_data->write_object_data($this, "PROJECT_ALL_STATUS_ARRAY", $return_array);
                 return $return_array;
             } else {
                 return null;
             }
         }
     } else {
         return null;
     }
 }