phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] CVS: sitemgr/modules/sitemgr_module_guestbook/inc cla


From: Michael Totschnig <address@hidden>
Subject: [Phpgroupware-cvs] CVS: sitemgr/modules/sitemgr_module_guestbook/inc class.guestbook_BO.inc.php,NONE,1.1class.guestbook_SO.inc.php,NONE,1.1
Date: Sun, 15 Jun 2003 02:37:00 -0400

Update of /cvsroot/phpgroupware/sitemgr/modules/sitemgr_module_guestbook/inc
In directory subversions:/tmp/cvs-serv11982/sitemgr_module_guestbook/inc

Added Files:
        class.guestbook_BO.inc.php class.guestbook_SO.inc.php 
Log Message:
a guestbook module for sitemgr (a test, probably not useable)


--- NEW FILE ---
<?php

        class guestbook_BO
        {
                var $so;

                function guestbook_BO()
                {
                        $this->so = 
CreateObject('sitemgr_module_guestbook.guestbook_SO', true);
                }

                function create_book($name)
                {
                        return $this->so->create_book($name);
                }

                function add_entry($name,$comment,$book_id)
                {
print_r($name);
                        $this->so->add_entry($name,$comment,$book_id);
                }

                function get_entries($book_id)
                {
                        return $this->so->get_entries($book_id);
                }

                function get_books()
                {
                        return $this->so->get_books();
                }

                function delete_book($book_id)
                {
                        return $this->so->delete_book($book_id);
                }

                function save_book($book_id,$name)
                {
                        return $this->so->save_book($book_id,$name);
                }
        }
--- NEW FILE ---
<?php

        class guestbook_SO
        {
                var $db;

                function guestbook_SO()
                {
                        $this->db = $GLOBALS['phpgw']->db;
                }


                function create_book($title)
                {
                        $this->db->query("INSERT INTO 
phpgw_sitemgr_module_guestbook_books (book_title) VALUES('$title')");
                        return 
$this->db->get_last_insert_id('phpgw_sitemgr_module_guestbook_books','book_id');
                }


                function add_entry($name,$comment,$book_id)
                {
                        $timestamp = time();
                        $this->db->query("INSERT INTO 
phpgw_sitemgr_module_guestbook_entries (name,book_id,comment,timestamp) VALUES 
('$name',$book_id,'$comment',$timestamp)");
                }

                function get_entries($book_id)
                {
                        $this->db->query("SELECT name,comment,timestamp FROM 
phpgw_sitemgr_module_guestbook_entries WHERE book_id = $book_id ORDER BY 
timestamp DESC");
                        while($this->db->next_record())
                        {
                                foreach(array('name','comment','timestamp') as 
$field)
                                {
                                        $entry[$field] = $this->db->f($field);
                                }
                                $result[] = $entry;
                        }
                        return $result;
                }

                function get_books()
                {
                        $this->db->query("SELECT * FROM 
phpgw_sitemgr_module_guestbook_books");
                        while($this->db->next_record())
                        {
                                $result[$this->db->f('book_id')] = 
$this->db->f('book_title');
                        }
                        return $result;
                }

                function delete_book($book_id)
                {
                        $this->db->query("DELETE FROM 
phpgw_sitemgr_module_guestbook_entries WHERE book_id = $book_id");
                        $this->db->query("DELETE FROM 
phpgw_sitemgr_module_guestbook_books WHERE book_id = $book_id");
                }
                function save_book($book_id,$title)
                {
                        $this->db->query("UPDATE 
phpgw_sitemgr_module_guestbook_books SET book_title='$title' WHERE book_id = 
$book_id");
                }
        }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]