+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2016 |
+ | Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2016
+ * @copyright CiviCRM LLC (c) 2004-2017
*/
class CRM_Logging_Schema {
private $logs = array();
if (!empty($cols[$alterType])) {
foreach ($cols[$alterType] as $col) {
$line = $this->_getColumnQuery($col, $create);
- CRM_Core_DAO::executeQuery("ALTER TABLE `{$this->db}`.log_$table {$alterType} {$line}");
+ CRM_Core_DAO::executeQuery("ALTER TABLE `{$this->db}`.log_$table {$alterType} {$line}", array(), TRUE, NULL, FALSE, FALSE);
}
}
}
foreach ($cols['OBSOLETE'] as $col) {
$line = $this->_getColumnQuery($col, $create);
// This is just going to make a not null column to nullable
- CRM_Core_DAO::executeQuery("ALTER TABLE `{$this->db}`.log_$table MODIFY {$line}");
+ CRM_Core_DAO::executeQuery("ALTER TABLE `{$this->db}`.log_$table MODIFY {$line}", array(), TRUE, NULL, FALSE, FALSE);
}
}
* @return array
*/
private function _getCreateQuery($table) {
- $dao = CRM_Core_DAO::executeQuery("SHOW CREATE TABLE {$table}");
+ $dao = CRM_Core_DAO::executeQuery("SHOW CREATE TABLE {$table}", array(), TRUE, NULL, FALSE, FALSE);
$dao->fetch();
$create = explode("\n", $dao->Create_Table);
return $create;
}
\Civi::$statics[__CLASS__]['columnsOf'][$table] = array();
while ($dao->fetch()) {
- \Civi::$statics[__CLASS__]['columnsOf'][$table][] = $dao->Field;
+ \Civi::$statics[__CLASS__]['columnsOf'][$table][] = CRM_Utils_type::escape($dao->Field, 'MysqlColumnNameOrAlias');
}
}
return \Civi::$statics[__CLASS__]['columnsOf'][$table];
* Predicate whether logging is enabled.
*/
public function isEnabled() {
- if (CRM_Core_Config::singleton()->logging) {
- return $this->tablesExist() and $this->triggersExist();
+ if (\Civi::settings()->get('logging')) {
+ return ($this->tablesExist() && (\Civi::settings()->get('logging_no_trigger_permission') || $this->triggersExist()));
}
return FALSE;
}
return array_intersect($tables, $this->tables);
}
+ /**
+ * Retrieve missing log tables.
+ *
+ * @return array
+ */
+ public function getMissingLogTables() {
+ if ($this->tablesExist()) {
+ return array_diff($this->tables, array_keys($this->logs));
+ }
+ return array();
+ }
+
}