announcements.install

  1. 7.x modules/announcements/announcements.install
  2. 6.x modules/announcements/announcements.install
  3. 4.x modules/announcements/announcements.install
  4. 5.x modules/announcements/announcements.install

File

modules/announcements/announcements.install
View source
  1. <?php
  2. /**
  3. * This file should contain only hooks relating to installing, enabling, disabling, and uninstalling this module.
  4. *
  5. */
  6. /**
  7. * Hook install. Called when the module is installed on the admin modules page.
  8. *
  9. */
  10. function announcements_install() {
  11. // Install our table
  12. $q = "
  13. CREATE TABLE `content__announcement` (
  14. `cid` int unsigned NOT NULL,
  15. `vid` int NOT NULL,
  16. `field__activity_datetime` datetime DEFAULT NULL,
  17. `field__msg` longtext,
  18. `field__visibility` varchar(255) DEFAULT NULL,
  19. PRIMARY KEY (`vid`),
  20. KEY `cid` (`cid`),
  21. KEY `visibility` (`field__visibility`),
  22. KEY `field__activity_datetime` (`field__activity_datetime`)
  23. );
  24. ";
  25. db_query($q);
  26. }
  27. function announcements_update($old_schema, $new_schema) {
  28. }
  29. function announcements_enable() {
  30. // Now, add a piece of custom content using content_save() function.
  31. $content = new stdClass();
  32. $content->type = 'announcement';
  33. $content->cid = "new";
  34. $content->published = 1;
  35. $content->delete_flag = 0;
  36. $content->title = "Sample Announcement";
  37. // TODO: This extra field data (aside from title) is not getting saved on first install, because hooks do not appear to be working
  38. // on first install of FlightPath. At least, not in this situation. I think it's because the content_content_save function cannot find
  39. // all the fields associated with this content type.
  40. $content->field__activity_datetime['value'] = date("Y-m-d H:ia");
  41. $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>';
  42. $content->field__visibility['value'] = 'public';
  43. 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
  44. // of just content_save, thereby skipping the hook check.
  45. }

Functions

Namesort descending Description
announcements_enable
announcements_install Hook install. Called when the module is installed on the admin modules page.
announcements_update