/** * 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 Exception public function upgrade_4203() { $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 = ts('Upgrade Batch (%1 => %2)', array( 1 => $startId, 2 => $endId, )); $sql = ' UPDATE civicrm_contribution SET foobar = whiz(wonky()+wanker) WHERE id BETWEEN %1 and %2 '; $params = array( 1 => array($startId, 'Integer'), 2 => array($endId, 'Integer'), ); $this->addTask($title, 'executeSql', $sql, $params); } return TRUE; } // */ public function upgrade_1400() { $this->ctx->log->info('Applying update 1400'); $finalTermDate = civicrm_api3('CustomField', 'getvalue', array('custom_group_id' => 'HRJobContract_Summary', 'name' => 'Final_Termination_Date', 'return' => 'id')); //create uffield $ufGroupID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', 'hrstaffdir_listing', 'id', 'name'); $ufFieldParam = array('uf_group_id' => $ufGroupID, 'field_name' => "custom_{$finalTermDate}", 'is_active' => "1", 'label' => "Final Termination Date", 'field_type' => "Individual", 'is_view' => "1", 'visibility' => 'Public Pages', 'is_searchable' => "0", 'is_selector' => "0"); $result = civicrm_api3('UFField', 'create', $ufFieldParam); _hrstaffdir_phone_type($ufGroupID); return TRUE; }
/** * Implementation of hook_civicrm_postInstall * * Note: This hook only runs in CiviCRM 4.4+. */ function hrstaffdir_civicrm_postInstall() { $ufGroupID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', 'hrstaffdir_listing', 'id', 'name'); _hrstaffdir_phone_type($ufGroupID); }