Lack of interest [suggestion] Track the edit date for templates

This suggestion has been closed automatically because it did not receive enough votes over an extended period of time. If you wish to see this, please search for an open suggestion and, if you don't find any, post a new one.

Mike Tougeron

Well-known member
It'd be nice to track when a template has been last edited. Possible patch is below. The one thing I'm not sure about is in the import* methods whether or not the imported value for last_modified_date will be retained.

Code:
ALTER TABLE xf_template ADD COLUMN last_modified_date INT(10) UNSIGNED NOT NULL default 0;

XenForo_DataWriter_Template::_getFields() line 80:
PHP:
'version_string'    => array('type' => self::TYPE_STRING, 'maxLength' => 30, 'default' =>''),
'last_modified_date' => array('type' => self::TYPE_UINT, 'default' => 0)

XenForo_DataWriter_Template::_writeMetaDataDevFileOutput() line 328-330:
PHP:
XenForo_Helper_DevelopmentXml::writeMetaDataOutput(
    $metaDataFile, $title, $data, array('version_id', 'version_string', 'last_modified_date')
);

XenForo_DataWriter_Template::_preSave() insert after line 225:
PHP:
if ( $this->hasChanges() ) {
    $this->set('last_modified_date', XenForo_Application::$time);
}

XenForo_Model_Template::importTemplatesAddOnXml() line 719:
PHP:
'version_string' => (string)$template['version_string'],
'last_modified_date' => (isset($template['last_modified_date']) ? (int)$template['last_modified_date'] : XenForo_Application::$time)

XenForo_Model_Template::importTemplatesStyleXml() line 769:
PHP:
'version_string' => (string)$template['version_string'],
'last_modified_date' => (isset($template['last_modified_date']) ? (int)$template['last_modified_date'] : XenForo_Application::$time)

XenForo_Model_Template::appendTemplatesAddOnXml() insert after line 793:
PHP:
$templateNode->setAttribute('last_modified_date', (isset($template['last_modified_date']) ? (int)$template['last_modified_date'] : XenForo_Application::$time));

XenForo_Model_Template::appendTemplatesStyleXml() insert after line 817:
PHP:
$templateNode->setAttribute('last_modified_date', (isset($template['last_modified_date']) ? (int)$template['last_modified_date'] : XenForo_Application::$time));

I don't think XenForo_Model_Template::importTemplatesFromDevelopment() will need any changes since if the XML has been updated via the code above, line 642 $dw->bulkSet($metaData[$templateName]); should properly import the last_modified_date field.

edit: switched to PHP instead of CODE tags.
 
Upvote 0
This suggestion has been closed. Votes are no longer accepted.
Top Bottom