X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=bin%2Fcli.class.php;h=de72c475b41673eb7f3297a250fd035059de530d;hb=a29a45d40bad75f52f1a13ecc63cc16c220171cb;hp=e69d25fa88130b2f416abd818c5f34b4e55388a6;hpb=68d36190d340137a13c51ce84613fa6e6cff9c11;p=civicrm-core.git diff --git a/bin/cli.class.php b/bin/cli.class.php index e69d25fa88..de72c475b4 100644 --- a/bin/cli.class.php +++ b/bin/cli.class.php @@ -1,7 +1,7 @@ register(); $this->_config = CRM_Core_Config::singleton(); + + // HTTP_HOST will be 'localhost' unless overwritten with the -s argument. + // Now we have a Config object, we can set it from the Base URL. + if ($_SERVER['HTTP_HOST'] == 'localhost') { + $_SERVER['HTTP_HOST'] = preg_replace( + '!^https?://([^/]+)/$!i', + '$1', + $this->_config->userFrameworkBaseURL); + } $class = 'CRM_Utils_System_' . $this->_config->userFramework; $cms = new $class(); - if (!CRM_Utils_System::loadBootstrap(array( - ), FALSE, FALSE, $civicrm_root)) { + if (!CRM_Utils_System::loadBootstrap(array(), FALSE, FALSE, $civicrm_root)) { $this->_log(ts("Failed to bootstrap CMS")); return FALSE; } @@ -299,6 +310,13 @@ class civicrm_cli_csv_exporter extends civicrm_cli { fputcsv($out, $columns, $this->separator, '"'); $first = false; } + //handle values returned as arrays (i.e. custom fields that allow multiple selections) by inserting a control character + foreach ($row as &$field) { + if(is_array($field)) { + //convert to string + $field = implode($field,CRM_Core_DAO::VALUE_SEPARATOR) . CRM_Core_DAO::VALUE_SEPARATOR; + } + } fputcsv($out, $row, $this->separator, '"'); } fclose($out); @@ -360,6 +378,11 @@ class civicrm_cli_csv_file extends civicrm_cli { function convertLine($data) { $params = array(); foreach ($this->header as $i => $field) { + //split any multiselect data, denoted with CRM_Core_DAO::VALUE_SEPARATOR + if (strpos($data[$i], CRM_Core_DAO::VALUE_SEPARATOR) !== FALSE) { + $data[$i] = explode(CRM_Core_DAO::VALUE_SEPARATOR,$data[$i]); + $data[$i] = array_combine($data[$i], $data[$i]); + } $params[$field] = $data[$i]; } $params['version'] = 3;