Exemplo n.º 1
0
 /**
  * Load saved search sql files into the DB.
  */
 public function loadSavedSearches()
 {
     $dsn = CRM_Core_Config::singleton()->dsn;
     foreach (glob(dirname(__FILE__) . "/SavedSearchDataSets/*.sql") as $file) {
         CRM_Utils_File::sourceSQLFile($dsn, $file);
     }
 }
Exemplo n.º 2
0
function civicrm_api3_speakcivi_update_stats($params)
{
    $config = CRM_Core_Config::singleton();
    $sql = file_get_contents(dirname(__FILE__) . '/../../sql/update.sql', true);
    CRM_Utils_File::sourceSQLFile($config->dsn, $sql, NULL, true);
    return civicrm_api3_create_success(array("query" => $sql), $params);
}
/**
 * Implements hook_civicrm_install().
 *
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_install
 */
function offlinerecurringcontributions_civicrm_install()
{
    $extensionDir = dirname(__FILE__) . DIRECTORY_SEPARATOR;
    $sqlName = $extensionDir . 'sql' . DIRECTORY_SEPARATOR . 'update.sql';
    CRM_Utils_File::sourceSQLFile(CIVICRM_DSN, $sqlName);
    _offlinerecurringcontributions_civix_civicrm_install();
}
Exemplo n.º 4
0
 /**
  * @dataProvider dataProvider
  */
 public function testReportOutput($reportClass, $inputParams, $dataSet, $expectedOutputCsvFile)
 {
     $config = CRM_Core_Config::singleton();
     CRM_Utils_File::sourceSQLFile($config->dsn, dirname(__FILE__) . "/{$dataSet}");
     $reportCsvFile = $this->getReportOutputAsCsv($reportClass, $inputParams);
     $reportCsvArray = $this->getArrayFromCsv($reportCsvFile);
     $expectedOutputCsvArray = $this->getArrayFromCsv(dirname(__FILE__) . "/{$expectedOutputCsvFile}");
     $this->assertCsvArraysEqual($expectedOutputCsvArray, $reportCsvArray);
 }
/**
 * Implementation of hook_civicrm_uninstall
 */
function eventcalendar_civicrm_uninstall()
{
    $cividiscountRoot = dirname(__FILE__) . DIRECTORY_SEPARATOR;
    $cividiscountSQL = $cividiscountRoot . DIRECTORY_SEPARATOR . 'uninstall.sql';
    CRM_Utils_File::sourceSQLFile(CIVICRM_DSN, $cividiscountSQL);
    // rebuild the menu so our path is picked up
    CRM_Core_Invoke::rebuildMenuAndCaches();
    //return _eventcalendar_civix_civicrm_uninstall();
}
Exemplo n.º 6
0
/**
 * Implementation of hook_civicrm_enable
 */
function banking_civicrm_enable()
{
    //add the required option groups
    banking_civicrm_install_options(_banking_options());
    // run the update script
    $config = CRM_Core_Config::singleton();
    $sql = file_get_contents(dirname(__FILE__) . '/sql/upgrade.sql', true);
    CRM_Utils_File::sourceSQLFile($config->dsn, $sql, NULL, true);
    return _banking_civix_civicrm_enable();
}
 function postProcess()
 {
     $config = CRM_Core_Config::singleton();
     $extenDr = $config->extensionsDir;
     $sDbScriptsDir = $extenDr . DIRECTORY_SEPARATOR . 'uk.co.vedaconsulting.recurdatafix' . DIRECTORY_SEPARATOR . 'sql' . DIRECTORY_SEPARATOR;
     CRM_Utils_File::sourceSQLFile(CIVICRM_DSN, sprintf("%supdate.sql", $sDbScriptsDir));
     //CRM_Core_Session::setStatus('Updated table civicrm_recur table with membership id', 'Success', 'info');
     CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/recurdatafix/create', 'reset=1'));
     CRM_Utils_System::civiExit();
 }
Exemplo n.º 8
0
/**
 * Load the navigation sql for the domain with the given name.
 *
 * @param string $domainName
 * @param int $domainID
 */
function _civicrm_load_navigation($domainName, $domainID)
{
    global $civicrm_root;
    $sqlPath = $civicrm_root . DIRECTORY_SEPARATOR . 'sql';
    $config = CRM_Core_Config::singleton();
    $generatedFile = $config->uploadDir . DIRECTORY_SEPARATOR . str_replace(' ', '_', $domainName) . uniqid() . 'nav.mysql';
    //read the entire string
    $str = file_get_contents($sqlPath . DIRECTORY_SEPARATOR . 'civicrm_navigation.mysql');
    $str = str_replace('SELECT @domainID := id FROM civicrm_domain where name = \'Default Domain Name\'', "SELECT @domainID := {$domainID}", $str);
    file_put_contents($generatedFile, $str);
    CRM_Utils_File::sourceSQLFile($config->dsn, $generatedFile, NULL, FALSE);
    CRM_Core_DAO::executeQuery("UPDATE civicrm_navigation SET label = name WHERE label = ''");
}
Exemplo n.º 9
0
 /**
  * Ensure that the required SQL table exists
  *
  * @return bool TRUE if table now exists
  */
 static function findCreateTable()
 {
     $checkTableSql = "show tables like 'civicrm_queue_item'";
     $foundName = CRM_Core_DAO::singleValueQuery($checkTableSql);
     if ($foundName == 'civicrm_queue_item') {
         return TRUE;
     }
     // civicrm/sql/civicrm_queue_item.mysql
     $fileName = dirname(__FILE__) . '/../../../sql/civicrm_queue_item.mysql';
     $config = CRM_Core_Config::singleton();
     CRM_Utils_File::sourceSQLFile($config->dsn, $fileName);
     // Make sure it succeeded
     $foundName = CRM_Core_DAO::singleValueQuery($checkTableSql);
     return $foundName == 'civicrm_queue_item';
 }
 public function onUninstall()
 {
     if (is_callable(array($this, 'uninstall'))) {
         $this->uninstall();
     }
     $files = glob($this->extensionDir . '/sql/*_uninstall.sql');
     if (is_array($files)) {
         foreach ($files as $file) {
             CRM_Utils_File::sourceSQLFile(CIVICRM_DSN, $file);
         }
     }
     $this->setCurrentRevision(NULL);
 }
Exemplo n.º 11
0
 function source($fileName, $isQueryString = false)
 {
     require_once 'CRM/Utils/File.php';
     CRM_Utils_File::sourceSQLFile($this->_config->dsn, $fileName, null, $isQueryString);
 }
Exemplo n.º 12
0
 public static function dropAllTables()
 {
     // first drop all the custom tables we've created
     CRM_Core_BAO_CustomGroup::dropAllTables();
     // drop all multilingual views
     CRM_Core_I18n_Schema::dropAllViews();
     CRM_Utils_File::sourceSQLFile(CIVICRM_DSN, dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'sql' . DIRECTORY_SEPARATOR . 'civicrm_drop.mysql');
 }
Exemplo n.º 13
0
 static function dropAllTables()
 {
     // first drop all the custom tables we've created
     require_once 'CRM/Core/BAO/CustomGroup.php';
     CRM_Core_BAO_CustomGroup::dropAllTables();
     // drop all multilingual views
     require_once 'CRM/Core/I18n/Schema.php';
     CRM_Core_I18n_Schema::dropAllViews();
     require_once 'CRM/Utils/File.php';
     CRM_Utils_File::sourceSQLFile(CIVICRM_DSN, dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'sql' . DIRECTORY_SEPARATOR . 'civicrm_drop.mysql');
 }
Exemplo n.º 14
0
/**
 * Implementation of hook_civicrm_install
 */
function sepa_civicrm_install()
{
    $config = CRM_Core_Config::singleton();
    //create the tables
    $sql = file_get_contents(dirname(__FILE__) . '/sql/sepa.sql', true);
    CRM_Utils_File::sourceSQLFile($config->dsn, $sql, NULL, true);
    return _sepa_civix_civicrm_install();
}
Exemplo n.º 15
0
 /**
  * @param string $fileName
  * @param bool $isQueryString
  */
 public function source($fileName, $isQueryString = FALSE)
 {
     CRM_Utils_File::sourceSQLFile($this->_config->dsn, $fileName, NULL, $isQueryString);
 }
Exemplo n.º 16
0
 /**
  * Load saved search sql files into the DB.
  */
 public function loadSavedSearches()
 {
     foreach (glob(dirname(__FILE__) . "/SavedSearchDataSets/*.sql") as $file) {
         CRM_Utils_File::sourceSQLFile(NULL, $file);
     }
 }
Exemplo n.º 17
0
/**
 * Implementation of hook_civicrm_disable
 */
function olarkchat_civicrm_disable() {
  foreach (glob(__DIR__ . '/sql/*_disable.sql') as $file) {
    CRM_Utils_File::sourceSQLFile(CIVICRM_DSN, $file);
  }
  return _olarkchat_civix_civicrm_disable();
}