JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
update wfpl and templates
[contractor-progress.git] / people.php
index 9a0f3a4..2443042 100644 (file)
@@ -1,21 +1,20 @@
 <?php
 
-# This form requires wfpl. See: http://jasonwoof.org/wfpl
-
-# This form was initially auto-generated. If you would like to alter the
-# parameters and generate a new one try this URL:
+#  Copyright (C) 2008  Jason Woofenden
 #
-# http://jasonwoof.com/metaform/?form_name=people&opt_email=No&opt_db=Yes&opt_listing=Yes&opt_http_pass=No&fields=username+textbox%0D%0Apassword+textbox%0D%0Aname+textbox%0D%0Aprivs+int%0D%0Abalance+decimal&edit=yes
-
-
-# SETUP
-
-# To save results to a database, you'll need to create the people table
-# (the file people.sql should help with this), and create the file
-# 'code/db_connect.php' which calls db_connect() see:
-# code/wfpl/examples/db_connect.php
+#  This program is free software: you can redistribute it and/or modify
+#  it under the terms of the GNU Affero General Public License as published by
+#  the Free Software Foundation, either version 3 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU Affero General Public License for more details.
 #
-# if you rename any of the database fields, you'll need to update this:
+#  You should have received a copy of the GNU Affero General Public License
+#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
 
 define('PEOPLE_DB_FIELDS', 'username,password,name,privs,balance');
 
@@ -47,8 +46,8 @@ function people_tem_sets($username, $password, $name, $privs, $balance) {
 }
 
 # You may pass a "where clause" for the db query.
-function people_display_listing($where = 'order by username limit 100') {
-       $rows = db_get_rows('people', 'id,username', $where);
+function people_display_listing($where = 'order by name limit 100') {
+       $rows = db_get_rows('people', 'id,name,username', $where);
        if($rows == false || count($rows) == 0) {
                tem_show('empty_listing');
                tem_show('listings');
@@ -56,11 +55,12 @@ function people_display_listing($where = 'order by username limit 100') {
        }
 
        foreach($rows as $row) {
-               list($id, $username) = $row;
+               list($id, $name, $username) = $row;
                tem_set('id', $id);
                if($username == '') {
                        $username = '--';
                }
+               tem_set('name', $name);
                tem_set('username', $username);
                tem_show('listing_row');
        }
@@ -80,7 +80,6 @@ function people_main() {
        if($ret) {
                return $ret;
        }
-       tem_show('main_body');
 }
 
 function _people_main() {
@@ -124,7 +123,7 @@ function _people_main() {
                                db_update('people', PEOPLE_DB_FIELDS, $username, $password_hash, $name, $privs, $balance, 'where id=%i', $edit_id);
                                message('Entry updated.');
                        } else {
-                               db_insert('people', PEOPLE_DB_FIELDS, $username, $password_hash, $name, $privs, $balance);
+                               db_insert('people', PEOPLE_DB_FIELDS . ',tiny_agreement', $username, $password_hash, $name, $privs, $balance, 1000);
                                message('Entry saved.');
                        }
                        if($error !== true) {