Source for file module_functions.php

Documentation is available at module_functions.php

  1. <?php
  2.  
  3. function system_start() {
  4. //performs system startup
  5.  
  6. if( !function_exists( 'allowed' ) ) {
  7. function allowed() { return true; }
  8. }
  9.  
  10. $GLOBALS['errorArray'] = array();
  11. if( !isset($GLOBALS['core'] ) ) {
  12. $GLOBALS['core'] = new core;
  13. $GLOBALS['core']->preload();
  14. }
  15.  
  16. //perform startup for each active module
  17. $activeModules = $GLOBALS['core']->core_get_active_modules();
  18. if( count($activeModules) ) {
  19. foreach( $activeModules as $module ) {
  20. if( $module['module_name'] != "system_beta_1" && function_exists( $module['module_name']."_start" ) ) {
  21. eval( $module['module_name']."_start();" );
  22. }
  23. if( $module['module_name'] != "system_beta_1" && function_exists( $module['module_name']."_process_post" ) ) {
  24. eval( $module['module_name']."_process_post();" );
  25. }
  26. }
  27. }
  28.  
  29. //system data handling
  30. system_beta_1_process_post();
  31. }
  32.  
  33. function system_beta_1_module_info() {
  34. //returns information about the system module
  35.  
  36. $object_types['type_set']['table_name'] = 'type_sets';
  37. $object_types['type_set']['name'] = 'type sets';
  38. $object_types['type_set']['description'] = 'FIX ME!!!';
  39. $object_types['type_set']['class_name'] = 'type_set';
  40. $object_types['type_set']['table'] = array( 'id'=>'int', 'relationship_typeID'=>'int', 'primary_constraintID'=>'int', 'secondary_constraintID'=>'int', 'bi_directional'=>'bool' );
  41.  
  42. $object_types['constraint']['table_name'] = 'constraints';
  43. $object_types['constraint']['name'] = 'constraints';
  44. $object_types['constraint']['description'] = 'FIX ME!!!';
  45. $object_types['constraint']['class_name'] = 'constraint';
  46. $object_types['constraint']['table'] = array( 'id'=>'int', 'name'=>'text', 'description'=>'text', 'object_constraints'=>'text', 'relationship_constraints'=>'text' );
  47.  
  48. return array(
  49. "module_name"=>"system_beta_1",
  50. "module_description"=>"This is the system module, DO NOT DEACTIVATE except to upgrade to a new system version. Version: Beta 1",
  51. "module_icon"=>"",
  52. "module_page"=>"Modules/system_beta_1/system_management.php",
  53. "module_location"=>"system_beta_1",
  54. "module_object_types"=> $object_types,
  55. "system_module"=>"1"
  56. );
  57. }
  58.  
  59. function system_beta_1_activate_module() {
  60. //activates the system module
  61. global $db;
  62.  
  63. //locate tables and install if nonexistant
  64. $db->hide_errors();
  65. //check object types table
  66. /*
  67. $db->get_results("SELECT * FROM object_types");
  68. if( !$db->col_info ) {
  69. $db->query("
  70. CREATE TABLE object_types
  71. (
  72. id int,
  73. name char(30),
  74. description text,
  75. table_name text,
  76. class_name char(30),
  77. icon text
  78. )
  79. ");
  80. }
  81. */
  82. //check system variables table
  83. $system_settings = array(
  84. 'table_name' => 'system_settings',
  85. 'table' => array ( 'name' => 'text', 'value' => 'text' )
  86. );
  87. insert_db_table( $system_settings );
  88. /*
  89. $db->get_results("SELECT * FROM system_settings");
  90. if( !$db->col_info ) {
  91. $db->query("
  92. CREATE TABLE system_settings
  93. (
  94. name text,
  95. value text
  96. )
  97. ");
  98. //insert initial settings
  99. $db->query( "
  100. INSERT INTO system_settings
  101. VALUES ( 'system_counter', 4 )
  102. " );*/
  103. $db->query( "
  104. INSERT INTO system_settings
  105. VALUES ( 'object_type_counter', 1 )
  106. " );
  107. $db->query( "
  108. INSERT INTO system_settings
  109. VALUES ( 'objects_counter', 1 )
  110. " );
  111. $db->query( "
  112. INSERT INTO system_settings
  113. VALUES ( 'error_log', NULL )
  114. " );
  115. //setup object types
  116. $module_info = system_beta_1_module_info();
  117. foreach( $module_info['module_object_types'] as $class_name => $object_type ) {
  118. insert_db_table( $object_type );
  119. insert_object_type( $object_type );
  120. /*
  121. $db->get_results("SELECT * FROM ".$object_type['table_name'] );
  122. if( !$db->col_info ) {
  123. $queryString = "CREATE TABLE ".$object_type['table_name']."( ";
  124. foreach( $object_type['table'] as $field => $fieldType ) {
  125. $queryString .= $field." ".$fieldType.",";
  126. }
  127. $queryString = rtrim($queryString, ",").")";
  128. $db->query( $queryString );
  129. $counter = $db->get_var( "SELECT value FROM system_settings WHERE name = 'object_type_counter'" );
  130. $db->query( "
  131. INSERT INTO object_types (id, name, description, table_name, class_name, icon )
  132. VALUES ( '".$counter."', '".$object_type['name']."', '".$object_type['description']."', '".$object_type['table_name']."', '".$class_name."', '' )
  133. " );
  134. $db->query( "UPDATE system_settings SET value = '".($counter + 1)."' WHERE name = 'object_type_counter'" );
  135. }*/
  136. }
  137.  
  138. $GLOBALS['core'] = new core;
  139. //setup constraints
  140. $constraintValues = array (
  141. 'name' => 'is constraint',
  142. 'description' => 'an object of type "constraint"',
  143. 'object_constraints' => array( array( 'attribute'=>'type', 'operator'=>'=', 'value'=>'constraints' ) ),
  144. 'relationship_constraints' => array(),
  145. );
  146. $constraint =& new constraint;
  147. $constraint->verify_set( $constraintValues );
  148.  
  149. $db->show_errors();
  150.  
  151. $db->query( "UPDATE core_settings SET value = 'Modules/system_beta_1/system_management.php' WHERE name = 'start_page'" );
  152.  
  153. return system_beta_1_verify_module();
  154. }
  155.  
  156. function system_beta_1_deactivate_module() {
  157. //deactivates the system module
  158. return true;
  159. }
  160.  
  161. function system_beta_1_verify_module() {
  162. //verifies the integrety of the system module
  163. return true;
  164. }
  165. ?>

Documentation generated on Tue, 24 May 2005 03:58:42 -0400 by phpDocumentor 1.3.0RC3