Index: branches/5.2.x/core/install/english.lang =================================================================== --- branches/5.2.x/core/install/english.lang +++ branches/5.2.x/core/install/english.lang @@ -268,6 +268,7 @@ RW1haWwgRGVzaWduIFRlbXBsYXRlIHNob3VsZCBjb250YWluIGF0IGxlYXN0ICIkYm9keSIgdGFnIGluIGl0Lg== RmlsZSBub3QgZm91bmQ= RmlsZSBpcyB0b28gbGFyZ2U= + VGhpcyBVUkwgaXMgY29uZmxpY3Rpbmcgd2l0aCBleGlzdGluZyBVUkwgYW5kIGNhbid0IGJlIHVzZWQ= Z3JvdXAgbm90IGZvdW5k RmllbGQgZG9lc24ndCBleGlzdCBpbiAiJXMiIHVuaXQgY29uZmln SW52YWxpZCBGaWxlIEZvcm1hdA== Index: branches/5.2.x/core/units/categories/categories_config.php =================================================================== --- branches/5.2.x/core/units/categories/categories_config.php +++ branches/5.2.x/core/units/categories/categories_config.php @@ -402,7 +402,12 @@ 'default' => NULL ), 'FormSubmittedTemplate' => Array ('type' => 'string', 'default' => null), - 'FriendlyURL' => Array ('type' => 'string', 'not_null' => 1, 'default' => ''), + 'FriendlyURL' => Array ( + 'type' => 'string', + 'unique' => array(), + 'error_msgs' => array('unique' => '!la_error_FriendlyUrlIsNotUnique!'), + 'not_null' => 1, 'default' => '', + ), 'ThemeId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0), 'EnablePageCache' => Array ( Index: branches/5.2.x/core/units/categories/categories_event_handler.php =================================================================== --- branches/5.2.x/core/units/categories/categories_event_handler.php +++ branches/5.2.x/core/units/categories/categories_event_handler.php @@ -1369,6 +1369,41 @@ } /** + * Validates category data. + * + * @param kEvent $event Event. + * + * @return void + */ + protected function OnBeforeItemValidate(kEvent $event) + { + parent::OnBeforeItemValidate($event); + + /** @var kDBItem $object */ + $object = $event->getObject(); + + $friendly_url = $object->GetDBField('FriendlyURL'); + + if ( strlen($friendly_url) && $friendly_url != $object->GetOriginalField('FriendlyURL') ) { + $sql = 'SELECT CategoryId + FROM %s + WHERE NamedParentPath = ' . $this->Conn->qstr('Content/' . $friendly_url); + $duplicate_id = $this->Conn->GetOne(sprintf($sql, $object->TableName)); + + if ( $duplicate_id === false && $object->IsTempTable() ) { + $duplicate_id = $this->Conn->GetOne(sprintf( + $sql, + $this->Application->GetLiveName($object->TableName) + )); + } + + if ( $duplicate_id !== false ) { + $object->SetError('FriendlyURL', 'unique'); + } + } + } + + /** * Sets correct status for new categories created on front-end * * @param kEvent $event