Index: branches/RC/core/units/phrases/phrases_event_handler.php =================================================================== diff -u -r9408 -r11430 --- branches/RC/core/units/phrases/phrases_event_handler.php (.../phrases_event_handler.php) (revision 9408) +++ branches/RC/core/units/phrases/phrases_event_handler.php (.../phrases_event_handler.php) (revision 11430) @@ -10,14 +10,26 @@ function CheckPermission(&$event) { if (!$this->Application->IsAdmin() && $this->Application->isDebugMode() && constOn('DBG_PHRASES')) { - if ($event->Name == 'OnNew' || $event->Name == 'OnCreate') { + if ($event->Name == 'OnNew' || $event->Name == 'OnCreate' || $event->Name == 'OnPrepareUpdate' || $event->Name == 'OnUpdate') { return true; } } + + return parent::CheckPermission($event); } + function mapPermissions() + { + parent::mapPermissions(); + $permissions = Array ( + 'OnItemBuild' => Array('self' => true, 'subitem' => true), + ); + + $this->permMapping = array_merge($this->permMapping, $permissions); + } + /** * Forces new label in case if issued from get link * @@ -53,6 +65,26 @@ } } + function OnPrepareUpdate(&$event) + { + $language_id = $this->Application->GetVar('m_lang'); + $label = $this->Application->GetVar('phrases_label'); + + $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName'); + $label_idfield = $this->Application->getUnitOption($event->Prefix, 'IDField'); + + $sql = 'SELECT '.$label_idfield.' FROM '.$table_name.' WHERE Phrase = '.$this->Conn->qstr($label).' AND LanguageId = '.$language_id; + $this->Application->SetVar($event->getPrefixSpecial() . '_id', $this->Conn->GetOne($sql)); +// $event->redirect = false; + } + + function OnUpdate(&$event) + { + parent::OnUpdate($event); + +// $event->redirect = + } + /** * Forces create to use live table *