mirror of
https://codeberg.org/artfulrobot/contactcats.git
synced 2025-06-25 21:48:05 +02:00
initial commit
This commit is contained in:
commit
3b393be4f4
16 changed files with 1594 additions and 0 deletions
7
CRM/Contactcats/BAO/ContactCategory.php
Normal file
7
CRM/Contactcats/BAO/ContactCategory.php
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
use CRM_Contactcats_ExtensionUtil as E;
|
||||
|
||||
class CRM_Contactcats_BAO_ContactCategory extends CRM_Contactcats_DAO_ContactCategory {
|
||||
|
||||
}
|
197
CRM/Contactcats/DAO/ContactCategory.php
Normal file
197
CRM/Contactcats/DAO/ContactCategory.php
Normal file
|
@ -0,0 +1,197 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC https://civicrm.org/licensing
|
||||
*
|
||||
* Generated from contactcats/xml/schema/CRM/Contactcats/ContactCategory.xml
|
||||
* DO NOT EDIT. Generated by CRM_Core_CodeGen
|
||||
* (GenCodeChecksum:c8054b52817309c4eb67221623e1c29e)
|
||||
*/
|
||||
use CRM_Contactcats_ExtensionUtil as E;
|
||||
|
||||
/**
|
||||
* Database access object for the ContactCategory entity.
|
||||
*/
|
||||
class CRM_Contactcats_DAO_ContactCategory extends CRM_Core_DAO {
|
||||
const EXT = E::LONG_NAME;
|
||||
const TABLE_ADDED = '';
|
||||
|
||||
/**
|
||||
* Static instance to hold the table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $_tableName = 'civicrm_contact_category';
|
||||
|
||||
/**
|
||||
* Should CiviCRM log any modifications to this table in the civicrm_log table.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public static $_log = FALSE;
|
||||
|
||||
/**
|
||||
* Unique ID, corresponds to contact id
|
||||
*
|
||||
* @var int|string|null
|
||||
* (SQL type: int unsigned)
|
||||
* Note that values will be retrieved from the database as a string.
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @var int|string
|
||||
* (SQL type: int unsigned)
|
||||
* Note that values will be retrieved from the database as a string.
|
||||
*/
|
||||
public $category;
|
||||
|
||||
/**
|
||||
* @var int|string
|
||||
* (SQL type: int unsigned)
|
||||
* Note that values will be retrieved from the database as a string.
|
||||
*/
|
||||
public $next_category;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->__table = 'civicrm_contact_category';
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns localized title of this entity.
|
||||
*
|
||||
* @param bool $plural
|
||||
* Whether to return the plural version of the title.
|
||||
*/
|
||||
public static function getEntityTitle($plural = FALSE) {
|
||||
return $plural ? E::ts('Contact Categories') : E::ts('Contact Category');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the column names of this table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function &fields() {
|
||||
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
|
||||
Civi::$statics[__CLASS__]['fields'] = [
|
||||
'id' => [
|
||||
'name' => 'id',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => E::ts('ID'),
|
||||
'description' => E::ts('Unique ID, corresponds to contact id'),
|
||||
'required' => TRUE,
|
||||
'usage' => [
|
||||
'import' => FALSE,
|
||||
'export' => FALSE,
|
||||
'duplicate_matching' => FALSE,
|
||||
'token' => FALSE,
|
||||
],
|
||||
'where' => 'civicrm_contact_category.id',
|
||||
'table_name' => 'civicrm_contact_category',
|
||||
'entity' => 'ContactCategory',
|
||||
'bao' => 'CRM_Contactcats_DAO_ContactCategory',
|
||||
'localizable' => 0,
|
||||
'html' => [
|
||||
'type' => 'Number',
|
||||
],
|
||||
'readonly' => TRUE,
|
||||
'add' => NULL,
|
||||
],
|
||||
'category' => [
|
||||
'name' => 'category',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => E::ts('Category'),
|
||||
'required' => TRUE,
|
||||
'usage' => [
|
||||
'import' => FALSE,
|
||||
'export' => FALSE,
|
||||
'duplicate_matching' => FALSE,
|
||||
'token' => FALSE,
|
||||
],
|
||||
'where' => 'civicrm_contact_category.category',
|
||||
'default' => '0',
|
||||
'table_name' => 'civicrm_contact_category',
|
||||
'entity' => 'ContactCategory',
|
||||
'bao' => 'CRM_Contactcats_DAO_ContactCategory',
|
||||
'localizable' => 0,
|
||||
'html' => [
|
||||
'type' => 'Select',
|
||||
],
|
||||
'pseudoconstant' => [
|
||||
'optionGroupName' => 'ContactCategories',
|
||||
'optionEditPath' => 'civicrm/admin/options/ContactCategories',
|
||||
],
|
||||
'add' => NULL,
|
||||
],
|
||||
'next_category' => [
|
||||
'name' => 'next_category',
|
||||
'type' => CRM_Utils_Type::T_INT,
|
||||
'title' => E::ts('Next Category'),
|
||||
'required' => TRUE,
|
||||
'usage' => [
|
||||
'import' => FALSE,
|
||||
'export' => FALSE,
|
||||
'duplicate_matching' => FALSE,
|
||||
'token' => FALSE,
|
||||
],
|
||||
'where' => 'civicrm_contact_category.next_category',
|
||||
'default' => '0',
|
||||
'table_name' => 'civicrm_contact_category',
|
||||
'entity' => 'ContactCategory',
|
||||
'bao' => 'CRM_Contactcats_DAO_ContactCategory',
|
||||
'localizable' => 0,
|
||||
'pseudoconstant' => [
|
||||
'optionGroupName' => 'ContactCategories',
|
||||
'optionEditPath' => 'civicrm/admin/options/ContactCategories',
|
||||
],
|
||||
'add' => NULL,
|
||||
],
|
||||
];
|
||||
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
|
||||
}
|
||||
return Civi::$statics[__CLASS__]['fields'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of fields that can be imported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function &import($prefix = FALSE) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contact_category', $prefix, []);
|
||||
return $r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of fields that can be exported
|
||||
*
|
||||
* @param bool $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function &export($prefix = FALSE) {
|
||||
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contact_category', $prefix, []);
|
||||
return $r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of indices
|
||||
*
|
||||
* @param bool $localize
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function indices($localize = TRUE) {
|
||||
$indices = [];
|
||||
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
|
||||
}
|
||||
|
||||
}
|
138
CRM/Contactcats/Upgrader.php
Normal file
138
CRM/Contactcats/Upgrader.php
Normal file
|
@ -0,0 +1,138 @@
|
|||
<?php
|
||||
|
||||
use CRM_Contactcats_ExtensionUtil as E;
|
||||
|
||||
/**
|
||||
* Collection of upgrade steps.
|
||||
*/
|
||||
class CRM_Contactcats_Upgrader extends CRM_Extension_Upgrader_Base {
|
||||
|
||||
// By convention, functions that look like "function upgrade_NNNN()" are
|
||||
// upgrade tasks. They are executed in order (like Drupal's hook_update_N).
|
||||
|
||||
/**
|
||||
* Example: Run an external SQL script when the module is installed.
|
||||
*
|
||||
* Note that if a file is present sql\auto_install that will run regardless of this hook.
|
||||
*/
|
||||
// public function install(): void {
|
||||
// $this->executeSqlFile('sql/my_install.sql');
|
||||
// }
|
||||
|
||||
/**
|
||||
* Example: Work with entities usually not available during the install step.
|
||||
*
|
||||
* This method can be used for any post-install tasks. For example, if a step
|
||||
* of your installation depends on accessing an entity that is itself
|
||||
* created during the installation (e.g., a setting or a managed entity), do
|
||||
* so here to avoid order of operation problems.
|
||||
*/
|
||||
// public function postInstall(): void {
|
||||
// $customFieldId = civicrm_api3('CustomField', 'getvalue', array(
|
||||
// 'return' => array("id"),
|
||||
// 'name' => "customFieldCreatedViaManagedHook",
|
||||
// ));
|
||||
// civicrm_api3('Setting', 'create', array(
|
||||
// 'myWeirdFieldSetting' => array('id' => $customFieldId, 'weirdness' => 1),
|
||||
// ));
|
||||
// }
|
||||
|
||||
/**
|
||||
* Example: Run an external SQL script when the module is uninstalled.
|
||||
*
|
||||
* Note that if a file is present sql\auto_uninstall that will run regardless of this hook.
|
||||
*/
|
||||
// public function uninstall(): void {
|
||||
// $this->executeSqlFile('sql/my_uninstall.sql');
|
||||
// }
|
||||
|
||||
/**
|
||||
* Example: Run a simple query when a module is enabled.
|
||||
*/
|
||||
// public function enable(): void {
|
||||
// CRM_Core_DAO::executeQuery('UPDATE foo SET is_active = 1 WHERE bar = "whiz"');
|
||||
// }
|
||||
|
||||
/**
|
||||
* Example: Run a simple query when a module is disabled.
|
||||
*/
|
||||
// public function disable(): void {
|
||||
// CRM_Core_DAO::executeQuery('UPDATE foo SET is_active = 0 WHERE bar = "whiz"');
|
||||
// }
|
||||
|
||||
/**
|
||||
* Example: Run a couple simple queries.
|
||||
*
|
||||
* @return TRUE on success
|
||||
* @throws CRM_Core_Exception
|
||||
*/
|
||||
// public function upgrade_4200(): bool {
|
||||
// $this->ctx->log->info('Applying update 4200');
|
||||
// CRM_Core_DAO::executeQuery('UPDATE foo SET bar = "whiz"');
|
||||
// CRM_Core_DAO::executeQuery('DELETE FROM bang WHERE willy = wonka(2)');
|
||||
// return TRUE;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Example: Run an external SQL script.
|
||||
*
|
||||
* @return TRUE on success
|
||||
* @throws CRM_Core_Exception
|
||||
*/
|
||||
// public function upgrade_4201(): bool {
|
||||
// $this->ctx->log->info('Applying update 4201');
|
||||
// // this path is relative to the extension base dir
|
||||
// $this->executeSqlFile('sql/upgrade_4201.sql');
|
||||
// return TRUE;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Example: Run a slow upgrade process by breaking it up into smaller chunk.
|
||||
*
|
||||
* @return TRUE on success
|
||||
* @throws CRM_Core_Exception
|
||||
*/
|
||||
// public function upgrade_4202(): bool {
|
||||
// $this->ctx->log->info('Planning update 4202'); // PEAR Log interface
|
||||
|
||||
// $this->addTask(E::ts('Process first step'), 'processPart1', $arg1, $arg2);
|
||||
// $this->addTask(E::ts('Process second step'), 'processPart2', $arg3, $arg4);
|
||||
// $this->addTask(E::ts('Process second step'), 'processPart3', $arg5);
|
||||
// return TRUE;
|
||||
// }
|
||||
// public function processPart1($arg1, $arg2) { sleep(10); return TRUE; }
|
||||
// public function processPart2($arg3, $arg4) { sleep(10); return TRUE; }
|
||||
// public function processPart3($arg5) { sleep(10); return TRUE; }
|
||||
|
||||
/**
|
||||
* Example: Run an upgrade with a query that touches many (potentially
|
||||
* millions) of records by breaking it up into smaller chunks.
|
||||
*
|
||||
* @return TRUE on success
|
||||
* @throws CRM_Core_Exception
|
||||
*/
|
||||
// public function upgrade_4203(): bool {
|
||||
// $this->ctx->log->info('Planning update 4203'); // PEAR Log interface
|
||||
|
||||
// $minId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(min(id),0) FROM civicrm_contribution');
|
||||
// $maxId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(max(id),0) FROM civicrm_contribution');
|
||||
// for ($startId = $minId; $startId <= $maxId; $startId += self::BATCH_SIZE) {
|
||||
// $endId = $startId + self::BATCH_SIZE - 1;
|
||||
// $title = E::ts('Upgrade Batch (%1 => %2)', array(
|
||||
// 1 => $startId,
|
||||
// 2 => $endId,
|
||||
// ));
|
||||
// $sql = '
|
||||
// UPDATE civicrm_contribution SET foobar = apple(banana()+durian)
|
||||
// WHERE id BETWEEN %1 and %2
|
||||
// ';
|
||||
// $params = array(
|
||||
// 1 => array($startId, 'Integer'),
|
||||
// 2 => array($endId, 'Integer'),
|
||||
// );
|
||||
// $this->addTask($title, 'executeSql', $sql, $params);
|
||||
// }
|
||||
// return TRUE;
|
||||
// }
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue