phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] notes/inc class.bonotes.inc.php, NONE, 1.21.2.1 class


From: Bettina Gille <address@hidden>
Subject: [Phpgroupware-cvs] notes/inc class.bonotes.inc.php, NONE, 1.21.2.1 class.sonotes.inc.php, NONE, 1.10.2.1 class.uinotes.inc.php, NONE, 1.29.2.1 class.bo.inc.php, 1.2.2.1.2.3, NONE class.so.inc.php, 1.2.4.4, NONE class.ui.inc.php, 1.5.2.6.2.3, NONE
Date: Tue, 04 Nov 2003 15:06:41 +0000

Update of /cvsroot/phpgroupware/notes/inc
In directory subversions:/tmp/cvs-serv11348/inc

Added Files:
      Tag: Version-0_9_16-branch
        class.bonotes.inc.php class.sonotes.inc.php 
        class.uinotes.inc.php 
Removed Files:
      Tag: Version-0_9_16-branch
        class.bo.inc.php class.so.inc.php class.ui.inc.php 
Log Message:
changed classnames

--- NEW FILE: class.bonotes.inc.php ---
<?php
        
/***************************************************************************\
        * phpGroupWare - Notes                                                  
    *
        * http://www.phpgroupware.org                                           
    *
        * Written by : Bettina Gille address@hidden                         *
        *              Andy Holman (LoCdOg)                                     
    *
        * -------------------------------------------------                     
    *
        * Copyright 2000 - 2003 Free Software Foundation, Inc                   
        *
        *                                                                       
    *
        * 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.                                            
    *
        
\***************************************************************************/
        /* $Id: class.bonotes.inc.php,v 1.21.2.1 2003/11/04 15:06:38 ceb Exp $ 
*/

        class bonotes
        {
                var $start;
                var $search;
                var $filter;
                var $cat_id;
                var $so;
                var $use_session;
                var $limit;
                var $debug;
                var $sort;
                var $total_records;

                var $public_functions = array(
                        '_list'            => True,
                        'read'             => True,
                        'save'             => True,
                        'delete'           => True,
                        'check_perms'      => True,
                        'set_font'         => True,
                        'set_font_size'    => True,
                        'read_preferences' => True,
                        'save_preferences' => True
                );

                var $soap_functions = array(
                        'list' => array(
                                'in'  => 
array('int','int','struct','string','int'),
                                'out' => array('array')
                        ),
                        'read' => array(
                                'in'  => array('int','struct'),
                                'out' => array('array')
                        ),
                        'save' => array(
                                'in'  => array('int','struct'),
                                'out' => array()
                        ),
                        'delete' => array(
                                'in'  => array('int','struct'),
                                'out' => array()
                        )
                );

                function bonotes($session=False)
                {
                        $this->so = CreateObject('notes.sonotes');

                        if ($session)
                        {
                                $this->read_sessiondata();
                                $this->use_session = True;
                        }

                        $_start   = $_POST['start']   ? $_POST['start']   : 
$_GET['start'];
                        $_search  = $_POST['search']  ? $_POST['search']  : 
$_GET['search'];
                        $_sort    = $_POST['sort']    ? $_POST['sort']    : 
$_GET['sort'];
                        $_order   = $_POST['order']   ? $_POST['order']   : 
$_GET['order'];
                        $_filter  = $_POST['filter']  ? $_POST['filter']  : 
$_GET['filter'];
                        $_fcat_id = $_POST['fcat_id'] ? $_POST['fcat_id'] : 
$_GET['fcat_id'];

                        if(!empty($_start) || ($_start == '0') || ($_start == 
0))
                        {
                                if($this->debug)
                                {
                                        echo '<br>overriding $start: "' . 
$this->start . '" now "' . $_start . '"';
                                }
                                $this->start = $_start;
                        }
                        if($_limit)
                        {
                                $this->limit  = $_limit;
                        }
                        if((empty($_search) && !empty($this->search)) || 
!empty($_search))
                        {
                                $this->search  = $_search;
                        }

                        if(isset($_fcat_id) && !empty($_fcat_id))
                        {
                                $this->cat_id = $_fcat_id;
                        }
                        if((isset($_POST['fcat_id']) || 
isset($_GET['fcat_id'])) &&
                                ($_fcat_id == '0' || $_fcat_id == 0 || 
$_fcat_id == ''))
                        {
                                $this->cat_id = 0;
                        }

                        if(isset($_sort)   && !empty($_sort))
                        {
                                if($this->debug)
                                {
                                        echo '<br>overriding $sort: "' . 
$this->sort . '" now "' . $_sort . '"';
                                }
                                $this->sort   = $_sort;
                        }

                        if(isset($_order)  && !empty($_order))
                        {
                                if($this->debug)
                                {
                                        echo '<br>overriding $order: "' . 
$this->order . '" now "' . $_order . '"';
                                }
                                $this->order  = $_order;
                        }

                        if(isset($_filter) && !empty($_filter))
                        {
                                if($this->debug) { echo '<br>overriding 
$filter: "' . $this->filter . '" now "' . $_filter . '"'; }
                                $this->filter = $_filter;
                        }
                }

                function list_methods($_type='xmlrpc')
                {
                        /*
                          This handles introspection or discovery by the logged 
in client,
                          in which case the input might be an array.  The 
server always calls
                          this function to fill the server dispatch map using a 
string.
                        */
                        if (is_array($_type))
                        {
                                $_type = $_type['type'] ? $_type['type'] : 
$_type[0];
                        }
                        switch($_type)
                        {
                                case 'xmlrpc':
                                        $xml_functions = array(
                                                'read' => array(
                                                        'function'  => 'read',
                                                        'signature' => 
array(array(xmlrpcInt,xmlrpcStruct)),
                                                        'docstring' => 
lang('Read a single entry by passing the id and fieldlist.')
                                                ),
                                                'save' => array(
                                                        'function'  => 'save',
                                                        'signature' => 
array(array(xmlrpcStruct,xmlrpcStruct)),
                                                        'docstring' => 
lang('Update a single entry by passing the fields.')
                                                ),
                                                'delete' => array(
                                                        'function'  => 'delete',
                                                        'signature' => 
array(array(xmlrpcBoolean,xmlrpcInt)),
                                                        'docstring' => 
lang('Delete a single entry by passing the id.')
                                                ),
                                                'list' => array(
                                                        'function'  => '_list',
                                                        'signature' => 
array(array(xmlrpcStruct,xmlrpcStruct)),
                                                        'docstring' => 
lang('Read a list of entries.')
                                                ),
                                                'list_methods' => array(
                                                        'function'  => 
'list_methods',
                                                        'signature' => 
array(array(xmlrpcStruct,xmlrpcString)),
                                                        'docstring' => 
lang('Read this list of methods.')
                                                )
                                        );
                                        return $xml_functions;
                                        break;
                                case 'soap':
                                        return $this->soap_functions;
                                        break;
                                default:
                                        return array();
                                        break;
                        }
                }

                function save_sessiondata($data)
                {
                        if ($this->use_session)
                        {
                                
$GLOBALS['phpgw']->session->appsession('session_data','notes',$data);
                        }
                }

                function read_sessiondata()
                {
                        $data = 
$GLOBALS['phpgw']->session->appsession('session_data','notes');

                        $this->start   = $data['start'];
                        $this->search  = $data['search'];
                        $this->filter  = $data['filter'];
                        $this->cat_id  = $data['cat_id'];
                }

                function check_perms($has, $needed)
                {
                        return (!!($has & $needed) == True);
                }

                function set_font()
                {
                        if 
(isset($GLOBALS['phpgw_info']['user']['preferences']['notes']['notes_font']))
                        {
                                $font = 
$GLOBALS['phpgw_info']['user']['preferences']['notes']['notes_font'];
                        }
                        else
                        {
                                $font = 'Arial';
                        }
                        return $font;
                }

                function set_font_size()
                {
                        if 
(isset($GLOBALS['phpgw_info']['user']['preferences']['notes']['notes_font_size']))
                        {
                                $font_size = 
$GLOBALS['phpgw_info']['user']['preferences']['notes']['notes_font_size'];
                        }
                        else
                        {
                                $font_size = '3';
                        }
                        return $font_size;
                }

                function _list($start = '', $search = '', $filter = '', $cat_id 
= '', $limit = true, $lastmod = -1)
                {
                        if (is_array($start))
                        {
                                $params = $start;
                        }
                        else
                        {
                                $params['start']  = $start;
                                $params['search'] = $search;
                                $params['filter'] = $filter;
                                $params['cat_id'] = $cat_id;
                                $params['limit']= $limit;
                                $params['lastmod']= $lastmod;
                        }

                        $notes = 
$this->so->read_notes($params['start'],$params['search'],$params['filter'],$params['cat_id'],
 $params['limit'], $params['lastmod']);
                        $this->total_records = $this->so->total_records;

                        for ($i=0; $i<count($notes); $i++)
                        {
                                $notes[$i]['date']  = 
$GLOBALS['phpgw']->common->show_date($notes[$i]['date']);
                                $notes[$i]['owner'] = 
$GLOBALS['phpgw']->accounts->id2name($notes[$i]['owner']);
                        }

                        return $notes;
                }

                function read($note_id)
                {
                        $note = $this->so->read_single_note($note_id);
                        return $note;
                }

                function save($note)
                {
                        if ($note['access'])
                        {
                                $note['access'] = 'private';
                        }
                        else
                        {
                                $note['access'] = 'public';
                        }

                        if ($note['id'])
                        {
                                if ($note['id'] != 0)
                                {
                                        $note_id = $note['id'];
                                        $this->so->edit_note($note);
                                }
                        }
                        else
                        {
                                $note_id = $this->so->add_note($note);
                        }
                        return $note_id;
                }

                function delete($params)
                {
                        if (is_array($params))
                        {
                                $this->so->delete_note($params[0]);
                        }
                        else
                        {
                                $this->so->delete_note($params);
                        }
                        return True;
                }

                function read_preferences()
                {
                        $GLOBALS['phpgw']->preferences->read_repository();

                        $prefs = array();

                        if 
($GLOBALS['phpgw_info']['user']['preferences']['notes'])
                        {
                                $prefs['notes_font'] = 
$GLOBALS['phpgw_info']['user']['preferences']['notes']['notes_font'];
                                $prefs['notes_font_size'] = 
$GLOBALS['phpgw_info']['user']['preferences']['notes']['notes_font_size'];
                        }
                        return $prefs;
                }

                function save_preferences($prefs)
                {
                        $GLOBALS['phpgw']->preferences->read_repository();

                        if ($prefs)
                        {
                                
$GLOBALS['phpgw']->preferences->change('notes','notes_font',$prefs['notes_font']);
                                
$GLOBALS['phpgw']->preferences->change('notes','notes_font_size',$prefs['notes_font_size']);
                                
$GLOBALS['phpgw']->preferences->save_repository(True);
                        }
                }
        }
?>

--- NEW FILE: class.uinotes.inc.php ---
<?php
        
/***************************************************************************\
        * phpGroupWare - Notes                                                  
    *
        * http://www.phpgroupware.org                                           
    *
        * Written by : Bettina Gille address@hidden                         *
        *              Andy Holman (LoCdOg)                                     
    *
        * -------------------------------------------------                     
    *
        * Copyright 2000 - 2003 Free Software Foundation, Inc                   
        *
        *                                                                       
    *
        * 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.                                            
    *
        
\***************************************************************************/
        /* $Id: class.uinotes.inc.php,v 1.29.2.1 2003/11/04 15:06:39 ceb Exp $ 
*/

        class uinotes
        {
                var $grants;
                var $cat_id;
                var $start;
                var $search;
                var $filter;
                var $bo;
                var $cats;
                var $nextmatchs;
                var $t;

                var $public_functions = array
                (
                        '_list'  => True,
                        'view'   => True,
                        'add'    => True,
                        'edit'   => True,
                        'delete' => True,
                        'preferences' => True
                );

                function uinotes()
                {
                        $this->cats       = CreateObject('phpgwapi.categories');
                        $this->nextmatchs = CreateObject('phpgwapi.nextmatchs');
                        $this->account    = 
$GLOBALS['phpgw_info']['user']['account_id'];
                        $this->t          = $GLOBALS['phpgw']->template;
                        $this->grants     = 
$GLOBALS['phpgw']->acl->get_grants('notes');
                        $this->grants[$this->account] = PHPGW_ACL_READ + 
PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE;
                        $this->bo         = CreateObject('notes.bonotes',True);

                        $this->start  = $this->bo->start;
                        $this->search = $this->bo->search;
                        $this->filter = $this->bo->filter;
                        $this->cat_id = $this->bo->cat_id;
                }

                function save_sessiondata()
                {
                        $data = array
                        (
                                'start'  => $this->start,
                                'search' => $this->search,
                                'filter' => $this->filter,
                                'cat_id' => $this->cat_id
                        );
                        $this->bo->save_sessiondata($data);
                }

                function set_app_langs()
                {
                        
$this->t->set_var('bg_color',$GLOBALS['phpgw_info']['theme']['th_bg']);
                        $tr_color = 
$this->nextmatchs->alternate_row_color($tr_color);
                        $this->t->set_var('tr_color',$tr_color);
                        $this->t->set_var('font',$this->bo->set_font());
                        
$this->t->set_var('font_size',$this->bo->set_font_size());
                        
$this->t->set_var('name',$GLOBALS['phpgw_info']['user']['fullname']);

                        $this->t->set_var('lang_categories',lang('Categories'));
                        $this->t->set_var('lang_category',lang('Category'));
                        $this->t->set_var('lang_notes',lang('Notes'));
                        $this->t->set_var('lang_search',lang('Search'));
                        $this->t->set_var('lang_submit',lang('Submit'));
                        $this->t->set_var('lang_all',lang('All'));
                        $this->t->set_var('lang_view',lang('View'));
                        $this->t->set_var('lang_choose',lang('Choose the 
category'));
                        $this->t->set_var('lang_access',lang('Private'));
                        $this->t->set_var('lang_done',lang('Done'));
                        $this->t->set_var('lang_save',lang('Save'));
                        
$this->t->set_var('done_action',$GLOBALS['phpgw']->link('/index.php','menuaction=notes.uinotes._list'));
                }

                function display_app_header()
                {
                        $this->t->set_file(array('header' => 'header.tpl'));
            $this->t->set_block('header','notes_header');

                        $this->set_app_langs();

                        
$this->t->set_var('link_categories',$GLOBALS['phpgw']->link('/index.php','menuaction=preferences.uicategories.index&cats_app=notes&cats_level=True&global_cats=True'));
                        
$this->t->set_var('link_notes',$GLOBALS['phpgw']->link('/notes/index.php','menuaction=notes.uinotes._list'));
                        $this->t->fp('app_header','notes_header');

                        $GLOBALS['phpgw']->common->phpgw_header();
                        echo parse_navbar();
                }

                function _list()
                {
                        $this->display_app_header();

                        $this->t->set_file(array('notes_list_t' => 'list.tpl'));
                        $this->t->set_block('notes_list_t','notes_list','list');

                        if (!$this->start)
                        {
                                $this->start = 0;
                        }

                        $notes_list = 
$this->bo->_list($this->start,$this->search,$this->filter,$this->cat_id);

// --------------------------------- nextmatch ---------------------------

                        $link_data = array
                        (
                                'menuaction' => 'notes.uinotes._list'
                        );

                        $left = 
$this->nextmatchs->left('/index.php',$this->start,$this->bo->total_records,$link_data);
                        $right = 
$this->nextmatchs->right('/index.php',$this->start,$this->bo->total_records,$link_data);
                        $this->t->set_var('left',$left);
                        $this->t->set_var('right',$right);

                        
$this->t->set_var('search_message',$this->nextmatchs->show_hits($this->bo->total_records,$this->start));

// -------------------------- end nextmatch ------------------------------------

                        
$this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
                        $this->t->set_var('title_notes',lang('Personalized 
notes for'));
                        
$this->t->set_var('cat_action',$GLOBALS['phpgw']->link('/index.php',$link_data));
                        
$this->t->set_var('filter_action',$GLOBALS['phpgw']->link('/index.php',$link_data));
                        
$this->t->set_var('category_list',$this->cats->formated_list('select','all',$this->cat_id,True));

                        switch($this->filter)
                        {
                                case 'all': $filter_sel[0]=' selected';break;
                                case 'public': $filter_sel[1]=' selected';break;
                                case 'private': $filter_sel[2]=' 
selected';break;
                        }

                        $filter_list = '<option value="all"' . $filter_sel[0] . 
'>' . lang('Show all') . '</option>' . "\n"
                                . '<option value="public"' . $filter_sel[1] . 
'>' . lang('Only yours') . '</option>' . "\n"
                                . '<option value="private"' . $filter_sel[2] . 
'>' . lang('Private') . '</option>' . "\n";

                        $this->t->set_var('filter_list',$filter_list);

                        for ($i=0;$i<count($notes_list);$i++)
                        {
                                $note_owner = 
intval($notes_list[$i]['owner_id']);
                                $new_dateout = $notes_list[$i]['date'];

                                $words = split(' 
',$GLOBALS['phpgw']->strip_html($notes_list[$i]['content']));
                                $first = "$words[0] $words[1] $words[2] 
$words[3] .....";
                                
$this->nextmatchs->template_alternate_row_color(&$this->t);

                                $this->t->set_var(array
                                (
                                        'new_date' => $new_dateout,
                                        'first' => $first
                                ));

                                $link_data['note_id']           = 
$notes_list[$i]['id'];
                                $link_data['menuaction']        = 
'notes.uinotes.view';

                                
$this->t->set_var('view',$GLOBALS['phpgw']->link('/index.php',$link_data));

                                if 
($this->bo->check_perms($this->grants[$note_owner],PHPGW_ACL_EDIT) || 
$note_owner == $this->account)
                                {
                                        $link_data['menuaction'] = 
'notes.uinotes.edit';
                                        
$this->t->set_var('edit',$GLOBALS['phpgw']->link('/index.php',$link_data));
                                        
$this->t->set_var('lang_edit',lang('Edit'));
                                }
                                else
                                {
                                        $this->t->set_var('edit','');
                                        $this->t->set_var('lang_edit','');
                                }

                                if 
($this->bo->check_perms($this->grants[$note_owner],PHPGW_ACL_DELETE) || 
$note_owner == $this->account)
                                {
                                        $link_data['menuaction'] = 
'notes.uinotes.delete';
                                        
$this->t->set_var('delete',$GLOBALS['phpgw']->link('/index.php',$link_data));
                                        
$this->t->set_var('lang_delete',lang('Delete'));
                                }
                                else
                                {
                                        $this->t->set_var('delete','');
                                        $this->t->set_var('lang_delete','');
                                }

                                $this->t->fp('list','notes_list',True);
                        }

                        if ($this->cat_id && $this->cat_id != 0)
                        {
                                $cat = 
$this->cats->return_single($this->cat_id);
                        }

                        $link_data['menuaction']        = 'notes.uinotes.add';
                        $link_data['cat_id']            = $this->cat_id;

                        if ($cat[0]['app_name'] == 'phpgw' || $cat[0]['owner'] 
== '-1' || !$this->cat_id)
                        {
                                $this->t->set_var('add','<form method="POST" 
action="' . $GLOBALS['phpgw']->link('/index.php',$link_data)
                                        . '"><input type="submit" name="Add" 
value="' . lang('Add note') .'"></font></form>');
                        }
                        else
                        {
                                if 
($this->bo->check_perms($this->grants[$cat[0]['owner']],PHPGW_ACL_ADD) || 
$cat[0]['owner'] == $this->account)
                                {
                                        $this->t->set_var('add','<form 
method="POST" action="' . $GLOBALS['phpgw']->link('/index.php',$link_data)
                                                . '"><input type="submit" 
name="Add" value="' . lang('Add note') .'"></font></form>');
                                }
                                else
                                {
                                        $this->t->set_var('add','');
                                }
                        }

                        $this->t->pfp('out','notes_list_t');
                        $this->save_sessiondata();
                }

                function add()
                {
                        $cat_id         = get_var('cat_id',array('POST','GET'));
                        $new_cat        = get_var('new_cat',array('POST'));
                        $addnote        = get_var('addnote',array('POST'));
                        $note           = get_var('note',array('POST'));

                /*      if ($GLOBALS['spellcheck'])
                        {
                                $check_fields = array(
                                        'content' => $GLOBALS['note']['content']
                                );

                                $spellcheck = 
createobject('phpgwapi.spellcheck');
                                
$spellcheck->check('notes.uinotes.add',$check_fields,array());

                                return False;
                        } */

                        if ($new_cat)
                        {
                                $cat_id = $new_cat;
                        }

                        if ($addnote)
                        {
                                $note['category'] = $cat_id;

                                $this->bo->save($note);
//                              $this->t->set_var('message',lang('Note has been 
added for %1 !',$GLOBALS['phpgw_info']['user']['fullname']));
                                $this->cat_id = $cat_id;
                                $this->_list();
                                return False;
                        }
                        else
                        {
                                $this->display_app_header();

                                $this->t->set_file(array('form' => 'form.tpl'));
                                $this->t->set_block('form','add','addhandle');
                                $this->t->set_block('form','edit','edithandle');

                                $this->t->set_var('message','');
                                $this->t->set_var('lang_action',lang('Add a 
note for'));
                                
$this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php','menuaction=notes.uinotes.add&cat_id='
 . $cat_id));
                                $this->t->set_var('content',$note['content']);
                                
$this->t->set_var('main_cat_list',$this->cats->formated_list('select','all',$cat_id,'True'));

                                $this->t->set_var('access','<input 
type="checkbox" name="note[access]" value="True" checked>');

                                $this->t->set_var('lang_reset',lang('Clear 
Form'));
                                $this->t->set_var('lang_add',lang('Add note'));
                                $this->t->set_var('edithandle','');
                                $this->t->set_var('addhandle','');
                                $this->t->pfp('out','form');
                                $this->t->pfp('addhandle','add');
                        }
                }

                function edit()
                {
                        $note_id        = 
get_var('note_id',array('GET','POST'));
                        $cat_id         = get_var('cat_id',array('GET','POST'));
                        $new_cat        = get_var('new_cat',array('POST'));
                        $editnote       = get_var('editnote',array('POST'));
                        $note           = get_var('note',array('POST'));

                        $this->display_app_header();

                        $this->t->set_file(array('form' => 'form.tpl'));
                        $this->t->set_block('form','add','addhandle');
                        $this->t->set_block('form','edit','edithandle');

                        if ($new_cat)
                        {
                                $cat_id = $new_cat;
                        }

                        if ($editnote)
                        {
                                $note['category'] = $cat_id;
                                $note['id'] = $note_id;

                                $this->bo->save($note);
                                $this->t->set_var('message',lang('Note has been 
updated for %1 !',$GLOBALS['phpgw_info']['user']['fullname']));
                        }
                        else
                        {
                                $this->t->set_var('message','');
                        }

                        $note = $this->bo->read($note_id);

                        $this->t->set_var('lang_action',lang('Edit note for'));
                        
$this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php','menuaction=notes.uinotes.edit&cat_id='
 . $cat_id . '&note_id=' . $note_id));
                        
$this->t->set_var('content',$GLOBALS['phpgw']->strip_html($note['content']));
                        
$this->t->set_var('main_cat_list',$this->cats->formated_list('select','all',$note['category'],'True'));
                        $this->t->set_var('lang_edit',lang('Edit'));

                        $this->t->set_var('access','<input type="checkbox" 
name="note[access]" value="True"' . ($note['access'] == 'private'?' 
checked':'') . '>');

                        if 
($this->bo->check_perms($this->grants[$note['owner']],PHPGW_ACL_DELETE) || 
$note['owner'] == $this->account)
                        {
                                $this->t->set_var('delete','<form method="POST" 
action="' . 
$GLOBALS['phpgw']->link('/index.php','menuaction=notes.uinotes.delete&note_id=' 
. $note_id)
                                        . '"><input type="submit" value="' . 
lang('Delete') .'"></form>');
                        }
                        else
                        {
                                $this->t->set_var('delete','&nbsp;');
                        }

                        $this->t->set_var('edithandle','');
                        $this->t->set_var('addhandle','');
                        $this->t->pfp('out','form');
                        $this->t->pfp('edithandle','edit');
                }

                function delete()
                {
                        $note_id        = 
get_var('note_id',array('GET','POST'));

                        if ($_POST['confirm'])
                        {
                                $this->bo->delete($note_id);
                                
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction=notes.uinotes._list');
                        }
                        else
                        {
                                $this->display_app_header();

                                $this->t->set_file('delete','delete.tpl');

                                
$this->t->set_var('action_url',$GLOBALS['phpgw']->link('/index.php','menuaction=notes.uinotes.delete&note_id='
 . $note_id));
                                
$this->t->set_var('done_action',$GLOBALS['phpgw']->link('/index.php','menuaction=notes.uinotes._list'));
                                $this->t->set_var('deleteheader',lang('Are you 
sure you want to delete this note ?'));
                                $this->t->set_var('lang_no',lang('No'));
                                $this->t->set_var('lang_yes',lang('Yes'));
                                $this->t->pfp('out','delete');
                        }
                }

                function view()
                {
                        $note_id = get_var('note_id',array('GET'));

                        $this->display_app_header();

                        $this->t->set_file('view','view.tpl');

                        $this->t->set_var('lang_time',lang('Time created'));
                        $this->t->set_var('lang_action',lang('Display note 
for'));
                        $this->t->set_var('lang_access',lang('Access'));

                        $note = $this->bo->read($note_id);

                        
$this->t->set_var('category',$this->cats->id2name($note['category']));
                        
$this->t->set_var('new_date',$GLOBALS['phpgw']->common->show_date($note['date']));
                        
$this->t->set_var('fnote',nl2br($GLOBALS['phpgw']->strip_html($note['content'])));
                        $this->t->set_var('access',ucfirst($note['access']));

                        $this->t->pfp('out','view');
                }

                function preferences()
                {
                        $submit = get_var('submit',array('POST'));
                        $prefs  = get_var('prefs',array('POST'));

                        if ($submit)
                        {
                                $this->bo->save_preferences($prefs);
                                Header('Location: ' . 
$GLOBALS['phpgw']->link('/preferences/index.php'));
                                $GLOBALS['phpgw']->common->phpgw_exit();
                        }

                        $GLOBALS['phpgw']->common->phpgw_header();
                        echo parse_navbar();

                        $this->t->set_file(array('preferences' => 
'preferences.tpl'));
                        
$this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php','menuaction=notes.uinotes.preferences'));

                        $this->set_app_langs();

                        $this->t->set_var('lang_action',lang('Notes 
preferences'));
                        $this->t->set_var('lang_select_font',lang('Choose a 
font'));
                        $this->t->set_var('lang_select_size',lang('Choose the 
font size'));

                        $prefs = $this->bo->read_preferences();

                        switch($prefs['notes_font'])
                        {
                                case'Arial,Helvetica,sans-serif': 
$font_sel[0]=' selected'; break;
                                case'Times New Roman,Times,serif': 
$font_sel[1]=' selected'; break;
                                case'Verdana,Arial,Helvetica,sans-serif': 
$font_sel[2]=' selected'; break; 
                                case'Georgia,Times New Roman,Times,serif': 
$font_sel[3]=' selected'; break;
                                case'Courier New,Courier,mono': $font_sel[4]=' 
selected'; break;
                                case'Helvetica,Arial,sans-serif': 
$font_sel[5]=' selected'; break; 
                                
case'Tahoma,Verdana,Arial,Helvetica,sans-serif': $font_sel[6]=' selected'; 
break;
                        }

                        $notes_font = '<option 
value="Arial,Helvetica,sans-serif"' . $font_sel[0] . '>' . lang('Arial') . 
'</option>' . "\n"
                                . '<option value="Times New Roman,Times,serif"' 
. $font_sel[1] . '>' . lang('Times New Roman') . '</option>' . "\n"
                                . '<option 
value="Verdana,Arial,Helvetica,sans-serif"' . $font_sel[2] . '>' . 
lang('Verdana') . '</option>' . "\n"
                                . '<option value="Georgia,Times New 
Roman,Times,serif"' . $font_sel[3] . '>' . lang('Georgia') . '</option>' . "\n"
                                . '<option value="Courier New,Courier,mono"' . 
$font_sel[4] . '>' . lang('Courier New') . '</option>' . "\n"
                                . '<option value="Helvetica,Arial,sans-serif"' 
. $font_sel[5] . '>' . lang('Helvetica') . '</option>' . "\n"
                                . '<option 
value="Tahoma,Verdana,Arial,Helvetica,sans-serif"' . $font_sel[6] . '>' . 
lang('Tahoma') . '</option>' . "\n";

                        $this->t->set_var('notes_font',$notes_font);

                        switch($prefs['notes_font_size'])
                        {
                                case 1: $size_sel[0]=' selected'; break;
                                case 2: $size_sel[1]=' selected'; break;
                                case 3: $size_sel[2]=' selected'; break;
                                case 4: $size_sel[3]=' selected'; break;
                                case 5: $size_sel[4]=' selected'; break;
                        }

                        $notes_font_size = '<option value="1"' . $size_sel[0] . 
'>' . lang('Very Small') . '</option>' . "\n"
                                . '<option value="2"' . $size_sel[1] . '>' . 
lang('Small') . '</option>' . "\n"
                                . '<option value="3"' . $size_sel[2] . '>' . 
lang('Medium') . '</option>' . "\n"
                                . '<option value="4"' . $size_sel[3] . '>' . 
lang('Large') . '</option>' . "\n"
                                . '<option value="5"' . $size_sel[4] . '>' . 
lang('Very Large') . '</option>' . "\n";

                        $this->t->set_var('notes_font_size',$notes_font_size);

                        $this->t->pfp('out','preferences');
                }
        }
?>

--- NEW FILE: class.sonotes.inc.php ---
<?php
        
/***************************************************************************\
        * phpGroupWare - Notes                                                  
    *
        * http://www.phpgroupware.org                                           
    *
        * Written by : Bettina Gille address@hidden                         *
        *              Andy Holman (LoCdOg)                                     
    *
        * -------------------------------------------------                     
    *
        * Copyright 2000 - 2003 Free Software Foundation, Inc                   
        *
        *                                                                       
    *
        * 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.                                            
    *
        
\***************************************************************************/
        /* $Id: class.sonotes.inc.php,v 1.10.2.1 2003/11/04 15:06:39 ceb Exp $ 
*/

        class sonotes
        {
                var $grants;
                var $db;
                var $db2;
                var $grants;
                var $owner;
                var $total_records;

                function sonotes()
                {
                        $this->db     = $GLOBALS['phpgw']->db;
                        $this->db2    = $this->db;
                        $this->grants = 
$GLOBALS['phpgw']->acl->get_grants('notes');
                        $this->owner  = 
intval($GLOBALS['phpgw_info']['user']['account_id']);
                }

                function read_notes($start, $search = '', $filter = '',$cat_id 
= '', $limit = True, $lastmod = -1)
                {
                        //cast/addslashes for security
                        $start          = intval($start);
                        $cat_id         = intval($cat_id);
                        $lastmod        = intval($lastmod);
                        $search         = $this->db->db_addslashes($search);
                        
                        if (! $filter)
                        {
                                $filter = 'all';
                        }

                        if ($filter == 'all')
                        {
                                $filtermethod = " ( note_owner=" . $this->owner;
                                if (is_array($this->grants))
                                {
                                        $grants = $this->grants;
                                        while (list($user) = each($grants))
                                        {
                                                $public_user_list[] = $user;
                                        }
                                        reset($public_user_list);
                                        $filtermethod .= " OR 
(note_access='public' AND note_owner in(" . implode(',',$public_user_list) . 
")))";
                                }
                                else
                                {
                                        $filtermethod .= ' )';
                                }
                        }
                        elseif ($filter == 'public')
                        {
                                $filtermethod = " note_owner='" . $this->owner 
. "'";
                        }
                        else
                        {
                                $filtermethod = " note_owner='" . $this->owner 
. "' AND note_access='private'";
                        }

                        if ($lastmod >= 0)
                        {
                                $filtermethod .= ' note_date > ' . 
intval($lastmod) . ' ';
                        } 

                        if ($cat_id)
                        {
                                $filtermethod .= ' AND note_category=' . 
intval($cat_id) . ' ';
                        }

                        if ($search)
                        {
                                $searchmethod = " AND note_content like 
'%".$this->db->db_addslashes($search)."%'";
                        }
                        
                        $sql = "SELECT * FROM phpgw_notes WHERE $filtermethod 
$searchmethod ORDER BY note_date DESC";

                        $this->db2->query($sql,__LINE__,__FILE__);
                        $this->total_records = $this->db2->num_rows();
                        if($limit)
                        {
                                
$this->db->limit_query($sql,$start,__LINE__,__FILE__);
                        }
                        else
                        {
                                $this->db->query($sql,__LINE__,__FILE__);
                        }

                        $i = 0;
                        while ($this->db->next_record())
                        {
                                $notes[$i]['id']        = 
intval($this->db->f('note_id'));
                                $notes[$i]['owner']     = 
$this->db->f('note_owner');
                                $notes[$i]['owner_id']  = 
intval($this->db->f('note_owner'));
                                $notes[$i]['access']    = 
$this->db->f('note_access');
                                $notes[$i]['date']      = 
$this->db->f('note_date');
                                $notes[$i]['category']  = 
intval($this->db->f('note_category'));
                                $notes[$i]['content']   = 
$this->db->f('note_content', True);
                                $notes[$i]['grants']    = 
intval($this->grants[$this->db->f('note_owner')]);
                                $notes[$i]['lastmod']   = 
intval($this->db->f('note_date'));
                                $i++;
                        }
                        return $notes;
                }

                function read_single_note($note_id)
                {
                        $this->db->query('SELECT * FROM phpgw_notes WHERE 
note_id=' . intval($note_id),__LINE__,__FILE__);

                        if ($this->db->next_record())
                        {
                                $note['id']             = 
intval($this->db->f('note_id'));
                                $note['owner']          = 
$this->db->f('note_owner');
                                $note['content']        = 
$this->db->f('note_content', True);
                                $note['access']         = 
$this->db->f('note_access');
                                $note['date']           = 
$this->db->f('note_date');
                                $note['category']       = 
intval($this->db->f('note_category'));

                                return $note;
                        }
                }

                function add_note($note)
                {
                        //cast/addslashes for security
                        $note['access']  = 
$this->db->db_addslashes($note['access']);
                        $note['content'] = 
$this->db->db_addslashes($note['content']);
                        $note['category']= intval($note['category']);
                        
                        $this->db->query("INSERT INTO phpgw_notes 
(note_owner,note_access,note_date,note_content,note_category) "
                                . "VALUES (" . $this->owner . ",'" . 
$note['access'] . "'," . time() . ",'" . $note['content']
                                . "'," . $note['category'] . 
")",__LINE__,__FILE__);
                        return 
$this->db->get_last_insert_id('phpgw_notes','note_id');
                }

                function edit_note($note)
                {
                        //cast/addslashes for security
                        $note['id']      = intval($note['id']);
                        $note['access']  = 
$this->db->db_addslashes($note['access']);
                        $note['content'] = 
$this->db->db_addslashes($note['content']);
                        $note['category']= intval($note['category']);

                        $this->db->query("UPDATE phpgw_notes set 
note_content='" . $note['content'] . "', note_date=" . time() . ", 
note_category=" . $note['category'] . ", "
                                . "note_access='" . $note['access'] . "' WHERE 
note_id=" . $note['id'],__LINE__,__FILE__);
                }

                function delete_note($note_id)
                {
                        $note_id = (int) $note_id;
                        $this->db->query('DELETE FROM phpgw_notes WHERE 
note_id=' . intval($note_id),__LINE__,__FILE__);
                }
        }
?>

--- class.ui.inc.php DELETED ---

--- class.bo.inc.php DELETED ---

--- class.so.inc.php DELETED ---





reply via email to

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