00001 <?php 00002 /************************************************************************ 00003 OptionalChoice.php - Copyright arklinux 00004 00005 Here you can write a license for your code, some comments or any other 00006 information you want to have in your generated code. To to this simply 00007 configure the "headings" directory in uml to point to a directory 00008 where you have your heading files. 00009 00010 or you can just replace the contents of this file with your own. 00011 If you want to do this, this file is located at 00012 00013 /usr/share/apps/umbrello/headings/heading.php 00014 00015 -->Code Generators searches for heading files based on the file extension 00016 i.e. it will look for a file name ending in ".h" to include in C++ header 00017 files, and for a file name ending in ".java" to include in all generated 00018 java code. 00019 If you name the file "heading.<extension>", Code Generator will always 00020 choose this file even if there are other files with the same extension in the 00021 directory. If you name the file something else, it must be the only one with that 00022 extension in the directory to guarantee that Code Generator will choose it. 00023 00024 you can use variables in your heading files which are replaced at generation 00025 time. possible variables are : author, date, time, filename and filepath. 00026 just write %variable_name% 00027 00028 This file was generated on %date% at %time% 00029 The original location of this file is /home/arklinux/public_html/confuzled/setup/modules/convention/code/OptionalChoice.php 00030 **************************************************************************/ 00031 00032 00033 00037 class OptionalChoice 00038 { 00039 var $category; 00040 var $title; 00041 var $description; 00042 var $price; 00043 var $adminOnly; 00044 var $available; 00045 00046 var $id; 00047 var $parentConvention; 00048 00049 function OptionalChoice( $parentConvention, $optionalChoiceID = 0 ) 00050 { 00051 $this->parentConvention = &$parentConvention; 00052 $this->id = $optionalChoiceID; 00053 00054 if( $optionalChoiceID > 0 ) 00055 $this->load(); 00056 } 00057 00058 function load() 00059 { 00060 $filename = $this->parentConvention->conventionBasedir . "/optionalchoices/" . $this->id . ".php"; 00061 00062 if( file_exists( $filename ) ) 00063 include( $filename ); 00064 00065 foreach( $settings as $key => $value ) 00066 $this->$key = $value; 00067 } 00068 00069 function save() 00070 { 00071 $basedir = $this->parentConvention->conventionBasedir . "/optionalchoices"; 00072 if( !is_dir( $basedir ) ) 00073 mkdir( $basedir ); 00074 00075 $filename = "$basedir/" . $this->id . ".php"; 00076 00077 if( file_exists( $filename ) ) 00078 unlink( $filename ); 00079 00080 $settings["category"] = $this->category; 00081 $settings["title"] = $this->title; 00082 $settings["description"] = $this->description; 00083 $settings["price"] = $this->price; 00084 $settings["adminOnly"] = $this->adminOnly; 00085 $settings["available"] = $this->available; 00086 00087 file_put_contents( $filename, array_export( $settings, "settings" ) ); 00088 } 00089 00090 function isAvailable() 00091 { 00092 $available = false; 00093 00094 if( isAllowed("global_admin") ) 00095 $available = true; 00096 if( !$this->adminOnly && $this->available == true ) 00097 $available = true; 00098 00099 return $available; 00100 } 00101 } // end of OptionalChoice 00102 ?>