예제 #1
0
 /**
  * ReMaps hierarchy levels so they always start from 1 and don't have any gaps.
  * @param array $data hierarchy_level data
  * @return array
  */
 function ReMapHierarchyLevels($data)
 {
     //Debug::Arr($data, ' aHierarchy Level Data: ', __FILE__, __LINE__, __METHOD__,10);
     $remapped_levels = HierarchyLevelFactory::ReMapHierarchyLevels($data);
     //Debug::Arr($remapped_levels, ' ReMapped Levels: ', __FILE__, __LINE__, __METHOD__,10);
     foreach ($data as $key => $arr) {
         $data[$key]['level'] = $remapped_levels[$arr['level']];
     }
     Debug::Arr($data, ' ReMapped Hierarchy Level Data: ', __FILE__, __LINE__, __METHOD__, 10);
     return $this->returnHandler($data);
 }
 $hcf->setName($hierarchy_control_data['name']);
 $hcf->setDescription($hierarchy_control_data['description']);
 if ($hcf->isValid()) {
     $hc_id = $hcf->Save(FALSE);
     if ($hc_id === TRUE) {
         $hc_id = $hierarchy_control_data['id'];
     }
     Debug::Text('Hierarchy Control ID: ' . $hc_id, __FILE__, __LINE__, __METHOD__, 10);
     if (isset($hierarchy_control_data['user_ids'])) {
         $hcf->setUser($hierarchy_control_data['user_ids']);
     } else {
         $hcf->setUser(array());
     }
     if (count($hierarchy_level_data) > 0) {
         //ReMap levels
         $hierarchy_level_map = $hlf->ReMapHierarchyLevels($hierarchy_level_data);
         Debug::Arr($hierarchy_level_map, 'Hierarchy Level Map: ', __FILE__, __LINE__, __METHOD__, 10);
         foreach ($hierarchy_level_data as $hierarchy_level_id => $hierarchy_level) {
             Debug::Text('Row ID: ' . $hierarchy_level_id . ' Level: ' . $hierarchy_level['level'], __FILE__, __LINE__, __METHOD__, 10);
             if ($hierarchy_level['level'] != '' and $hierarchy_level['level'] >= 0 and isset($hierarchy_level_map[$hierarchy_level['level']])) {
                 if ($hierarchy_level_id > 0) {
                     $hlf->setID($hierarchy_level_id);
                 }
                 $hlf->setHierarchyControl($hc_id);
                 $hlf->setLevel($hierarchy_level_map[$hierarchy_level['level']]);
                 $hlf->setUser($hierarchy_level['user_id']);
                 if ($hlf->isValid()) {
                     Debug::Text('Saving Level Row ID: ' . $hierarchy_level_id, __FILE__, __LINE__, __METHOD__, 10);
                     $hlf->Save();
                 } else {
                     $redirect++;