X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=bin%2Fcli.class.php;h=d64802efb5f56dbc512cc819264046988ee7b95f;hb=4f99ca551bc52520216559a918d84915fc992338;hp=c9215ec8619acbab2a66e44fecfc3482abc4ba0f;hpb=3838662faff56daff7b4fbbd25c60a4b7242a484;p=civicrm-core.git diff --git a/bin/cli.class.php b/bin/cli.class.php index c9215ec861..d64802efb5 100644 --- a/bin/cli.class.php +++ b/bin/cli.class.php @@ -1,7 +1,7 @@ _joblog = TRUE; } else { - while(list($short, $long) = each ($this->_additional_arguments)) { + while (list($short, $long) = each($this->_additional_arguments)) { if ($arg == '-' . $short || $arg == '--' . $long) { $property = '_' . $long; $this->$property = $value; @@ -211,7 +211,7 @@ class civicrm_cli { $civicrm_root = dirname(__DIR__); chdir($civicrm_root); - require_once ('civicrm.config.php'); + require_once 'civicrm.config.php'; // autoload if ( !class_exists('CRM_Core_ClassLoader') ) { require_once $civicrm_root . '/CRM/Core/ClassLoader.php'; @@ -223,7 +223,7 @@ class civicrm_cli { // 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( + $_SERVER['HTTP_HOST'] = preg_replace( '!^https?://([^/]+)/$!i', '$1', $this->_config->userFrameworkBaseURL); @@ -245,7 +245,7 @@ class civicrm_cli { } if (!empty($this->_user)) { - if(!CRM_Utils_System::authenticateScript(TRUE, $this->_user, $this->_password, TRUE, FALSE, FALSE)) { + if (!CRM_Utils_System::authenticateScript(TRUE, $this->_user, $this->_password, TRUE, FALSE, FALSE)) { $this->_log(ts("Failed to login as %1. Wrong username or password.", array('1' => $this->_user))); return FALSE; } @@ -332,18 +332,18 @@ class civicrm_cli_csv_exporter extends civicrm_cli { $this->row = 1; $result = civicrm_api($this->_entity, 'Get', $this->_params); - $first = true; + $first = TRUE; foreach ($result['values'] as $row) { - if($first) { + if ($first) { $columns = array_keys($row); fputcsv($out, $columns, $this->separator, '"'); - $first = false; + $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)) { + if (is_array($field)) { //convert to string - $field = implode($field,CRM_Core_DAO::VALUE_SEPARATOR) . CRM_Core_DAO::VALUE_SEPARATOR; + $field = implode($field, CRM_Core_DAO::VALUE_SEPARATOR) . CRM_Core_DAO::VALUE_SEPARATOR; } } fputcsv($out, $row, $this->separator, '"'); @@ -368,7 +368,7 @@ class civicrm_cli_csv_file extends civicrm_cli { * */ function __construct() { - $this->_required_arguments = array('entity','file'); + $this->_required_arguments = array('entity', 'file'); $this->_additional_arguments = array('f' => 'file'); parent::initialize(); } @@ -397,7 +397,9 @@ class civicrm_cli_csv_file extends civicrm_cli { $this->header = $header; while (($data = fgetcsv($handle, 0, $this->separator)) !== FALSE) { // skip blank lines - if(count($data) == 1 && is_null($data[0])) continue; + if (count($data) == 1 && is_null($data[0])) { + continue; + } $this->row++; $params = $this->convertLine($data); $this->processLine($params); @@ -417,7 +419,7 @@ class civicrm_cli_csv_file extends civicrm_cli { 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] = explode(CRM_Core_DAO::VALUE_SEPARATOR, $data[$i]); $data[$i] = array_combine($data[$i], $data[$i]); } $params[$field] = $data[$i]; @@ -435,7 +437,7 @@ class civicrm_cli_csv_file extends civicrm_cli { class civicrm_cli_csv_importer extends civicrm_cli_csv_file { /** - * @param $params + * @param array $params */ function processline($params) { $result = civicrm_api($this->_entity, 'Create', $params); @@ -456,13 +458,14 @@ class civicrm_cli_csv_importer extends civicrm_cli_csv_file { class civicrm_cli_csv_deleter extends civicrm_cli_csv_file { /** - * @param $params + * @param array $params */ function processline($params) { $result = civicrm_api($this->_entity, 'Delete', $params); if ($result['is_error']) { echo "\nERROR line " . $this->row . ": " . $result['error_message'] . "\n"; - } else { + } + else { echo "\nline " . $this->row . ": deleted\n"; } }