[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] notes/class.base.php, 1.1.2.17
From: |
nomail |
Subject: |
[Phpgroupware-cvs] notes/class.base.php, 1.1.2.17 |
Date: |
Fri, 9 Jul 2004 16:11:25 +0200 |
Update of /notes
Modified Files:
Branch: proposal-branch
class.base.php
date: 2004/07/09 14:11:25; author: dcech; state: Exp; lines: +273 -314
Log Message:
various updates for notes, as far as I can tell nothing is broken...
=====================================================================
Index: notes/class.base.php
diff -u notes/class.base.php:1.1.2.16 notes/class.base.php:1.1.2.17
--- notes/class.base.php:1.1.2.16 Tue Jul 6 07:22:50 2004
+++ notes/class.base.php Fri Jul 9 14:11:25 2004
@@ -12,28 +12,28 @@
\**************************************************************************/
/* $Id$ */
- /* $Source$ */
+ /* $Source$ */
- $functions = array();
+ $functions = array();
$functions['notes_base'] = array
- (
- 'type' => 'public',
- 'abstract' => 'base class for notes',
- 'discussion' => 'base class for notes'
- );
-
+ (
+ 'type' => 'public',
+ 'abstract' => 'base class for notes',
+ 'discussion' => 'base class for notes'
+ );
+
$functions['start'] = array
- (
- 'type' => 'public',
- 'title' => 'Notes',
- 'abstract' => 'Show list of notes',
- 'discussion' => 'This will show a list of notes the user owns
or has access to'
- );
-
+ (
+ 'type' => 'public',
+ 'title' => 'Notes',
+ 'abstract' => 'Show list of notes',
+ 'discussion' => 'This will show a list of notes the user owns
or has access to'
+ );
+
$functions['create'] = array
- (
- 'type' => 'public',
- 'title' => 'Create note',
+ (
+ 'type' => 'public',
+ 'title' => 'Create note',
'abstract' => 'Create note',
'params' => array
(
@@ -42,24 +42,24 @@
'content' => array('type' => 'any',
'default' => NOTSET, 'desc' => 'Note content'),
'dm_type' => array('type' => 'enum',
'default' => array('N','D'), 'desc' => 'Datamine type'),
'datamine_location' => array('type' => 'any',
'default' => NOTSET, 'desc' => 'Datamine location')
- )
+ )
);
$functions['view'] = array
- (
- 'type' => 'public',
- 'title' => 'View note',
+ (
+ 'type' => 'public',
+ 'title' => 'View note',
'abstract' => 'View note',
'params' => array
(
'note_id' => array('type' => 'number', 'default' =>
REQUIRED, 'desc' => 'Note ID number')
- )
- );
+ )
+ );
$functions['edit'] = array
- (
- 'type' => 'public',
- 'title' => 'Edit note',
+ (
+ 'type' => 'public',
+ 'title' => 'Edit note',
'abstract' => 'Edit note',
'params' => array
(
@@ -67,44 +67,44 @@
'note_id' => array('type' => 'number', 'default' =>
REQUIRED, 'desc' => 'Note ID number'),
'category' => array('type' => 'number', 'default' =>
0, 'desc' => 'Category ID number'),
'content' => array('type' => 'any', 'default' =>
NOTSET, 'desc' => 'Note content')
- )
- );
+ )
+ );
$functions['delete'] = array
- (
- 'type' => 'public',
- 'title' => 'Delete note',
+ (
+ 'type' => 'public',
+ 'title' => 'Delete note',
'abstract' => 'Delete note',
'params' => array
(
'note_id' => array('type' => 'number', 'default' =>
REQUIRED, 'desc' => 'Note ID number'),
'answer' => array('type' => 'any', 'default' =>
NOVAR, 'desc' => 'Answer to yes no dialog')
- )
- );
-
+ )
+ );
+
$GLOBALS['docs']['notes']['classes']['notes_base'] = array
- (
- 'abstract' => 'Default class for notes',
- 'functions' => $functions
- );
-
- class notes_base
- {
- function notes_base()
+ (
+ 'abstract' => 'Default class for notes',
+ 'functions' => $functions
+ );
+
+ class notes_base
+ {
+ function notes_base()
{
$GLOBALS['phpgw']->add_xsl('notes.base');
$GLOBALS['phpgw']->add_xsl('api.widgets');
// The no_app_menu is *ONLY* a temp workaround for not
showing the app menu
- // durring _datamine_get(), I am currently working on
another solution to it
+ // during _datamine_get(), I am currently working on
another solution to it
if (! $GLOBALS['notes_menus_loaded'] && !
$GLOBALS['no_app_menu'])
{
$GLOBALS['phpgw']->add_appmenu('Notes
menu','Add note','notes.base.create');
//$GLOBALS['phpgw']->add_appmenu('Notes
menu','Preferences','api.base.prefs&appname=notes');
$GLOBALS['notes_menus_loaded'] = true;
- }
- }
+ }
+ }
// This is only until categorys is done
function _temp_cat()
@@ -112,117 +112,126 @@
return '-';
}
- function __get_record(&$db)
+ function __get_record()
{
- // Belive it or not, some browsers don't have strlen or
substr support in XSLT,
+ $args = new safe_args();
+ $args->set('note_id' ,REQUIRED
,'number');
+ $args->set('note_owner' ,REQUIRED
,'number');
+ $args->set('note_access' ,REQUIRED ,'any');
+ $args->set('note_dm_type' ,REQUIRED ,'any');
+ $args->set('note_category' ,REQUIRED
,'number');
+ $args->set('note_content' ,''
,'any');
+ $args->set('note_modified' ,REQUIRED
,'number');
+ $args->set('note_created' ,REQUIRED
,'number');
+ $args = $args->get(func_get_args());
+
+ // Believe it or not, some browsers don't have strlen
or substr support in XSLT,
// this is a work around
// FIXME: This should be a preference option for the
cut off point
- if (strlen($db->fields['note_content']) > 55)
+ if (strlen($args['note_content']) > 55)
{
- $content_title =
substr($db->fields['note_content'],0,55) . ' ...';
+ $content_title =
substr($args['note_content'],0,51) . ' ...';
}
else
{
- $content_title = $db->fields['note_content'];
+ $content_title = $args['note_content'];
}
- return array
- (
- 'id' => $db->fields['note_id'],
+ return array(
+
+ 'id' => $args['note_id'],
// FIXME: Need to create a function to handle
displaying loginids in the proper format.
// Based on preference and the system settings
- 'dm_type' => $db->fields['note_dm_type'],
- 'owner' =>
$GLOBALS['phpgw']->accounts->cross_reference((int)$db->fields['note_owner']),
- 'owner_id' => $db->fields['note_owner'],
- 'category' =>
$this->_temp_cat($db->fields['note_category']),
- 'category_id' => $db->fields['note_category'],
- 'content' => $db->fields['note_content'],
+ 'owner' =>
$GLOBALS['phpgw']->accounts->cross_reference((int)$args['note_owner']),
+ 'owner_id' => $args['note_owner'],
+ 'access' => $args['note_access'],
+ 'category' =>
$this->_temp_cat($args['note_category']),
+ 'category_id' => $args['note_category'],
+ 'content' =>
$args['note_content'],
'content_title' => $content_title,
- 'created' =>
execMethod('api.history._record_creation_date','notes.base.' .
$db->fields['note_id']),
- 'modified' =>
execMethod('api.history._record_modified_date','notes.base.' .
$db->fields['note_id'])
+ 'created' =>
execMethod('api.history._record_creation_date','notes.base.' .
$args['note_id']),
+ 'modified' =>
execMethod('api.history._record_modified_date','notes.base.' . $args['note_id'])
);
}
function start()
{
- $args = new safe_args();
- $args->set('start',0,'number');
- $args->set('search',NOTSET,'any');
- $args->set('sort','desc','any');
- $args->set('order','note_created','string');
+ $args = new safe_args();
+ $args->set('start' ,0
,'number');
+ $args->set('search' ,NOTSET ,'any');
+ $args->set('sort' ,'desc' ,'any');
+ $args->set('order' ,'note_created' ,'string');
$args = $args->get(func_get_args());
- $result['action_type'] = 'note_start';
- $result['notes'] = array();
-
- if
($GLOBALS['phpgw']->acl->check('notes.base.edit',1,1))
- {
- $result['edit_allowed'] = true;
- }
+ $result = array(
+ 'action_type' => 'note_start',
+ 'notes' => array(),
+ 'edit_allowed' =>
$GLOBALS['phpgw']->acl->check('notes.base.edit',1,1),
+ 'delete_allowed' =>
$GLOBALS['phpgw']->acl->check('notes.base.delete',1,1)
+ );
- if
($GLOBALS['phpgw']->acl->check('notes.base.delete',1,1))
+ $sql = 'SELECT * '
+ . ' FROM phpgw_notes'
+ . ' WHERE note_owner=' .
$GLOBALS['phpgw']->db->qstr($GLOBALS['phpgw_data']['user']['id'])
+ . ' AND note_dm_type=' .
$GLOBALS['phpgw']->db->qstr('N')
+ . ' ORDER BY ' . $args['order'] . ' ' .
$args['sort'];
+ if (!is_object($rs =
$GLOBALS['phpgw']->db->execute($sql)))
{
- $result['delete_allowed'] = true;
+ return $result;
}
- $db = $GLOBALS['phpgw']->db->execute("SELECT * FROM
phpgw_notes WHERE note_owner="
- . $GLOBALS['phpgw_data']['user']['id'] . " AND
note_dm_type in ('N','S') order by "
- . $args['order'] . " " . $args['sort']);
-
- while (! $db->EOF)
+ while ($row = $rs->FetchRow())
{
- $result['notes'][] = $this->__get_record(&$db);
-
- $db->MoveNext();
+ $result['notes'][] = $this->__get_record($row);
}
return $result;
}
// FIXME: When the note_content is one *really* large string,
it totally screaws up the display
- // Create a way to split oversized strings so they wrap
- function view()
- {
+ // Create a way to split oversized strings so they wrap
+ function view()
+ {
$args = new safe_args();
- $args->set('note_id',REQUIRED,'number');
+ $args->set('note_id',REQUIRED,'number');
$args = $args->get(func_get_args());
- $result['action_type'] = 'note_view';
- $note = $this->_read($args['note_id']);
-
- if (! $GLOBALS['phpgw']->acl->check('notes.' .
$args['note_id'],PHPGW_ACL_READ))
+ if (!$GLOBALS['phpgw']->acl->check('notes.' .
$args['note_id'],PHPGW_ACL_READ))
{
$GLOBALS['phpgw']->interface->access_denied('this record');
return array();
}
- else if (! is_array($note))
+
+ $result = array(
+ 'action_type' => 'note_view'
+ );
+
+ $note = $this->_read($args['note_id'],'N');
+ if (!is_array($note))
{
$GLOBALS['msgbox']->add(lang('Record not
found'),'notice');
return array();
}
- else
- {
- $GLOBALS['phpgw']->add_appmenu('Notes
menu','Edit note','notes.base.edit¬e_id=' . $args['note_id']);
- $GLOBALS['phpgw']->add_appmenu('Notes
menu','Delete note','notes.base.delete¬e_id=' . $args['note_id']);
- $result['note'] = $note;
- $obj =
createObject('api_history');
- $obj->field_desc = array
- (
- 'category' => lang('Category'),
- 'content' => lang('Content')
- );
- $obj->field_execMethod['category'] =
'notes.base._temp_cat';
- $result['history_data'] =
$obj->get('notes.base.' . $args['note_id']);
- $result['history_location'] = 'notes.base.' .
$args['note_id'];
- $result['datamine'] =
execMethod('api.datamine._get','notes.base.' . $args['note_id']);
- $result['datamine_location'] =
'notes.base.view.' . $args['note_id'];
- }
+ $GLOBALS['phpgw']->add_appmenu('Notes menu','Edit
note','notes.base.edit¬e_id=' . $args['note_id']);
+ $GLOBALS['phpgw']->add_appmenu('Notes menu','Delete
note','notes.base.delete¬e_id=' . $args['note_id']);
+
+ $result['note'] = $note;
+ $obj =
createObject('api_history');
+ $obj->field_desc = array(
+ 'category' => lang('Category'),
+ 'content' => lang('Content')
+ );
+ $obj->field_execMethod['category'] =
'notes.base._temp_cat';
+ $result['history_data'] =
$obj->get('notes.base.' . $args['note_id']);
+ $result['history_location'] = 'notes.base.' .
$args['note_id'];
+ $result['datamine'] =
execMethod('api.datamine._get','notes.base.' . $args['note_id']);
+ $result['datamine_location'] = 'notes.base.view.' .
$args['note_id'];
return $result;
- }
-
- function create()
+ }
+
+ function create()
{
$args = new safe_args();
$args->set('form_submit',array('false','true'),'enum');
@@ -232,233 +241,195 @@
$args->set('category',0,'number');
$args = $args->get(func_get_args());
- $result['note'] = array
- (
- 'content' => $args['content'],
- 'category' => $args['category'],
- 'dm_type' => $args['dm_type'],
- 'dm_redirect' => $args['dm_redirect'],
- 'datamine_location' =>
$args['datamine_location']
+ $result['note'] = array(
+ 'content' =>
$args['content'],
+ 'category' =>
$args['category'],
+ 'dm_type' =>
$args['dm_type'],
+ 'dm_redirect' => $args['dm_redirect'],
+ 'datamine_location' =>
$args['datamine_location']
);
$result['action_type'] = 'note_create';
- if ($args['form_submit'] == 'true')
+ if ($args['form_submit'] != 'true')
{
- if (! strlen($args['content']))
- {
- $result['missing_fields']['content'] =
true;
- $GLOBALS['msgbox']->add(lang('You
forgot to enter some of the required fields. The missing fields have been
marked'),'notice');
- //$GLOBALS['phpgw']->form_lock();
- }
- else
- {
- $note_id =
$GLOBALS['phpgw']->db->genid('phpgw_notes_seq');
- $GLOBALS['phpgw']->db->starttrans();
- $GLOBALS['phpgw']->db->execute("
- INSERT INTO
- phpgw_notes
- (
- note_id,
- note_owner,
- note_category,
- note_content,
- note_dm_type,
- note_modified,
- note_created,
- acl_id
- )
- VALUES
- (
- $note_id,
- '" .
$GLOBALS['phpgw_data']['user']['id'] . "',
- '" . $args['category']
. "',
- '" . $args['content'] .
"',
- '" . $args['dm_type'] .
"',
- now(),
- now(),
- -1
- )
- ");
+ $GLOBALS['phpgw']->form_lock();
+ return $result;
+ }
+
+ if (!strlen($args['content']))
+ {
+ $result['missing_fields']['content'] = true;
+ $GLOBALS['msgbox']->add(lang('You forgot to
enter some of the required fields. The missing fields have been
marked'),'notice');
+ //$GLOBALS['phpgw']->form_lock();
+ return $result;
+ }
- // If insert works, show this message
then forward them to view the new note
- if
($GLOBALS['phpgw']->db->completetrans())
- {
-
$this->__update_history($note_id,$args,array());
-
-
$GLOBALS['msgbox']->add(lang('Note has been successfully created'),'notice');
-
- if ($args['dm_type'] != 'N')
- {
- $dm_params = array
- (
- 'location_from'
=> $args['datamine_location'],
- 'location_to'
=> 'notes.base.' . $note_id,
- 'type'
=> $args['dm_type']
- );
-
execMethod('api.datamine._set',$dm_params);
- list($app,$class,$id) =
explode('.',$args['datamine_location']);
-
- return
execMethod(sprintf('%s.%s.view.%s',$app,$class,$id));
- }
- else
- {
- return
$this->view($note_id);
- }
- }
- else
- {
-
$GLOBALS['msgbox']->add(lang('There was a problem creating this
record'),'warning');
- $GLOBALS['phpgw']->form_lock();
- }
- }
+ $sql = 'SELECT * FROM phpgw_notes WHERE FALSE';
+ if (!is_object($rs =
$GLOBALS['phpgw']->db->execute($sql)))
+ {
+ trigger_error(lang('There was a problem
creating this record'),E_USER_WARNING);
+ $GLOBALS['phpgw']->form_lock();
+ return $result;
}
- else
+
+ $note = array(
+ 'note_id' =>
$GLOBALS['phpgw']->db->GenID('phpgw_notes_id'),
+ 'note_owner' =>
$GLOBALS['phpgw_data']['user']['id'],
+ 'note_category' => $args['category'],
+ 'note_content' => $args['content'],
+ 'note_dm_type' => $args['dm_type'],
+ 'note_modified' => gmtime(),
+ 'note_created' => gmtime(),
+ 'acl_id' => -1
+ );
+ $sql = $GLOBALS['phpgw']->db->GetInsertSQL($rs,$note);
+
+ // If insert works, show this message then forward them
to view the new note
+ if (!is_object($rs =
$GLOBALS['phpgw']->db->execute($sql)))
{
+ trigger_error(lang('There was a problem
creating this record'),E_USER_WARNING);
$GLOBALS['phpgw']->form_lock();
+ return $result;
}
- return $result;
+ $this->__update_history($note['note_id'],$args,array());
+
+ $GLOBALS['msgbox']->add(lang('Note has been
successfully created'),'notice');
+
+ if ($args['dm_type'] != 'N')
+ {
+ $dm_params = array(
+ 'location_from' =>
$args['datamine_location'],
+ 'location_to' => 'notes.base.' .
$note['note_id'],
+ 'type' => $args['dm_type']
+ );
+ execMethod('api.datamine._set',$dm_params);
+ list($app,$class,$id) =
explode('.',$args['datamine_location']);
+
+ return
execMethod(sprintf('%s.%s.view.%s',$app,$class,$id));
+ }
+ return $this->view($note['note_id']);
}
-
- function edit()
- {
+
+ function edit()
+ {
$args = new safe_args();
- $args->set('form_submit',array('false','true'),'enum');
+ $args->set('form_submit',array('false','true'),'enum');
$args->set('note_id',REQUIRED,'number');
$args->set('content', NOTSET, 'any');
- $args->set('category',0,'number');
+ $args->set('category',0,'number');
$args = $args->get(func_get_args());
- $result['nextop'] =
$GLOBALS['phpgw_data']['api']['nextop'];
- $result['action_type'] = 'note_edit';
- $db = $GLOBALS['phpgw']->db->execute("SELECT * from
phpgw_notes where note_id='"
- . $args['note_id'] . "'");
-
+ $result = array(
+ 'nextop' =>
$GLOBALS['phpgw_data']['api']['nextop'],
+ 'action_type' => 'note_edit'
+ );
if (! $GLOBALS['phpgw']->acl->check('notes.' .
$args['note_id'],PHPGW_ACL_READ))
{
$GLOBALS['phpgw']->interface->access_denied('this record');
return array();
}
- else if ($db->EOF)
+
+ $sql = 'SELECT * FROM phpgw_notes'
+ . ' WHERE note_id=' .
$GLOBALS['phpgw']->db->qstr($args['note_id']);
+ if (!is_object($rs =
$GLOBALS['phpgw']->db->execute($sql)) || $rs->EOF)
{
$GLOBALS['msgbox']->add(lang('Record not
found'),'notice');
return array();
}
- else
+
+ $result['note'] = $this->__get_record($rs->FetchRow());
+ if ($args['form_submit'] == 'true')
{
- $note_values = $this->__get_record(&$db);
- if ($args['form_submit'] == 'true')
- {
- $GLOBALS['phpgw']->add_appmenu('Notes
menu','Edit note','notes.base.edit¬e_id=' . $args['note_id']);
- $GLOBALS['phpgw']->add_appmenu('Notes
menu','Delete note','notes.base.delete¬e_id=' . $args['note_id']);
+ $GLOBALS['phpgw']->add_appmenu('Notes
menu','Edit note','notes.base.edit¬e_id=' . $args['note_id']);
+ $GLOBALS['phpgw']->add_appmenu('Notes
menu','Delete note','notes.base.delete¬e_id=' . $args['note_id']);
- // _update() needs 'id' since its
generic
- $args['id'] = $args['note_id'];
- if ($this->_update($args))
- {
-
//$this->__update_history($args['note_id'],$note_values,$args);
-
-
$GLOBALS['msgbox']->add(lang('Note has been successfully updated'),'notice');
- }
- else
- {
-
$GLOBALS['msgbox']->add(lang('There was a problem updating this
note'),'warning');
- }
-
- if
($GLOBALS['phpgw_data']['api']['nextop'])
- {
-// list($app,$class,$method,$id) =
explode('.',$GLOBALS['phpgw_data']['api']['nextop']);
-
-// return
execMethod(sprintf('%s.%s.%s.%s',$app,$class,$method,$id));
- return
$this->view($args['note_id']);
- }
- else
- {
- return
$this->view($args['note_id']);
- }
+ // _update() needs 'id' since its generic
+ $args['id'] = $args['note_id'];
+ if ($this->_update($args))
+ {
+
//$this->__update_history($args['note_id'],$result['note'],$args);
+ $GLOBALS['msgbox']->add(lang('Note has
been successfully updated'),'notice');
}
else
{
- $result['note'] = $note_values;
+ $GLOBALS['msgbox']->add(lang('There was
a problem updating this note'),'warning');
}
+
+ return $this->view($args['note_id']);
}
+
+ return $result;
+ }
- return $result;
- }
-
- function delete()
+ function delete()
{
- $args = new safe_args();
+ $args = new safe_args();
$args->set('note_id',REQUIRED,'number');
- $args->set('answer',NOVAR,'any');
- $args = $args->get(func_get_args());
+ $args->set('answer',NOTSET,'any');
+ $args = $args->get(func_get_args());
+
+ $result= array();
- if (! $GLOBALS['phpgw']->acl->check('notes.' .
$args['note_id'],PHPGW_ACL_DELETE))
+ if (!$GLOBALS['phpgw']->acl->check('notes.' .
$args['note_id'],PHPGW_ACL_DELETE))
{
$GLOBALS['phpgw']->interface->access_denied('this record');
- return array();
+ return $result;
}
- if ($args['answer'] == NOVAR)
+ if (!isset($args['answer']))
{
$note = $this->_read($args['note_id']);
- if (! is_array($note))
+ if (!is_array($note))
{
$GLOBALS['msgbox']->add(lang('Record
not found'),'notice');
- return array();
+ return $result;
}
+
$result['note'] = $note;
-
$result['dialog'] = array(
- 'question' => lang('Are you sure you
want to delete this note ?'),
- 'yes_op' => 'notes.base.delete',
- 'no_op' => 'api.statecache.cancel',
- 'current_inputs' => array(
+ 'question' =>
lang('Are you sure you want to delete this note ?'),
+ 'yes_op' =>
'notes.base.delete',
+ 'no_op' =>
'api.statecache.cancel',
+ 'current_inputs' => array(
0 => array(
- 'name' => 'note_id',
- 'value' =>
$args['note_id']
+ 'name' => 'note_id',
+ 'value' =>
$args['note_id']
)
)
);
$result['action_type'] = 'note_delete';
}
- else if ($args['answer'] == 'Yes')
+ elseif ($args['answer'] == 'Yes')
{
- $db = $GLOBALS['phpgw']->db->execute("DELETE
FROM phpgw_notes WHERE note_id='"
- . $args['note_id'] . "'");
+ $sql = 'DELETE FROM phpgw_notes'
+ . ' WHERE note_id=' .
$GLOBALS['phpgw']->db->qstr($args['note_id']);
+ $rs = $GLOBALS['phpgw']->db->execute($sql);
if ($GLOBALS['phpgw']->db->affected_rows())
{
execMethod('api.history.clear','notes.base.' . $args['note_id']);
-
execMethod('api.datamine._delete','notes.base.' . $args['note_id']);
$GLOBALS['msgbox']->add(lang('Note has
been deleted successfully'),'notice');
-
return $this->start();
}
- else
- {
- $GLOBALS['msgbox']->add(lang('There was
a problem deleting this note'),'warning');
-
- return $this->view($args['note_id']);
- }
+
+ $GLOBALS['msgbox']->add(lang('There was a
problem deleting this note'),'warning');
+ return $this->view($args['note_id']);
}
-
return $result;
- }
+ }
function __update_history($note_id,$_old_values,$_new_values)
{
// args
- $history_data = array
- (
+ $history_data = array(
'category' => ($_new_values['category'] == '-'
? '0' : $_new_values['category']),
'content' => $_new_values['content']
);
// note_values
- $old_values = array
- (
+ $old_values = array(
'category' => ($_old_values['category'] == '-'
? '0' : $_old_values['category']),
'content' => $_old_values['content']
);
@@ -469,76 +440,64 @@
function _update()
{
- $args = new safe_args();
+ $args = new safe_args();
$args->set('id',REQUIRED,'number');
$args->set('content',NOTSET,'string');
- $args->set('category',NOTSET,'number');
+ $args->set('category',NOTSET,'number');
$args = $args->get(func_get_args());
$old_values = $this->_read($args['id']);
- $dbresult = $GLOBALS['phpgw']->db->execute("
- UPDATE
- phpgw_notes
- SET
- note_content='" .
$args['content'] . "',
- note_category='" .
$args['category'] . "'
- WHERE
- note_id=" . $args['id']);
- $update_result = $GLOBALS['phpgw']->db->affected_rows();
-
- $this->__update_history($args['id'],$old_values,$args);
-
- return ($update_result ? True : False);
+ $sql = 'UPDATE phpgw_notes'
+ . ' SET note_content=' .
$GLOBALS['phpgw']->db->qstr($args['content'])
+ . ', note_category=' .
$GLOBALS['phpgw']->db->qstr($args['category'])
+ . ' WHERE note_id=' .
$GLOBALS['phpgw']->db->qstr($args['id']);
+ $rs = $GLOBALS['phpgw']->db->execute($sql);
+ if ($GLOBALS['phpgw']->db->affected_rows() == 1)
+ {
+
$this->__update_history($args['id'],$old_values,$args);
+ return true;
+ }
+ return false;
}
function _read()
{
$args = new safe_args();
- $args->set('note_id',REQUIRED,'number');
+ $args->set('note_id',REQUIRED,'number');
$args = $args->get(func_get_args());
- $dbresult = $GLOBALS['phpgw']->db->execute("
- SELECT
- *
- FROM
- phpgw_notes
- WHERE
- note_id='" . $args['note_id'] . "'
- AND
- note_owner='" .
$GLOBALS['phpgw_data']['user']['id'] . "'");
-
- if (! $dbresult->_numOfRows)
+ $sql = 'SELECT *'
+ . ' FROM phpgw_notes'
+ . ' WHERE note_id=' .
$GLOBALS['phpgw']->db->qstr($args['note_id'])
+ //. ' AND note_dm_type=' .
$GLOBALS['phpgw']->db->qstr($args['note_dm_type'])
+ . ' AND note_owner=' .
$GLOBALS['phpgw']->db->qstr($GLOBALS['phpgw_data']['user']['id']);
+ if (!is_object($rs =
$GLOBALS['phpgw']->db->execute($sql)) || $rs->EOF)
{
return false;
}
- else
- {
- return $this->__get_record(&$dbresult);
- }
+ return $this->__get_record($rs->FetchRow());
}
function _datamine_get()
{
- $args = new safe_args();
- $args->set('note_id',REQUIRED,'number');
+ $args = new safe_args();
+ $args->set('note_id',REQUIRED,'number');
$args = $args->get(func_get_args());
$GLOBALS['phpgw']->add_xsl('notes.widgets');
// FIXME: This needs ACL check
- $dbresult = $GLOBALS['phpgw']->db->execute("
- SELECT
- *
- FROM
- phpgw_notes
- WHERE
- note_id='" . $args['note_id'] . "'
- AND
- note_dm_type in ('S','H')");
-
+ $sql = 'SELECT *'
+ . ' FROM phpgw_notes'
+ . ' WHERE note_id=' .
$GLOBALS['phpgw']->db->qstr($args['note_id'])
+ . ' AND note_dm_type IN (\'S\',\'H\')';
+ if (!is_object($rs =
$GLOBALS['phpgw']->db->execute($sql)) || $rs->EOF)
+ {
+ return false;
+ }
//return $this->_read($args['note_id']);
- return $this->__get_record(&$dbresult);
+ return $this->__get_record($rs->FetchRow());
}
- }
-
+ }
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] notes/class.base.php, 1.1.2.17,
nomail <=