announcements.install
Search API
- 6.x modules/announcements/announcements.install
- 4.x modules/announcements/announcements.install
- 5.x modules/announcements/announcements.install
File
modules/announcements/announcements.installView source
- <?php
-
- /**
- * This file should contain only hooks relating to installing, enabling, disabling, and uninstalling this module.
- *
- */
-
-
- /**
- * Hook install. Called when the module is installed on the admin modules page.
- *
- */
- function announcements_install() {
- // Install our table
- $q = "
- CREATE TABLE `content__announcement` (
- `cid` int unsigned NOT NULL,
- `vid` int NOT NULL,
- `field__activity_datetime` datetime DEFAULT NULL,
- `field__msg` longtext,
- `field__visibility` varchar(255) DEFAULT NULL,
- PRIMARY KEY (`vid`),
- KEY `cid` (`cid`),
- KEY `visibility` (`field__visibility`),
- KEY `field__activity_datetime` (`field__activity_datetime`)
- );
- ";
- db_query($q);
-
-
- }
-
-
-
- function announcements_update($old_schema, $new_schema) {
-
- if (intval($old_schema) < 2) {
- // Convert text fields to longtext.
- db_query("ALTER TABLE content__announcement MODIFY field__msg LONGTEXT");
- fpm("Altered content__announcement table to change 'field__msg' to LONGTEXT.");
- }
-
- }
-
-
-
-
- function announcements_enable() {
-
- // Now, add a piece of custom content using content_save() function.
-
- $content = new stdClass();
- $content->type = 'announcement';
- $content->cid = "new";
- $content->published = 1;
- $content->delete_flag = 0;
- $content->title = "Sample Announcement";
-
- // TODO: This extra field data (aside from title) is not getting saved on first install, because hooks do not appear to be working
- // on first install of FlightPath. At least, not in this situation. I think it's because the content_content_save function cannot find
- // all the fields associated with this content type.
-
- $content->field__activity_datetime['value'] = date("Y-m-d H:ia");
- $content->field__msg['value'] = '<p>This is a sample announcement! You may add new announcements (or delete this one) from the Admin Tools, then Content.</p>';
- $content->field__visibility['value'] = 'public';
-
- content_content_save($content); // Since this is in our install script (which is run on first installation of FlightPath, we will call content_content_save, instead
- // of just content_save, thereby skipping the hook check.
-
- }
Functions
Name | Description |
---|---|
announcements_enable | |
announcements_install | Hook install. Called when the module is installed on the admin modules page. |
announcements_update |