<?php $this->query("\n CREATE TABLE `message_application` (\n `message_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n `author_id` int(11) unsigned NOT NULL,\n `app_id` int(11) unsigned NOT NULL,\n `message` text COLLATE utf8_unicode_ci NOT NULL,\n `created_at` datetime NOT NULL,\n PRIMARY KEY (`message_id`),\n KEY `author_id` (`author_id`),\n KEY `app_id` (`app_id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n"); $this->query("\n CREATE TABLE `message_application_file` (\n `file_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n `message_id` int(11) unsigned NOT NULL,\n `file` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\n PRIMARY KEY (`file_id`),\n KEY `message_id` (`message_id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;\n"); $this->query("\n ALTER TABLE `message_application`\n ADD CONSTRAINT `FK_MESSAGE_APPLICATION_APP_ID`\n FOREIGN KEY (`app_id`) REFERENCES `application` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n"); $this->query("\n ALTER TABLE `message_application_file`\n ADD CONSTRAINT `FK_MESSAGE_APPLICATION_FILE_MESSAGE_ID`\n FOREIGN KEY (`message_id`) REFERENCES `message_application` (`message_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n"); $resource = new Acl_Model_Resource(); $resource->find("editor_settings", "code"); if ($resource_id = $resource->getId()) { $data = array("parent_id" => $resource_id, "code" => "editor_settings_messages", "label" => "Access the editor messages", "url" => "message/application/*"); $resource = new Acl_Model_Resource(); $resource->find("editor_settings_messages", "code"); $resource->addData($data)->save(); }