phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: addressbook/inc class.uiaddressbook.inc.php,1.49


From: Ralf Becker <address@hidden>
Subject: [Phpgroupware-cvs] CVS: addressbook/inc class.uiaddressbook.inc.php,1.49.2.1,1.49.2.2
Date: Wed, 25 Sep 2002 18:18:23 -0400

Update of /cvsroot/phpgroupware/addressbook/inc
In directory subversions:/tmp/cvs-serv16056

Modified Files:
      Tag: eTemplate
        class.uiaddressbook.inc.php 
Log Message:
get edit fully working

Index: class.uiaddressbook.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/addressbook/inc/class.uiaddressbook.inc.php,v
retrieving revision 1.49.2.1
retrieving revision 1.49.2.2
diff -C2 -r1.49.2.1 -r1.49.2.2
*** class.uiaddressbook.inc.php 25 Sep 2002 00:28:32 -0000      1.49.2.1
--- class.uiaddressbook.inc.php 25 Sep 2002 22:18:20 -0000      1.49.2.2
***************
*** 269,272 ****
--- 269,274 ----
                function index($entries='')
                {
+                       //echo "<p>uiaddressbook.index</p>\n";
+ 
                        
$GLOBALS['phpgw']->template->set_file(array('addressbook_list_t' => 
'index.tpl'));
                        
$GLOBALS['phpgw']->template->set_block('addressbook_list_t','addressbook_header','addressbook_header');
***************
*** 738,781 ****
                }
  
!               function edit()
                {
!                       if($GLOBALS['HTTP_POST_VARS']['submit'])
!                       {
!                               $_fields = $this->get_form();
!                               /* _debug_array($_fields);exit; */
!                               $check = $this->bo->read_entry(array('id' => 
$_fields['ab_id'], 'fields' => array('owner' => 'owner','tid' => 'tid')));
  
!                               if(($this->contacts->grants[$check[0]['owner']] 
& PHPGW_ACL_EDIT) &&
!                                       $check[0]['owner'] != 
$GLOBALS['phpgw_info']['user']['account_id'])
                                {
!                                       $userid = $check[0]['owner'];
                                }
!                               else
                                {
!                                       $userid = 
$GLOBALS['phpgw_info']['user']['account_id'];
!                               }
!                               $_fields['owner'] = $userid;
!                               $referer = urlencode($_fields['referer']);
!                               unset($_fields['referer']);
  
!                               $this->bo->update_entry($_fields);
!                               $GLOBALS['ab_id'] = $_fields['ab_id'];
!                               
$GLOBALS['phpgw']->hooks->process('addressbook_save');
  
!                               Header('Location: '
!                                       . 
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.view&ab_id='
 . $_fields['ab_id'] . '&referer=' . $referer)
!                               );
  
!                               $GLOBALS['phpgw']->common->phpgw_exit();
                        }
  
                        /* First, make sure they have permission to this entry 
*/
!                       $check = $this->bo->read_entry(array('id' => 
$GLOBALS['HTTP_GET_VARS']['ab_id'], 'fields' => array('owner' => 'owner','tid' 
=> 'tid')));
! 
!                       
if(!$this->contacts->check_perms($this->contacts->grants[$check[0]['owner']],PHPGW_ACL_EDIT)
 &&
!                               ($check[0]['owner'] != 
$GLOBALS['phpgw_info']['user']['account_id']))
                        {
!                               Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
!                               $GLOBALS['phpgw']->common->phpgw_exit();
                        }
  
--- 740,786 ----
                }
  
!               function edit($content='')
                {
!                       //echo "<p>uiaddressbook.edit: 
ab_id=$content[ab_id]</p>\n";
  
!                       if(is_array($content))
!                       {
!                               if ($content['delete'])
                                {
!                                       return $this->delete($content['ab_id']);
                                }
!                               if ($content['save'])
                                {
!                                       unset($content['save']);
!                                       unset($content['_tab_widget']);
  
!                                       list(,$check) = 
$this->bo->read_entry(array('id' => $content['ab_id'], 'fields' => 
array('owner' => 'owner','tid' => 'tid')));
!                                       
if(($this->contacts->grants[$check['owner']] & PHPGW_ACL_EDIT) &&
!                                               $check['owner'] != 
$GLOBALS['phpgw_info']['user']['account_id'])
!                                       {
!                                               $content['owner'] = 
$check['owner'];
!                                       }
!                                       else
!                                       {
!                                               $content['owner'] = 
$GLOBALS['phpgw_info']['user']['account_id'];
!                                       }
!                                       //$referer = 
urlencode($content['referer']);
!                                       unset($content['referer']);
  
!                                       $this->bo->update_entry($content);
  
!                                       //$GLOBALS['ab_id'] = $content['ab_id'];
!                                       
//$GLOBALS['phpgw']->hooks->process('addressbook_save');
!                               }
!                               return $this->view($content['ab_id']);
                        }
+                       $ab_id = $content > 0 ? $content : 
get_var('ab_id',array('POST','GET'));
  
                        /* First, make sure they have permission to this entry 
*/
!                       list($check) = $this->bo->read_entry(array('id' => 
$ab_id, 'fields' => array('owner' => 'owner','tid' => 'tid')));
!                       
if(!$this->contacts->check_perms($this->contacts->grants[$check['owner']],PHPGW_ACL_EDIT)
 &&
!                               ($check['owner'] != 
$GLOBALS['phpgw_info']['user']['account_id']))
                        {
!                               return $this->index();
                        }
  
***************
*** 787,834 ****
                                $customfields[$y['name']] = $y['title'];
                        }
- 
                        /* merge in extra fields */
                        $qfields = $this->contacts->stock_contact_fields + 
$this->extrafields + $customfields;
!                       $fields = $this->bo->read_entry(array('id' => 
$GLOBALS['HTTP_GET_VARS']['ab_id'], 'fields' => $qfields));
! 
!                       /*
!                       
$this->addressbook_form('edit','menuaction=addressbook.uiaddressbook.edit',lang('Edit'),$fields[0],$customfields);
! 
!                       $GLOBALS['phpgw']->template->set_file(array('edit' => 
'edit.tpl'));
! 
!                       
$GLOBALS['phpgw']->template->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']);
!                       
$GLOBALS['phpgw']->template->set_var('ab_id',$GLOBALS['HTTP_GET_VARS']['ab_id']);
!                       
$GLOBALS['phpgw']->template->set_var('tid',$check[0]['tid']);
!                       
$GLOBALS['phpgw']->template->set_var('referer',$referer);
!                       
$GLOBALS['phpgw']->template->set_var('lang_ok',lang('ok'));
!                       
$GLOBALS['phpgw']->template->set_var('lang_clear',lang('clear'));
!                       
$GLOBALS['phpgw']->template->set_var('lang_cancel',lang('cancel'));
!                       
$GLOBALS['phpgw']->template->set_var('lang_submit',lang('submit'));
!                       
$GLOBALS['phpgw']->template->set_var('cancel_link','<form method="POST" 
action="'
!                               . 
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index')
 . '">');
  
-                       if(($this->contacts->grants[$check[0]['owner']] & 
PHPGW_ACL_DELETE) ||
-                               $check[0]['owner'] == 
$GLOBALS['phpgw_info']['user']['account_id'])
-                       {
-                               
$GLOBALS['phpgw']->template->set_var('delete_link','<form method="POST" 
action="'.$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.delete')
 . '">');
-                               
$GLOBALS['phpgw']->template->set_var('delete_button','<input type="submit" 
name="delete" value="' . lang('Delete') . '">');
-                       }
- 
-                       $this->output .= 
$GLOBALS['phpgw']->template->fp('out','edit');
-                       $this->totpl();
-                       $GLOBALS['phpgw']->hooks->process('addressbook_edit');
-                       */
-                       $content = $fields[0];
                        //_debug_array($content);
                        $content['owner'] = 
$GLOBALS['phpgw']->common->grab_owner_name($content['owner']);
                        $content['access'] = $content['access'] == 'private';
!                       $no_button['delete'] = 
!($this->contacts->grants[$check[0]['owner']] & PHPGW_ACL_DELETE);
                        $etpl = 
CreateObject('etemplate.etemplate','addressbook.edit');
!                       
$etpl->exec('addressbook.uiaddressbook.edit',$content,'',$no_button,$content);
                }
  
!               function delete()
                {
!                       $ab_id = $GLOBALS['HTTP_POST_VARS']['entry']['ab_id'] ? 
$GLOBALS['HTTP_POST_VARS']['entry']['ab_id'] : 
$GLOBALS['HTTP_POST_VARS']['ab_id'];
                        $confirm = $GLOBALS['HTTP_GET_VARS']['confirm'] ? 
$GLOBALS['HTTP_GET_VARS']['confirm'] :$GLOBALS['HTTP_POST_VARS']['confirm'];
                        if(!$ab_id)
--- 792,815 ----
                                $customfields[$y['name']] = $y['title'];
                        }
                        /* merge in extra fields */
                        $qfields = $this->contacts->stock_contact_fields + 
$this->extrafields + $customfields;
!                       list($content) = $this->bo->read_entry(array('id' => 
$ab_id, 'fields' => $qfields));
  
                        //_debug_array($content);
                        $content['owner'] = 
$GLOBALS['phpgw']->common->grab_owner_name($content['owner']);
                        $content['access'] = $content['access'] == 'private';
! 
!                       $no_button['delete'] = 
!($this->contacts->grants[$check['owner']] & PHPGW_ACL_DELETE);
! 
                        $etpl = 
CreateObject('etemplate.etemplate','addressbook.edit');
!                       
$etpl->exec('addressbook.uiaddressbook.edit',$content,'',$no_button,array('ab_id'
 => $content['id']));
! 
!                       //$GLOBALS['phpgw']->hooks->process('addressbook_edit');
                }
  
!               function delete($content='')
                {
!                       $ab_id   = !is_array($content) && $content > 0 ? 
$content : get_var('ab_id',array('POST','GET'));
!                       //echo "<p>uiaddressbook.delete: ab_id=$ab_id</p>\n";
                        $confirm = $GLOBALS['HTTP_GET_VARS']['confirm'] ? 
$GLOBALS['HTTP_GET_VARS']['confirm'] :$GLOBALS['HTTP_POST_VARS']['confirm'];
                        if(!$ab_id)
***************
*** 870,876 ****
                }
  
!               function view()
                {
!                       $ab_id   = $GLOBALS['HTTP_GET_VARS']['ab_id'];
                        $submit  = $GLOBALS['HTTP_POST_VARS']['submit'];
                        $referer = $GLOBALS['HTTP_GET_VARS']['referer'];
--- 851,858 ----
                }
  
!               function view($content='')
                {
!                       $ab_id   = !is_array($content) && $content > 0 ? 
$content : get_var('ab_id',array('POST','GET'));
!                       //echo "<p>uiaddressbook.view: ab_id=$ab_id</p>\n";
                        $submit  = $GLOBALS['HTTP_POST_VARS']['submit'];
                        $referer = $GLOBALS['HTTP_GET_VARS']['referer'];





reply via email to

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