[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] notes/inc class.bonotes.inc.php class.ipc_notes...
From: |
Johan Gunnarsson |
Subject: |
[Phpgroupware-cvs] notes/inc class.bonotes.inc.php class.ipc_notes... |
Date: |
Wed, 18 Jul 2007 14:54:35 +0000 |
CVSROOT: /sources/phpgroupware
Module name: notes
Changes by: Johan Gunnarsson <johang> 07/07/18 14:54:35
Modified files:
inc : class.bonotes.inc.php class.ipc_notes.inc.php
class.sonotes.inc.php class.uinotes.inc.php
Log message:
* patch #6102: various fixes in {ipc_, so, bo}notes
* patch #6101: fix for a bunch of notice errors in uinotes
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/notes/inc/class.bonotes.inc.php?cvsroot=phpgroupware&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/notes/inc/class.ipc_notes.inc.php?cvsroot=phpgroupware&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/notes/inc/class.sonotes.inc.php?cvsroot=phpgroupware&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/notes/inc/class.uinotes.inc.php?cvsroot=phpgroupware&r1=1.40&r2=1.41
Patches:
Index: class.bonotes.inc.php
===================================================================
RCS file: /sources/phpgroupware/notes/inc/class.bonotes.inc.php,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- class.bonotes.inc.php 18 Feb 2007 21:03:14 -0000 1.27
+++ class.bonotes.inc.php 18 Jul 2007 14:54:35 -0000 1.28
@@ -6,7 +6,7 @@
* @copyright Copyright (C) 2000-2003,2005 Free Software Foundation,
Inc. http://www.fsf.org/
* @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
* @package notes
- * @version $Id: class.bonotes.inc.php,v 1.27 2007/02/18 21:03:14 Caeies
Exp $
+ * @version $Id: class.bonotes.inc.php,v 1.28 2007/07/18 14:54:35 johang
Exp $
*/
@@ -232,7 +232,7 @@
function save($note)
{
- if ($note['access'])
+ if (isset($note['access']) && $note['access'])
{
$note['access'] = 'private';
}
@@ -241,10 +241,9 @@
$note['access'] = 'public';
}
- if (intval($note['note_id']) > 0)
+ if (isset($note['note_id']) && intval($note['note_id'])
&& $this->sonotes->edit($note))
{
$note_id = $note['note_id'];
- $this->sonotes->edit($note);
}
else
{
@@ -257,11 +256,11 @@
{
if (is_array($params))
{
- $this->sonotes->delete($params[0]);
+ return $this->sonotes->delete($params[0]);
}
else
{
- $this->sonotes->delete($params);
+ return $this->sonotes->delete($params);
}
}
Index: class.ipc_notes.inc.php
===================================================================
RCS file: /sources/phpgroupware/notes/inc/class.ipc_notes.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- class.ipc_notes.inc.php 28 Apr 2005 18:33:52 -0000 1.2
+++ class.ipc_notes.inc.php 18 Jul 2007 14:54:35 -0000 1.3
@@ -3,11 +3,12 @@
* Notes IPC Layer
*
* @author Dirk Schaller <address@hidden>
+ * @author Johan Gunnarsson <address@hidden>
* @copyright Copyright (C) 2003,2005 Free Software Foundation
http://www.fsf.org/
* @license http://www.fsf.org/licenses/gpl.html GNU General Public License
* @package notes
* @subpackage ipc
- * @version $Id: class.ipc_notes.inc.php,v 1.2 2005/04/28 18:33:52 powerstat
Exp $
+ * @version $Id: class.ipc_notes.inc.php,v 1.3 2007/07/18 14:54:35 johang Exp $
*/
// require_once(PHPGW_API_INC . 'class.ipc_.inc.php');
@@ -95,6 +96,28 @@
return $this->bonotes->exportData($dataIntern, $type);
}
+ /**
+ * Return a list with the available id's in the application.
+ * The optional lastmod parameter allows a limitations of the data id
list.
+ * The list contains all the id's of the modified data since the passed
lastmod timestamp.
+ *
+ * @abstract
+ * @param integer $lastmod last modification time, default is -1 and
means return all data id's
+ * @return array list of data id's
+ */
+ function getIdList($time=-1)
+ {
+ $all_notes = $this->bonotes->read();
+ $note_count = count($all_notes);
+ $all_note_ids = array();
+
+ for($i = 0; $i < $note_count; $i++)
+ {
+ $all_note_ids[] = intval($all_notes[$i]['note_id']);
+ }
+
+ return $all_note_ids;
+ }
/**
* Remove data of the passed id.
@@ -104,16 +127,7 @@
*/
function removeData($id)
{
- $this->bonotes->delete($id);
- // return status workaround: delete() : void --> check if sql
error
- if ($GLOBALS['phpgw']->db->Error)
- {
- return false;
- }
- else
- {
- return true;
- }
+ return $this->bonotes->delete($id);
}
/**
@@ -133,19 +147,12 @@
return false;
}
- $dataIntern['id'] = (int) $id;
+ $dataIntern['note_id'] = intval($id);
// 2: replace data
- $this->bonotes->save($dataIntern);
- // return status workaround: save() : void --> check if sql
error
- if ($GLOBALS['phpgw']->db->Error)
- {
- return false;
- }
- else
- {
- return true;
- }
+ $note_id = $this->bonotes->save($dataIntern);
+
+ return $note_id == $id;
}
@@ -157,24 +164,7 @@
*/
function existData($id)
{
- // I don't know what we need to check? You want to check for a
note with identically content? (ceb)
- // workaround: sonotes doesn't support a method for check
- // --> sql query
- $sql = "SELECT * FROM phpgw_notes WHERE note_id=".intval($id);
- $this->so->db->query($sql,__LINE__,__FILE__);
- if ($GLOBALS['phpgw']->db->Error)
- {
- return false;
- }
-
- if ($this->so->db->num_rows() == 1)
- {
- return true;
- }
- else
- {
- return false;
- }
+ return !is_null($this->bonotes->read_single($id));
}
}
?>
Index: class.sonotes.inc.php
===================================================================
RCS file: /sources/phpgroupware/notes/inc/class.sonotes.inc.php,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- class.sonotes.inc.php 18 Feb 2007 21:03:14 -0000 1.16
+++ class.sonotes.inc.php 18 Jul 2007 14:54:35 -0000 1.17
@@ -6,10 +6,9 @@
* @copyright Copyright (C) 2000-2003,2005 Free Software Foundation,
Inc. http://www.fsf.org/
* @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
* @package notes
- * @version $Id: class.sonotes.inc.php,v 1.16 2007/02/18 21:03:14 Caeies
Exp $
+ * @version $Id: class.sonotes.inc.php,v 1.17 2007/07/18 14:54:35 johang
Exp $
*/
-
/**
* Notes storage object class
*
@@ -19,13 +18,11 @@
{
var $grants;
var $db;
- var $db2;
var $account;
function sonotes()
{
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = clone($this->db);
+ $this->db = &$GLOBALS['phpgw']->db;
$this->grants =
$GLOBALS['phpgw']->acl->get_grants('notes');
$this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
}
@@ -150,7 +147,7 @@
$this->db->query('INSERT INTO phpgw_notes
(note_owner,note_access,note_date,note_content,note_category) '
. 'VALUES (' . $this->account . ",'" .
$note['access'] . "'," . time() . ",'" . $note['content']
- . "'," . intval($note['cat_id']) .
')',__LINE__,__FILE__);
+ . "'," . (isset($note['cat_id']) ?
intval($note['cat_id']) : 0) . ')',__LINE__,__FILE__);
return
$this->db->get_last_insert_id('phpgw_notes','note_id');
}
@@ -159,12 +156,16 @@
$note['content'] =
$this->db->db_addslashes($note['content']);
$this->db->query("UPDATE phpgw_notes set
note_content='" . $note['content'] . "', note_date=" . time() . ',
note_category='
- .
intval($note['cat_id']) . ", note_access='" . $note['access'] . "' WHERE
note_id=" . intval($note['note_id']),__LINE__,__FILE__);
+ .
(isset($note['cat_id']) ? intval($note['cat_id']) : 0) . ", note_access='" .
$note['access'] . "' WHERE note_id=" .
intval($note['note_id']),__LINE__,__FILE__);
+
+ return $this->db->affected_rows();
}
function delete($note_id)
{
$this->db->query('DELETE FROM phpgw_notes WHERE
note_id=' . intval($note_id),__LINE__,__FILE__);
+
+ return $this->db->affected_rows() > 0;
}
}
?>
Index: class.uinotes.inc.php
===================================================================
RCS file: /sources/phpgroupware/notes/inc/class.uinotes.inc.php,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- class.uinotes.inc.php 18 Feb 2007 21:03:14 -0000 1.40
+++ class.uinotes.inc.php 18 Jul 2007 14:54:35 -0000 1.41
@@ -6,7 +6,7 @@
* @copyright Copyright (C) 2000-2003,2005 Free Software Foundation,
Inc. http://www.fsf.org/
* @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
* @package notes
- * @version $Id: class.uinotes.inc.php,v 1.40 2007/02/18 21:03:14 Caeies
Exp $
+ * @version $Id: class.uinotes.inc.php,v 1.41 2007/07/18 14:54:35 johang
Exp $
*/
/**
@@ -85,8 +85,8 @@
$content = array();
while (is_array($notes_list) && list(,$note) =
each($notes_list))
{
- $words = split(' ',$note['content']);
- $first = "$words[0] $words[1] $words[2]
$words[3] .....";
+ $words = explode(' ', $note['content'], 4);
+ $first = implode(' ', array_slice($words, 0,
3)) . ' ... ';
$content[] = array
(
@@ -94,9 +94,18 @@
'first'
=> $first,
'date'
=> $note['date'],
'owner'
=> $note['owner'],
- 'link_view'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction=notes.uinotes.view¬e_id=' .
$note['note_id']),
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction=notes.uinotes.edit¬e_id=' .
$note['note_id']),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction=notes.uinotes.delete¬e_id='
. $note['note_id']),
+ 'link_view'
=> $GLOBALS['phpgw']->link(
+ '/index.php', array(
+ 'menuaction' =>
'notes.uinotes.view',
+ 'note_id' =>
$note['note_id'])),
+ 'link_edit'
=> $GLOBALS['phpgw']->link(
+ '/index.php', array(
+ 'menuaction' =>
'notes.uinotes.edit',
+ 'note_id' =>
$note['note_id'])),
+ 'link_delete'
=> $GLOBALS['phpgw']->link(
+ '/index.php', array(
+ 'menuaction' =>
'notes.uinotes.delete',
+ 'note_id' =>
$note['note_id'])),
'lang_view_statustext' =>
lang('view the note'),
'lang_edit_statustext' =>
lang('edit the note'),
'lang_delete_statustext' =>
lang('delete the note'),
@@ -169,14 +178,14 @@
if (is_array($values))
{
- if ($values['save'])
+ if (isset($values['save']) && $values['save'])
{
$values['note_id'] = $note_id;
$note_id =
$this->bonotes->save($values);
$this->cat_id =
($values['cat_id']?$values['cat_id']:$this->cat_id);
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'notes.uinotes.index'));
}
- elseif($values['cancel'])
+ elseif(isset($values['cancel']) &&
$values['cancel'])
{
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'notes.uinotes.index'));
}
@@ -204,7 +213,7 @@
$data = array
(
- 'msgbox_data'
=> (($action=='apply')?$GLOBALS['phpgw']->common->msgbox('note has been
saved',True):''),
+ 'msgbox_data'
=> ((isset($action) &&
$action=='apply')?$GLOBALS['phpgw']->common->msgbox('note has been
saved',True):''),
'edit_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
'lang_content'
=> lang('content'),
'lang_category'
=> lang('category'),
@@ -212,8 +221,8 @@
'lang_save'
=> lang('save'),
'lang_cancel'
=> lang('cancel'),
'lang_apply'
=> lang('apply'),
- 'value_content'
=> $note['content'],
- 'value_access'
=> $note['access'],
+ 'value_content'
=> isset($note['content']) ? $note['content'] : '',
+ 'value_access'
=> isset($note['access']) ? $note['access'] : '',
'lang_content_statustext' =>
lang('Enter the content of the note'),
'lang_apply_statustext' =>
lang('Apply the values'),
'lang_cancel_statustext' =>
lang('Leave the note untouched and return back to the list'),
@@ -221,7 +230,7 @@
'lang_access_off_statustext' => lang('The
note is public. If the note should be private, check this box'),
'lang_access_on_statustext' =>
lang('The note is private. If the note should be public, uncheck this box'),
'lang_no_cat'
=> lang('no category'),
- 'cat_select'
=> $this->cats->formatted_xslt_list(array('select_name' =>
'values[cat_id]','selected' => $note['cat_id']))
+ 'cat_select'
=> $this->cats->formatted_xslt_list(array('select_name' =>
'values[cat_id]','selected' => isset($note['cat_id']) ? $note['cat_id'] : ''))
);
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
}
@@ -237,13 +246,13 @@
'menuaction' => 'notes.uinotes.index'
);
- if ($_POST['delete'])
+ if ($delete)
{
$this->bonotes->delete($note_id);
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
}
- if ($_POST['cancel'])
+ if ($cancel)
{
$GLOBALS['phpgw']->redirect_link('/index.php',$link_data);
}
@@ -254,7 +263,10 @@
$data = array
(
- 'delete_url' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=notes.uinotes.delete¬e_id='
. $note_id),
+ 'delete_url' =>
$GLOBALS['phpgw']->link(
+ '/index.php', array(
+ 'menuaction' =>
'notes.uinotes.delete',
+ 'note_id' => $note_id)),
'lang_confirm_msg' =>
lang('do you really want to delete this note ?'),
'lang_delete' =>
lang('delete'),
'lang_delete_statustext' => lang('Delete
the note'),
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] notes/inc class.bonotes.inc.php class.ipc_notes...,
Johan Gunnarsson <=