phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: calendar/inc class.bocalendar.inc.php, 1.71.2.33


From: Ralf Becker <address@hidden>
Subject: [Phpgroupware-cvs] CVS: calendar/inc class.bocalendar.inc.php, 1.71.2.33.2.13, 1.71.2.33.2.14 class.bocustom_fields.inc.php, 1.1.2.1, 1.1.2.2 class.uicalendar.inc.php, 1.66.2.55.2.16, 1.66.2.55.2.17 class.uicustom_fields.inc.php, 1.1.2.1, 1.1.2.2
Date: Sat, 09 Aug 2003 10:06:31 -0400

Update of /cvsroot/phpgroupware/calendar/inc
In directory subversions:/tmp/cvs-serv21400

Modified Files:
      Tag: Version-0_9_16-branch
        class.bocalendar.inc.php class.bocustom_fields.inc.php 
        class.uicalendar.inc.php class.uicustom_fields.inc.php 
Log Message:
fix to give custom-fields a compelte separate namespace from the stock-fields 
and to preserve the content of disabled fields during edit


Index: class.bocalendar.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/calendar/inc/class.bocalendar.inc.php,v
retrieving revision 1.71.2.33.2.13
retrieving revision 1.71.2.33.2.14
diff -C2 -r1.71.2.33.2.13 -r1.71.2.33.2.14
*** class.bocalendar.inc.php    9 Aug 2003 00:33:26 -0000       1.71.2.33.2.13
--- class.bocalendar.inc.php    9 Aug 2003 14:06:28 -0000       1.71.2.33.2.14
***************
*** 869,876 ****
                                        {
                                                
$this->so->add_attribute($name,stripslashes($value));
-                                               //echo "<p>update: 
$name='$value'</p>\n";
                                        }
                                }
! 
                                $event = $this->get_cached_event();
  
--- 869,888 ----
                                        {
                                                
$this->so->add_attribute($name,stripslashes($value));
                                        }
                                }
!                               if (isset($_POST['preserved']) && 
is_array($preserved = unserialize(stripslashes($_POST['preserved']))))
!                               {
!                                       foreach($preserved as $name => $value)
!                                       {
!                                               switch($name)
!                                               {
!                                                       case 'owner':
!                                                               
$this->so->add_attribute('participants',$value,$l_cal['owner']);
!                                                               break;
!                                                       default:
!                                                               
$this->so->add_attribute($name,str_replace(array('&amp;','&quot;','&lt;','&gt;'),array('&','"','<','>'),$value));
!                                               }
!                                       }
!                               }
                                $event = $this->get_cached_event();
  
***************
*** 1414,1417 ****
--- 1426,1441 ----
                function long_date($first,$last=0)
                {
+                       if (!is_array($first))
+                       {
+                               $first = $this->time2array($raw = $first);
+                               $first['raw'] = $raw;
+                               $first['day'] = $first['mday'];
+                       }
+                       if ($last && !is_array($last))
+                       {
+                               $last = $this->time2array($raw = $last);
+                               $last['raw'] = $raw;
+                               $last['day'] = $last['mday'];
+                       }
                        $datefmt = $this->prefs['common']['dateformat'];
                        
***************
*** 2786,2790 ****
                                        {
                                                $recur_end -= 
$GLOBALS['phpgw']->datetime->tz_offset;
!                                               $str_extra .= lang('ends').': 
'.lang($GLOBALS['phpgw']->common->show_date($recur_end,'l')).', 
'.lang($GLOBALS['phpgw']->common->show_date($recur_end,'F')).' 
'.$GLOBALS['phpgw']->common->show_date($recur_end,'d, Y').' ';
                                        }
                                }
--- 2810,2814 ----
                                        {
                                                $recur_end -= 
$GLOBALS['phpgw']->datetime->tz_offset;
!                                               $str_extra .= lang('ends').': 
'.lang($GLOBALS['phpgw']->common->show_date($recur_end,'l')).', 
'.$this->long_date($recur_end).' ';
                                        }
                                }
***************
*** 2826,2847 ****
                                $this->stock_fields = 
&$this->custom_fields->stock_fields;
                        }
!                       foreach($this->fields as $name => $data)
                        {
                                if (!$data['disabled'])
                                {
!                                       if (isset($var[$name]))
                                        {
!                                               $sorted[$name] = $var[$name];
                                        }
!                                       elseif 
(!isset($this->stock_fields[$name]) && strlen($event['#'.$name]))        // 
Custom field
                                        {
!                                               $lang = lang($name);
!                                               $sorted['#'.$name] = array(
                                                        'field' => $lang == 
$name.'*' ? $name : $lang,
!                                                       'data'  => 
$event['#'.$name]
                                                );
                                        }
                                }
!                               unset($var[$name]);
                        }
                        foreach($var as $name => $v)
--- 2850,2871 ----
                                $this->stock_fields = 
&$this->custom_fields->stock_fields;
                        }
!                       foreach($this->fields as $field => $data)
                        {
                                if (!$data['disabled'])
                                {
!                                       if (isset($var[$field]))
                                        {
!                                               $sorted[$field] = $var[$field];
                                        }
!                                       elseif 
(!isset($this->stock_fields[$field]) && strlen($event[$field]))  // Custom field
                                        {
!                                               $lang = lang($name = 
substr($field,1));
!                                               $sorted[$field] = array(
                                                        'field' => $lang == 
$name.'*' ? $name : $lang,
!                                                       'data'  => 
$event[$field]
                                                );
                                        }
                                }
!                               unset($var[$field]);
                        }
                        foreach($var as $name => $v)
***************
*** 2850,2854 ****
  
                        }
- 
                        return $sorted;
                }
--- 2874,2877 ----

Index: class.bocustom_fields.inc.php
===================================================================
RCS file: 
/cvsroot/phpgroupware/calendar/inc/Attic/class.bocustom_fields.inc.php,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -r1.1.2.1 -r1.1.2.2
*** class.bocustom_fields.inc.php       9 Aug 2003 00:33:26 -0000       1.1.2.1
--- class.bocustom_fields.inc.php       9 Aug 2003 14:06:29 -0000       1.1.2.2
***************
*** 30,34 ****
                        'access'      => 'Access',
                        'participants'=> 'Participants',
!                       'alarm'       => 'Email reminder',
                        'recure_type' => 'Repetition'
                );
--- 30,34 ----
                        'access'      => 'Access',
                        'participants'=> 'Participants',
!                       'alarm'       => 'Alarm',
                        'recure_type' => 'Repetition'
                );
***************
*** 41,61 ****
                        $this->fields = &$this->config->config_data['fields'];
  
                        foreach($this->stock_fields as $field => $data)
                        {
                                if (!isset($this->fields[$field]))
                                {
-                                       if (!is_array($data))
-                                       {
-                                               $data = array('label' => $data);
-                                       }
                                        $this->fields[$field] = array(
                                                'name'     => $field,
-                                               'label'    => $data['label'],
-                                               'length'   => $data['length'],
-                                               'shown'    => $data['shown'],
                                                'title'    => $data['title'],
                                                'disabled' => $data['disabled']
                                        );
                                }
                        }
                }
--- 41,70 ----
                        $this->fields = &$this->config->config_data['fields'];
  
+                       foreach ($this->fields as $field => $data)      // this 
can be removed after a while
+                       {
+                               if (!isset($this->stock_fields[$field]) && 
$field[0] != '#')
+                               {
+                                       unset($this->fields[$field]);
+                                       $this->fields['#'.$field] = $data;
+                               }
+                       }
+ 
                        foreach($this->stock_fields as $field => $data)
                        {
+                               if (!is_array($data))
+                               {
+                                       $data = array('label' => $data);
+                               }
                                if (!isset($this->fields[$field]))
                                {
                                        $this->fields[$field] = array(
                                                'name'     => $field,
                                                'title'    => $data['title'],
                                                'disabled' => $data['disabled']
                                        );
                                }
+                               $this->fields[$field]['label']  = 
$data['label'];
+                               $this->fields[$field]['length'] = 
$data['length'];
+                               $this->fields[$field]['shown']  = 
$data['shown'];
                        }
                }
***************
*** 65,69 ****
                        if (is_array($data) && strlen($data['name']) > 0)
                        {
!                               $this->fields[$data['name']] = $data;
                        }
                }
--- 74,82 ----
                        if (is_array($data) && strlen($data['name']) > 0)
                        {
!                               if (!isset($this->stock_fields[$name = 
$data['name']]))
!                               {
!                                       $name = '#'.$name;
!                               }
!                               $this->fields[$name] = $data;
                        }
                }
***************
*** 78,80 ****
                        $this->config->save_repository();
                }
!       }
\ No newline at end of file
--- 91,93 ----
                        $this->config->save_repository();
                }
!       }

Index: class.uicalendar.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/calendar/inc/class.uicalendar.inc.php,v
retrieving revision 1.66.2.55.2.16
retrieving revision 1.66.2.55.2.17
diff -C2 -r1.66.2.55.2.16 -r1.66.2.55.2.17
*** class.uicalendar.inc.php    9 Aug 2003 00:33:26 -0000       1.66.2.55.2.16
--- class.uicalendar.inc.php    9 Aug 2003 14:06:29 -0000       1.66.2.55.2.17
***************
*** 3827,3831 ****
  
                                $var['alarm'] = Array(
!                                       'field' => lang('Email Reminder'),
                                        'data'  => 
$dout.$hout.$mout.lang('before the event')
                                );
--- 3827,3831 ----
  
                                $var['alarm'] = Array(
!                                       'field' => lang('Alarm'),
                                        'data'  => 
$dout.$hout.$mout.lang('before the event')
                                );
***************
*** 3887,3897 ****
                                $this->stock_fields = 
&$this->custom_fields->stock_fields;
                        }
!                       foreach($this->fields as $name => $data)
                        {
                                if (!$data['disabled'])
                                {
!                                       if (isset($var[$name]))
                                        {
!                                               switch($name)
                                                {
                                                        case 'startdate':
--- 3887,3898 ----
                                $this->stock_fields = 
&$this->custom_fields->stock_fields;
                        }
!                       $preserved = False;
!                       foreach($this->fields as $field => $data)
                        {
                                if (!$data['disabled'])
                                {
!                                       if (isset($var[$field]))
                                        {
!                                               switch($field)
                                                {
                                                        case 'startdate':
***************
*** 3913,3927 ****
                                                                break;
                                                        default:
!                                                               
$this->output_template_array($p,'row','list',$var[$name]);
                                                }
                                        }
!                                       elseif 
(!isset($this->stock_fields[$name]))     // Custom field
                                        {
!                                               $lang = lang($name);
                                                $size = 'SIZE='.($data['shown'] 
? $data['shown'] : ($data['length'] ? $data['length'] : 30)).
                                                        ' 
MAXLENGTH='.($data['length'] ? $data['length'] : 255);
                                                $v = array(
                                                        'field' => $lang == 
$name.'*' ? $name : $lang,
!                                                       'data'  => '<input 
name="cal[#'.htmlspecialchars($name).']" '.$size.' 
value="'.$event['#'.$name].'">'
                                                );
                                                if ($data['title'])
--- 3914,3928 ----
                                                                break;
                                                        default:
!                                                               
$this->output_template_array($p,'row','list',$var[$field]);
                                                }
                                        }
!                                       elseif 
(!isset($this->stock_fields[$field]))    // Custom field
                                        {
!                                               $lang = lang($name = 
substr($field,1));
                                                $size = 'SIZE='.($data['shown'] 
? $data['shown'] : ($data['length'] ? $data['length'] : 30)).
                                                        ' 
MAXLENGTH='.($data['length'] ? $data['length'] : 255);
                                                $v = array(
                                                        'field' => $lang == 
$name.'*' ? $name : $lang,
!                                                       'data'  => '<input 
name="cal['.htmlspecialchars($field).']" '.$size.' 
value="'.$event['#'.$name].'">'
                                                );
                                                if ($data['title'])
***************
*** 3941,3947 ****
                                        }
                                }
                        }
                        unset($var);
! 
                        $p->set_var('submit_button',lang('Save'));
  
--- 3942,3972 ----
                                        }
                                }
+                               else    // preserve disabled fields
+                               {
+                                       switch ($field)
+                                       {
+                                               case 'owner':
+                                                       $preserved[$field] = 
$event['id'] ? $event['participants'][$event['owner']] : 'A';
+                                                       break;
+                                               case 'recure_type':
+                                                       
foreach(array('recur_type','recur_enddate','recur_data','recur_interval') as 
$field)
+                                                       {
+                                                               
$preserved[$field] = $event[$field];
+                                                       }
+                                                       break;
+                                               case 'startdate':
+                                               case 'enddate':
+                                                       $field = 
substr($field,0,-4);
+                                               default:
+                                                       $preserved[$field] = 
$event[$field];
+                                       }
+                               }
                        }
                        unset($var);
!                       if (is_array($preserved))
!                       {
!                               //echo "preserving<pre>"; print_r($preserved); 
echo "</pre>\n";
!                               
$p->set_var('common_hidden',$p->get_var('common_hidden').'<input type="hidden" 
name="preserved" value="'.htmlspecialchars(serialize($preserved)).'">'."\n");
!                       }
                        $p->set_var('submit_button',lang('Save'));
  

Index: class.uicustom_fields.inc.php
===================================================================
RCS file: 
/cvsroot/phpgroupware/calendar/inc/Attic/class.uicustom_fields.inc.php,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -r1.1.2.1 -r1.1.2.2
*** class.uicustom_fields.inc.php       9 Aug 2003 00:33:26 -0000       1.1.2.1
--- class.uicustom_fields.inc.php       9 Aug 2003 14:06:29 -0000       1.1.2.2
***************
*** 26,29 ****
--- 26,30 ----
                {
                        $this->bocustom_fields();       // call constructor of 
extended class
+ 
                        $this->tpl = $GLOBALS['phpgw']->template;
                        if (!is_object($GLOBALS['phpgw']->nextmatchs))
***************
*** 89,93 ****
                        }
                        $this->tpl->set_var(array(
!                               'name'    => $values['label'] ? 
lang($values['label'])." ($values[name])" : 
$this->html->input('name'.$id,$values['name'],'','SIZE="40" MAXLENGTH="40"'),
                                'length'  => $values['label'] ? '&nbsp' : 
$this->html->input('length'.$id,$values['length'],'','SIZE="3"'),
                                'shown'   => $values['label'] ? '&nbsp' : 
$this->html->input('shown'.$id,$values['shown'],'','SIZE="3"'),
--- 90,94 ----
                        }
                        $this->tpl->set_var(array(
!                               'name'    => $values['label'] ? 
lang($values['label']) : 
$this->html->input('name'.$id,$values['name'],'','SIZE="40" MAXLENGTH="40"'),
                                'length'  => $values['label'] ? '&nbsp' : 
$this->html->input('length'.$id,$values['length'],'','SIZE="3"'),
                                'shown'   => $values['label'] ? '&nbsp' : 
$this->html->input('shown'.$id,$values['shown'],'','SIZE="3"'),
***************
*** 112,118 ****
                        //echo "<pre>"; print_r($_POST); echo "</pre>";
  
!                       foreach ($_POST['order'] as $name => $order)
                        {
!                               if (isset($_POST['delete'][$name]) || $name == 
'***new***')
                                {
                                        continue;
--- 113,119 ----
                        //echo "<pre>"; print_r($_POST); echo "</pre>";
  
!                       foreach ($_POST['order'] as $field => $order)
                        {
!                               if (isset($_POST['delete'][$field]) || $field 
== '***new***')
                                {
                                        continue;
***************
*** 123,136 ****
                                }
                                $ordered[$order] = array(
!                                       'name'      => 
stripslashes($_POST['name'][$name]),
!                                       'length'    => 
intval($_POST['length'][$name]),
!                                       'shown'     => 
intval($_POST['shown'][$name]),
!                                       'title'     => !!$_POST['title'][$name],
!                                       'disabled'  => 
!!$_POST['disabled'][$name]
                                );
!                               if (isset($this->stock_fields[$name]))
                                {
!                                       $ordered[$order]['name']  = 
$this->fields[$name]['name'];
!                                       $ordered[$order]['label'] = 
$this->fields[$name]['label'];
                                }
                        }
--- 124,138 ----
                                }
                                $ordered[$order] = array(
!                                       'field'     => $field,
!                                       'name'      => 
stripslashes($_POST['name'][$field]),
!                                       'length'    => 
intval($_POST['length'][$field]),
!                                       'shown'     => 
intval($_POST['shown'][$field]),
!                                       'title'     => 
!!$_POST['title'][$field],
!                                       'disabled'  => 
!!$_POST['disabled'][$field]
                                );
!                               if (isset($this->stock_fields[$field]))
                                {
!                                       $ordered[$order]['name']  = 
$this->fields[$field]['name'];
!                                       $ordered[$order]['label'] = 
$this->fields[$field]['label'];
                                }
                        }
***************
*** 139,144 ****
                                $name = 
stripslashes($_POST['name']['***new***']);
  
!                               if (!strlen($name) || 
isset($this->stock_fields[strtolower($name)]) ||
!                                   array_search($name,$_POST['name']) != 
'***new***')
                                {
                                        $error .= lang('New name must not exist 
and not be empty!!!');
--- 141,145 ----
                                $name = 
stripslashes($_POST['name']['***new***']);
  
!                               if (!strlen($name) || 
array_search($name,$_POST['name']) != '***new***')
                                {
                                        $error .= lang('New name must not exist 
and not be empty!!!');
***************
*** 152,155 ****
--- 153,157 ----
                                        }
                                        $ordered[$order] = array(
+                                               'field'     => '#'.$name,
                                                'name'      => $name,
                                                'length'    => 
intval($_POST['length']['***new***']),
***************
*** 186,190 ****
                                        unset($data['disabled']);
                                }
!                               $this->fields[$data['name']] = $data;
                        }
                        if (!$error && isset($_POST['save']))
--- 188,194 ----
                                        unset($data['disabled']);
                                }
!                               $field = $data['field'];
!                               unset($data['field']);
!                               $this->fields[$field] = $data;
                        }
                        if (!$error && isset($_POST['save']))





reply via email to

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