示例#1
0
 /**
  * @see ProjectInterface::get_status_requirements()
  * @param integer $status_id
  * @return array
  */
 public function get_status_requirements($status_id)
 {
     if ($this->project_id and $this->project and is_numeric($status_id)) {
         $project_template = new ProjectTemplate($this->project->get_template_id());
         $status_attribute_array = $project_template->get_status_attributes($status_id);
         $requirements_array = $project_template->get_status_requirements($status_id);
         if ($status_attribute_array['requirement'] == "optional") {
             $requirement_default = "optional";
         } else {
             $requirement_default = "force";
         }
         $return_array = array();
         $counter = 0;
         $type_counter = 0;
         if (is_array($requirements_array) and count($requirements_array) >= 1) {
             foreach ($requirements_array as $key => $value) {
                 if ($value['xml_element'] == "item" and !$value['close']) {
                     $in_item = true;
                     $return_array[$counter]['type'] = $value['type'];
                     $return_array[$counter]['name'] = $value['name'];
                     if ($value['requirement'] and $status_attribute_array['requirement'] != "optional") {
                         $return_array[$counter]['requirement'] = $value['requirement'];
                     } else {
                         $return_array[$counter]['requirement'] = $requirement_default;
                     }
                     if ($value['occurrence']) {
                         $return_array[$counter]['occurrence'] = $value['occurrence'];
                     } else {
                         $return_array[$counter]['occurrence'] = "once";
                     }
                 }
                 if ($value['xml_element'] == "item" and $value['close'] == "1") {
                     $counter++;
                     $type_counter = 0;
                     $in_item = false;
                 }
                 if ($value['xml_element'] == "type" and !$value['close'] and $in_item == true and is_numeric($value['id'])) {
                     $return_array[$counter]['type_id'][$type_counter] = $value['id'];
                     $type_counter++;
                 }
             }
         }
         return $return_array;
     } else {
         return null;
     }
 }