[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] notes/class.base.php, 1.1.2.5
From: |
nomail |
Subject: |
[Phpgroupware-cvs] notes/class.base.php, 1.1.2.5 |
Date: |
Thu, 20 May 2004 20:28:06 -0000 |
Update of /notes
Modified Files:
Branch: proposal-branch
class.base.php
date: 2004/04/18 08:05:27; author: jengo; state: Exp; lines: +46 -39
Log Message:
Added in support for history rollbacks on an item, in order for an app to
support this there are some strict guidelines
=====================================================================
No syntax errors detected in -
=====================================================================
Index: notes/class.base.php
diff -u notes/class.base.php:1.1.2.4 notes/class.base.php:1.1.2.5
--- notes/class.base.php:1.1.2.4 Sun Apr 18 04:50:01 2004
+++ notes/class.base.php Sun Apr 18 08:05:27 2004
@@ -185,7 +185,7 @@
// Create a way to split oversized strings so they wrap
function view()
{
- $args = new safe_args();
+ $args = new safe_args();
$args->set('note_id',REQUIRED,'number');
$args = $args->get(func_get_args());
@@ -276,15 +276,8 @@
// If insert works, show this message
then forward them to view the new note
if ($note_id)
{
- $history_data = array
- (
- 'access' =>
$args['access'],
- 'category' =>
$args['category'],
- 'content' =>
$args['content']
- );
+
$this->__update_history($note_id,$args,array());
- $obj =
createObject('api_history');
- $obj->set('notes.base.' .
$note_id,$history_data,array());
$GLOBALS['msgbox']->add(lang('Note has been successfully created'),'notice');
if ($args['dm_type'] == 'D')
@@ -310,7 +303,7 @@
}
return $result;
- }
+ }
function edit()
{
@@ -344,30 +337,11 @@
$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))
{
- $old_values = array
- (
- 'access' =>
$note_values['access'],
- 'category' =>
($note_values['category'] == '-' ? '0' : $note_values['category']),
- 'content' =>
$note_values['content']
- );
-
- $history_data = array
- (
- 'access' =>
$args['access'],
- 'category' =>
$args['category'],
- 'content' =>
$args['content']
- );
-
- $obj =
createObject('api_history');
- $obj->field_desc = array
- (
- 'access' =>
lang('Access'),
- 'category' =>
lang('Category'),
- 'content' =>
lang('Content')
- );
- $obj->set('notes.base.' .
$args['note_id'],$history_data,$old_values);
+
//$this->__update_history($args['note_id'],$note_values,$args);
$GLOBALS['msgbox']->add(lang('Note has been successfully updated'),'notice');
}
@@ -433,7 +407,7 @@
if ($GLOBALS['phpgw']->db->affected_rows())
{
- execMethod('api.history.clear','notes.'
. $args['note_id']);
+
execMethod('api.history.clear','notes.base.' . $args['note_id']);
$GLOBALS['msgbox']->add(lang('Note has
been deleted successfully'),'notice');
return $this->start();
@@ -449,16 +423,39 @@
return $result;
}
+ function __update_history($note_id,$_old_values,$_new_values)
+ {
+ // args
+ $history_data = array
+ (
+ 'access' => $_new_values['access'],
+ 'category' => ($_new_values['category'] == '-'
? '0' : $_new_values['category']),
+ 'content' => $_new_values['content']
+ );
+
+ // note_values
+ $old_values = array
+ (
+ 'access' => $_old_values['access'],
+ 'category' => ($_old_values['category'] == '-'
? '0' : $_old_values['category']),
+ 'content' => $_old_values['content']
+ );
+
+ $obj = createObject('api_history');
+ return $obj->set('notes.base.' .
$note_id,$history_data,$old_values);
+ }
+
function _update()
{
$args = new safe_args();
- $args->set('note_id',REQUIRED,'number');
+ $args->set('id',REQUIRED,'number');
$args->set('access',NOTSET,'string');
$args->set('content',NOTSET,'string');
$args->set('category',NOTSET,'number');
$args = $args->get(func_get_args());
- $dbresult = $GLOBALS['phpgw']->db->execute("
+ $old_values = $this->_read($args['id']);
+ $dbresult = $GLOBALS['phpgw']->db->execute("
UPDATE
phpgw_notes
SET
@@ -466,9 +463,12 @@
note_access='" .
$args['access'] . "',
note_category='" .
$args['category'] . "'
WHERE
- note_id=" . $args['note_id']);
+ note_id=" . $args['id']);
+ $update_result = $GLOBALS['phpgw']->db->affected_rows();
+
+ $this->__update_history($args['id'],$old_values,$args);
- return ($GLOBALS['phpgw']->db->affected_rows() ? True :
False);
+ return ($update_result ? True : False);
}
function _read()
@@ -480,7 +480,14 @@
$dbresult = $GLOBALS['phpgw']->db->execute("SELECT *
FROM phpgw_notes WHERE note_id='"
. $args['note_id'] . "'");
- return $this->__get_record(&$dbresult);
+ if (! $dbresult->_numOfRows)
+ {
+ return false;
+ }
+ else
+ {
+ return $this->__get_record(&$dbresult);
+ }
}
function _datamine_get()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] notes/class.base.php, 1.1.2.5,
nomail <=