Source for file functions_display.php

Documentation is available at functions_display.php

  1. <?php
  2.  
  3.  
  4.  
  5. function get_nav_content( $navArray = NULL ) {
  6.  
  7. $returnString = '<div class="navigation">';
  8.  
  9.  
  10. if( $referrerObject = get_object( $_SESSION['new_object']['object'] ) ) {
  11.  
  12. $returnString .= '<strong><a href="'.$_SESSION['new_object']['referrer'].'">return to '.$referrerObject->get_index().'</a></strong>';
  13.  
  14. } else if( !isset( $_SESSION['new_object']['referrer'] ) && $navArray ) {
  15.  
  16. foreach( $navArray as $currentNav ) {
  17.  
  18. //for( reset($navArray); $currentNav = current($navArray); next($navArray) ) {
  19.  
  20. if( allowed( $currentNav['permission'] ) || !$currentNav['permission'] ) {
  21.  
  22. $returnString .= '<a href="'.$currentNav['link'].'" '.mouseover().'>'.$currentNav['title'].'</a><br>';
  23.  
  24. }
  25.  
  26. if( $currentNav['submenu'] ) {
  27.  
  28. for( reset($currentNav['submenu']); $subNav = current($currentNav['submenu']); next($currentNav['submenu'] ) ) {
  29.  
  30. $returnString .= '<a href="'.$subNav['link'].'" class="indent" '.mouseover().'>'.limitString($subNav['title']).'</a><br>';
  31.  
  32. }
  33.  
  34. }
  35.  
  36. }
  37.  
  38. }
  39.  
  40.  
  41. $returnString .= '</div><!-- end navigation -->';
  42.  
  43. return $returnString;
  44.  
  45. }
  46.  
  47.  
  48.  
  49. function error_text( $key = NULL, $list = true ) {
  50.  
  51. //echos any errors in the error array - if key is specified echos the error for the given key
  52.  
  53. $returnString;
  54.  
  55.  
  56. if( is_array( $GLOBALS['errorArray'] ) ) {
  57.  
  58. if( $key && array_key_exists( $key, $GLOBALS['errorArray'] ) && $GLOBALS['errorArray'][$key] ) {
  59.  
  60. $returnString .= '<span class="error_text">'.$GLOBALS['errorArray'][$key].'</span><br>';
  61.  
  62. } else if( !$key && $GLOBALS['errorArray'] ) {
  63.  
  64. if( $list ) { $returnString .= '<span class="error_text">'.'the following errors occurred:'.'</span><ul>'; }
  65.  
  66. foreach( $GLOBALS['errorArray'] as $error ) {
  67.  
  68. if( $error ) {
  69.  
  70. if( $list ) { $returnString .= '<li>'; }
  71.  
  72. $returnString .= '<span class="error_text">'.$error.'</span>';
  73.  
  74. if( $list ) { $returnString .= '</li>'; }
  75.  
  76. }
  77.  
  78. }
  79.  
  80. if( $list ) { $returnString .= '</ul>'; }
  81.  
  82. }
  83.  
  84. }
  85.  
  86.  
  87. return $returnString;
  88.  
  89. }
  90.  
  91.  
  92.  
  93. function system_get_module_tabs() {
  94.  
  95. //system implementation of the get_module_tabs function
  96.  
  97. $modules = $GLOBALS['core']->core_get_active_modules();
  98.  
  99. $html = "";
  100.  
  101.  
  102. if( isset( $GLOBALS['user'] ) ) {
  103.  
  104. $html .= $GLOBALS['user']->get_index().' logged in | <a href="system_management.php?object_type=people&object='.$GLOBALS['user']->id.'">my account</a> | ';
  105.  
  106. }
  107.  
  108.  
  109.  
  110. for( reset($modules); $module=current($modules);next($modules) ) {
  111.  
  112. if( allowed( "view ".$module['module_name'] ) ) {
  113.  
  114. $evalCode = "\$moduleHTML = ".$module['module_name']."_get_module_tab_html();";
  115.  
  116. eval($evalCode);
  117.  
  118. if( key($modules) ) {
  119.  
  120. $html .= " | ";
  121.  
  122. }
  123.  
  124. $html .= $moduleHTML;
  125.  
  126. }
  127.  
  128. }
  129.  
  130.  
  131.  
  132. return $html;
  133.  
  134. }
  135.  
  136.  
  137.  
  138. function system_get_module_content() {
  139.  
  140. //echos content for each module based on current form data
  141.  
  142. $modules = $GLOBALS['core']->core_get_active_modules();
  143.  
  144. $returnString;
  145.  
  146.  
  147.  
  148. if( count($modules) ) {
  149.  
  150. foreach( $modules as $module ) {
  151.  
  152. if( !$returnString && function_exists( $module['module_name']."_get_content" ) ) {
  153.  
  154. $evalCode = "\$returnString = ".$module['module_name']."_get_content();";
  155.  
  156. eval($evalCode);
  157.  
  158. }
  159.  
  160.  
  161. }
  162.  
  163.  
  164. if( !$returnString && $_GET['object'] && ( $_GET['action'] != 'delete' ) ) {
  165.  
  166. if( $object =& get_object( $_GET['object'], $_GET['object_type'] ) ) {
  167.  
  168. $returnString = $object->get_contents( make_nav_array() );
  169.  
  170. $control = true;
  171.  
  172. }
  173.  
  174. }
  175.  
  176. if( !$returnString && $_GET['object_type'] ) {
  177.  
  178. $object_type =& $GLOBALS['core']->get_object_type($_GET['object_type']);
  179.  
  180. $returnString =$object_type->get_contents( make_nav_array() );
  181.  
  182. }
  183.  
  184. return $returnString;
  185.  
  186. }
  187.  
  188. }
  189.  
  190.  
  191.  
  192. function make_nav_array() {
  193.  
  194. if( $_GET['module'] ) {
  195.  
  196. if( $module =& $GLOBALS['core']->get_module( $_GET['module'] ) ) {
  197.  
  198. if( !is_array( $module['module_object_types'] ) ) {
  199.  
  200. $module['module_object_types'] = unserialize( $module['module_object_types'] );
  201.  
  202. }
  203.  
  204. foreach( $module['module_object_types'] as $object_type ) {
  205.  
  206.  
  207. //security routine
  208.  
  209. if( allowed( 'view object type '.$object_type['name'] ) ) {
  210.  
  211. $returnArray[ $object_type['name'] ] = array( 'title'=>$object_type['name'], 'link'=>'system_management.php?module='.$_GET['module'].'&object_type='.$object_type['name'] );
  212.  
  213. }
  214.  
  215. }
  216.  
  217. }
  218.  
  219. } else if( $object =& get_object( $_GET['object'], $_GET['object_type'] ) ) {
  220.  
  221.  
  222. //security routine
  223.  
  224. if( allowed( 'view object type '.$object->type->type_name ) ) {
  225.  
  226. $returnArray[ $object->type->get_attribute( 'type_name' ) ] = array( 'title'=>$object->type->get_attribute( 'type_name' ), 'link'=>'system_management.php?object_type='.$object->type->get_attribute( 'type_name' ) );
  227.  
  228.  
  229. }
  230.  
  231. }
  232.  
  233. if( $object || $object = get_object( $_GET['object'], $_GET['object_type'] ) ) {
  234.  
  235. //security routine
  236.  
  237. if( allowed( 'view any '.$object->type->type_name ) ) {
  238.  
  239. if( $navObjects = $object->type->retrieve_all() ) {
  240.  
  241. foreach( $navObjects as $navObject ) {
  242.  
  243. $subNav[] = array( 'title'=>$navObject->get_index(), 'link'=>'system_management.php?object_type='.$_GET['object_type'].'&object='.$navObject->get_attribute('id') );
  244.  
  245. }
  246.  
  247. $returnArray[ $object->type->get_attribute( 'type_name' ) ]['submenu'] =$subNav;
  248.  
  249. }
  250.  
  251. }
  252.  
  253. } else if( $type = $GLOBALS['core']->get_object_type( $_GET['object_type'] ) ) {
  254.  
  255. if( allowed( 'view any '.$type->type_name ) ) {
  256.  
  257. if( $navObjects = $type->retrieve_all() ) {
  258.  
  259. foreach( $navObjects as $navObject ) {
  260.  
  261. $subNav[] = array( 'title'=>$navObject->get_index(), 'link'=>'system_management.php?object_type='.$_GET['object_type'].'&object='.$navObject->get_attribute('id') );
  262.  
  263. }
  264.  
  265. $returnArray[ $type->get_attribute( 'type_name' ) ]['submenu'] =$subNav;
  266.  
  267. }
  268.  
  269. }
  270.  
  271. }
  272.  
  273. /*$returnArray = array();
  274.  
  275. if( $_GET['module'] ) {
  276.  
  277. if( $module =& $GLOBALS['core']->get_module( $_GET['module'] ) ) {
  278.  
  279. if( !is_array( $module['module_object_types'] ) ) {
  280.  
  281. $module['module_object_types'] = unserialize( $module['module_object_types'] );
  282.  
  283. }
  284.  
  285. foreach( $module['module_object_types'] as $object_type ) {
  286.  
  287.  
  288. //security routine
  289.  
  290. if( allowed( 'view object type '.$object_type['name'] ) ) {
  291.  
  292. $returnArray[ $object_type['name'] ] = array( 'title'=>$object_type['name'], 'link'=>'system_management.php?module='.$_GET['module'].'&object_type='.$object_type['name'] );
  293.  
  294. }
  295.  
  296. }
  297.  
  298. }
  299.  
  300. if( $_GET['object_type'] && $_GET['object'] && $_GET['action'] != 'delete' ) {
  301.  
  302. //NOTE: something in here is causing new objects to be created after they've been deleted
  303.  
  304. //i've gotten around it by not running the code if delete has been called, but the underlying problem may show up elsewhere
  305.  
  306. $subNav;
  307.  
  308. $object_type =& $GLOBALS['core']->get_object_type( $_GET['object_type'] );
  309.  
  310.  
  311. if( !$module ) {
  312.  
  313. $returnArray[ $object_type->type_name ] = array( 'title'=>$object_type->type_name, 'link'=>'system_management.php?object_type='.$object_type->type_name );
  314.  
  315. }
  316.  
  317.  
  318. //security routine
  319.  
  320. if( allowed( 'view any '.$object_type->type_name ) ) {
  321.  
  322. if( $objects =& $object_type->retrieve_all() ) {
  323.  
  324. foreach( $objects as $navObject ) {
  325.  
  326. $subNav[] = array( 'title'=>$navObject->get_index(), 'link'=>'system_management.php?module='.$_GET['module'].'&object_type='.$_GET['object_type'].'&object='.$navObject->get_attribute('id') );
  327.  
  328. }
  329.  
  330. $returnArray[ $_GET['object_type'] ]['submenu'] = $subNav;
  331.  
  332. }
  333.  
  334. }
  335.  
  336. }
  337.  
  338. } else if( $_GET['object'] ) {
  339.  
  340. if( $object = get_object( $_GET['object'] ) ) {
  341.  
  342.  
  343. //security routine
  344.  
  345. if( allowed( 'view object type '.$object->type->type_name ) ) {
  346.  
  347. $returnArray[ $object->type->get_attribute( 'type_name' ) ] = array( 'title'=>$object->type->get_attribute( 'type_name' ), 'link'=>'system_management.php?object_type='.$object->type->get_attribute( 'type_name' ) );
  348.  
  349.  
  350. //security routine
  351.  
  352. if( allowed( 'view any '.$object->type->type_name ) ) {
  353.  
  354. if( $navObjects = $object->type->retrieve_all() ) {
  355.  
  356. foreach( $navObjects as $navObject ) {
  357.  
  358. $subNav[] = array( 'title'=>$navObject->get_index(), 'link'=>'system_management.php?object_type='.$_GET['object_type'].'&object='.$navObject->get_attribute('id') );
  359.  
  360. }
  361.  
  362. $returnArray[ $object->type->get_attribute( 'type_name' ) ]['submenu'] =$subNav;
  363.  
  364. }
  365.  
  366. }
  367.  
  368. }
  369.  
  370. }
  371.  
  372. }
  373.  
  374. */
  375.  
  376. //not very elegant but...
  377.  
  378. //if this isn't the system module don't show permissions
  379.  
  380. if( $_GET['module'] != 'system' ) { unset( $returnArray['permissions'] ); }
  381.  
  382.  
  383.  
  384. return $returnArray;
  385.  
  386. }
  387.  
  388.  
  389.  
  390. function system_beta_1_get_content() {
  391.  
  392. //system implementation of system_get_module_content function
  393.  
  394. if( ( $_GET['p'] == "start" || !$_GET['module'] || $_GET['module'] == "system" ) && !$_GET['object_type'] && !$_GET['object'] ) {
  395.  
  396. if( $modules = $GLOBALS['core']->core_get_active_modules() ) {
  397.  
  398. foreach( $modules as $module ) {
  399.  
  400. if( allowed( 'view '.$module->module_name ) ) {
  401.  
  402. if( !is_array( $module['module_object_types'] ) ) {
  403.  
  404. $module['module_object_types'] = unserialize( $module['module_object_types'] );
  405.  
  406. }
  407.  
  408. foreach( $module['module_object_types'] as $object_type ) {
  409.  
  410. if( allowed( 'view object type '.$object_type['name'] ) ) {
  411.  
  412. $navArray[ $object_type['name'] ] = array( 'title'=>$object_type['name'], 'link'=>'system_management.php?module=system&object_type='.$object_type['name'] );
  413.  
  414. }
  415.  
  416. }
  417.  
  418. }
  419.  
  420. }
  421.  
  422. }
  423.  
  424.  
  425. $returnString = '<div id="sidebar">'.get_nav_content( $navArray ).'</div>';
  426.  
  427.  
  428. //open the content div
  429.  
  430. $returnString .= '<div id="sub_content">';
  431.  
  432.  
  433. if( $_GET['p'] == "start" ) { $returnString .= '<h1> welcome '.$GLOBALS['user']->get_index().'</h1>'; }
  434.  
  435. else { $returnString .= '<h1> welcome to pi</h1>'; }
  436.  
  437.  
  438. //close the content div
  439.  
  440. $returnString .= '<p>to update the system, click which type of information you would like to view/modify below or the type of object you would like to create to the right</p></div>';
  441.  
  442.  
  443. return $returnString;
  444.  
  445. }
  446.  
  447. }
  448.  
  449. ?>

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