return TRUE;
}
+ if ($path && preg_match('/^civicrm\/ajax\/l10n-js/', $path)
+ && !empty($_SERVER['HTTP_REFERER'])
+ ) {
+ $ref = parse_url($_SERVER['HTTP_REFERER']);
+ if (preg_match('/civicrm\/upgrade/', $ref['path']) || preg_match('/civicrm\/upgrade/', urldecode($ref['query']))) {
+ return TRUE;
+ }
+ }
+
return FALSE;
}
return new self($table);
}
+ /**
+ * Insert a record based on a DAO.
+ *
+ * @param \CRM_Core_DAO $dao
+ * @return \CRM_Utils_SQL_Insert
+ * @throws \CRM_Core_Exception
+ */
+ public static function dao(CRM_Core_DAO $dao) {
+ $table = CRM_Core_DAO::getLocaleTableName($dao->getTableName());
+ $row = array();
+ foreach ((array) $dao as $key => $value) {
+ if ($value === 'null') {
+ $value = NULL; // Blerg!!!
+ }
+ // Skip '_foobar' and '{\u00}*_options' and 'N'.
+ if (preg_match('/[a-zA-Z]/', $key{0}) && $key !== 'N') {
+ $row[$key] = $value;
+ }
+ }
+ return self::into($table)->row($row);
+ }
+
/**
* Create a new SELECT query.
*
$dao->created_id = $session->get('userID');
}
- $dao->save();
+ if ($dao->id) {
+ $dao->save();
+ }
+ else {
+ // Cannot use $dao->save(); in upgrade mode (eg WP + Civi 4.4=>4.7), the DAO will refuse
+ // to save the field `group_name`, which is required in older schema.
+ \CRM_Core_DAO::executeQuery(\CRM_Utils_SQL_Insert::dao($dao)->toSQL());
+ }
$dao->free();
}