public function testSaveMappingFileSavesNumberFieldAssociationCorrectly() { $lead = new Lead(); $importSource = new ImportFile($this->testFile, ',', '', false); $importer = new Bug61172TestImporterMock($importSource, $lead); $importer->saveMappingFile(); $mappingFile = new ImportMap(); $mappingFile->retrieve_by_string_fields(array('name' => $_REQUEST['save_map_as'])); $this->assertNotEmpty($mappingFile->content); $contentFields = explode('&', $mappingFile->content); $this->assertContains('1=status', $contentFields, "Field status should be associated with #1"); $mappingFile->mark_deleted($mappingFile->id); }
function mark_published($user_id, $flag) { $other_map = new ImportMap(); if ($flag == 'yes') { // if you are trying to publish your map // but there's another published map // by the same name $query_arr = array('name' => $this->name, 'is_published' => 'yes'); } else { // if you are trying to unpublish a map // but you own an unpublished map by the same name $query_arr = array('name' => $this->name, 'assigned_user_id' => $user_id, 'is_published' => 'no'); } $other_map->retrieve_by_string_fields($query_arr, false); if (isset($other_map->id)) { //.. don't do it! return -1; } $query = "UPDATE {$this->table_name} set is_published='{$flag}', assigned_user_id='{$user_id}' where id='" . $this->id . "'"; $this->db->query($query, true, "Error marking import map published: "); return 1; }
/** * Mark an import map as published * * @param string $user_id * @param bool $flag true if we are publishing or false if we are unpublishing * @return bool */ public function mark_published($user_id, $flag) { global $current_user; if (!is_admin($current_user)) { return false; } // check for problems if ($flag) { // if you are trying to publish your map // but there's another published map // by the same name $query_arr = array('name' => $this->name, 'is_published' => 'yes'); } else { // if you are trying to unpublish a map // but you own an unpublished map by the same name $query_arr = array('name' => $this->name, 'assigned_user_id' => $user_id, 'is_published' => 'no'); } $other_map = new ImportMap(); $other_map->retrieve_by_string_fields($query_arr, false); // if we find this other map, quit if (isset($other_map->id)) { return false; } // otherwise update the is_published flag $query = "UPDATE {$this->table_name}\n SET is_published = '" . ($flag ? 'yes' : 'no') . "',\n assigned_user_id = '{$user_id}'\n WHERE id = '{$this->id}'"; $this->db->query($query, true, "Error marking import map published: "); return true; }