Page MenuHomeIn-Portal Phabricator

D535.id.diff
No OneTemporary

File Metadata

Created
Tue, Sep 23, 12:44 PM

D535.id.diff

Index: core/units/logs/change_logs/change_log_eh.php
===================================================================
--- core/units/logs/change_logs/change_log_eh.php
+++ core/units/logs/change_logs/change_log_eh.php
@@ -35,6 +35,41 @@
}
/**
+ * @inheritDoc
+ */
+ protected function prepareObject(&$object, kEvent $event)
+ {
+ parent::prepareObject($object, $event);
+
+ $object->SetFieldOption('Prefix', 'options', $this->generatePrefixFieldOptions('Prefix'));
+ $object->SetFieldOption('MasterPrefix', 'options', $this->generatePrefixFieldOptions('MasterPrefix'));
+ }
+
+ /**
+ * Builds prefix options.
+ *
+ * @param string $field Field.
+ *
+ * @return array
+ */
+ protected function generatePrefixFieldOptions($field)
+ {
+ $sql = 'SELECT DISTINCT ' . $field . '
+ FROM ' . TABLE_PREFIX . 'ChangeLogs';
+ $prefixes = $this->Conn->GetCol($sql);
+
+ $ret = array();
+
+ foreach ( $prefixes as $prefix ) {
+ $ret[$prefix] = 'la_prefix_' . $prefix;
+ }
+
+ asort($ret);
+
+ return $ret;
+ }
+
+ /**
* Updates affected record count in session, when change log record is deleted
*
* @param kEvent $event
@@ -63,4 +98,4 @@
{
$this->Application->SetConfigValue('UseChangeLog', 1);
}
-}
\ No newline at end of file
+}
Index: core/units/logs/change_logs/change_logs_config.php
===================================================================
--- core/units/logs/change_logs/change_logs_config.php
+++ core/units/logs/change_logs/change_logs_config.php
@@ -106,22 +106,16 @@
),
'OccuredOn' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'time_format' => 'H:i:s', 'default' => NULL),
'Prefix' => Array (
- 'type' => 'string', 'formatter' => 'kOptionsFormatter',
- 'options_sql' => 'SELECT DISTINCT %s FROM '.TABLE_PREFIX.'ChangeLogs ORDER BY Phrase',
- 'option_key_field' => 'Prefix',
- 'option_title_field' => 'CONCAT(\'la_prefix_\', Prefix) AS Phrase',
- 'use_phrases' => 1,
- 'max_len' => 255, 'not_null' => 1, 'default' => ''
+ 'type' => 'string', 'max_len' => 255,
+ 'formatter' => 'kOptionsFormatter', 'options' => array(), 'use_phrases' => 1,
+ 'not_null' => 1, 'default' => '',
),
'ItemId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
'Changes' => Array ('type' => 'string', 'formatter' => 'kChangesFormatter', 'default' => NULL),
'MasterPrefix' => Array (
- 'type' => 'string', 'formatter' => 'kOptionsFormatter',
- 'options_sql' => 'SELECT DISTINCT %s FROM '.TABLE_PREFIX.'ChangeLogs ORDER BY Phrase',
- 'option_key_field' => 'MasterPrefix',
- 'option_title_field' => 'CONCAT(\'la_prefix_\',MasterPrefix) AS Phrase',
- 'use_phrases' => 1,
- 'max_len' => 255, 'not_null' => 1, 'default' => ''
+ 'type' => 'string', 'max_len' => 255,
+ 'formatter' => 'kOptionsFormatter', 'options' => array(), 'use_phrases' => 1,
+ 'not_null' => 1, 'default' => '',
),
'MasterId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
),

Event Timeline