*/
-
-require_once ('bin/cli.php');
+require_once('bin/cli.php');
require_once 'CRM/Core/BAO/Tag.php';
/**
die("you need to profide a csv file (1st column parent name, 2nd tag name");
}
$this->file = $this->args[0];
- $this->tags = array_flip(CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE)));
+ $this->tags = array_flip(CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', ['onlyActive' => FALSE]));
}
//format expected: parent name, tag
echo "\n- exists already: " . $param['name'];
return;
}
- $key = array('tag' => '');
+ $key = ['tag' => ''];
if ($param['parent']) {
if (array_key_exists($param['parent'], $this->tags)) {
$param['parent_id'] = $this->tags[$param['parent']];
}
- else $param['parent_id'] = $this->addTag(array(parent => '', name => $param['parent']));
+ else {
+ $param['parent_id'] = $this->addTag([
+ parent => '',
+ name => $param['parent'],
+ ]);
+ }
$tag = CRM_Core_BAO_Tag::add($param, $key);
echo "\n" . $tag->id . ": create " . $param['name'] . " below " . $param['parent'];
}
require_once 'Console/Getopt.php';
$shortOptions = "n:p:k:pre";
- $longOptions = array('name=', 'pass=', 'key=', 'prefix=');
+ $longOptions = ['name=', 'pass=', 'key=', 'prefix='];
$getopt = new Console_Getopt();
$args = $getopt->readPHPArgv();
array_shift($args);
list($valid, $dontCare) = $getopt->getopt2($args, $shortOptions, $longOptions);
- $vars = array(
+ $vars = [
'name' => 'n',
'pass' => 'p',
'key' => 'k',
'prefix' => 'pre',
- );
+ ];
foreach ($vars as $var => $short) {
$$var = NULL;
$dao = &CRM_Core_DAO::executeQuery($query);
$updateQuery = "UPDATE civicrm_phone SET phone = %1 where id = %2";
- $params = array(1 => array('', 'String'),
- 2 => array(0, 'Integer'),
- );
+ $params = [
+ 1 => ['', 'String'],
+ 2 => [0, 'Integer'],
+ ];
$totalPhone = $validPhone = $nonPrefixedPhone = 0;
while ($dao->fetch()) {
$newPhone = processPhone($dao->phone, $prefix);
* Scrape all config options from the CKEditor documentation site.
*/
$content = file_get_contents('http://docs.ckeditor.com/?print=/api/CKEDITOR.config');
-$matches = $output = array();
+$matches = $output = [];
preg_match_all("#name expandable'>([^<]+)</a>\s?:\s?(.*)<span.*'short'>([\s\S]*?)</div>#", $content, $matches);
foreach ($matches[1] as $i => $name) {
- $output[] = array(
+ $output[] = [
'id' => $name,
'type' => strip_tags($matches[2][$i]),
- 'description' => str_replace(array("\n", '. ...'), array(' ', '.'), $matches[3][$i]),
- );
+ 'description' => str_replace(["\n", '. ...'], [' ', '.'], $matches[3][$i]),
+ ];
}
if ($output) {
$location = str_replace('tools/bin/scripts', '', __DIR__);
/**
* A PHP shell script
-
- On drupal if you have a symlink to your civi module, don't forget to create a new file - settings_location.php
- Enter the following code (substitute the actual location of your <drupal root>/sites directory)
- <?php
- define( 'CIVICRM_CONFDIR', '/var/www/drupal.6/sites' );
- ?>
-
+ *
+ * On drupal if you have a symlink to your civi module, don't forget to create a new file - settings_location.php
+ * Enter the following code (substitute the actual location of your <drupal root>/sites directory)
+ * <?php
+ * define( 'CIVICRM_CONFDIR', '/var/www/drupal.6/sites' );
+ * ?>
*/
$include_path = "../packages/:" . get_include_path();
set_include_path($include_path);
// set_include_path( $include_path );
require_once 'Console/Getopt.php';
$shortOptions = "s:u:p:k:";
- $longOptions = array('site=', 'user', 'pass');
+ $longOptions = ['site=', 'user', 'pass'];
$getopt = new Console_Getopt();
$args = $getopt->readPHPArgv();
array_shift($args);
list($valid, $this->args) = $getopt->getopt2($args, $shortOptions, $longOptions);
- $vars = array(
+ $vars = [
'user' => 'u',
'pass' => 'p',
'key' => 'k',
'site' => 's',
- );
+ ];
foreach ($vars as $var => $short) {
$$var = NULL;
$_SERVER['PHP_SELF'] = "/index.php";
$_SERVER['HTTP_HOST'] = $this->site;
$_REQUEST['key'] = $this->key;
- require_once ("./civicrm.config.php");
+ require_once("./civicrm.config.php");
}
}
$config = CRM_Core_Config::singleton();
$cache = CRM_Utils_Cache::singleton();
-$cache->set('CRM_Core_Config' .CRM_Core_Config::domainID(), $config);
+$cache->set('CRM_Core_Config' . CRM_Core_Config::domainID(), $config);
CRM_Core_Error::debug('get', $cache->get('CRM_Core_Config' . CRM_Core_Config::domainID()));
echo "Changing version from $oldVersion to $newVersion...\n";
$verName = makeVerName($newVersion);
-$phpFile = initFile("CRM/Upgrade/Incremental/php/{$verName}.php", function() use ($verName) {
+$phpFile = initFile("CRM/Upgrade/Incremental/php/{$verName}.php", function () use ($verName) {
ob_start();
global $camelNumber;
$camelNumber = $verName;
return ob_get_clean();
});
-$sqlFile = initFile("CRM/Upgrade/Incremental/sql/{$newVersion}.mysql.tpl", function() use ($newVersion) {
+$sqlFile = initFile("CRM/Upgrade/Incremental/sql/{$newVersion}.mysql.tpl", function () use ($newVersion) {
return "{* file to handle db changes in $newVersion during upgrade *}\n";
});
<?php
-require_once '../civicrm.config.php'; require_once 'CRM/Core/Config.php';
+require_once '../civicrm.config.php';
+require_once 'CRM/Core/Config.php';
require_once 'CRM/Core/Error.php';
$config = CRM_Core_Config::singleton();
exit();
$xmlProcessor->run(104, 1, 'Substance Abuse', '15 Day Review');
-$params = array('clientID' => 104,
+$params = [
+ 'clientID' => 104,
'creatorID' => 108,
'standardTimeline' => 1,
'activityTypeName' => 'Open Case',
'dueDateTime' => time(),
'caseID' => 1,
-);
+];
require_once 'CRM/Case/XMLProcessor/Process.php';
$xmlProcessor = new CRM_Case_XMLProcessor_Process();
*/
-
/*
* This script recaches the display_name and sort_name values
*
function __construct() {
// you can run this program either from an apache command, or from the cli
if (php_sapi_name() == "cli") {
- require_once ("cli.php");
+ require_once("cli.php");
$cli = new civicrm_cli();
//if it doesn't die, it's authenticated
}
$prefixes = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id');
$suffixes = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id');
- $tokens = array();
+ $tokens = [];
CRM_Utils_Hook::tokens($tokens);
- $tokenFields = array();
+ $tokenFields = [];
foreach ($tokens as $category => $catTokens) {
foreach ($catTokens as $token) {
$tokenFields[] = $token;
while ($dao->fetch()) {
$contactID = $dao->id;
- $params = array('first_name' => $dao->first_name,
+ $params = [
+ 'first_name' => $dao->first_name,
'middle_name' => $dao->middle_name,
'last_name' => $dao->last_name,
'prefix_id' => $dao->prefix_id,
'suffix_id' => $dao->suffix_id,
- );
+ ];
$params['individual_prefix'] = $prefixes[$dao->prefix_id];
$params['individual_suffix'] = $suffixes[$dao->suffix_id];
* Implementation of hook_enable
*/
function civicrm_webtest_enable() {
- user_role_grant_permissions(1, array(
+ user_role_grant_permissions(1, [
'access CiviMail subscribe/unsubscribe pages',
'access all custom data',
'access uploaded files',
'profile create',
'profile view',
'register for events',
- ));
+ ]);
$roles = user_roles();
if (!in_array('civicrm_webtest_user', $roles)) {
$role->name = 'civicrm_webtest_user';
user_role_save($role);
$rid = $role->rid;
- } else {
+ }
+ else {
$rid = array_search('civicrm_webtest_user', $roles);
}
- user_role_grant_permissions($rid, array(
+ user_role_grant_permissions($rid, [
// FIXME: whoa, why do we bother with users if both need admin rights?
- 'access AJAX API',
+ 'access AJAX API',
// 'access all cases and activities',
- 'access all custom data',
- 'access CiviContribute',
- 'access CiviCRM',
- 'access CiviEvent',
- // 'access CiviGrant',
- 'access CiviMail',
- 'access CiviMail subscribe/unsubscribe pages',
- 'access CiviMember',
- 'access CiviPledge',
- 'access CiviReport',
- 'access Contact Dashboard',
- 'access contact reference fields',
- 'access deleted contacts',
- // 'access my cases and activities',
- 'access Report Criteria',
- 'save Report Criteria',
- 'access uploaded files',
- // 'add cases',
- 'add contacts',
- // 'administer CiviCase',
- 'administer CiviCRM',
- 'administer dedupe rules',
- 'administer Reports',
- 'administer reserved groups',
- 'administer reserved reports',
- 'administer reserved tags',
- 'administer Tagsets',
- 'delete activities',
- 'delete contacts',
- // 'delete in CiviCase',
- 'delete in CiviContribute',
- 'delete in CiviEvent',
- // 'delete in CiviGrant',
- 'delete in CiviMail',
- 'delete in CiviMember',
- 'delete in CiviPledge',
- 'edit all contacts',
- 'view my contact',
- 'edit my contact',
- 'edit all events',
- 'edit contributions',
- 'edit event participants',
- 'edit message templates',
- // 'edit grants',
- 'edit groups',
- 'edit memberships',
- 'edit pledges',
- 'import contacts',
- 'make online contributions',
- 'manage tags',
- 'merge duplicate contacts',
- 'profile create',
- 'profile edit',
- 'profile listings',
- 'profile listings and forms',
- 'profile view',
- 'register for events',
- 'translate CiviCRM',
- 'view all activities',
- 'view all contacts',
- 'view all notes',
- 'view event info',
- 'view event participants',
- 'view public CiviMail content',
- 'administer payment processors',
- 'create manual batch',
- 'edit own manual batches',
- 'edit all manual batches',
- 'view own manual batches',
- 'view all manual batches',
- 'delete own manual batches',
- 'delete all manual batches',
- 'export own manual batches',
- 'export all manual batches',
- ));
+ 'access all custom data',
+ 'access CiviContribute',
+ 'access CiviCRM',
+ 'access CiviEvent',
+ // 'access CiviGrant',
+ 'access CiviMail',
+ 'access CiviMail subscribe/unsubscribe pages',
+ 'access CiviMember',
+ 'access CiviPledge',
+ 'access CiviReport',
+ 'access Contact Dashboard',
+ 'access contact reference fields',
+ 'access deleted contacts',
+ // 'access my cases and activities',
+ 'access Report Criteria',
+ 'save Report Criteria',
+ 'access uploaded files',
+ // 'add cases',
+ 'add contacts',
+ // 'administer CiviCase',
+ 'administer CiviCRM',
+ 'administer dedupe rules',
+ 'administer Reports',
+ 'administer reserved groups',
+ 'administer reserved reports',
+ 'administer reserved tags',
+ 'administer Tagsets',
+ 'delete activities',
+ 'delete contacts',
+ // 'delete in CiviCase',
+ 'delete in CiviContribute',
+ 'delete in CiviEvent',
+ // 'delete in CiviGrant',
+ 'delete in CiviMail',
+ 'delete in CiviMember',
+ 'delete in CiviPledge',
+ 'edit all contacts',
+ 'view my contact',
+ 'edit my contact',
+ 'edit all events',
+ 'edit contributions',
+ 'edit event participants',
+ 'edit message templates',
+ // 'edit grants',
+ 'edit groups',
+ 'edit memberships',
+ 'edit pledges',
+ 'import contacts',
+ 'make online contributions',
+ 'manage tags',
+ 'merge duplicate contacts',
+ 'profile create',
+ 'profile edit',
+ 'profile listings',
+ 'profile listings and forms',
+ 'profile view',
+ 'register for events',
+ 'translate CiviCRM',
+ 'view all activities',
+ 'view all contacts',
+ 'view all notes',
+ 'view event info',
+ 'view event participants',
+ 'view public CiviMail content',
+ 'administer payment processors',
+ 'create manual batch',
+ 'edit own manual batches',
+ 'edit all manual batches',
+ 'view own manual batches',
+ 'view all manual batches',
+ 'delete own manual batches',
+ 'delete all manual batches',
+ 'export own manual batches',
+ 'export all manual batches',
+ ]);
}
*/
function _angularex_civix_civicrm_config(&$config = NULL) {
static $configured = FALSE;
- if ($configured) return;
+ if ($configured) {
+ return;
+ }
$configured = TRUE;
$template =& CRM_Core_Smarty::singleton();
- $extRoot = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
+ $extRoot = dirname(__FILE__) . DIRECTORY_SEPARATOR;
$extDir = $extRoot . 'templates';
- if ( is_array( $template->template_dir ) ) {
- array_unshift( $template->template_dir, $extDir );
- } else {
- $template->template_dir = array( $extDir, $template->template_dir );
+ if (is_array($template->template_dir)) {
+ array_unshift($template->template_dir, $extDir);
+ }
+ else {
+ $template->template_dir = [$extDir, $template->template_dir];
}
- $include_path = $extRoot . PATH_SEPARATOR . get_include_path( );
- set_include_path( $include_path );
+ $include_path = $extRoot . PATH_SEPARATOR . get_include_path();
+ set_include_path($include_path);
}
/**
function _angularex_civix_civicrm_enable() {
_angularex_civix_civicrm_config();
if ($upgrader = _angularex_civix_upgrader()) {
- if (is_callable(array($upgrader, 'onEnable'))) {
+ if (is_callable([$upgrader, 'onEnable'])) {
return $upgrader->onEnable();
}
}
function _angularex_civix_civicrm_disable() {
_angularex_civix_civicrm_config();
if ($upgrader = _angularex_civix_upgrader()) {
- if (is_callable(array($upgrader, 'onDisable'))) {
+ if (is_callable([$upgrader, 'onDisable'])) {
return $upgrader->onDisable();
}
}
* @return CRM_Angularex_Upgrader
*/
function _angularex_civix_upgrader() {
- if (!file_exists(__DIR__.'/CRM/Angularex/Upgrader.php')) {
+ if (!file_exists(__DIR__ . '/CRM/Angularex/Upgrader.php')) {
return NULL;
- } else {
+ }
+ else {
return CRM_Angularex_Upgrader_Base::instance();
}
}
* @return array(string)
*/
function _angularex_civix_find_files($dir, $pattern) {
- if (is_callable(array('CRM_Utils_File', 'findFiles'))) {
+ if (is_callable(['CRM_Utils_File', 'findFiles'])) {
return CRM_Utils_File::findFiles($dir, $pattern);
}
- $todos = array($dir);
- $result = array();
+ $todos = [$dir];
+ $result = [];
while (!empty($todos)) {
$subdir = array_shift($todos);
foreach (_angularex_civix_glob("$subdir/$pattern") as $match) {
while (FALSE !== ($entry = readdir($dh))) {
$path = $subdir . DIRECTORY_SEPARATOR . $entry;
if ($entry{0} == '.') {
- } elseif (is_dir($path)) {
+ }
+ elseif (is_dir($path)) {
$todos[] = $path;
}
}
CRM_Core_Error::fatal($errorMessage);
// throw new CRM_Core_Exception($errorMessage);
}
- $caseTypes[$name] = array(
+ $caseTypes[$name] = [
'module' => 'org.civicrm.angularex',
'name' => $name,
'file' => $file,
- );
+ ];
}
}
*/
function _angularex_civix_glob($pattern) {
$result = glob($pattern);
- return is_array($result) ? $result : array();
+ return is_array($result) ? $result : [];
}
/**
// If we are done going down the path, insert menu
if (empty($path)) {
- if (!$navId) $navId = CRM_Core_DAO::singleValueQuery("SELECT max(id) FROM civicrm_navigation");
- $navId ++;
- $menu[$navId] = array (
- 'attributes' => array_merge($item, array(
- 'label' => CRM_Utils_Array::value('name', $item),
- 'active' => 1,
- 'parentID' => $parentId,
- 'navID' => $navId,
- ))
- );
- return true;
- } else {
+ if (!$navId) {
+ $navId = CRM_Core_DAO::singleValueQuery("SELECT max(id) FROM civicrm_navigation");
+ }
+ $navId++;
+ $menu[$navId] = [
+ 'attributes' => array_merge($item, [
+ 'label' => CRM_Utils_Array::value('name', $item),
+ 'active' => 1,
+ 'parentID' => $parentId,
+ 'navID' => $navId,
+ ]),
+ ];
+ return TRUE;
+ }
+ else {
// Find an recurse into the next level down
- $found = false;
+ $found = FALSE;
$path = explode('/', $path);
$first = array_shift($path);
foreach ($menu as $key => &$entry) {
if ($entry['attributes']['name'] == $first) {
- if (!$entry['child']) $entry['child'] = array();
+ if (!$entry['child']) {
+ $entry['child'] = [];
+ }
$found = _angularex_civix_insert_navigation_menu($entry['child'], implode('/', $path), $item, $key);
}
}
*/
function _angularex_civix_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) {
static $configured = FALSE;
- if ($configured) return;
+ if ($configured) {
+ return;
+ }
$configured = TRUE;
$settingsDir = __DIR__ . DIRECTORY_SEPARATOR . 'settings';
- if(is_dir($settingsDir) && !in_array($settingsDir, $metaDataFolders)) {
+ if (is_dir($settingsDir) && !in_array($settingsDir, $metaDataFolders)) {
$metaDataFolders[] = $settingsDir;
}
}
* @param $angularModule
*/
function angularex_civicrm_angularModules(&$angularModule) {
- $angularModule['example'] = array(
+ $angularModule['example'] = [
'ext' => 'org.civicrm.angularex',
- 'js' => array('js/*.js'),
- 'partials' => array('partials'),
- );
+ 'js' => ['js/*.js'],
+ 'partials' => ['partials'],
+ ];
}
const QUEUE_NAME = 'demo-queue';
function run() {
- $queue = CRM_Queue_Service::singleton()->create(array(
+ $queue = CRM_Queue_Service::singleton()->create([
'type' => 'Sql',
'name' => self::QUEUE_NAME,
'reset' => TRUE,
- ));
+ ]);
for ($i = 0; $i < 5; $i++) {
$queue->createItem(new CRM_Queue_Task(
- array('CRM_Demoqueue_Page_DemoQueue', 'doMyWork'), // callback
- array($i, "Task $i takes $i second(s)"), // arguments
+ ['CRM_Demoqueue_Page_DemoQueue', 'doMyWork'], // callback
+ [$i, "Task $i takes $i second(s)"], // arguments
"Task $i" // title
));
if ($i == 2) {
$queue->createItem(new CRM_Queue_Task(
- array('CRM_Demoqueue_Page_DemoQueue', 'addMoreWork'), // callback
- array(), // arguments
+ ['CRM_Demoqueue_Page_DemoQueue', 'addMoreWork'], // callback
+ [], // arguments
"Add More Work" // title
));
}
}
- $runner = new CRM_Queue_Runner(array(
+ $runner = new CRM_Queue_Runner([
'title' => ts('Demo Queue Runner'),
'queue' => $queue,
- 'onEnd' => array('CRM_Demoqueue_Page_DemoQueue', 'onEnd'),
+ 'onEnd' => ['CRM_Demoqueue_Page_DemoQueue', 'onEnd'],
'onEndUrl' => CRM_Utils_System::url('civicrm/demo-queue/done'),
- ));
+ ]);
$runner->runAllViaWeb(); // does not return
}
sleep(1);
for ($i = 0; $i < 5; $i++) {
$ctx->queue->createItem(new CRM_Queue_Task(
- array('CRM_Demoqueue_Page_DemoQueue', 'doMyWork'), // callback
- array($i, "Extra task $i takes $i second(s)"), // arguments
+ ['CRM_Demoqueue_Page_DemoQueue', 'doMyWork'], // callback
+ [$i, "Extra task $i takes $i second(s)"], // arguments
"Extra Task $i" // title
- ), array(
+ ), [
'weight' => -1,
- ));
+ ]);
}
return TRUE; // success
}
* Class CRM_Demoqueue_Page_DemoQueueDone
*/
class CRM_Demoqueue_Page_DemoQueueDone extends CRM_Core_Page {
- function run() {
- // Example: Set the page-title dynamically; alternatively, declare a static title in xml/Menu/*.xml
- CRM_Utils_System::setTitle(ts('DemoQueueDone'));
- parent::run();
- }
+ function run() {
+ // Example: Set the page-title dynamically; alternatively, declare a static title in xml/Menu/*.xml
+ CRM_Utils_System::setTitle(ts('DemoQueueDone'));
+ parent::run();
+ }
}
function _demoqueue_civix_civicrm_config(&$config) {
$template =& CRM_Core_Smarty::singleton();
- $extRoot = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
+ $extRoot = dirname(__FILE__) . DIRECTORY_SEPARATOR;
$extDir = $extRoot . 'templates';
- if ( is_array( $template->template_dir ) ) {
- array_unshift( $template->template_dir, $extDir );
- } else {
- $template->template_dir = array( $extDir, $template->template_dir );
+ if (is_array($template->template_dir)) {
+ array_unshift($template->template_dir, $extDir);
+ }
+ else {
+ $template->template_dir = [$extDir, $template->template_dir];
}
- $include_path = $extRoot . PATH_SEPARATOR . get_include_path( );
- set_include_path( $include_path );
+ $include_path = $extRoot . PATH_SEPARATOR . get_include_path();
+ set_include_path($include_path);
}
/**
global $civicrm_root;
$realArgs = $argv;
$diffCmd = FALSE;
-$files = array();
+$files = [];
array_shift($realArgs);
foreach ($realArgs as $arg) {
echo "File \"$file\" appears to have consistency issues. Created $newFile.\n";
file_put_contents($newFile, $newMarkup);
if ($diffCmd) {
- passthru($diffCmd . ' ' . escapeshellarg($file) . ' ' . escapeshellarg($newFile));
+ passthru($diffCmd . ' ' . escapeshellarg($file) . ' ' . escapeshellarg($newFile));
}
}
-}
\ No newline at end of file
+}
<?php
-$options = getopt('bc:ht:'); if (isset($options['h'])) {
+$options = getopt('bc:ht:');
+if (isset($options['h'])) {
print ("\nUsage: php civimail-spooler.php [-bh] [-c <config>] [-t <period>]\n");
print (" -b Run this process continuously\n");
print (" -c Path to CiviCRM civicrm.settings.php\n");
* process into the background and provide init.d scripts */
-
CRM_Mailing_BAO_MailingJob::runJobs();
sleep($config->mailerPeriod);
}
function &splitContactIDs(&$contactIDs) {
// contactIDs could be a real large array, so we split it up into
// smaller chunks and then general xml for each chunk
- $chunks = array();
- $current = 0;
- $chunks[$current] = array();
- $count = 0;
+ $chunks = [];
+ $current = 0;
+ $chunks[$current] = [];
+ $count = 0;
foreach ($contactIDs as $cid) {
$chunks[$current][] = $cid;
if ($count == CHUNK_SIZE) {
$current++;
- $chunks[$current] = array();
+ $chunks[$current] = [];
$count = 0;
}
}
foreach ($tokens as $n => $v) {
if (is_array($v)) {
- $str = array();
+ $str = [];
foreach ($v as $el) {
$el = escapeJsonString($el);
$str[] = "\"$el\"";
* @return mixed
*/
function escapeJsonString($value) {
- $escapers = array("\\", "/", "\"", "\n", "\r", "\t", "\x08", "\x0c");
- $replacements = array("\\\\", "\\/", "\\\"", "\\n", "\\r", "\\t", "\\f", "\\b");
+ $escapers = ["\\", "/", "\"", "\n", "\r", "\t", "\x08", "\x0c"];
+ $replacements = ["\\\\", "\\/", "\\\"", "\\n", "\\r", "\\t", "\\f", "\\b"];
return str_replace($escapers, $replacements, $value);
}
* @return array
*/
function getValues(&$contactIDs, &$values) {
- $values = array();
+ $values = [];
foreach ($contactIDs as $cid) {
- $values[$cid] = array();
+ $values[$cid] = [];
}
getContactInfo($contactIDs, $values);
* @param $values
*/
function getContactInfo(&$contactIDs, &$values) {
- $fields = array('sort_name' => NULL,
+ $fields = [
+ 'sort_name' => NULL,
'display_name' => NULL,
'contact_type' => NULL,
'legal_identifier' => NULL,
'organization_name' => NULL,
'legal_name' => NULL,
'job_title' => NULL,
- );
+ ];
getTableInfo($contactIDs, $values, 'civicrm_contact', $fields, 'id');
}
WHERE c.id IN ( $ids )
";
- $fields = array('location_type', 'street_address', 'supplemental_address_1',
- 'supplemental_address_2', 'supplemental_address_3', 'city', 'postal_code',
- 'state', 'country',
- );
+ $fields = [
+ 'location_type',
+ 'street_address',
+ 'supplemental_address_1',
+ 'supplemental_address_2',
+ 'supplemental_address_3',
+ 'city',
+ 'postal_code',
+ 'state',
+ 'country',
+ ];
$dao = &CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
$address = '';
else {
if (!is_array($values[$contactID][$name])) {
$save = $values[$contactID][$name];
- $values[$contactID][$name] = array();
+ $values[$contactID][$name] = [];
$values[$contactID][$name][] = $save;
}
$values[$contactID][$name][] = $value;
$chunks = &splitContactIDs($contactIDs);
foreach ($chunks as $chunk) {
- $values = array();
+ $values = [];
getValues($chunk, $values);
$xml = &generateSolrJSON($values);
echo $xml;
$dao = &CRM_Core_DAO::executeQuery($sql);
-$contactIDs = array();
+$contactIDs = [];
while ($dao->fetch()) {
$contactIDs[] = $dao->id;
}
function &splitContactIDs(&$contactIDs) {
// contactIDs could be a real large array, so we split it up into
// smaller chunks and then general xml for each chunk
- $chunks = array();
- $current = 0;
- $chunks[$current] = array();
- $count = 0;
+ $chunks = [];
+ $current = 0;
+ $chunks[$current] = [];
+ $count = 0;
foreach ($contactIDs as $cid) {
$chunks[$current][] = $cid;
if ($count == CHUNK_SIZE) {
$current++;
- $chunks[$current] = array();
+ $chunks[$current] = [];
$count = 0;
}
}
* @return array
*/
function getValues(&$contactIDs, &$values) {
- $values = array();
+ $values = [];
foreach ($contactIDs as $cid) {
- $values[$cid] = array();
+ $values[$cid] = [];
}
getContactInfo($contactIDs, $values);
if (!$name) {
$name = $fld;
}
- $values[$dao->contact_id][] = array($name, $dao->$fld);
+ $values[$dao->contact_id][] = [$name, $dao->$fld];
}
}
}
* @param $values
*/
function getContactInfo(&$contactIDs, &$values) {
- $fields = array('sort_name' => NULL,
+ $fields = [
+ 'sort_name' => NULL,
'display_name' => NULL,
'contact_type' => NULL,
'legal_identifier' => NULL,
'external_identifier' => NULL,
'source' => 'contact_source',
- );
+ ];
getTableInfo($contactIDs, $values, 'civicrm_contact', $fields, 'id');
- $fields = array('first_name' => NULL,
+ $fields = [
+ 'first_name' => NULL,
'last_name' => NULL,
'middle_name' => NULL,
'job_title' => NULL,
- );
+ ];
getTableInfo($contactIDs, $values, 'civicrm_individual', $fields, 'contact_id');
- $fields = array('household_name' => NULL);
+ $fields = ['household_name' => NULL];
getTableInfo($contactIDs, $values, 'civicrm_household', $fields, 'contact_id');
- $fields = array('organization_name' => NULL,
+ $fields = [
+ 'organization_name' => NULL,
'legal_name' => NULL,
'sic_code' => NULL,
- );
+ ];
getTableInfo($contactIDs, $values, 'civicrm_organization', $fields, 'contact_id');
- $fields = array('note' => 'note_body',
+ $fields = [
+ 'note' => 'note_body',
'subject' => 'note_subject',
- );
+ ];
getTableInfo($contactIDs, $values, 'civicrm_note', $fields, 'entity_id', "entity_table = 'civicrm_contact'");
}
AND l.entity_id IN ( $ids )
";
- $fields = array('location_name', 'street_address', 'supplemental_address_1',
- 'supplemental_address_2', 'supplemental_address_3', 'city', 'postal_code', 'county', 'state',
- 'country', 'email', 'phone', 'im',
- );
+ $fields = [
+ 'location_name',
+ 'street_address',
+ 'supplemental_address_1',
+ 'supplemental_address_2',
+ 'supplemental_address_3',
+ 'city',
+ 'postal_code',
+ 'county',
+ 'state',
+ 'country',
+ 'email',
+ 'phone',
+ 'im',
+ ];
$dao = CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
foreach ($fields as $fld) {
if (empty($dao->$fld)) {
continue;
}
- $values[$dao->contact_id][] = array($fld, $dao->$fld);
+ $values[$dao->contact_id][] = [$fld, $dao->$fld];
}
}
}
$chunks = &splitContactIDs($contactIDs);
foreach ($chunks as $chunk) {
- $values = array();
+ $values = [];
getValues($chunk, $values);
$xml = &generateSolrXML($values);
echo $xml;
EOT;
$dao = CRM_Core_DAO::executeQuery($sql);
-$contactIDs = array();
+$contactIDs = [];
while ($dao->fetch()) {
$contactIDs[] = $dao->id;
}
function &splitContactIDs(&$contactIDs) {
// contactIDs could be a real large array, so we split it up into
// smaller chunks and then general xml for each chunk
- $chunks = array();
- $current = 0;
- $chunks[$current] = array();
- $count = 0;
+ $chunks = [];
+ $current = 0;
+ $chunks[$current] = [];
+ $count = 0;
foreach ($contactIDs as $k => $v) {
$chunks[$current][$k] = $v;
if ($count == CHUNK_SIZE) {
$current++;
- $chunks[$current] = array();
+ $chunks[$current] = [];
$count = 0;
}
}
* @return array
*/
function getValues(&$contactIDs, &$values, &$allContactIDs, &$addditionalContactIDs) {
- $values = array();
+ $values = [];
getContactInfo($contactIDs, $values);
getAddressInfo($contactIDs, $values);
* @param bool $flat
*/
function getTableInfo(&$contactIDs, &$values, $tableName, &$fields,
- $whereField, $additionalWhereCond = NULL,
- $flat = FALSE
+ $whereField, $additionalWhereCond = NULL,
+ $flat = FALSE
) {
$selectString = implode(',', array_keys($fields));
$idString = implode(',', $contactIDs);
$dao = &CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
- $contact = array();
+ $contact = [];
foreach ($fields as $fld => $name) {
$name = $name ? $name : $fld;
if (empty($dao->$fld)) {
* @param $values
*/
function getContactInfo(&$contactIDs, &$values) {
- $fields = array('id' => NULL,
+ $fields = [
+ 'id' => NULL,
'sort_name' => NULL,
'display_name' => NULL,
'contact_type' => NULL,
'organization_name' => NULL,
'legal_name' => NULL,
'job_title' => NULL,
- );
+ ];
getTableInfo($contactIDs, $values, 'civicrm_contact', $fields, 'id', NULL, TRUE);
}
$dao = &CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
- $note = array('id' => $dao->id,
+ $note = [
+ 'id' => $dao->id,
'contact_id' => $dao->contact_id,
'subject' => empty($dao->subject) ? NULL : $dao->subject,
'note' => empty($dao->note) ? NULL : $dao->note,
- );
+ ];
appendValue($values, $dao->id, 'note', $note);
}
$dao = &CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
- $phone = array('id' => $dao->id,
+ $phone = [
+ 'id' => $dao->id,
'contact_id' => $dao->contact_id,
'location_type' => empty($dao->location_type) ? NULL : $dao->location_type,
'phone' => $dao->phone,
'phone_type' => empty($dao->phone_type) ? NULL : $dao->phone_type,
- );
+ ];
appendValue($values, $dao->id, 'phone', $phone);
}
$dao = &CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
- $email = array('id' => $dao->id,
+ $email = [
+ 'id' => $dao->id,
'contact_id' => $dao->contact_id,
'location_type' => empty($dao->location_type) ? NULL : $dao->location_type,
'email' => $dao->email,
- );
+ ];
appendValue($values, $dao->id, 'email', $email);
}
$dao->free();
WHERE c.id IN ( $ids )
";
- $fields = array('id', 'contact_id',
- 'location_type', 'street_address', 'supplemental_address_1',
- 'supplemental_address_2', 'supplemental_address_3', 'city', 'postal_code',
- 'state', 'country',
- );
+ $fields = [
+ 'id',
+ 'contact_id',
+ 'location_type',
+ 'street_address',
+ 'supplemental_address_1',
+ 'supplemental_address_2',
+ 'supplemental_address_3',
+ 'city',
+ 'postal_code',
+ 'state',
+ 'country',
+ ];
$dao = &CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
- $address = array();
+ $address = [];
foreach ($fields as $fld) {
if (empty($dao->$fld)) {
$address[$fld] = NULL;
*/
function getRelationshipInfo(&$contactIDs, &$values, &$allContactIDs, &$additionalContacts) {
// handle relationships only once
- static $_relationshipsHandled = array();
+ static $_relationshipsHandled = [];
$ids = implode(',', $contactIDs);
";
$relationshipFields = getDBFields('CRM_Contact_DAO_Relationship');
- $fields = array_keys($relationshipFields);
- $dao = &CRM_Core_DAO::executeQuery($sql);
+ $fields = array_keys($relationshipFields);
+ $dao = &CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
if (isset($_relationshipsHandled[$dao->id])) {
continue;
}
$_relationshipsHandled[$dao->id] = $dao->id;
- $relationship = array();
+ $relationship = [];
foreach ($fields as $fld) {
if (empty($dao->$fld)) {
$relationship[$fld] = NULL;
}
appendValue($values, $dao->id, 'relationship', $relationship);
- addAdditionalContacts(array($dao->contact_id_a,
- $dao->contact_id_b,
- ),
+ addAdditionalContacts([
+ $dao->contact_id_a,
+ $dao->contact_id_b,
+ ],
$allContactIDs, $additionalContacts
);
}
* @param $additionalContacts
*/
function getActivityInfo(&$contactIDs, &$values, &$allContactIDs, &$additionalContacts) {
- static $_activitiesHandled = array();
+ static $_activitiesHandled = [];
$ids = implode(',', $contactIDs);
$activityFields = &getDBFields('CRM_Activity_DAO_Activity');
$fields = array_keys($activityFields);
- $activityIDs = array();
+ $activityIDs = [];
$dao = &CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
if (isset($_activitiesHandled[$dao->id])) {
$_activitiesHandled[$dao->id] = $dao->id;
$activityIDs[] = $dao->id;
- $activity = array();
+ $activity = [];
foreach ($fields as $fld) {
if (empty($dao->$fld)) {
$activity[$fld] = NULL;
}
appendValue($values, $dao->id, 'activity', $activity);
- addAdditionalContacts(array($dao->source_contact_id),
+ addAdditionalContacts([$dao->source_contact_id],
$allContactIDs, $additionalContacts
);
}
$activityIDString = implode(",", $activityIDs);
// now get all assignee contact ids and target contact ids for this activity
- $sql = "SELECT * FROM civicrm_activity_assignment WHERE activity_id IN ($activityIDString)";
- $aaDAO = &CRM_Core_DAO::executeQuery($sql);
- $activityContacts = array();
+ $sql = "SELECT * FROM civicrm_activity_assignment WHERE activity_id IN ($activityIDString)";
+ $aaDAO = &CRM_Core_DAO::executeQuery($sql);
+ $activityContacts = [];
while ($aaDAO->fetch()) {
- $activityAssignee = array('id' => $aaDAO->id,
+ $activityAssignee = [
+ 'id' => $aaDAO->id,
'assignee_contact_id' => $aaDAO->assignee_contact_id,
'activity_id' => $aaDAO->activity_id,
- );
+ ];
appendValue($values, $aaDAO->id, 'activity_assignment', $activityAssignee);
$activityContacts[] = $aaDAO->assignee_contact_id;
}
$sql = "SELECT * FROM civicrm_activity_target WHERE activity_id IN ($activityIDString)";
$atDAO = &CRM_Core_DAO::executeQuery($sql);
while ($atDAO->fetch()) {
- $activityTarget = array('id' => $atDAO->id,
+ $activityTarget = [
+ 'id' => $atDAO->id,
'target_contact_id' => $atDAO->target_contact_id,
'activity_id' => $atDAO->activity_id,
- );
+ ];
appendValue($values, $atDAO->id, 'activity_target', $activityTarget);
$activityContacts[] = $atDAO->target_contact_id;
}
}
if (!isset($values[$name])) {
- $values[$name] = array();
+ $values[$name] = [];
$values[$name][] = array_keys($value);
}
$values[$name][] = array_values($value);
* @return mixed
*/
function getDBFields($daoName) {
- static $_fieldsRetrieved = array();
+ static $_fieldsRetrieved = [];
if (!isset($_fieldsRetrieved[$daoName])) {
- $_fieldsRetrieved[$daoName] = array();
+ $_fieldsRetrieved[$daoName] = [];
$daoFile = str_replace('_',
- DIRECTORY_SEPARATOR,
- $daoName
- ) . '.php';
- include_once ($daoFile);
+ DIRECTORY_SEPARATOR,
+ $daoName
+ ) . '.php';
+ include_once($daoFile);
$daoFields = &$daoName::fields();
require_once 'CRM/Utils/Array.php';
foreach ($daoFields as $key => & $value) {
- $_fieldsRetrieved[$daoName][$value['name']] = array('uniqueName' => $key,
+ $_fieldsRetrieved[$daoName][$value['name']] = [
+ 'uniqueName' => $key,
'type' => $value['type'],
'title' => CRM_Utils_Array::value('title', $value, NULL),
- );
+ ];
}
}
return $_fieldsRetrieved[$daoName];
function run(&$values, &$contactIDs, &$allContactIDs) {
$chunks = &splitContactIDs($contactIDs);
- $additionalContactIDs = array();
+ $additionalContactIDs = [];
foreach ($chunks as $chunk) {
getValues($chunk, $values, $allContactIDs, $additionalContactIDs);
$dao = &CRM_Core_DAO::executeQuery($sql);
-$contactIDs = array();
+$contactIDs = [];
while ($dao->fetch()) {
$contactIDs[$dao->id] = $dao->id;
}
-$values = array();
+$values = [];
run($values, $contactIDs, $contactIDs);
$json = json_encode($values);
// FIXME: Make this a proper app with unit-tests
-$civi_pkgs_dir = dirname( dirname( dirname( __FILE__ ) ) ) . DIRECTORY_SEPARATOR . 'packages';
+$civi_pkgs_dir = dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'packages';
require_once $civi_pkgs_dir . DIRECTORY_SEPARATOR . 'simple_html_dom.php';
exit(main($argv));
$files = $argv;
array_shift($files); // skip program name
foreach ($files as $file) {
- check_tpl($file, function($code, $message) use ($file) {
+ check_tpl($file, function ($code, $message) use ($file) {
printf("[%s] %s\n", $file, $message);
});
}