Ejemplo n.º 1
0
 public function saveMap()
 {
     $saveMap = $this->userInputObject->get('save_map');
     $mapName = $this->userInputObject->get('save_map_as');
     if ($saveMap && !empty($mapName)) {
         $fieldMapping = $this->userInputObject->get('field_mapping');
         $fileReader = Import_Utils::getFileReader($this->userInputObject, $this->user);
         if ($fileReader == null) {
             return false;
         }
         $hasHeader = $fileReader->hasHeader();
         if ($hasHeader) {
             $firstRowData = $fileReader->getFirstRowData($hasHeader);
             $headers = array_keys($firstRowData);
             foreach ($fieldMapping as $fieldName => $index) {
                 $saveMapping["{$headers[$index]}"] = $fieldName;
             }
         } else {
             $saveMapping = array_flip($fieldMapping);
         }
         $map = array();
         $map['name'] = $mapName;
         $map['content'] = $saveMapping;
         $map['module'] = $this->userInputObject->get('module');
         $map['has_header'] = $hasHeader ? 1 : 0;
         $map['assigned_user_id'] = $this->user->id;
         $importMap = new Import_Map($map, $this->user);
         $importMap->save();
     }
 }
Ejemplo n.º 2
0
	public static function deleteMap($userInputObject, $user) {
		$adb = PearDatabase::getInstance();
		$moduleName = $userInputObject->get('module');
		$mapId = $userInputObject->get('mapid');
		Import_Map::markAsDeleted($mapId);

		$viewer = new Import_UI_Viewer();
		$viewer->assign('FOR_MODULE', $moduleName);
		$viewer->assign('SAVED_MAPS', Import_Map::getAllByModule($moduleName));
		echo $viewer->fetch('Import_Saved_Maps.tpl');
	}
Ejemplo n.º 3
0
 public static function getAllByModule($moduleName)
 {
     global $current_user;
     $adb = PearDatabase::getInstance();
     $result = $adb->pquery('SELECT * FROM ' . self::$tableName . ' WHERE deleted=0 AND module=?', array($moduleName));
     $noOfMaps = $adb->num_rows($result);
     $savedMaps = array();
     for ($i = 0; $i < $noOfMaps; ++$i) {
         $importMap = Import_Map::getInstanceFromDb($adb->query_result_rowdata($result, $i), $current_user);
         $savedMaps[$importMap->getId()] = $importMap;
     }
     return $savedMaps;
 }