[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] CVS: bookmarks/inc class.bo.inc.php,1.4,1.5 class.so.
From: |
Michael Totschnig <address@hidden> |
Subject: |
[Phpgroupware-cvs] CVS: bookmarks/inc class.bo.inc.php,1.4,1.5 class.so.inc.php,1.3,1.4 class.ui.inc.php,1.7,1.8 |
Date: |
Fri, 16 May 2003 16:57:48 -0400 |
Update of /cvsroot/phpgroupware/bookmarks/inc
In directory subversions:/tmp/cvs-serv14108
Modified Files:
class.bo.inc.php class.so.inc.php class.ui.inc.php
Log Message:
improve error handling
go to view after creating or editing (resolves magic quote bug)
Index: class.bo.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/bookmarks/inc/class.bo.inc.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** class.bo.inc.php 8 Apr 2003 21:58:12 -0000 1.4
--- class.bo.inc.php 16 May 2003 20:57:45 -0000 1.5
***************
*** 27,30 ****
--- 27,32 ----
var $type;
var $expanded;
+ var $error_msg;
+ var $msg;
function bo()
***************
*** 37,41 ****
$GLOBALS['phpgw']->config->read_repository();
$this->config =
$GLOBALS['phpgw']->config->config_data;
! $this->url_format_check = 2;
$this->validate = createobject('phpgwapi.validator');
}
--- 39,43 ----
$GLOBALS['phpgw']->config->read_repository();
$this->config =
$GLOBALS['phpgw']->config->config_data;
! $this->url_format_check = True;
$this->validate = createobject('phpgwapi.validator');
}
***************
*** 159,166 ****
function add($values)
{
-
if ($this->validate($values))
{
! return $this->so->add($values);
}
else
--- 161,177 ----
function add($values)
{
if ($this->validate($values))
{
! if ($this->so->exists($values['url']))
! {
! $this->error_msg .= sprintf('<br>URL
<B>%s</B> already exists!', $values['url']);
! return False;
! }
! $bm_id = $this->so->add($values);
! if ($bm_id)
! {
! $this->msg .= lang('Bookmark created
successfully.');
! return $bm_id;
! }
}
else
***************
*** 174,178 ****
if ($this->validate($values) &&
$this->check_perms($id,PHPGW_ACL_EDIT))
{
! return $this->so->update($id,$values);
}
else
--- 185,193 ----
if ($this->validate($values) &&
$this->check_perms($id,PHPGW_ACL_EDIT))
{
! if ($this->so->update($id,$values))
! {
! $this->msg .= lang('Bookmark changed
sucessfully');
! return True;
! }
}
else
***************
*** 186,194 ****
$this->so->updatetimestamp($id,$timestamp);
}
function delete($id)
{
if ($this->check_perms($id,PHPGW_ACL_DELETE))
{
! return $this->so->delete($id);
}
else
--- 201,214 ----
$this->so->updatetimestamp($id,$timestamp);
}
+
function delete($id)
{
if ($this->check_perms($id,PHPGW_ACL_DELETE))
{
! if ($this->so->delete($id))
! {
! $this->msg .= "Bookmark deleted
sucessfully.";
! return True;
! }
}
else
***************
*** 198,253 ****
}
! function validate ($values)
{
! global $error_msg, $msg;
!
! $error_msg = '';
! // Do we have all necessary data?
! if (! $values['url'] || $values['url'] == 'http://')
{
! $error_msg .= '<br>URL is required.';
}
! if (! $values['name'])
{
! $error_msg .= '<br>' . lang('Name is required');
! }
// does the admin want us to check URL format
! if ($this->url_format_check > 0)
{
! // Is the URL format valid
! if ($values['url'] == 'http://')
{
! $error_msg .= '<br>You must enter a
URL';
}
- else
- {
- if (!
$this->validate->is_url($values['url']))
- {
- $format_msg = '<br>URL invalid.
Format must be <strong>http://</strong> or
- <strong>ftp://</strong> followed by a valid
hostname and
- URL!<br><small>' . $this->validate->ERROR
. '</small>';
-
- // does the admin want this
formatted as a warning or an error?
- if ($this->url_format_check ==
2)
- {
- $error_msg .=
$format_msg;
- }
- else
- {
- $msg .= $format_msg;
- }
- }
- }
- }
- if ($error_msg)
- {
- return False;
- }
- else
- {
- return True;
}
}
--- 218,253 ----
}
! function validate($values)
{
! $result = True;
! if (! $values['name'])
{
! $this->error_msg .= '<br>' . lang('Name is
required');
! $result = False;
}
! if (! $values['category'])
{
! $this->error_msg .= '<br>' . lang('You must
select a category');
! $result = False;
! }
+ if (! $values['url'] || $values['url'] == 'http://')
+ {
+ $this->error_msg .= '<br>' . lang('URL is
required.');
+ $result = False;
+ }
// does the admin want us to check URL format
! elseif ($this->url_format_check)
{
! if (! $this->validate->is_url($values['url']))
{
! $this->error_msg = '<br>URL invalid.
Format must be <strong>http://</strong> or
! <strong>ftp://</strong> followed by a valid
hostname and
! URL!<br><small>' . $this->validate->ERROR .
'</small>';
! $result = False;
}
}
+ return $result;
}
***************
*** 301,306 ****
function import($bkfile,$parent)
{
- global $error_msg,$msg;
-
$this->_debug('<p><b>DEBUG OUTPUT:</b>');
$this->_debug('<br>file_name: ' . $bkfile['name']);
--- 301,304 ----
***************
*** 314,318 ****
if (!$bkfile['name'])
{
! $error_msg .= '<br>'.lang('Netscape bookmark
filename is required!');
}
else
--- 312,316 ----
if (!$bkfile['name'])
{
! $this->error_msg .= '<br>'.lang('Netscape
bookmark filename is required!');
}
else
***************
*** 361,368 ****
$inserts++;
}
- else
- {
-
$all_errors .= $error_msg;
- }
$this->_debug(sprintf("<tr><td>%s</td> <td>%s</td> <td>%s</td> <td>%s</td>
<td>%s</td> <td>%s</td> <td>%s</td>
</tr>",$cid,$scid,$match[2],$match[1],$add_info[1],$change_info[1],$vist_info[1]));
--- 359,362 ----
***************
*** 389,398 ****
@fclose($fd);
$this->_debug('</table>');
! $msg = '<br>'.lang("%1 bookmarks
imported from %2 successfully.", $inserts, $bkfile['name']);
! $error_msg = $all_errors;
}
else
{
! $error_msg .= '<br>'.lang('Unable to
open temp file %1 for import.',$bkfile['name']);
}
}
--- 383,391 ----
@fclose($fd);
$this->_debug('</table>');
! $this->msg = '<br>'.lang("%1 bookmarks
imported from %2 successfully.", $inserts, $bkfile['name']);
}
else
{
! $this->error_msg .= '<br>'.lang('Unable
to open temp file %1 for import.',$bkfile['name']);
}
}
Index: class.so.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/bookmarks/inc/class.so.inc.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** class.so.inc.php 8 Apr 2003 21:58:12 -0000 1.3
--- class.so.inc.php 16 May 2003 20:57:45 -0000 1.4
***************
*** 101,121 ****
}
! function add($values)
{
! global $error_msg, $msg;
!
! unset($error_msg);
!
! // Does the bookmark already exist?
! $query = sprintf("select count(*) from phpgw_bookmarks
where bm_url='%s' and bm_owner='%s'",$values['url'],
$GLOBALS['phpgw_info']['user']['account_id']);
$this->db->query($query,__LINE__,__FILE__);
$this->db->next_record();
! if ($this->db->f(0) != 0)
! {
! $error_msg .= sprintf('<br>URL <B>%s</B>
already exists!', $values['url']);
! return False;
! }
if (! $values['access'])
{
--- 101,115 ----
}
! function exists($url)
{
! $query = sprintf("select count(*) from phpgw_bookmarks
where bm_url='%s' and bm_owner='%s'",$url,
$GLOBALS['phpgw_info']['user']['account_id']);
$this->db->query($query,__LINE__,__FILE__);
$this->db->next_record();
! return (bool)$this->db->f(0);
! }
+ function add($values)
+ {
if (! $values['access'])
{
***************
*** 128,137 ****
}
- if (! $values['category'])
- {
- $error_msg .= 'You must select a category';
- return False;
- }
-
$query = sprintf("insert into phpgw_bookmarks (bm_url,
bm_name, bm_desc, bm_keywords, bm_category,"
. "bm_rating, bm_owner, bm_access, bm_info,
bm_visits) "
--- 122,125 ----
***************
*** 143,148 ****
if ($this->db->query($query,__LINE__,__FILE__))
{
! $msg .= 'Bookmark created successfully.';
! return true;
}
else
--- 131,135 ----
if ($this->db->query($query,__LINE__,__FILE__))
{
! return
$this->db->get_last_insert_id('phpgw_bookmarks','bm_id');
}
else
***************
*** 154,159 ****
function update($id, $values)
{
- global $error_msg, $msg;
-
if (! $values['access'])
{
--- 141,144 ----
***************
*** 178,182 ****
if ($this->db->query($query,__LINE__,__FILE__))
{
! $msg .= lang('Bookmark changed sucessfully');
return true;
}
--- 163,167 ----
if ($this->db->query($query,__LINE__,__FILE__))
{
!
return true;
}
***************
*** 195,200 ****
function delete($id)
{
- global $error_msg, $msg;
-
$query = "delete from phpgw_bookmarks where bm_id=$id";
$this->db->query($query,__LINE__,__FILE__);
--- 180,183 ----
***************
*** 203,207 ****
return False;
}
- $msg .= "Bookmark deleted sucessfully.";
return true;
}
--- 186,189 ----
Index: class.ui.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/bookmarks/inc/class.ui.inc.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** class.ui.inc.php 6 May 2003 20:53:06 -0000 1.7
--- class.ui.inc.php 16 May 2003 20:57:45 -0000 1.8
***************
*** 109,121 ****
function app_messages()
{
! global $error_msg,$msg;
!
! if ($error_msg)
{
! $bk_output_html = '<center>' . lang('Error') .
': ' . $error_msg . '</center>';
}
! if ($msg)
{
! $bk_output_html .= '<center>' . $msg .
'</center>';
}
--- 109,119 ----
function app_messages()
{
! if ($this->bo->error_msg)
{
! $bk_output_html = '<center style="color:red">'
. lang('Error') . ': ' . $this->bo->error_msg . '</center>';
}
! if ($this->bo->msg)
{
! $bk_output_html .= '<center>' . $this->bo->msg
. '</center>';
}
***************
*** 166,170 ****
{
$bookmark =
$GLOBALS['HTTP_POST_VARS']['bookmark'];
! $this->bo->add($bookmark);
}
//if we come back from editing categories we restore
form values
--- 164,174 ----
{
$bookmark =
$GLOBALS['HTTP_POST_VARS']['bookmark'];
! $bm_id = $this->bo->add($bookmark);
! if ($bm_id)
! {
! $this->location_info['bm_id'] = $bm_id;
! $this->view();
! return;
! }
}
//if we come back from editing categories we restore
form values
***************
*** 275,283 ****
$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/index.php','menuaction=preferences.uicategories.index&cats_app=bookmarks&global_cats=True'));
}
! //save bookmark and return to view we came from
if ($GLOBALS['HTTP_POST_VARS']['save_x'] ||
$GLOBALS['HTTP_POST_VARS']['save_y'])
{
$bookmark =
$GLOBALS['HTTP_POST_VARS']['bookmark'];
! $this->bo->update($bm_id,$bookmark);
}
$bookmark = $this->bo->read($bm_id);
--- 279,292 ----
$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/index.php','menuaction=preferences.uicategories.index&cats_app=bookmarks&global_cats=True'));
}
! //save bookmark and go to view interface
if ($GLOBALS['HTTP_POST_VARS']['save_x'] ||
$GLOBALS['HTTP_POST_VARS']['save_y'])
{
$bookmark =
$GLOBALS['HTTP_POST_VARS']['bookmark'];
! if ($this->bo->update($bm_id,$bookmark))
! {
! $this->location_info['bm_id'] = $bm_id;
! $this->view();
! return;
! }
}
$bookmark = $this->bo->read($bm_id);
***************
*** 285,289 ****
if (!$bookmark[PHPGW_ACL_EDIT])
{
! $GLOBALS['error_msg'] = lang('Bookmark not
editable');
unset($this->location_info['returnto2']);
$this->init();
--- 294,298 ----
if (!$bookmark[PHPGW_ACL_EDIT])
{
! $this->bo->error_msg = lang('Bookmark not
editable');
unset($this->location_info['returnto2']);
$this->init();
***************
*** 741,746 ****
));
$this->t->set_var(Array(
! 'th_bg' =>
$GLOBALS['phpgw_info']['theme']['th_bg'],
! 'messages' => lang('Tree view')
));
--- 750,754 ----
));
$this->t->set_var(Array(
! 'th_bg' =>
$GLOBALS['phpgw_info']['theme']['th_bg']
));
***************
*** 906,910 ****
if (!$bookmark[PHPGW_ACL_READ])
{
! $GLOBALS['error_msg'] = lang('Bookmark not
readable');
unset($this->location_info['returnto2']);
$this->init();
--- 914,918 ----
if (!$bookmark[PHPGW_ACL_READ])
{
! $this->bo->error_msg = lang('Bookmark not
readable');
unset($this->location_info['returnto2']);
$this->init();
***************
*** 977,981 ****
function mail()
{
- global $error_msg, $msg;
$GLOBALS['phpgw']->common->phpgw_header();
echo parse_navbar();
--- 985,988 ----
***************
*** 1001,1005 ****
if (empty($to) || empty($subject) ||
empty($message))
{
! $error_msg .= '<br>'.lang('Please fill
out <B>To E-Mail Address</B>, <B>Subject</B>, and <B>Message</B>!');
}
else
--- 1008,1012 ----
if (empty($to) || empty($subject) ||
empty($message))
{
! $this->bo->error_msg .=
'<br>'.lang('Please fill out <B>To E-Mail Address</B>, <B>Subject</B>, and
<B>Message</B>!');
}
else
***************
*** 1014,1018 ****
if (!$validate->is_email($val))
{
! $error_msg .= '<br>' .
lang('To
address %1 invalid. Format must be <strong>address@hidden</strong> and domain
must exist!',$val).
'<br><small>'.$validate->ERROR.'</small>';
--- 1021,1025 ----
if (!$validate->is_email($val))
{
! $this->bo->error_msg .=
'<br>' .
lang('To
address %1 invalid. Format must be <strong>address@hidden</strong> and domain
must exist!',$val).
'<br><small>'.$validate->ERROR.'</small>';
***************
*** 1021,1025 ****
}
}
! if (!isset ($error_msg))
{
$send =
createobject('phpgwapi.send');
--- 1028,1032 ----
}
}
! if (!isset ($this->bo->error_msg))
{
$send =
createobject('phpgwapi.send');
***************
*** 1037,1041 ****
// send the message
$send->msg('email',$to,$subject,$message ."\n".
$this->bo->config['mail_footer'],'','','',$reply_to);
! $msg .= '<br>'.lang('mail-this-link
message sent to %1.',$to);
}
}
--- 1044,1048 ----
// send the message
$send->msg('email',$to,$subject,$message ."\n".
$this->bo->config['mail_footer'],'','','',$reply_to);
! $this->bo->msg .=
'<br>'.lang('mail-this-link message sent to %1.',$to);
}
}
***************
*** 1096,1100 ****
function mass()
{
- global $msg;
$item_cb = $GLOBALS['HTTP_POST_VARS']['item_cb'];
if ($GLOBALS['HTTP_POST_VARS']['delete_x'] ||
$GLOBALS['HTTP_POST_VARS']['delete_y'])
--- 1103,1106 ----
***************
*** 1110,1114 ****
}
}
! $msg = lang('%1 bookmarks have been
deleted',$i);
}
--- 1116,1120 ----
}
}
! $this->bo->msg = lang('%1 bookmarks
have been deleted',$i);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] CVS: bookmarks/inc class.bo.inc.php,1.4,1.5 class.so.inc.php,1.3,1.4 class.ui.inc.php,1.7,1.8,
Michael Totschnig <address@hidden> <=
- Prev by Date:
[Phpgroupware-cvs] CVS: bookmarks/inc class.bo.inc.php,1.1.2.3,1.1.2.4 class.so.inc.php,1.1.2.2,1.1.2.3 class.ui.inc.php,1.1.2.6,1.1.2.7
- Next by Date:
[Phpgroupware-cvs] CVS: inv/setup tables_update.inc.php,1.16.2.1,1.16.2.1.2.1
- Previous by thread:
[Phpgroupware-cvs] CVS: bookmarks/inc class.bo.inc.php,1.1.2.3,1.1.2.4 class.so.inc.php,1.1.2.2,1.1.2.3 class.ui.inc.php,1.1.2.6,1.1.2.7
- Next by thread:
[Phpgroupware-cvs] CVS: inv/setup tables_update.inc.php,1.16.2.1,1.16.2.1.2.1
- Index(es):