X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;ds=sidebyside;f=bin%2Fcli.class.php;h=10bb27db0d472a27bd73a111659237aed45e8e18;hb=1284e6407f58a0822d740f8a00e75bdf34525cc2;hp=9d23e4dd7e8bd78321955497dcc948c91c4ed9f1;hpb=d36b8b20ac964dc3c0a74f98f580dc7b0ad7383e;p=civicrm-core.git diff --git a/bin/cli.class.php b/bin/cli.class.php index 9d23e4dd7e..10bb27db0d 100644 --- a/bin/cli.class.php +++ b/bin/cli.class.php @@ -21,7 +21,7 @@ | GNU Affero General Public License or the licensing of CiviCRM, | | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ -*/ + */ /** * This files provides several classes for doing command line work with @@ -30,12 +30,12 @@ * In addition, there are several additional classes that inherit * civicrm_cli to do more precise functions. * - **/ + */ /** * base class for doing all command line operations via civicrm * used by cli.php - **/ + */ class civicrm_cli { // required values that must be passed // via the command line @@ -307,23 +307,24 @@ class civicrm_cli { // that properly logs print "$error\n"; } + } /** * class used by csv/export.php to export records from * the database in a csv file format. - **/ + */ class civicrm_cli_csv_exporter extends civicrm_cli { var $separator = ','; /** */ - function __construct() { + public function __construct() { $this->_required_arguments = array('entity'); parent::initialize(); } - function run() { + public function run() { $out = fopen("php://output", 'w'); fputcsv($out, $this->columns, $this->separator, '"'); @@ -348,6 +349,7 @@ class civicrm_cli_csv_exporter extends civicrm_cli { fclose($out); echo "\n"; } + } /** @@ -355,20 +357,20 @@ class civicrm_cli_csv_exporter extends civicrm_cli { * and civicrm_cli_csv_deleter to add or delete * records based on those found in a csv file * passed to the script. - **/ + */ class civicrm_cli_csv_file extends civicrm_cli { var $header; var $separator = ','; /** */ - function __construct() { + public function __construct() { $this->_required_arguments = array('entity', 'file'); $this->_additional_arguments = array('f' => 'file'); parent::initialize(); } - function run() { + public function run() { $this->row = 1; $handle = fopen($this->_file, "r"); @@ -400,7 +402,7 @@ class civicrm_cli_csv_file extends civicrm_cli { $this->processLine($params); } fclose($handle); - return; + return NULL; } /* return a params as expected */ @@ -409,7 +411,7 @@ class civicrm_cli_csv_file extends civicrm_cli { * * @return array */ - function convertLine($data) { + public function convertLine($data) { $params = array(); foreach ($this->header as $i => $field) { //split any multiselect data, denoted with CRM_Core_DAO::VALUE_SEPARATOR @@ -422,18 +424,19 @@ class civicrm_cli_csv_file extends civicrm_cli { $params['version'] = 3; return $params; } + } /** * class for processing records to add * used by csv/import.php * - **/ + */ class civicrm_cli_csv_importer extends civicrm_cli_csv_file { /** * @param array $params */ - function processline($params) { + public function processline($params) { $result = civicrm_api($this->_entity, 'Create', $params); if ($result['is_error']) { echo "\nERROR line " . $this->row . ": " . $result['error_message'] . "\n"; @@ -442,18 +445,19 @@ class civicrm_cli_csv_importer extends civicrm_cli_csv_file { echo "\nline " . $this->row . ": created " . $this->_entity . " id: " . $result['id'] . "\n"; } } + } /** * class for processing records to delete * used by csv/delete.php * - **/ + */ class civicrm_cli_csv_deleter extends civicrm_cli_csv_file { /** * @param array $params */ - function processline($params) { + public function processline($params) { $result = civicrm_api($this->_entity, 'Delete', $params); if ($result['is_error']) { echo "\nERROR line " . $this->row . ": " . $result['error_message'] . "\n"; @@ -462,4 +466,5 @@ class civicrm_cli_csv_deleter extends civicrm_cli_csv_file { echo "\nline " . $this->row . ": deleted\n"; } } + }