function __construct($log_conn_id, $log_date)
 {
     $dsn = defined('CIVICRM_LOGGING_DSN') ? DB::parseDSN(CIVICRM_LOGGING_DSN) : DB::parseDSN(CIVICRM_DSN);
     $this->db = $dsn['database'];
     $this->log_conn_id = $log_conn_id;
     $this->log_date = $log_date;
 }
Ejemplo n.º 2
0
 /**
  * Class constructor.
  */
 public function __construct()
 {
     // don’t display the ‘Add these Contacts to Group’ button
     $this->_add2groupSupported = FALSE;
     $dsn = defined('CIVICRM_LOGGING_DSN') ? DB::parseDSN(CIVICRM_LOGGING_DSN) : DB::parseDSN(CIVICRM_DSN);
     $this->loggingDB = $dsn['database'];
     // used for redirect back to contact summary
     $this->cid = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject);
     $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
     $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
     $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
     $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
     $this->_logTables = array('log_civicrm_contact' => array('fk' => 'id'), 'log_civicrm_email' => array('fk' => 'contact_id', 'log_type' => 'Contact'), 'log_civicrm_phone' => array('fk' => 'contact_id', 'log_type' => 'Contact'), 'log_civicrm_address' => array('fk' => 'contact_id', 'log_type' => 'Contact'), 'log_civicrm_note' => array('fk' => 'entity_id', 'entity_table' => TRUE, 'bracket_info' => array('table' => 'log_civicrm_note', 'column' => 'subject')), 'log_civicrm_note_comment' => array('fk' => 'entity_id', 'table_name' => 'log_civicrm_note', 'joins' => array('table' => 'log_civicrm_note', 'join' => "entity_log_civireport.entity_id = fk_table.id AND entity_log_civireport.entity_table = 'civicrm_note'"), 'entity_table' => TRUE, 'bracket_info' => array('table' => 'log_civicrm_note', 'column' => 'subject')), 'log_civicrm_group_contact' => array('fk' => 'contact_id', 'bracket_info' => array('entity_column' => 'group_id', 'table' => 'log_civicrm_group', 'column' => 'title'), 'action_column' => 'status', 'log_type' => 'Group'), 'log_civicrm_entity_tag' => array('fk' => 'entity_id', 'bracket_info' => array('entity_column' => 'tag_id', 'table' => 'log_civicrm_tag', 'column' => 'name'), 'entity_table' => TRUE), 'log_civicrm_relationship' => array('fk' => 'contact_id_a', 'bracket_info' => array('entity_column' => 'relationship_type_id', 'table' => 'log_civicrm_relationship_type', 'column' => 'label_a_b')), 'log_civicrm_activity_for_target' => array('fk' => 'contact_id', 'table_name' => 'log_civicrm_activity', 'joins' => array('table' => 'log_civicrm_activity_contact', 'join' => "(entity_log_civireport.id = fk_table.activity_id AND fk_table.record_type_id = {$targetID})"), 'bracket_info' => array('entity_column' => 'activity_type_id', 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE)), 'log_type' => 'Activity'), 'log_civicrm_activity_for_assignee' => array('fk' => 'contact_id', 'table_name' => 'log_civicrm_activity', 'joins' => array('table' => 'log_civicrm_activity_contact', 'join' => "entity_log_civireport.id = fk_table.activity_id AND fk_table.record_type_id = {$assigneeID}"), 'bracket_info' => array('entity_column' => 'activity_type_id', 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE)), 'log_type' => 'Activity'), 'log_civicrm_activity_for_source' => array('fk' => 'contact_id', 'table_name' => 'log_civicrm_activity', 'joins' => array('table' => 'log_civicrm_activity_contact', 'join' => "entity_log_civireport.id = fk_table.activity_id AND fk_table.record_type_id = {$sourceID}"), 'bracket_info' => array('entity_column' => 'activity_type_id', 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE)), 'log_type' => 'Activity'), 'log_civicrm_case' => array('fk' => 'contact_id', 'joins' => array('table' => 'log_civicrm_case_contact', 'join' => 'entity_log_civireport.id = fk_table.case_id'), 'bracket_info' => array('entity_column' => 'case_type_id', 'options' => CRM_Case_PseudoConstant::caseType('title', FALSE))));
     $logging = new CRM_Logging_Schema();
     // build _logTables for contact custom tables
     $customTables = $logging->entityCustomDataLogTables('Contact');
     foreach ($customTables as $table) {
         $this->_logTables[$table] = array('fk' => 'entity_id', 'log_type' => 'Contact');
     }
     // build _logTables for address custom tables
     $customTables = $logging->entityCustomDataLogTables('Address');
     foreach ($customTables as $table) {
         $this->_logTables[$table] = array('fk' => 'contact_id', 'joins' => array('table' => 'log_civicrm_address', 'join' => 'entity_log_civireport.entity_id = fk_table.id'), 'log_type' => 'Contact');
     }
     // Allow log tables to be extended via report hooks.
     CRM_Report_BAO_Hook::singleton()->alterLogTables($this, $this->_logTables);
     parent::__construct();
 }
 function __construct()
 {
     // don’t display the ‘Add these Contacts to Group’ button
     $this->_add2groupSupported = FALSE;
     $dsn = defined('CIVICRM_LOGGING_DSN') ? DB::parseDSN(CIVICRM_LOGGING_DSN) : DB::parseDSN(CIVICRM_DSN);
     $this->db = $dsn['database'];
     $this->log_conn_id = CRM_Utils_Request::retrieve('log_conn_id', 'Integer', CRM_Core_DAO::$_nullObject);
     $this->log_date = CRM_Utils_Request::retrieve('log_date', 'String', CRM_Core_DAO::$_nullObject);
     $this->cid = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject);
     $this->raw = CRM_Utils_Request::retrieve('raw', 'Boolean', CRM_Core_DAO::$_nullObject);
     parent::__construct();
     CRM_Utils_System::resetBreadCrumb();
     $breadcrumb = array(array('title' => ts('Home'), 'url' => CRM_Utils_System::url()), array('title' => ts('CiviCRM'), 'url' => CRM_Utils_System::url('civicrm', 'reset=1')), array('title' => ts('View Contact'), 'url' => CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->cid}")), array('title' => ts('Search Results'), 'url' => CRM_Utils_System::url('civicrm/contact/search', "force=1")));
     CRM_Utils_System::appendBreadCrumb($breadcrumb);
     if (CRM_Utils_Request::retrieve('revert', 'Boolean', CRM_Core_DAO::$_nullObject)) {
         $reverter = new CRM_Logging_Reverter($this->log_conn_id, $this->log_date);
         $reverter->revert($this->tables);
         CRM_Core_Session::setStatus(ts('The changes have been reverted.'));
         if ($this->cid) {
             CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view', "reset=1&selectedChild=log&cid={$this->cid}", FALSE, NULL, FALSE));
         } else {
             CRM_Utils_System::redirect(CRM_Report_Utils_Report::getNextUrl($this->summary, 'reset=1', FALSE, TRUE));
         }
     }
     // make sure the report works even without the params
     if (!$this->log_conn_id or !$this->log_date) {
         $dao = new CRM_Core_DAO();
         $dao->query("SELECT log_conn_id, log_date FROM `{$this->db}`.log_{$this->tables[0]} WHERE log_action = 'Update' ORDER BY log_date DESC LIMIT 1");
         $dao->fetch();
         $this->log_conn_id = $dao->log_conn_id;
         $this->log_date = $dao->log_date;
     }
     $this->_columnHeaders = array('field' => array('title' => ts('Field')), 'from' => array('title' => ts('Changed From')), 'to' => array('title' => ts('Changed To')));
 }
Ejemplo n.º 4
0
 /**
  * Populate $this->tables and $this->logs with current db state.
  */
 public function __construct()
 {
     $dao = new CRM_Contact_DAO_Contact();
     $civiDBName = $dao->_database;
     $dao = CRM_Core_DAO::executeQuery("\nSELECT TABLE_NAME\nFROM   INFORMATION_SCHEMA.TABLES\nWHERE  TABLE_SCHEMA = '{$civiDBName}'\nAND    TABLE_TYPE = 'BASE TABLE'\nAND    TABLE_NAME LIKE 'civicrm_%'\n");
     while ($dao->fetch()) {
         $this->tables[] = $dao->TABLE_NAME;
     }
     // do not log temp import, cache, menu and log tables
     $this->tables = preg_grep('/^civicrm_import_job_/', $this->tables, PREG_GREP_INVERT);
     $this->tables = preg_grep('/_cache$/', $this->tables, PREG_GREP_INVERT);
     $this->tables = preg_grep('/_log/', $this->tables, PREG_GREP_INVERT);
     $this->tables = preg_grep('/^civicrm_queue_/', $this->tables, PREG_GREP_INVERT);
     $this->tables = preg_grep('/^civicrm_menu/', $this->tables, PREG_GREP_INVERT);
     //CRM-14672
     $this->tables = preg_grep('/_temp_/', $this->tables, PREG_GREP_INVERT);
     // do not log civicrm_mailing_event* tables, CRM-12300
     $this->tables = preg_grep('/^civicrm_mailing_event_/', $this->tables, PREG_GREP_INVERT);
     // do not log civicrm_mailing_recipients table, CRM-16193
     $this->tables = array_diff($this->tables, array('civicrm_mailing_recipients'));
     if (defined('CIVICRM_LOGGING_DSN')) {
         $dsn = DB::parseDSN(CIVICRM_LOGGING_DSN);
         $this->useDBPrefix = CIVICRM_LOGGING_DSN != CIVICRM_DSN;
     } else {
         $dsn = DB::parseDSN(CIVICRM_DSN);
         $this->useDBPrefix = FALSE;
     }
     $this->db = $dsn['database'];
     $dao = CRM_Core_DAO::executeQuery("\nSELECT TABLE_NAME\nFROM   INFORMATION_SCHEMA.TABLES\nWHERE  TABLE_SCHEMA = '{$this->db}'\nAND    TABLE_TYPE = 'BASE TABLE'\nAND    TABLE_NAME LIKE 'log_civicrm_%'\n");
     while ($dao->fetch()) {
         $log = $dao->TABLE_NAME;
         $this->logs[substr($log, 4)] = $log;
     }
 }
 /**
  * Connect to database by using the given DSN string
  *
  * @author  copied from PEAR::Auth, Martin Jansen, slightly modified
  * @access private
  * @param  string DSN string
  * @return mixed  Object on error, otherwise bool
  */
 function _connectDB($dsn)
 {
     // only include the db if one really wants to connect
     require_once 'DB.php';
     if (is_string($dsn) || is_array($dsn)) {
         // put the dsn parameters in an array
         // DB would be confused with an additional URL-queries, like ?table=...
         // so we do it before connecting to the DB
         if (is_string($dsn)) {
             $dsn = DB::parseDSN($dsn);
         }
         $this->dbh = DB::Connect($dsn);
     } else {
         if (get_parent_class($dsn) == "db_common") {
             $this->dbh = $dsn;
         } else {
             if (is_object($dsn) && DB::isError($dsn)) {
                 return new DB_Error($dsn->code, PEAR_ERROR_DIE);
             } else {
                 return new PEAR_Error("The given dsn was not valid in file " . __FILE__ . " at line " . __LINE__, 41, PEAR_ERROR_RETURN, null, null);
             }
         }
     }
     if (DB::isError($this->dbh)) {
         return new DB_Error($this->dbh->code, PEAR_ERROR_DIE);
     }
     return true;
 }
Ejemplo n.º 6
0
 /**
  * Initialize the constants used during lock acquire / release
  *
  * @param string  $name name of the lock. Please prefix with component / functionality
  *                      e.g. civimail.cronjob.JOB_ID
  * @param int     $timeout the number of seconds to wait to get the lock. 1 if not set
  * @param boolean $serverWideLock should this lock be applicable across your entire mysql server
  *                                this is useful if you have mutliple sites running on the same
  *                                mysql server and you want to limit the number of parallel cron
  *                                jobs - CRM-91XX
  *
  * @return object the lock object
  *
  */
 function __construct($name, $timeout = NULL, $serverWideLock = FALSE)
 {
     $config = CRM_Core_Config::singleton();
     $dsnArray = DB::parseDSN($config->dsn);
     $database = $dsnArray['database'];
     $domainID = CRM_Core_Config::domainID();
     if ($serverWideLock) {
         $this->_name = $name;
     } else {
         $this->_name = $database . '.' . $domainID . '.' . $name;
     }
     if (defined('CIVICRM_LOCK_DEBUG')) {
         CRM_Core_Error::debug_log_message('trying to construct lock for ' . $this->_name);
     }
     static $jobLog = FALSE;
     if ($jobLog && CRM_Core_DAO::singleValueQuery("SELECT IS_USED_LOCK( '{$jobLog}')")) {
         return $this->hackyHandleBrokenCode($jobLog);
     }
     if (stristr($name, 'civimail.job.')) {
         $jobLog = $this->_name;
     }
     //if (defined('CIVICRM_LOCK_DEBUG')) {
     //CRM_Core_Error::debug_var('backtrace', debug_backtrace());
     //}
     $this->_timeout = $timeout !== NULL ? $timeout : self::TIMEOUT;
     $this->acquire();
 }
Ejemplo n.º 7
0
 /**
  * @param int $log_conn_id
  * @param $log_date
  * @param string $interval
  */
 public function __construct($log_conn_id, $log_date, $interval = '10 SECOND')
 {
     $dsn = defined('CIVICRM_LOGGING_DSN') ? DB::parseDSN(CIVICRM_LOGGING_DSN) : DB::parseDSN(CIVICRM_DSN);
     $this->db = $dsn['database'];
     $this->log_conn_id = $log_conn_id;
     $this->log_date = $log_date;
     $this->interval = $interval;
 }
Ejemplo n.º 8
0
 function getDBConn($dsn, $persistent)
 {
     @($obj =& new db_Wrap());
     debug("DB", "connecting to: {$dsn}");
     $dsninfo = DB::parseDSN($dsn);
     $obj->connect($dsninfo, $persistent);
     return $obj;
 }
Ejemplo n.º 9
0
 function __construct()
 {
     $this->_add2groupSupported = false;
     // don’t display the ‘Add these Contacts to Group’ button
     $dsn = defined('CIVICRM_LOGGING_DSN') ? DB::parseDSN(CIVICRM_LOGGING_DSN) : DB::parseDSN(CIVICRM_DSN);
     $this->loggingDB = $dsn['database'];
     $this->_columns = array('log_civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('id' => array('no_display' => true, 'required' => true), 'log_user_id' => array('no_display' => true, 'required' => true), 'log_date' => array('default' => true, 'required' => true, 'type' => CRM_Utils_Type::T_TIME, 'title' => ts('When')), 'altered_contact' => array('default' => true, 'name' => 'display_name', 'title' => ts('Altered Contact')), 'log_conn_id' => array('no_display' => true, 'required' => true), 'log_action' => array('default' => true, 'title' => ts('Action')), 'is_deleted' => array('no_display' => true, 'required' => true)), 'filters' => array('log_date' => array('title' => ts('When'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE), 'altered_contact' => array('name' => 'display_name', 'title' => ts('Altered Contact'), 'type' => CRM_Utils_Type::T_STRING), 'log_action' => array('operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => array('Insert' => ts('Insert'), 'Update' => ts('Update'), 'Delete' => ts('Delete')), 'title' => ts('Action'), 'type' => CRM_Utils_Type::T_STRING))), 'civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('altered_by' => array('default' => true, 'name' => 'display_name', 'title' => ts('Altered By'))), 'filters' => array('altered_by' => array('name' => 'display_name', 'title' => ts('Altered By'), 'type' => CRM_Utils_Type::T_STRING))));
     parent::__construct();
 }
Ejemplo n.º 10
0
 public static function connect($dsn = null)
 {
     $pdsn = DB::parseDSN($dsn);
     if (!empty($pdsn)) {
         $db_port = empty($pdsn['port']) ? '' : ';port=' . $pdsn['port'];
         return new DB(new \FreePBX\Database($pdsn['dbsyntax'] . ':host=' . $pdsn['hostspec'] . $db_port . ';dbname=' . $pdsn['database'], $pdsn['username'], $pdsn['password']));
     }
     throw new \Exception(_("Could not understand DSN for connect"));
 }
Ejemplo n.º 11
0
 function &connect($dsn, $options = array())
 {
     $dsninfo = DB::parseDSN($dsn);
     $type = $dsninfo['phptype'];
     @($obj = DB::factory($type, $options));
     $obj->_dsninfo = $dsninfo;
     $obj->_dboptions = $options;
     return $obj;
 }
Ejemplo n.º 12
0
 function makeConnection($dsn, $persistent)
 {
     if ($this->debug) {
         logger("DB", "connecting to: {$dsn}");
     }
     $dsninfo = DB::parseDSN($dsn);
     $success = $this->connect($dsninfo, $persistent);
     return $success;
 }
 /**
  *	Ethna_DB_PEARクラスのコンストラクタ
  *
  *	@access	public
  *	@param	object	Ethna_Controller	&$controller	コントローラオブジェクト
  *	@param	string	$dsn								DSN
  *	@param	bool	$persistent							持続接続設定
  */
 function Ethna_DB_PEAR(&$controller, $dsn, $persistent)
 {
     parent::Ethna_DB($controller, $dsn, $persistent);
     $this->db = null;
     $this->logger =& $controller->getLogger();
     $this->sql =& $controller->getSQL();
     $dsninfo = DB::parseDSN($dsn);
     $this->type = $dsninfo['phptype'];
 }
Ejemplo n.º 14
0
 function view_dsn($dsn = false)
 {
     if (!$dsn) {
         $dsninfo = DB::parseDSN($GLOBALS['DBParams']['dsn']);
     } else {
         $dsninfo = DB::parseDSN($dsn);
     }
     return sprintf("%s://%s:<not displayed>@%s/%s", $dsninfo['phptype'], $dsninfo['username'], $dsninfo['hostspec'], $dsninfo['database']);
 }
Ejemplo n.º 15
0
 function __construct($name, $timeout = null)
 {
     $config = CRM_Core_Config::singleton();
     $dsnArray = DB::parseDSN($config->dsn);
     $database = $dsnArray['database'];
     $domainID = CRM_Core_Config::domainID();
     $this->_name = $database . '.' . $domainID . '.' . $name;
     $this->_timeout = $timeout ? $timeout : self::TIMEOUT;
     $this->acquire();
 }
 function __construct()
 {
     // don’t display the ‘Add these Contacts to Group’ button
     $this->_add2groupSupported = FALSE;
     $dsn = defined('CIVICRM_LOGGING_DSN') ? DB::parseDSN(CIVICRM_LOGGING_DSN) : DB::parseDSN(CIVICRM_DSN);
     $this->loggingDB = $dsn['database'];
     // used for redirect back to contact summary
     $this->cid = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject);
     parent::__construct();
 }
Ejemplo n.º 17
0
Archivo: PEAR.php Proyecto: riaf/ethna
 /**
  *  Ethna_DB_PEARクラスのコンストラクタ
  *
  *  @access public
  *  @param  object  Ethna_Controller    $controller    コントローラオブジェクト
  *  @param  string  $dsn                                DSN
  *  @param  bool    $persistent                         持続接続設定
  */
 public function __construct($controller, $dsn, $persistent)
 {
     parent::__construct($controller, $dsn, $persistent);
     $this->db = null;
     $this->logger = $controller->getLogger();
     $this->sql = $controller->getSQL();
     $this->dsninfo = DB::parseDSN($dsn);
     $this->dsninfo['new_link'] = true;
     $this->type = $this->dsninfo['phptype'];
 }
Ejemplo n.º 18
0
 function makeConnection($dsn, $persistent, $name = '')
 {
     if ($this->debug) {
         logger("postgres DB:{$name}", "connecting to: {$dsn}");
     }
     $this->name = $name;
     $dsninfo = DB::parseDSN($dsn);
     $success = $this->connect($dsninfo, $persistent);
     return $success;
 }
 function __construct()
 {
     $config = CRM_Core_Config::singleton();
     $dsnArray = DB::parseDSN($config->userFrameworkDSN);
     $this->_drupalDatabase = $dsnArray['database'];
     self::getWebforms();
     $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('display_name' => array('title' => ts('Student Info'), 'required' => TRUE, 'default' => TRUE, 'no_repeat' => TRUE)), 'filters' => array('display_name' => array('title' => ts('Student Name'), 'operator' => 'like'), 'id' => array('no_display' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'fields' => array('street_address' => array('default' => TRUE), 'city' => array('default' => TRUE), 'postal_code' => array('default' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => array('default' => TRUE)), 'grouping' => 'contact-fields'), NRM_PRO => array('dao' => 'CRM_Core_DAO_CustomField', 'fields' => array(HIGH_SCHOOL => array('title' => ts('High School'), 'required' => TRUE, 'default' => TRUE, 'no_repeat' => TRUE), GRAD_YEAR => array('title' => ts('Grad Year'), 'required' => TRUE, 'default' => TRUE, 'no_repeat' => TRUE), MAJOR => array('title' => ts('Major Interests'), 'required' => TRUE, 'default' => TRUE, 'no_repeat' => TRUE)), 'filters' => array(HIGH_SCHOOL => array('title' => ts('High School'), 'operator' => 'like'), MAJOR => array('title' => ts('Major Interests'), 'operator' => 'like')), 'grouping' => 'contact-fields'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('default' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_log' => array('dao' => 'CRM_Core_DAO_Log', 'fields' => array('modified_date' => array('title' => ts('Last Updated'), 'default' => TRUE)), 'grouping' => 'contact-fields'));
     $this->_groupFilter = TRUE;
     $this->_tagFilter = TRUE;
     parent::__construct();
 }
 function __construct()
 {
     $config = CRM_Core_Config::singleton();
     $dsnArray = DB::parseDSN($config->userFrameworkDSN);
     $this->_drupalDatabase = $dsnArray['database'];
     self::getWebforms();
     $this->_columns = array('watchdog' => array('fields' => array('location' => array('title' => ts('Location'), 'required' => TRUE, 'default' => TRUE, 'no_repeat' => TRUE)), 'filters' => array('webforms' => array('title' => ts('Webforms'), 'type' => CRM_Utils_Type::T_STRING, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->webForms, 'default' => self::getDefaultWebforms()))));
     $this->_groupFilter = FALSE;
     $this->_tagFilter = FALSE;
     parent::__construct();
 }
 function __construct()
 {
     $config = CRM_Core_Config::singleton();
     $dsnArray = DB::parseDSN($config->userFrameworkDSN);
     $this->_drupalDatabase = $dsnArray['database'];
     self::getWebforms();
     $this->_columns = array('watchdog' => array('fields' => array('location' => array('title' => ts('Daily Activity Statistics'), 'required' => TRUE, 'default' => TRUE, 'no_repeat' => FALSE)), 'filters' => array('webforms_visits' => array('title' => ts('Webform(s) to Request or Register for a Visit'), 'type' => CRM_Utils_Type::T_STRING, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->webForms), 'webforms_applications' => array('title' => ts('Webform(s) to Submit an Application'), 'type' => CRM_Utils_Type::T_STRING, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->webForms), 'webforms_engagement' => array('title' => ts('Webform(s) Indicating Engagement'), 'type' => CRM_Utils_Type::T_STRING, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->webForms))));
     $this->_groupFilter = FALSE;
     $this->_tagFilter = FALSE;
     parent::__construct();
 }
Ejemplo n.º 22
0
function connect(&$dsn, $persistent = false)
{
    if (is_array($dsn)) {
        $dsninfo =& $dsn;
    } else {
        $dsninfo = DB::parseDSN($dsn);
    }
    if (!$dsninfo || !$dsninfo['phptype']) {
        return $this->raiseError();
    }
    return true;
}
Ejemplo n.º 23
0
 /**
  * Function to create the dump from backup.sql
  * 
  * @param NULL
  *
  * @return void
  * 
  * @access public
  * @static
  */
 function backupData()
 {
     global $civicrm_root;
     $file = $civicrm_root . '/sql/civicrm_backup.mysql';
     //we get the upload folder for storing the huge backup data
     $config =& new CRM_Core_Config();
     chdir($config->uploadDir);
     $fileName = 'domainDump.sql';
     //get the username and password from dsn
     $values = DB::parseDSN($config->dsn);
     $username = $values['username'];
     $password = $values['password'];
     $database = $values['database'];
     if (is_file($fileName)) {
         unlink($fileName);
     }
     //read the contents of the file into an array
     $sql = file($file);
     if (empty($sql)) {
         CRM_Utils_System::statusBounce(ts('We could not find the backup sql script. Check %1 in the CiviCRM root directory.', array(1 => 'sql/civicrm_backup.mysql')));
     }
     // make sure mysqldump exists
     if (!file_exists($config->mysqlPath . 'mysqldump')) {
         CRM_Utils_System::statusBounce(ts('We could not find the mysqldump program. Check the configuration variable CIVICRM_MYSQL_PATH in your CiviCRM config file.'));
     }
     foreach ($sql as $value) {
         $val = explode("|", $value);
         $domainDAO =& new CRM_Core_DAO();
         $domainDAO->query($val[1]);
         $ids = array();
         while ($domainDAO->fetch()) {
             $ids[] = $domainDAO->id;
         }
         //if ( !empty($ids) ) {
         $dumpCommand = $config->mysqlPath . "mysqldump  -u" . $username . " -p" . $password . " --opt --single-transaction  " . $database . " " . $val[0] . " -w 'id IN ( " . implode(",", $ids) . " ) ' >> " . $fileName;
         exec($dumpCommand);
         //} fixed for Issue CRM-670
     }
     $tarFileName = 'backupData.tgz';
     if (is_file($tarFileName)) {
         unlink($tarFileName);
     }
     $tarCommand = 'tar -czf ' . $tarFileName . ' ' . $fileName;
     exec($tarCommand);
     $fileSize = filesize($tarFileName);
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Content-Description: File Transfer');
     header('ContentType Extension=".tgz" ContentType="application/x-compressed" ');
     header('Content-Length: ' . $fileSize);
     header('Content-Disposition: attachment; filename=backupData.tgz');
     readfile($tarFileName);
 }
Ejemplo n.º 24
0
 /**
  * Get the data source used for testing.
  *
  * @param string|NULL $part
  *   One of NULL, 'hostspec', 'port', 'username', 'password', 'database'.
  * @return string|array|NULL
  *   If $part is omitted, return full DSN array.
  *   If $part is a string, return that part of the DSN.
  */
 public static function dsn($part = NULL)
 {
     if (!isset(self::$singletons['dsn'])) {
         require_once "DB.php";
         self::$singletons['dsn'] = DB::parseDSN(CIVICRM_DSN);
     }
     if ($part === NULL) {
         return self::$singletons['dsn'];
     }
     if (isset(self::$singletons['dsn'][$part])) {
         return self::$singletons['dsn'][$part];
     }
     return NULL;
 }
Ejemplo n.º 25
0
 /**
  * Initialize the constants used during lock acquire / release
  *
  * @param string  $name name of the lock. Please prefix with component / functionality
  *                      e.g. civimail.cronjob.JOB_ID
  * @param int     $timeout the number of seconds to wait to get the lock. 1 if not set
  * @param boolean $serverWideLock should this lock be applicable across your entire mysql server
  *                                this is useful if you have mutliple sites running on the same
  *                                mysql server and you want to limit the number of parallel cron
  *                                jobs - CRM-91XX
  *
  * @return object the lock object
  *
  */
 function __construct($name, $timeout = NULL, $serverWideLock = FALSE)
 {
     $config = CRM_Core_Config::singleton();
     $dsnArray = DB::parseDSN($config->dsn);
     $database = $dsnArray['database'];
     $domainID = CRM_Core_Config::domainID();
     if ($serverWideLock) {
         $this->_name = $name;
     } else {
         $this->_name = $database . '.' . $domainID . '.' . $name;
     }
     $this->_timeout = $timeout !== NULL ? $timeout : self::TIMEOUT;
     $this->acquire();
 }
Ejemplo n.º 26
0
function connect_to_db()
{
    $db_user = "******";
    $db_password = "******";
    $db_host = "removed";
    $db = "removed";
    $db_type = "removed";
    $dsn = DB::parseDSN("{$db_type}://{$db_user}:{$db_password}@{$db_host}/{$db}");
    $db = DB::connect($dsn);
    if (DB::isError($db)) {
        print "Error connecting to the database... ";
        die($db->getMessage());
    }
    $db->setFetchMode(DB_FETCHMODE_ASSOC);
    $db->query("SET NAMES 'utf8' COLLATE 'utf8_unicode_ci'");
    return $db;
}
Ejemplo n.º 27
0
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     $config =& CRM_Core_Config::singleton();
     $uf = $config->userFramework;
     CRM_Utils_System::setTitle(ts('Settings - %1 Integration', array(1 => $uf)));
     $this->addElement('text', 'userFrameworkVersion', ts('%1 Version', array(1 => $uf)));
     $this->addElement('text', 'userFrameworkUsersTableName', ts('%1 Users Table Name', array(1 => $uf)));
     if (function_exists('module_exists') && module_exists('views') && $config->dsn != $config->userFrameworkDSN) {
         $dsnArray = DB::parseDSN($config->dsn);
         $tableNames = CRM_Core_DAO::GetStorageValues(null, 0, 'Name');
         $tablePrefixes = '$db_prefix = array(';
         foreach ($tableNames as $tableName => $value) {
             $tablePrefixes .= "\n  '" . str_pad($tableName . "'", 41) . " => '{$dsnArray['database']}.',";
         }
         $tablePrefixes .= "\n);";
         $this->assign('tablePrefixes', $tablePrefixes);
     }
     parent::buildQuickForm();
 }
Ejemplo n.º 28
0
 function __construct()
 {
     $this->_add2groupSupported = false;
     // don’t display the ‘Add these Contacts to Group’ button
     $dsn = defined('CIVICRM_LOGGING_DSN') ? DB::parseDSN(CIVICRM_LOGGING_DSN) : DB::parseDSN(CIVICRM_DSN);
     $this->loggingDB = $dsn['database'];
     $this->log_conn_id = CRM_Utils_Request::retrieve('log_conn_id', 'Integer', CRM_Core_DAO::$_nullObject);
     $this->log_date = CRM_Utils_Request::retrieve('log_date', 'String', CRM_Core_DAO::$_nullObject);
     // make sure the report works even without the params
     if (!$this->log_conn_id or !$this->log_date) {
         $dao = new CRM_Core_DAO();
         $dao->query("SELECT log_conn_id, log_date FROM `{$this->loggingDB}`.log_civicrm_contact WHERE log_action = 'Update' ORDER BY log_date DESC LIMIT 1");
         $dao->fetch();
         $this->log_conn_id = $dao->log_conn_id;
         $this->log_date = $dao->log_date;
     }
     $this->_columnHeaders = array('field' => array('title' => ts('Field')), 'from' => array('title' => ts('Changed From')), 'to' => array('title' => ts('Changed To')));
     parent::__construct();
 }
Ejemplo n.º 29
0
 function &connect($dsn, $options = array())
 {
     $dsninfo = DB::parseDSN($dsn);
     $type = $dsninfo['phptype'];
     if (!is_array($options)) {
         /*
          * For backwards compatibility.  $options used to be boolean,
          * indicating whether the connection should be persistent.
          */
         $options = array('persistent' => $options);
     }
     if (isset($options['debug']) && $options['debug'] >= 2) {
         // expose php errors with sufficient debug level
         include_once "DB/{$type}.php";
     } else {
         @(include_once "DB/{$type}.php");
     }
     $classname = "DB_{$type}";
     if (!class_exists($classname)) {
         $tmp = PEAR::raiseError(null, DB_ERROR_NOT_FOUND, null, null, "Unable to include the DB/{$type}.php" . " file for '{$dsn}'", 'DB_Error', true);
         return $tmp;
     }
     include dirname(__FILE__) . '/freepbx_DB_extends.php';
     $classname = class_exists('freepbx_' . $classname) ? 'freepbx_' . $classname : $classname;
     @($obj = new $classname());
     foreach ($options as $option => $value) {
         $test = $obj->setOption($option, $value);
         if (DB::isError($test)) {
             return $test;
         }
     }
     $err = $obj->connect($dsninfo, $obj->getOption('persistent'));
     if (DB::isError($err)) {
         if (is_array($dsn)) {
             $err->addUserInfo(DB::getDSNString($dsn, true));
         } else {
             $err->addUserInfo($dsn);
         }
         return $err;
     }
     return $obj;
 }
Ejemplo n.º 30
0
 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     $config = CRM_Core_Config::singleton();
     $this->_uf = $config->userFramework;
     if ($this->_uf == 'WordPress') {
         $this->_settings['wpBasePage'] = CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME;
     }
     CRM_Utils_System::setTitle(ts('Settings - %1 Integration', array(1 => $this->_uf)));
     if ($config->userSystem->is_drupal) {
         $this->_settings['userFrameworkUsersTableName'] = CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME;
     }
     // find out if drupal has its database prefixed
     global $databases;
     $drupal_prefix = '';
     if (isset($databases['default']['default']['prefix'])) {
         if (is_array($databases['default']['default']['prefix'])) {
             $drupal_prefix = $databases['default']['default']['prefix']['default'];
         } else {
             $drupal_prefix = $databases['default']['default']['prefix'];
         }
     }
     if (function_exists('module_exists') && module_exists('views') && ($config->dsn != $config->userFrameworkDSN || !empty($drupal_prefix))) {
         $dsnArray = DB::parseDSN($config->dsn);
         $tableNames = CRM_Core_DAO::GetStorageValues(NULL, 0, 'Name');
         $tablePrefixes = '$databases[\'default\'][\'default\'][\'prefix\']= array(';
         $tablePrefixes .= "\n  'default' => '{$drupal_prefix}',";
         // add default prefix: the drupal database prefix
         $prefix = "";
         if ($config->dsn != $config->userFrameworkDSN) {
             $prefix = "`{$dsnArray['database']}`.";
         }
         foreach ($tableNames as $tableName => $value) {
             $tablePrefixes .= "\n  '" . str_pad($tableName . "'", 41) . " => '{$prefix}',";
         }
         $tablePrefixes .= "\n);";
         $this->assign('tablePrefixes', $tablePrefixes);
     }
     parent::buildQuickForm();
 }