Location: PHPKode > projects > O - OpenSource GroupWare > osgw/notebook/class.notebook.php
<?php
/**************************************************************************
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   @Authors:	Ryan Thompson(hide@address.com)
***************************************************************************/
/*$Id: class.notebook.php,v 1.9 2003/12/10 20:40:55 rthomp Exp $*/
class notebook
{
	function msg($message, $service = 'nb')
	{
		GLOBAL $O, $lang;
		return $lang->get_msg($message, $service);
	}
	
	function nav_buttons()
	{
		$navigation .= "<input type=\"submit\" name=\"notes_list\" value=\"". $this->msg('notes_list') ."\" onClick=\"window.location='index.php'\" class=\"button1\">";
		$navigation .= "<input type=\"submit\" name=\"add_note\" value=\"". $this->msg('add_note') ."\" onClick=\"window.location='add_note.php'\" class=\"button1\">";
		return $navigation;	
	}

	/*!
		@function save_note()
		@author Ryan Thompson
		@abstract Saves note to database
		@version 0.1
		@params $data
		@params $user_id
		@return TRUE/FALSE
		@since 10-12-2003
	*/	
	function save_note($data, $user_id)
	{
		GLOBAL $db, $category, $share;
		
		$sql = "INSERT INTO o_notebook (user_id, title, note, posted) 
			VALUES ('$user_id','{$data['title']}','{$data['note']}','". time() ."')";
		$db->query($sql);
		
		$insert_id = $db->insert_id;
		$category->categorize($insert_id, 'nb', $data['category']);
		
		
		$share->add_share($insert_id, 'nb', $data['share_users']);
		
	}	

	/*!
		@function verify_title()
		@author Ryan Thompson
		@abstract Makes sure the title isn't empty
		@version 0.1
		@params $title
		@return TRUE/FALSE
		@since 10-12-2003
	*/	
	function verify_title($title)
	{
		GLOBAL $error;
		if(empty($title))
		{
			$error->get_message('15000');
			return FALSE;
		}
		
		return TRUE;
		
	}
	
	/*!
		@function update()
		@author Ryan Thompson
		@abstract Updates note in database
		@version 0.1
		@params $note_id
		@params $data[]
		@params $user_id
		@return TRUE/FALSE
		@since 10-12-2003
	*/		
	function update($note_id, $data, $user_id)
	{
		GLOBAL $O, $db, $category, $share;
		$title = $data['title'];

		$sql = "UPDATE o_notebook SET title='$title',note='{$data['note']}'
			WHERE note_id='$note_id' AND user_id='$user_id'";
		$db->query($sql);
		
		
		$category->edit_category($note_d, 'nb', $data['category']);
		
		$share->update_share($data['enable_sharing'], $note_id, 'nb', $data['share_users']);
		//Add Update Category and update data sharing
		return;	
	}
}
Return current item: O - OpenSource GroupWare