├── .gitignore ├── README.md ├── application ├── config │ └── datamapper.php ├── datamapper │ ├── array.php │ ├── csv.php │ ├── htmlform.php │ ├── json.php │ ├── nestedsets.php │ ├── rowindex.php │ ├── simplecache.php │ └── translate.php ├── helpers │ └── inflector_helper.php ├── language │ ├── ca │ │ └── datamapper_lang.php │ ├── english │ │ └── datamapper_lang.php │ ├── es │ │ └── datamapper_lang.php │ ├── fr │ │ └── datamapper_lang.php │ ├── it │ │ └── datamapper_lang.php │ ├── nl │ │ └── datamapper_lang.php │ └── pt_BR │ │ └── datamapper_lang.php ├── libraries │ └── datamapper.php ├── models │ └── _template.php ├── third_party │ └── datamapper │ │ ├── bootstrap.php │ │ └── system │ │ ├── DB.php │ │ ├── DB_driver.php │ │ ├── Lang.php │ │ └── Loader.php └── views │ └── dmz_htmlform │ ├── form.php │ ├── row.php │ └── section.php ├── examples ├── application │ ├── config │ │ ├── autoload.php │ │ └── datamapper.php │ ├── controllers │ │ ├── admin.php │ │ ├── bugs.php │ │ ├── login.php │ │ ├── logout.php │ │ ├── users.php │ │ └── welcome.php │ ├── helpers │ │ └── utilities_helper.php │ ├── language │ │ └── english │ │ │ ├── model_bug_lang.php │ │ │ ├── model_category_lang.php │ │ │ ├── model_comment_lang.php │ │ │ ├── model_group_lang.php │ │ │ ├── model_status_lang.php │ │ │ └── model_user_lang.php │ ├── libraries │ │ └── login_manager.php │ ├── models │ │ ├── bug.php │ │ ├── category.php │ │ ├── comment.php │ │ ├── group.php │ │ ├── status.php │ │ └── user.php │ ├── sql │ │ ├── data │ │ │ ├── category.csv │ │ │ ├── group.csv │ │ │ └── status.csv │ │ ├── mysql │ │ │ ├── bugs.sql │ │ │ ├── bugs_categories.sql │ │ │ ├── bugs_users.sql │ │ │ ├── categories.sql │ │ │ ├── comments.sql │ │ │ ├── dependencies_dependents.sql │ │ │ ├── groups.sql │ │ │ ├── statuses.sql │ │ │ └── users.sql │ │ ├── mysqli │ │ │ ├── bugs.sql │ │ │ ├── bugs_categories.sql │ │ │ ├── bugs_users.sql │ │ │ ├── categories.sql │ │ │ ├── comments.sql │ │ │ ├── dependencies_dependents.sql │ │ │ ├── groups.sql │ │ │ ├── statuses.sql │ │ │ └── users.sql │ │ ├── postgre │ │ │ ├── bugs.sql │ │ │ ├── bugs_categories.sql │ │ │ ├── bugs_users.sql │ │ │ ├── categories.sql │ │ │ ├── comments.sql │ │ │ ├── dependencies_dependents.sql │ │ │ ├── groups.sql │ │ │ ├── statuses.sql │ │ │ └── users.sql │ │ └── tabledroplist.txt │ └── views │ │ ├── admin │ │ ├── index.php │ │ ├── init.php │ │ └── reset.php │ │ ├── bugs │ │ ├── edit.php │ │ ├── list.php │ │ ├── paging.php │ │ ├── search.php │ │ └── view.php │ │ ├── login.php │ │ ├── template_footer.php │ │ ├── template_header.php │ │ ├── users │ │ ├── delete.php │ │ ├── edit.php │ │ └── index.php │ │ └── welcome │ │ └── index.php ├── css │ └── style.css └── img │ ├── bg.png │ ├── cc.png │ ├── favicon.png │ ├── header-logo.jpg │ ├── icon │ ├── 16 │ │ ├── add.png │ │ ├── back.png │ │ ├── delete.png │ │ ├── edit.png │ │ ├── move_bottom.png │ │ ├── move_down.png │ │ ├── move_top.png │ │ ├── move_up.png │ │ ├── search.png │ │ └── view.png │ └── 64 │ │ ├── categories.png │ │ ├── database.png │ │ ├── groups.png │ │ ├── statuses.png │ │ └── users.png │ └── profiler.png ├── license.txt └── manual ├── css └── userguide.css ├── images ├── arrow.gif ├── dmz.png ├── dmzlogo.png ├── donate_button.gif ├── download.png ├── example.png ├── favicon.png ├── feed.png ├── nav_bg_darker.jpg ├── nav_separator_darker.jpg ├── nav_toggle_darker.jpg ├── nestedsets.gif ├── notice_icon.jpg └── searchlogo.png ├── index.html ├── js ├── menu.js ├── mootools.js └── rot13.js ├── pages ├── _template.html ├── accessingrelations.html ├── advancedrelations.html ├── advancedusage.html ├── changelog.html ├── changelog │ ├── 1.2.html │ ├── 1.3.html │ ├── 1.4.html │ └── 1.5.html ├── clear.html ├── clonecopy.html ├── config.html ├── controllers.html ├── count.html ├── credits.html ├── database.html ├── delete.html ├── deleteall.html ├── deletingrelations.html ├── download.html ├── examples.html ├── examples │ ├── htmlform.html │ └── login.html ├── exists.html ├── extensions.html ├── extensions │ ├── array.html │ ├── csv.html │ ├── htmlform.html │ ├── json.html │ ├── nestedsets.html │ ├── rowindex.html │ ├── simplecache.html │ └── translate.html ├── extlist.html ├── extwrite.html ├── functions.html ├── get.html ├── getadvanced.html ├── getalt.html ├── getby.html ├── getrules.html ├── gettingstarted.html ├── glossary.html ├── installation.html ├── joinfields.html ├── license.html ├── localize.html ├── manual.html ├── models.html ├── prefix.html ├── prodcache.html ├── refreshall.html ├── relationtypes.html ├── requirements.html ├── reservednames.html ├── roadmap.html ├── save.html ├── savingrelations.html ├── settingrelations.html ├── subqueries.html ├── timestamp.html ├── toc.html ├── transactions.html ├── troubleshooting.html ├── update.html ├── upgrade.html ├── utility.html ├── validate.html └── validation.html ├── robots.txt ├── rss.xml └── sitemap.xml /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Eclipse project files 2 | .buildpath 3 | .project 4 | .settings/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | datamapper 2 | ========== 3 | 4 | CodeIgniter Datamapper 5 | DataMapper is an Object Relational Mapper written in PHP for CodeIgniter. It is designed to map your Database tables into easy to work with objects, fully aware of the relationships between each other. 6 | 7 | General Features 8 | 9 | Everything is an object! 10 | Easy to setup, easy to use. 11 | Custom Validation on object properties. 12 | Lazy Loading (related objects are only loaded upon access). 13 | Relations and their integrity are automatically managed for you. 14 | One to One, One to Many, and Many to Many relations fully supported. 15 | Select data in the style of Active Record (with or without Method Chaining). 16 | -------------------------------------------------------------------------------- /application/config/datamapper.php: -------------------------------------------------------------------------------- 1 | '; 12 | $config['error_suffix'] = '
'; 13 | $config['created_field'] = 'created'; 14 | $config['updated_field'] = 'updated'; 15 | $config['local_time'] = FALSE; 16 | $config['unix_timestamp'] = FALSE; 17 | $config['timestamp_format'] = 'Y-m-d H:i:s'; 18 | $config['lang_file_format'] = 'model_${model}'; 19 | $config['field_label_lang_format'] = '${model}_${field}'; 20 | $config['auto_transaction'] = FALSE; 21 | $config['auto_populate_has_many'] = FALSE; 22 | $config['auto_populate_has_one'] = FALSE; 23 | $config['all_array_uses_ids'] = FALSE; 24 | // set to FALSE to use the same DB instance across the board (breaks subqueries) 25 | // Set to any acceptable parameters to $CI->database() to override the default. 26 | $config['db_params'] = ''; 27 | // Uncomment to enable the production cache 28 | // $config['production_cache'] = 'datamapper/cache'; 29 | $config['extensions_path'] = 'datamapper'; 30 | $config['extensions'] = array(); 31 | $config['cascade_delete'] = TRUE; 32 | 33 | /* End of file datamapper.php */ 34 | /* Location: ./application/config/datamapper.php */ 35 | -------------------------------------------------------------------------------- /application/datamapper/csv.php: -------------------------------------------------------------------------------- 1 | fields; 40 | } 41 | 42 | $success = TRUE; 43 | 44 | // determine if we need to open the file or not. 45 | if(is_string($filename)) 46 | { 47 | // open the file, if possible. 48 | $fp = fopen($filename, 'w'); 49 | if($fp === FALSE) 50 | { 51 | log_message('error', 'CSV Extension: Unable to open file ' . $filename); 52 | return FALSE; 53 | } 54 | } 55 | else 56 | { 57 | // assume file pointer. 58 | $fp = $filename; 59 | } 60 | 61 | if($include_header) 62 | { 63 | // Print out header line 64 | $success = fputcsv($fp, $fields); 65 | } 66 | 67 | if($success) 68 | { 69 | foreach($object as $o) 70 | { 71 | // convert each object into an array 72 | $result = array(); 73 | foreach($fields as $f) 74 | { 75 | $result[] = $o->{$f}; 76 | } 77 | // output CSV-formatted line 78 | $success = fputcsv($fp, $result); 79 | if(!$success) 80 | { 81 | // stop on first failure. 82 | break; 83 | } 84 | } 85 | } 86 | 87 | if(is_string($filename)) 88 | { 89 | fclose($fp); 90 | } 91 | 92 | return $success; 93 | } 94 | 95 | /** 96 | * Import objects from a CSV file. 97 | * 98 | * Completely empty rows are automatically skipped, as are rows that 99 | * start with a # sign (assumed to be comments). 100 | * 101 | * @param DataMapper $object The type of DataMapper Object to import 102 | * @param mixed $filename Name of CSV file, or a file pointer. 103 | * @param array $fields If empty, the database fields are used. Otherwise used to limit what fields are saved. 104 | * @param boolean $header_row If true, the first line is assumed to be a header row. Defaults to true. 105 | * @param mixed $callback A callback method for each row. Can return FALSE on failure to save, or 'stop' to stop the import. 106 | * @return array Array of imported objects, or FALSE if unable to import. 107 | */ 108 | function csv_import($object, $filename, $fields = '', $header_row = TRUE, $callback = NULL) 109 | { 110 | $class = get_class($object); 111 | 112 | if(empty($fields)) 113 | { 114 | $fields = $object->fields; 115 | } 116 | 117 | // determine if we need to open the file or not. 118 | if(is_string($filename)) 119 | { 120 | // open the file, if possible. 121 | $fp = fopen($filename, 'r'); 122 | if($fp === FALSE) 123 | { 124 | log_message('error', 'CSV Extension: Unable to open file ' . $filename); 125 | return FALSE; 126 | } 127 | } 128 | else 129 | { 130 | // assume file pointer. 131 | $fp = $filename; 132 | } 133 | 134 | if(empty($callback)) 135 | { 136 | $result = array(); 137 | } 138 | else 139 | { 140 | $result = 0; 141 | } 142 | $columns = NULL; 143 | 144 | while(($data = fgetcsv($fp)) !== FALSE) 145 | { 146 | // get column names 147 | if(is_null($columns)) 148 | { 149 | if($header_row) 150 | { 151 | // store header row for column names 152 | $columns = $data; 153 | // only include columns in $fields 154 | foreach($columns as $index => $name) 155 | { 156 | if( ! in_array($name, $fields)) 157 | { 158 | // mark column as false to skip 159 | $columns[$index] = FALSE; 160 | } 161 | } 162 | continue; 163 | } 164 | else 165 | { 166 | $columns = $fields; 167 | } 168 | } 169 | 170 | // skip on comments and empty rows 171 | if(empty($data) || $data[0][0] == '#' || implode('', $data) == '') 172 | { 173 | continue; 174 | } 175 | 176 | // create the object to save 177 | $o = new $class(); 178 | foreach($columns as $index => $key) 179 | { 180 | if(count($data) <= $index) 181 | { 182 | // more header columns than data columns 183 | break; 184 | } 185 | 186 | // skip columns that were determined to not be needed above. 187 | if($key === FALSE) 188 | { 189 | continue; 190 | } 191 | 192 | // finally, it's OK to save the data column. 193 | $o->{$key} = $data[$index]; 194 | } 195 | 196 | if( empty($callback)) 197 | { 198 | $result[] = $o; 199 | } 200 | else 201 | { 202 | $test = call_user_func($callback, $o); 203 | if($test === 'stop') 204 | { 205 | break; 206 | } 207 | if($test !== FALSE) 208 | { 209 | $result++; 210 | } 211 | } 212 | } 213 | 214 | if(is_string($filename)) 215 | { 216 | fclose($fp); 217 | } 218 | 219 | return $result; 220 | } 221 | 222 | } 223 | 224 | /* End of file csv.php */ 225 | /* Location: ./application/datamapper/csv.php */ 226 | -------------------------------------------------------------------------------- /application/datamapper/simplecache.php: -------------------------------------------------------------------------------- 1 | _should_delete_cache) ) 35 | { 36 | $object->db->cache_delete(); 37 | $object->_should_delete_cache = FALSE; 38 | } 39 | 40 | $object->db->cache_on(); 41 | // get the arguments, but pop the object. 42 | $args = func_get_args(); 43 | array_shift($args); 44 | call_user_func_array(array($object, 'get'), $args); 45 | $object->db->cache_off(); 46 | return $object; 47 | } 48 | 49 | /** 50 | * Clears the cached query the next time get_cached is called. 51 | * 52 | * @param DataMapper $object The DataMapper Object. 53 | * @return DataMapper The DataMapper $object for chaining. 54 | */ 55 | function clear_cache($object) 56 | { 57 | $args = func_get_args(); 58 | array_shift($args); 59 | if( ! empty($args)) { 60 | call_user_func_array(array($object->db, 'cache_delete'), $args); 61 | } else { 62 | $object->_should_delete_cache = TRUE; 63 | } 64 | return $object; 65 | } 66 | 67 | } 68 | 69 | /* End of file simplecache.php */ 70 | /* Location: ./application/datamapper/simplecache.php */ 71 | -------------------------------------------------------------------------------- /application/datamapper/translate.php: -------------------------------------------------------------------------------- 1 | fields; 40 | } 41 | 42 | // loop through the fields 43 | foreach($fields as $f) 44 | { 45 | // first, deal with the loaded fields 46 | if ( isset($object->{$f}) ) 47 | { 48 | $line = lang($object->{$f}); 49 | if ( $line ) 50 | { 51 | $object->{$f}; 52 | } 53 | } 54 | 55 | // then, loop through the all array 56 | foreach($object->all as $key => $all_object) 57 | { 58 | if ( isset($all_object->{$f}) ) 59 | { 60 | $line = lang($all_object->{$f}); 61 | if ( $line ) 62 | { 63 | $object->all[$key]->{$f} = $line; 64 | } 65 | } 66 | } 67 | } 68 | 69 | // return the Datamapper object 70 | return $object; 71 | } 72 | 73 | } 74 | 75 | /* End of file translate.php */ 76 | /* Location: ./application/datamapper/translate.php */ 77 | -------------------------------------------------------------------------------- /application/helpers/inflector_helper.php: -------------------------------------------------------------------------------- 1 | 4 OR in_array($end3, array('ses', 'hes', 'oes'))) 64 | { 65 | $str = substr($str, 0, -2); 66 | } 67 | elseif (in_array($end2, array('da', 'ia', 'la'))) 68 | { 69 | $str = substr($str, 0, -1).'um'; 70 | } 71 | elseif (in_array($end2, array('bi', 'ei', 'gi', 'li', 'mi', 'pi'))) 72 | { 73 | $str = substr($str, 0, -1).'us'; 74 | } 75 | else 76 | { 77 | if ($end1 == 's' && $end2 != 'us' && $end2 != 'ss') 78 | { 79 | $str = substr($str, 0, -1); 80 | } 81 | } 82 | 83 | return $str; 84 | } 85 | } 86 | 87 | // -------------------------------------------------------------------- 88 | 89 | /** 90 | * Plural 91 | * 92 | * Takes a singular word and makes it plural (improved by stensi) 93 | * 94 | * @access public 95 | * @param string 96 | * @param bool 97 | * @return str 98 | */ 99 | if ( ! function_exists('plural')) 100 | { 101 | function plural($str, $force = FALSE) 102 | { 103 | $str = strtolower(trim($str)); 104 | $end3 = substr($str, -3); 105 | $end2 = substr($str, -2); 106 | $end1 = substr($str, -1); 107 | 108 | if ($end3 == 'eau') 109 | { 110 | $str .= 'x'; 111 | } 112 | elseif ($end3 == 'man') 113 | { 114 | $str = substr($str, 0, -2).'en'; 115 | } 116 | elseif (in_array($end3, array('dum', 'ium', 'lum'))) 117 | { 118 | $str = substr($str, 0, -2).'a'; 119 | } 120 | elseif (strlen($str) > 4 && in_array($end3, array('bus', 'eus', 'gus', 'lus', 'mus', 'pus'))) 121 | { 122 | $str = substr($str, 0, -2).'i'; 123 | } 124 | elseif ($end3 == 'ife') 125 | { 126 | $str = substr($str, 0, -2).'ves'; 127 | } 128 | elseif ($end1 == 'f') 129 | { 130 | $str = substr($str, 0, -1).'ves'; 131 | } 132 | elseif ($end1 == 'y') 133 | { 134 | if(preg_match('#[aeiou]y#i', $end2)) 135 | { 136 | // ays, oys, etc. 137 | $str = $str . 's'; 138 | } 139 | else 140 | { 141 | $str = substr($str, 0, -1).'ies'; 142 | } 143 | } 144 | elseif ($end1 == 'o') 145 | { 146 | if(preg_match('#[aeiou]o#i', $end2)) 147 | { 148 | // oos, etc. 149 | $str = $str . 's'; 150 | } 151 | else 152 | { 153 | $str .= 'es'; 154 | } 155 | } 156 | elseif ($end1 == 'x' || in_array($end2, array('ss', 'ch', 'sh')) ) 157 | { 158 | $str .= 'es'; 159 | } 160 | elseif ($end1 == 's') 161 | { 162 | if ($force == TRUE) 163 | { 164 | $str .= 'es'; 165 | } 166 | } 167 | else 168 | { 169 | $str .= 's'; 170 | } 171 | 172 | return $str; 173 | } 174 | } 175 | 176 | // -------------------------------------------------------------------- 177 | 178 | /** 179 | * Camelize 180 | * 181 | * Takes multiple words separated by spaces or underscores and camelizes them 182 | * 183 | * @access public 184 | * @param string 185 | * @return str 186 | */ 187 | if ( ! function_exists('camelize')) 188 | { 189 | function camelize($str) 190 | { 191 | $str = 'x'.strtolower(trim($str)); 192 | $str = ucwords(preg_replace('/[\s_]+/', ' ', $str)); 193 | return substr(str_replace(' ', '', $str), 1); 194 | } 195 | } 196 | 197 | // -------------------------------------------------------------------- 198 | 199 | /** 200 | * Underscore 201 | * 202 | * Takes multiple words separated by spaces and underscores them 203 | * 204 | * @access public 205 | * @param string 206 | * @return str 207 | */ 208 | if ( ! function_exists('underscore')) 209 | { 210 | function underscore($str) 211 | { 212 | return preg_replace('/[\s]+/', '_', strtolower(trim($str))); 213 | } 214 | } 215 | 216 | // -------------------------------------------------------------------- 217 | 218 | /** 219 | * Humanize 220 | * 221 | * Takes multiple words separated by underscores and changes them to spaces 222 | * 223 | * @access public 224 | * @param string 225 | * @return str 226 | */ 227 | if ( ! function_exists('humanize')) 228 | { 229 | function humanize($str) 230 | { 231 | return ucwords(preg_replace('/[_]+/', ' ', strtolower(trim($str)))); 232 | } 233 | } 234 | 235 | /* End of file inflector_helper.php */ 236 | /* Location: ./application/helpers/inflector_helper.php */ -------------------------------------------------------------------------------- /application/language/ca/datamapper_lang.php: -------------------------------------------------------------------------------- 1 | array( 51 | * 'class' => 'user', 52 | * 'other_field' => 'created_template' 53 | * ) 54 | * ); 55 | * 56 | * Don't forget to add 'created_template' to User, with class set to 57 | * 'template', and the other_field set to 'creator'! 58 | * 59 | */ 60 | 61 | // -------------------------------------------------------------------- 62 | // Validation 63 | // Add validation requirements, such as 'required', for your fields. 64 | // -------------------------------------------------------------------- 65 | 66 | var $validation = array( 67 | 'example' => array( 68 | // example is required, and cannot be more than 120 characters long. 69 | 'rules' => array('required', 'max_length' => 120), 70 | 'label' => 'Example' 71 | ) 72 | ); 73 | 74 | // -------------------------------------------------------------------- 75 | // Default Ordering 76 | // Uncomment this to always sort by 'name', then by 77 | // id descending (unless overridden) 78 | // -------------------------------------------------------------------- 79 | 80 | // var $default_order_by = array('name', 'id' => 'desc'); 81 | 82 | // -------------------------------------------------------------------- 83 | 84 | /** 85 | * Constructor: calls parent constructor 86 | */ 87 | function __construct($id = NULL) 88 | { 89 | parent::__construct($id); 90 | } 91 | 92 | // -------------------------------------------------------------------- 93 | // Post Model Initialisation 94 | // Add your own custom initialisation code to the Model 95 | // The parameter indicates if the current config was loaded from cache or not 96 | // -------------------------------------------------------------------- 97 | function post_model_init($from_cache = FALSE) 98 | { 99 | } 100 | 101 | // -------------------------------------------------------------------- 102 | // Custom Methods 103 | // Add your own custom methods here to enhance the model. 104 | // -------------------------------------------------------------------- 105 | 106 | /* Example Custom Method 107 | function get_open_templates() 108 | { 109 | return $this->where('status <>', 'closed')->get(); 110 | } 111 | */ 112 | 113 | // -------------------------------------------------------------------- 114 | // Custom Validation Rules 115 | // Add custom validation rules for this model here. 116 | // -------------------------------------------------------------------- 117 | 118 | /* Example Rule 119 | function _convert_written_numbers($field, $parameter) 120 | { 121 | $nums = array('one' => 1, 'two' => 2, 'three' => 3); 122 | if(in_array($this->{$field}, $nums)) 123 | { 124 | $this->{$field} = $nums[$this->{$field}]; 125 | } 126 | } 127 | */ 128 | } 129 | 130 | /* End of file template.php */ 131 | /* Location: ./application/models/template.php */ 132 | -------------------------------------------------------------------------------- /application/third_party/datamapper/bootstrap.php: -------------------------------------------------------------------------------- 1 | {\$function}(...\$args); 29 | } 30 | 31 | // public interface to internal driver properties 32 | public function dm_get(\$var) 33 | { 34 | return isset(\$this->{\$var}) ? \$this->{\$var} : NULL; 35 | } 36 | 37 | public function dm_set(\$var, \$value) 38 | { 39 | \$this->{\$var} = \$value; 40 | } 41 | 42 | public function dm_set_append(\$var, \$value) 43 | { 44 | \$this->{\$var}[] = \$value; 45 | } 46 | } 47 | CODE; 48 | 49 | // dynamically add our class extension 50 | eval($dmclass); 51 | unset($dmclass); 52 | } 53 | 54 | /* End of file DB_driver.php */ 55 | /* Location: ./application/third_party/datamapper/system/DB_driver.php */ 56 | -------------------------------------------------------------------------------- /application/third_party/datamapper/system/Lang.php: -------------------------------------------------------------------------------- 1 | language[\$line])) ? FALSE : \$this->language[\$line]; 32 | } 33 | } 34 | CODE; 35 | 36 | // dynamically add our class extension 37 | eval($dmclass); 38 | unset($dmclass); 39 | 40 | // and update the name of the class to instantiate 41 | $name = 'DM_Lang'; 42 | 43 | /* End of file Lang.php */ 44 | /* Location: ./application/third_party/datamapper/system/Lang.php */ 45 | -------------------------------------------------------------------------------- /application/third_party/datamapper/system/Loader.php: -------------------------------------------------------------------------------- 1 | db) AND is_object(\$CI->db)) 36 | { 37 | return FALSE; 38 | } 39 | 40 | require_once(DATAMAPPERPATH.'third_party/datamapper/system/DB.php'); 41 | 42 | if (\$return === TRUE) 43 | { 44 | return DB(\$params, \$active_record); 45 | } 46 | 47 | // Initialize the db variable. Needed to prevent 48 | // reference errors with some configurations 49 | \$CI->db = ''; 50 | 51 | // Load the DB class 52 | \$CI->db =& DB(\$params, \$active_record); 53 | } 54 | } 55 | CODE; 56 | 57 | // dynamically add our class extension 58 | eval($dmclass); 59 | unset($dmclass); 60 | 61 | // and update the name of the class to instantiate 62 | $name = 'DM_Loader'; 63 | 64 | /* End of file Loader.php */ 65 | /* Location: ./application/third_party/datamapper/system/Loader.php */ 66 | -------------------------------------------------------------------------------- /application/views/dmz_htmlform/form.php: -------------------------------------------------------------------------------- 1 | 18 | error->all)): ?> 19 |There was an error saving the form.
21 |' . var_export($user->error, TRUE) . ''); 173 | } 174 | $this->session->unset_userdata('first_time'); 175 | $user->trans_complete(); 176 | redirect('welcome'); 177 | } 178 | } 179 | 180 | $user->load_extension('htmlform'); 181 | 182 | // ID is not included because it is not necessary 183 | $form_fields = array( 184 | 'Contact Information' => 'section', 185 | 'name' => array( 186 | 'label' => 'Your Name' 187 | ), 188 | 'email', 189 | 'Login Information' => 'section', 190 | 'username', 191 | 'password', 192 | 'confirm_password' 193 | ); 194 | 195 | $this->load->view('template_header', array('title' => 'Set Up Your Account', 'section' => 'admin')); 196 | $this->load->view('admin/init', array('user' => $user, 'form_fields' => $form_fields)); 197 | $this->load->view('template_footer'); 198 | } 199 | 200 | } 201 | -------------------------------------------------------------------------------- /examples/application/controllers/login.php: -------------------------------------------------------------------------------- 1 | load->library('login_manager', array('autologin' => FALSE)); 9 | } 10 | 11 | function index() 12 | { 13 | $user = $this->login_manager->get_user(); 14 | if($user !== FALSE) 15 | { 16 | // already logged in, redirect to welcome page 17 | redirect('welcome'); 18 | } 19 | // Create a user to store the login validation 20 | $user = new User(); 21 | if($this->input->post('username') !== FALSE) 22 | { 23 | // A login was attempted, load the user data 24 | $user->from_array($_POST, array('username', 'password')); 25 | // get the result of the login request 26 | $login_redirect = $this->login_manager->process_login($user); 27 | if($login_redirect) 28 | { 29 | if($login_redirect === TRUE) 30 | { 31 | // if the result was simply TRUE, redirect to the welcome page. 32 | redirect('welcome'); 33 | } 34 | else 35 | { 36 | // otherwise, redirect to the stored page that was last accessed. 37 | redirect($login_redirect); 38 | } 39 | } 40 | } 41 | 42 | $user->load_extension('htmlform'); 43 | 44 | $this->output->enable_profiler(TRUE); 45 | $this->load->view('template_header', array('title' => 'Login', 'hide_nav' => TRUE)); 46 | $this->load->view('login', array('user' => $user)); 47 | $this->load->view('template_footer'); 48 | } 49 | } 50 | 51 | /* End of file login.php */ 52 | /* Location: ./system/application/controllers/login.php */ -------------------------------------------------------------------------------- /examples/application/controllers/logout.php: -------------------------------------------------------------------------------- 1 | load->library('login_manager', array('autologin' => FALSE)); 9 | } 10 | 11 | function index() 12 | { 13 | $this->login_manager->logout(); 14 | redirect('login'); 15 | } 16 | } 17 | 18 | /* End of file login.php */ 19 | /* Location: ./system/application/controllers/login.php */ -------------------------------------------------------------------------------- /examples/application/controllers/users.php: -------------------------------------------------------------------------------- 1 | load->library('login_manager', array('required_group' => 1)); 10 | } 11 | 12 | function index() 13 | { 14 | $users = new User(); 15 | $users->include_related('group', 'name'); 16 | $bug = $users->bug; 17 | $bug 18 | ->select_func('COUNT', '*', 'count') 19 | ->where_related_status('closed', FALSE) 20 | ->where_related('user', 'id', '${parent}.id'); 21 | $users->select_subquery($bug, 'bug_count'); 22 | $users->get_iterated(); 23 | 24 | $this->output->enable_profiler(TRUE); 25 | $this->load->view('template_header', array('title' => 'Users', 'section' => 'admin')); 26 | $this->load->view('users/index', array('users' => $users)); 27 | $this->load->view('template_footer'); 28 | 29 | } 30 | 31 | function add($save = FALSE) 32 | { 33 | $this->edit($save); 34 | } 35 | 36 | function edit($id = -1) 37 | { 38 | $this->output->enable_profiler(TRUE); 39 | 40 | // Create User Object 41 | $user = new User(); 42 | 43 | if($id == 'save') 44 | { 45 | // Try to save the user 46 | $id = $this->input->post('id'); 47 | $this->_get_user($user, $id); 48 | 49 | $user->trans_start(); 50 | 51 | // Only add the passwords in if they aren't empty 52 | // New users start with blank passwords, so they will get an error automatically. 53 | if( ! empty($_POST['password'])) 54 | { 55 | $user->from_array($_POST, array('password', 'confirm_password')); 56 | } 57 | 58 | // Load and save the reset of the data at once 59 | // The passwords saved above are already stored. 60 | $success = $user->from_array($_POST, array( 61 | 'name', 62 | 'email', 63 | 'username', 64 | 'group' 65 | ), TRUE); // TRUE means save immediately 66 | 67 | // redirect on save 68 | if($success) 69 | { 70 | $user->trans_complete(); 71 | if($id < 1) 72 | { 73 | $this->session->set_flashdata('message', 'The user ' . $user->name . ' was successfully created.'); 74 | } 75 | else 76 | { 77 | $this->session->set_flashdata('message', 'The user ' . $user->name . ' was successfully updated.'); 78 | } 79 | redirect('users'); 80 | } 81 | } 82 | else 83 | { 84 | // load an existing user 85 | $this->_get_user($user, $id); 86 | } 87 | 88 | // Load the HTML Form extension 89 | $user->load_extension('htmlform'); 90 | 91 | // These are the fields to edit. 92 | $form_fields = array( 93 | 'id', 94 | 'Contact Information' => 'section', 95 | 'name', 96 | 'email', 97 | 'Login Information' => 'section', 98 | 'username', 99 | 'password', 100 | 'confirm_password', 101 | 'Access Restrictions' => 'section', 102 | 'group' 103 | ); 104 | 105 | // Set up page text 106 | if($id > 0) 107 | { 108 | $title = 'Edit User'; 109 | $url = 'users/edit/save'; 110 | } 111 | else 112 | { 113 | $title = 'Add User'; 114 | $url = 'users/add/save'; 115 | } 116 | 117 | $this->load->view('template_header', array('title' => $title, 'section' => 'admin')); 118 | $this->load->view('users/edit', array('user' => $user, 'form_fields' => $form_fields, 'url' => $url)); 119 | $this->load->view('template_footer'); 120 | } 121 | 122 | function _get_user($user, $id) 123 | { 124 | if( ! empty($id)) 125 | { 126 | $user->get_by_id($id); 127 | if( ! $user->exists()) 128 | { 129 | show_error('Invalid User ID'); 130 | } 131 | } 132 | } 133 | 134 | function delete($id = 0) 135 | { 136 | $user = new User(); 137 | $user->get_by_id($id); 138 | if( ! $user->exists()) 139 | { 140 | show_error('Invalid User Id'); 141 | } 142 | if($this->input->post('deleteok') !== FALSE) 143 | { 144 | // Delete the user 145 | $name = $user->name; 146 | $user->delete(); 147 | $this->session->set_flashdata('message', 'The user ' . $name . ' was successfully deleted.'); 148 | redirect('users'); 149 | } 150 | else if($this->input->post('cancel') !== FALSE) 151 | { 152 | redirect('users'); 153 | } 154 | 155 | $this->load->view('template_header', array('title' => 'Delete User', 'section' => 'admin')); 156 | $this->load->view('users/delete', array('user' => $user)); 157 | $this->load->view('template_footer'); 158 | } 159 | } 160 | 161 | /* End of file users.php */ 162 | /* Location: ./system/application/controllers/users.php */ -------------------------------------------------------------------------------- /examples/application/controllers/welcome.php: -------------------------------------------------------------------------------- 1 | load->library('login_manager'); 9 | } 10 | 11 | function index() 12 | { 13 | $user = $this->login_manager->get_user(); 14 | // get open bugs, order with most recently updated at the top 15 | $bugs = $user->bugs; 16 | $bugs->where_related_status('closed', FALSE); 17 | $bugs->include_related('status', 'name', TRUE, TRUE); 18 | $bugs = $bugs->order_by('updated', 'DESC')->order_by_related_status('sortorder')->limit(25)->get_iterated(); 19 | 20 | $this->output->enable_profiler(TRUE); 21 | $this->load->view('template_header', array('title' => 'Welcome', 'section' => 'welcome')); 22 | $this->load->view('welcome/index', array('bugs' => $bugs)); 23 | $this->load->view('template_footer'); 24 | } 25 | } 26 | 27 | /* End of file welcome.php */ 28 | /* Location: ./system/application/controllers/welcome.php */ -------------------------------------------------------------------------------- /examples/application/helpers/utilities_helper.php: -------------------------------------------------------------------------------- 1 | "; 11 | } 12 | } -------------------------------------------------------------------------------- /examples/application/language/english/model_bug_lang.php: -------------------------------------------------------------------------------- 1 | CI =& get_instance(); 14 | $this->session =& $this->CI->session; 15 | 16 | if( ! isset($params['autologin']) || $params['autologin'] !== FALSE) 17 | { 18 | $required_group = -1; 19 | if(isset($params['required_group'])) 20 | { 21 | $required_group = $params['required_group']; 22 | } 23 | $this->check_login($required_group); 24 | } 25 | } 26 | 27 | function check_login($required_group = -1) 28 | { 29 | // Special auto-setup routine 30 | if( ! $this->CI->db->table_exists('users')) 31 | { 32 | redirect('admin/reset_warning'); 33 | } 34 | else 35 | { 36 | // see if there are any users in the system 37 | $u = new User(); 38 | if($u->count() == 0) 39 | { 40 | redirect('admin/init'); 41 | } 42 | } 43 | // if not logged in, automatically redirect 44 | $u = $this->get_user(); 45 | if($u === FALSE) 46 | { 47 | $this->session->set_userdata('login_redirect', uri_string()); 48 | redirect('login'); 49 | } 50 | if($required_group > 0) 51 | { 52 | if($u->group->id > $required_group) 53 | { 54 | show_error('You do not have access to this section.'); 55 | } 56 | } 57 | } 58 | 59 | /** 60 | * process_login 61 | * Validates that a username and password are correct. 62 | * 63 | * @param object $user The user containing the login information. 64 | * @return FALSE if invalid, TRUE or a redirect string if valid. 65 | */ 66 | function process_login($user) 67 | { 68 | // attempt the login 69 | $success = $user->login(); 70 | if($success) 71 | { 72 | // store the userid if the login was successful 73 | $this->session->set_userdata('logged_in_id', $user->id); 74 | // store the user for this request 75 | $this->logged_in_user = $user; 76 | // if a redirect is necessary, return it. 77 | $redirect = $this->session->userdata('login_redirect'); 78 | if( ! empty($redirect)) 79 | { 80 | $success = $redirect; 81 | } 82 | } 83 | return $success; 84 | } 85 | 86 | function logout() 87 | { 88 | $this->session->sess_destroy(); 89 | $this->logged_in_user = NULL; 90 | } 91 | 92 | function get_user() 93 | { 94 | if(is_null($this->logged_in_user)) 95 | { 96 | if( ! $this->CI->db->table_exists('users')) 97 | { 98 | return FALSE; 99 | } 100 | $id = $this->session->userdata('logged_in_id'); 101 | if(is_numeric($id)) 102 | { 103 | $u = new User(); 104 | $u->get_by_id($id); 105 | if($u->exists()) { 106 | $u->group->get(); 107 | $this->logged_in_user = $u; 108 | return $this->logged_in_user; 109 | } 110 | } 111 | return FALSE; 112 | } 113 | else 114 | { 115 | return $this->logged_in_user; 116 | } 117 | } 118 | 119 | } 120 | -------------------------------------------------------------------------------- /examples/application/models/bug.php: -------------------------------------------------------------------------------- 1 | array( 23 | 'class' => 'user', 24 | 'other_field' => 'created_bug' 25 | ), 26 | // The editor of this bug 27 | 'editor' => array( 28 | 'class' => 'user', 29 | 'other_field' => 'edited_bug' 30 | ), 31 | // Keep track of this bug's status 32 | 'status' 33 | ); 34 | 35 | // Insert related models that Bug can have more than one of. 36 | public $has_many = array( 37 | // users assigned to this bug 38 | 'user', 39 | // Other Bugs that depend on this Bug 40 | 'dependent' => array( 41 | 'class' => 'bug', 42 | 'other_field' => 'dependency' 43 | ), 44 | // Other Bugs that this Bug depends on 45 | 'dependency' => array( 46 | 'class' => 'bug', 47 | 'other_field' => 'dependent' 48 | ), 49 | // categories for this Bug 50 | 'category' 51 | ); 52 | 53 | // -------------------------------------------------------------------- 54 | // Validation 55 | // -------------------------------------------------------------------- 56 | 57 | public $validation = array( 58 | 'title' => array( 59 | 'rules' => array('required', 'trim', 'max_length' => 100) 60 | ), 61 | 'description' => array( 62 | 'rules' => array('required', 'xss_clean'), 63 | 'type' => 'textarea' 64 | ), 65 | 'priority' => array( 66 | 'rules' => array('required', 'integer', 'min_size' => 0, 'max_size' => 3), 67 | 'get_rules' => array('intval'), 68 | 'type' => 'dropdown', 69 | 'values' => array( 70 | '0' => 'None', 71 | '1' => 'Low', 72 | '2' => 'Medium', 73 | '3' => 'High' 74 | ) 75 | ), 76 | 'creator' => array( 77 | 'rules' => array('required') 78 | ), 79 | 'editor' => array( 80 | 'rules' => array('required') 81 | ), 82 | 'status' => array( 83 | 'rules' => array('required') 84 | ) 85 | ); 86 | 87 | // -------------------------------------------------------------------- 88 | 89 | public function get_priority() 90 | { 91 | $p = $this->priority; 92 | if( ! is_numeric($p)) 93 | { 94 | $p = 0; 95 | } 96 | return $this->validation['priority']['values'][$p]; 97 | } 98 | } 99 | 100 | /* End of file bug.php */ 101 | /* Location: ./application/models/bug.php */ 102 | -------------------------------------------------------------------------------- /examples/application/models/category.php: -------------------------------------------------------------------------------- 1 | array( 26 | 'rules' => array('required', 'trim', 'unique', 'max_length' => 40) 27 | ) 28 | ); 29 | 30 | // Default to ordering by name 31 | public $default_order_by = array('name'); 32 | 33 | // -------------------------------------------------------------------- 34 | 35 | /** 36 | * Returns the name of this status. 37 | * @return $this->name 38 | */ 39 | function __toString() 40 | { 41 | return empty($this->name) ? $this->localize_label('unset') : $this->name; 42 | } 43 | } 44 | 45 | /* End of file category.php */ 46 | /* Location: ./application/models/category.php */ -------------------------------------------------------------------------------- /examples/application/models/comment.php: -------------------------------------------------------------------------------- 1 | array( 31 | 'rules' => array('required') 32 | ), 33 | // Bug is required 34 | 'bug' => array( 35 | 'rules' => array('required') 36 | ), 37 | // User is required 38 | 'user' => array( 39 | 'rules' => array('required') 40 | ) 41 | ); 42 | 43 | // Default to ordering by updated 44 | public $default_order_by = array('updated'); 45 | 46 | } 47 | 48 | /* End of file comment.php */ 49 | /* Location: ./application/models/comment.php */ -------------------------------------------------------------------------------- /examples/application/models/group.php: -------------------------------------------------------------------------------- 1 | array( 26 | 'rules' => array('required', 'trim', 'unique', 'min_length' => 3, 'max_length' => 20) 27 | ) 28 | ); 29 | 30 | // Default to ordering by name 31 | public $default_order_by = array('id' => 'desc'); 32 | 33 | /** 34 | * Returns the name of this status. 35 | * @return $this->name 36 | */ 37 | function __toString() 38 | { 39 | return empty($this->name) ? $this->localize_label('unset') : $this->name; 40 | } 41 | 42 | // -------------------------------------------------------------------- 43 | 44 | /** 45 | * This method is provided for the htmlform extension. 46 | * It is used to prevent logged-in users from being able to accidentally 47 | * convert themselves away from being an admin. 48 | * 49 | * @param object $object 50 | * @param object $field 51 | * @return 52 | */ 53 | function get_htmlform_list($object, $field) 54 | { 55 | if($object->model == 'user') 56 | { 57 | // limit the items if the user is the logged-in user 58 | $CI =& get_instance(); 59 | if($CI->login_manager->get_user()->id == $object->id) 60 | { 61 | $this->get_by_id(1); 62 | return; 63 | } 64 | } 65 | $this->get_iterated(); 66 | } 67 | } 68 | 69 | /* End of file group.php */ 70 | /* Location: ./application/models/group.php */ -------------------------------------------------------------------------------- /examples/application/models/status.php: -------------------------------------------------------------------------------- 1 | statuses 15 | public $model = 'status'; 16 | public $table = 'statuses'; 17 | 18 | // -------------------------------------------------------------------- 19 | // Relationships 20 | // -------------------------------------------------------------------- 21 | 22 | public $has_many = array('bug'); 23 | 24 | // -------------------------------------------------------------------- 25 | // Validation 26 | // -------------------------------------------------------------------- 27 | 28 | public $validation = array( 29 | 'name' => array( 30 | 'rules' => array('required', 'trim', 'unique', 'max_length' => 40) 31 | ), 32 | 'closed' => array( 33 | 'rules' => array('boolean'), 34 | 'type' => 'checkbox' 35 | ) 36 | ); 37 | 38 | // Default to ordering by sortorder 39 | public $default_order_by = array('sortorder'); 40 | 41 | // -------------------------------------------------------------------- 42 | 43 | /** 44 | * Returns the name of this status. 45 | * @return $this->name 46 | */ 47 | function __toString() 48 | { 49 | return empty($this->name) ? $this->localize_label('unset') : $this->name; 50 | } 51 | } 52 | 53 | /* End of file status.php */ 54 | /* Location: ./application/models/status.php */ -------------------------------------------------------------------------------- /examples/application/models/user.php: -------------------------------------------------------------------------------- 1 | array( 25 | 'class' => 'bug', 26 | 'other_field' => 'creator' 27 | ), 28 | // bugs edited by this user 29 | 'edited_bug' => array( 30 | 'class' => 'bug', 31 | 'other_field' => 'editor' 32 | ), 33 | // bugs assigned to this user 34 | 'bug' 35 | ); 36 | 37 | // -------------------------------------------------------------------- 38 | // Validation 39 | // -------------------------------------------------------------------- 40 | 41 | public $validation = array( 42 | 'name' => array( 43 | 'rules' => array('required', 'trim', 'unique', 'max_length' => 100) 44 | ), 45 | 'email' => array( 46 | 'rules' => array('required', 'trim', 'unique', 'valid_email') 47 | ), 48 | 'username' => array( 49 | 'rules' => array('required', 'trim', 'unique', 'alpha_dash', 'min_length' => 3, 'max_length' => 20) 50 | ), 51 | 'password' => array( 52 | 'rules' => array('required', 'trim', 'min_length' => 3, 'max_length' => 40, 'encrypt'), 53 | 'type' => 'password' 54 | ), 55 | 'confirm_password' => array( 56 | 'rules' => array('required', 'encrypt', 'matches' => 'password', 'min_length' => 3, 'max_length' => 40), 57 | 'type' => 'password' 58 | ), 59 | 'group' => array( 60 | 'rules' => array('required') 61 | ) 62 | ); 63 | 64 | // Default to ordering by name 65 | public $default_order_by = array('name'); 66 | 67 | // -------------------------------------------------------------------- 68 | 69 | function __toString() 70 | { 71 | return empty($this->name) ? $this->localize_label('newuser') : $this->name; 72 | } 73 | 74 | // -------------------------------------------------------------------- 75 | 76 | /** 77 | * Returns an array list of all users that can have bugs assigned 78 | * to them. 79 | * 80 | * @return $this for chaining 81 | */ 82 | function get_assignable() 83 | { 84 | return $this->where_in_related_group('id', array(1, 2))->get(); 85 | } 86 | 87 | // -------------------------------------------------------------------- 88 | 89 | /** 90 | * Login 91 | * 92 | * Authenticates a user for logging in. 93 | * 94 | * @access public 95 | * @return bool 96 | */ 97 | function login() 98 | { 99 | // backup username for invalid logins 100 | $uname = $this->username; 101 | 102 | // Create a temporary user object 103 | $u = new User(); 104 | 105 | // Get this users stored record via their username 106 | $u->where('username', $uname)->get(); 107 | 108 | // Give this user their stored salt 109 | $this->salt = $u->salt; 110 | 111 | // Validate and get this user by their property values, 112 | // this will see the 'encrypt' validation run, encrypting the password with the salt 113 | $this->validate()->get(); 114 | 115 | // If the username and encrypted password matched a record in the database, 116 | // this user object would be fully populated, complete with their ID. 117 | 118 | // If there was no matching record, this user would be completely cleared so their id would be empty. 119 | if ($this->exists()) 120 | { 121 | // Login succeeded 122 | return TRUE; 123 | } 124 | else 125 | { 126 | // Login failed, so set a custom error message 127 | $this->error_message('login', $this->localize_label('error_login')); 128 | 129 | // restore username for login field 130 | $this->username = $uname; 131 | 132 | return FALSE; 133 | } 134 | } 135 | 136 | // -------------------------------------------------------------------- 137 | 138 | /** 139 | * Encrypt (prep) 140 | * 141 | * Encrypts this objects password with a random salt. 142 | * 143 | * @access private 144 | * @param string 145 | * @return void 146 | */ 147 | function _encrypt($field) 148 | { 149 | if (!empty($this->{$field})) 150 | { 151 | if (empty($this->salt)) 152 | { 153 | $this->salt = md5(uniqid(rand(), true)); 154 | } 155 | 156 | $this->{$field} = sha1($this->salt . $this->{$field}); 157 | } 158 | } 159 | } 160 | 161 | /* End of file user.php */ 162 | /* Location: ./application/models/user.php */ -------------------------------------------------------------------------------- /examples/application/sql/data/category.csv: -------------------------------------------------------------------------------- 1 | "name" 2 | "Website" 3 | "Application" -------------------------------------------------------------------------------- /examples/application/sql/data/group.csv: -------------------------------------------------------------------------------- 1 | name 2 | Administrators 3 | Users 4 | Reporters -------------------------------------------------------------------------------- /examples/application/sql/data/status.csv: -------------------------------------------------------------------------------- 1 | "name","closed","sortorder" 2 | New,0,1 3 | Unconfirmed,0,2 4 | Confirmed,0,3 5 | In Progress,0,4 6 | Fixed,1,5 7 | "Won't Fix",1,6 8 | Works For Me,1,7 -------------------------------------------------------------------------------- /examples/application/sql/mysql/bugs.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `bugs` ( 2 | `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, 3 | `title` character varying(100) NOT NULL, 4 | `description` text, 5 | `priority` smallint DEFAULT 0 NOT NULL, 6 | `created` DATETIME NULL, 7 | `updated` DATETIME NULL, 8 | `status_id` BIGINT UNSIGNED, 9 | `creator_id` BIGINT UNSIGNED, 10 | `editor_id` BIGINT UNSIGNED, 11 | PRIMARY KEY (`id`) 12 | ) ENGINE = InnoDB; -------------------------------------------------------------------------------- /examples/application/sql/mysql/bugs_categories.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `bugs_categories` ( 2 | `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, 3 | `bug_id` BIGINT UNSIGNED NOT NULL, 4 | `category_id` BIGINT UNSIGNED NOT NULL, 5 | PRIMARY KEY (`id`) 6 | ) ENGINE = InnoDB; -------------------------------------------------------------------------------- /examples/application/sql/mysql/bugs_users.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `bugs_users` ( 2 | `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, 3 | `user_id` BIGINT UNSIGNED, 4 | `bug_id` BIGINT UNSIGNED, 5 | `iscompleted` smallint DEFAULT 0 NOT NULL, 6 | `isowner` smallint DEFAULT 0 NOT NULL, 7 | PRIMARY KEY (`id`) 8 | ) ENGINE = InnoDB; -------------------------------------------------------------------------------- /examples/application/sql/mysql/categories.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `categories` ( 2 | `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, 3 | `name` character varying(40) NOT NULL, 4 | PRIMARY KEY (`id`), 5 | UNIQUE INDEX name (`name` ASC) 6 | ) ENGINE = InnoDB; -------------------------------------------------------------------------------- /examples/application/sql/mysql/comments.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `comments` ( 2 | `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, 3 | `comment` text, 4 | `created` DATETIME NULL, 5 | `updated` DATETIME NULL, 6 | `user_id` BIGINT UNSIGNED, 7 | `bug_id` BIGINT UNSIGNED, 8 | PRIMARY KEY (`id`) 9 | ) ENGINE = InnoDB; -------------------------------------------------------------------------------- /examples/application/sql/mysql/dependencies_dependents.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `dependencies_dependents` ( 2 | `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, 3 | `dependency_id` BIGINT UNSIGNED NOT NULL, 4 | `dependent_id` BIGINT UNSIGNED NOT NULL, 5 | PRIMARY KEY (`id`) 6 | ) ENGINE = InnoDB; -------------------------------------------------------------------------------- /examples/application/sql/mysql/groups.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `groups` ( 2 | `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, 3 | `name` character varying(20) NOT NULL, 4 | PRIMARY KEY (`id`), 5 | UNIQUE INDEX name (`name` ASC) 6 | ) ENGINE = InnoDB; -------------------------------------------------------------------------------- /examples/application/sql/mysql/statuses.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `statuses` ( 2 | `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, 3 | `name` character varying(40) NOT NULL, 4 | `closed` smallint DEFAULT 0 NOT NULL, 5 | `sortorder` BIGINT UNSIGNED DEFAULT 0 NOT NULL, 6 | PRIMARY KEY (`id`), 7 | UNIQUE INDEX name (`name` ASC) 8 | ) ENGINE = InnoDB; -------------------------------------------------------------------------------- /examples/application/sql/mysql/users.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `users` ( 2 | `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, 3 | `name` character varying(100) NOT NULL, 4 | `username` character varying(20) NOT NULL, 5 | `email` character varying(120) NOT NULL, 6 | `password` character(40) NOT NULL, 7 | `salt` character varying(32), 8 | `group_id` BIGINT UNSIGNED, 9 | PRIMARY KEY (`id`), 10 | UNIQUE INDEX username (`username` ASC), 11 | UNIQUE INDEX email (`email` ASC) 12 | ) ENGINE = InnoDB; -------------------------------------------------------------------------------- /examples/application/sql/mysqli/bugs.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `bugs` ( 2 | `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, 3 | `title` character varying(100) NOT NULL, 4 | `description` text, 5 | `priority` smallint DEFAULT 0 NOT NULL, 6 | `created` DATETIME NULL, 7 | `updated` DATETIME NULL, 8 | `status_id` BIGINT UNSIGNED, 9 | `creator_id` BIGINT UNSIGNED, 10 | `editor_id` BIGINT UNSIGNED, 11 | PRIMARY KEY (`id`) 12 | ) ENGINE = InnoDB; -------------------------------------------------------------------------------- /examples/application/sql/mysqli/bugs_categories.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `bugs_categories` ( 2 | `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, 3 | `bug_id` BIGINT UNSIGNED NOT NULL, 4 | `category_id` BIGINT UNSIGNED NOT NULL, 5 | PRIMARY KEY (`id`) 6 | ) ENGINE = InnoDB; -------------------------------------------------------------------------------- /examples/application/sql/mysqli/bugs_users.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `bugs_users` ( 2 | `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, 3 | `user_id` BIGINT UNSIGNED, 4 | `bug_id` BIGINT UNSIGNED, 5 | `iscompleted` smallint DEFAULT 0 NOT NULL, 6 | `isowner` smallint DEFAULT 0 NOT NULL, 7 | PRIMARY KEY (`id`) 8 | ) ENGINE = InnoDB; -------------------------------------------------------------------------------- /examples/application/sql/mysqli/categories.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `categories` ( 2 | `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, 3 | `name` character varying(40) NOT NULL, 4 | PRIMARY KEY (`id`), 5 | UNIQUE INDEX name (`name` ASC) 6 | ) ENGINE = InnoDB; -------------------------------------------------------------------------------- /examples/application/sql/mysqli/comments.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `comments` ( 2 | `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, 3 | `comment` text, 4 | `created` DATETIME NULL, 5 | `updated` DATETIME NULL, 6 | `user_id` BIGINT UNSIGNED, 7 | `bug_id` BIGINT UNSIGNED, 8 | PRIMARY KEY (`id`) 9 | ) ENGINE = InnoDB; -------------------------------------------------------------------------------- /examples/application/sql/mysqli/dependencies_dependents.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `dependencies_dependents` ( 2 | `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, 3 | `dependency_id` BIGINT UNSIGNED NOT NULL, 4 | `dependent_id` BIGINT UNSIGNED NOT NULL, 5 | PRIMARY KEY (`id`) 6 | ) ENGINE = InnoDB; -------------------------------------------------------------------------------- /examples/application/sql/mysqli/groups.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `groups` ( 2 | `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, 3 | `name` character varying(20) NOT NULL, 4 | PRIMARY KEY (`id`), 5 | UNIQUE INDEX name (`name` ASC) 6 | ) ENGINE = InnoDB; -------------------------------------------------------------------------------- /examples/application/sql/mysqli/statuses.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `statuses` ( 2 | `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, 3 | `name` character varying(40) NOT NULL, 4 | `closed` smallint DEFAULT 0 NOT NULL, 5 | `sortorder` BIGINT UNSIGNED DEFAULT 0 NOT NULL, 6 | PRIMARY KEY (`id`), 7 | UNIQUE INDEX name (`name` ASC) 8 | ) ENGINE = InnoDB; -------------------------------------------------------------------------------- /examples/application/sql/mysqli/users.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `users` ( 2 | `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, 3 | `name` character varying(100) NOT NULL, 4 | `username` character varying(20) NOT NULL, 5 | `email` character varying(120) NOT NULL, 6 | `password` character(40) NOT NULL, 7 | `salt` character varying(32), 8 | `group_id` BIGINT UNSIGNED, 9 | PRIMARY KEY (`id`), 10 | UNIQUE INDEX username (`username` ASC), 11 | UNIQUE INDEX email (`email` ASC) 12 | ) ENGINE = InnoDB; -------------------------------------------------------------------------------- /examples/application/sql/postgre/bugs.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE "bugs" ( 2 | "id" serial NOT NULL PRIMARY KEY, 3 | "title" character varying(100) NOT NULL, 4 | "description" text, 5 | "priority" smallint DEFAULT 0 NOT NULL, 6 | "created" timestamp with time zone DEFAULT now() NOT NULL, 7 | "updated" timestamp with time zone DEFAULT now() NOT NULL, 8 | "status_id" integer, 9 | "creator_id" integer, 10 | "editor_id" integer 11 | ); -------------------------------------------------------------------------------- /examples/application/sql/postgre/bugs_categories.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE "bugs_categories" ( 2 | "id" serial NOT NULL PRIMARY KEY, 3 | "bug_id" integer NOT NULL, 4 | "category_id" integer NOT NULL 5 | ); -------------------------------------------------------------------------------- /examples/application/sql/postgre/bugs_users.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE "bugs_users" ( 2 | "id" serial NOT NULL PRIMARY KEY, 3 | "user_id" integer, 4 | "bug_id" integer, 5 | "iscompleted" smallint DEFAULT 0 NOT NULL, 6 | "isowner" smallint DEFAULT 0 NOT NULL 7 | ); -------------------------------------------------------------------------------- /examples/application/sql/postgre/categories.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE "categories" ( 2 | "id" serial NOT NULL PRIMARY KEY, 3 | "name" character varying(40) NOT NULL UNIQUE 4 | ); -------------------------------------------------------------------------------- /examples/application/sql/postgre/comments.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE "comments" ( 2 | "id" serial NOT NULL PRIMARY KEY, 3 | "comment" text, 4 | "created" timestamp with time zone DEFAULT now() NOT NULL, 5 | "updated" timestamp with time zone DEFAULT now() NOT NULL, 6 | "user_id" integer, 7 | "bug_id" integer 8 | ); -------------------------------------------------------------------------------- /examples/application/sql/postgre/dependencies_dependents.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE "dependencies_dependents" ( 2 | "id" serial NOT NULL PRIMARY KEY, 3 | "dependency_id" integer NOT NULL, 4 | "dependent_id" integer NOT NULL 5 | ); -------------------------------------------------------------------------------- /examples/application/sql/postgre/groups.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE "groups" ( 2 | "id" serial NOT NULL PRIMARY KEY, 3 | "name" character varying(20) NOT NULL UNIQUE 4 | ); -------------------------------------------------------------------------------- /examples/application/sql/postgre/statuses.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE "statuses" ( 2 | "id" serial NOT NULL PRIMARY KEY, 3 | "name" character varying(40) NOT NULL, 4 | "closed" smallint DEFAULT 0 NOT NULL, 5 | "sortorder" integer DEFAULT 0 NOT NULL 6 | ); -------------------------------------------------------------------------------- /examples/application/sql/postgre/users.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE "users" ( 2 | "id" serial NOT NULL PRIMARY KEY, 3 | "name" character varying(100) NOT NULL, 4 | "username" character varying(20) NOT NULL UNIQUE, 5 | "email" character varying(120) NOT NULL UNIQUE, 6 | "password" character(40) NOT NULL, 7 | "salt" character varying(32), 8 | "group_id" integer 9 | ); -------------------------------------------------------------------------------- /examples/application/sql/tabledroplist.txt: -------------------------------------------------------------------------------- 1 | # Join Tables 2 | bugs_categories 3 | bugs_users 4 | dependencies_dependents 5 | 6 | # Model Tables 7 | bugs 8 | categories 9 | comments 10 | groups 11 | statuses 12 | users -------------------------------------------------------------------------------- /examples/application/views/admin/index.php: -------------------------------------------------------------------------------- 1 |
Manage User Accounts
2 | Add, edit, and delete users from this section.
Create an administrative account for yourself.
2 | render_form( 5 | $form_fields, 6 | 'admin/init/save'); 7 | 8 | ?> 9 | -------------------------------------------------------------------------------- /examples/application/views/admin/reset.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |The database has not yet been created. Please click on the link below if you want to have the database automatically created.
4 | 5 | 6 |
7 | Click here to automatically the database.
8 |
9 | This will be created on the db->dbdriver; ?> database “db->database; ?>”.
10 |
11 | Procede with caution: Any existing Squash Bug Tracker tables in this database will be erased!
12 |
ID | 4 |Title | 5 |Status | 6 |Options | 7 |
---|---|---|---|
No Bugs Found. | 11 ||||
id; ?> | 19 |title); ?> | 20 |status->name); ?> | 21 |22 | 23 | 24 | 25 | | 26 |
Welcome to the Squash Bug Tracker. Please log in.
4 | render_form(array( 7 | 'username', 8 | 'password' 9 | ), 10 | 'login', 11 | array( 12 | 'save_button' => 'Log In', 13 | 'reset_button' => 'Clear' 14 | ) 15 | ); 16 | 17 | ?> 18 |