source: contrib/Resources/inc/class.uiresources.inc.php @ 4362

Revision 4362, 56.6 KB checked in by afernandes, 13 years ago (diff)

Ticket #1416 - Disponibilizado módulo de recursos para a comunidade

  • Property svn:executable set to *
Line 
1<?php
2  /**************************************************************************\
3  * eGroupWare - resources                                                    *
4  * http://www.eGroupWare.org                                                *
5  * Maintained and further developed by RalfBecker@outdoor-training.de       *
6  * Based on Webresources by Craig Knudsen <cknudsen@radix.net>               *
7  *          http://www.radix.net/~cknudsen                                  *
8  * Originaly modified by Mark Peters <skeeter@phpgroupware.org>             *
9  * --------------------------------------------                             *
10  *  This program is free software; you can redistribute it and/or modify it *
11  *  under the terms of the GNU General Public License as published by the   *
12  *  Free Software Foundation; either version 2 of the License, or (at your  *
13  *  option) any later version.                                              *
14  \**************************************************************************/
15
16
17        class uiresources
18        {
19                var $dbb;
20                var $template;
21                var $cat;
22                var $debug = False;
23                var $cat_id;
24                var $theme;
25                var $link_tpl;
26                var $public_functions = array(
27                'index' => True,               
28                'view' => True,
29                'edit' => True,
30                'update'=> True,                               
31                'delete' => True,
32                'close'       => True,
33                'import_mail' => True,
34                'search' => True,
35                'search2' => True,
36                'header' => True,
37                'footer' => True                       
38                );
39
40
41
42
43        var $prefs;
44        /**
45         * instance of the bo-class
46         *
47         * @var boresources
48         */
49        var $bo;
50        /**
51         * reference to instance of the link-class of bo
52         *
53         * @var bolink
54         */
55        var $link;
56        /**
57         * instance of the etemplate class
58         *
59         * @var etemplate
60         */
61        var $tmpl;
62        /**
63         * reference to the html object of etemplate
64         *
65         * @var html
66         */
67        var $html;
68        /**
69         * allowed units and hours per day, can be overwritten by the projectmanager configuration, default all units, 8h
70         *
71         * @var string
72         */
73        var $duration_format = ',';     // comma is necessary!
74       
75        var $icons = array(
76                'type' => array(
77                        'task'      => 'task.png',      'task_alt'      => 'Task',
78                        'phone'     => 'phone.gpng',     'phone_alt'     => 'Phonecall',
79                        'note'      => 'note.png',      'note_alt'      => 'Note',
80                        'confirm'   => 'confirm.png',   'confirm_alt'   => 'Confirmation',
81                        'reject'    => 'reject.png',    'reject_alt'    => 'Reject',
82                        'email'     => 'email.png',     'email_alt'     => 'Email' ),
83                'action' => array(
84                        'new'       => 'new.png',       'new_alt'       => 'Add Sub',
85                        'view'      => 'view.png',      'view_alt'      => 'View Subs',
86                        'parent'    => 'parent.png',    'parent_alt'    => 'View other Subs',
87                        'edit'      => 'edit.png',      'edit_alt'      => 'Edit',
88                        'addfile'   => 'addfile.png',   'addfile_alt'   => 'Add a file',
89                        'delete'    => 'delete.png',    'delete_alt'    => 'Delete',
90                        'close'     => 'done.png',      'close_alt'     => 'Close' ),
91                'status' => array(
92                        'billed'    => 'billed.png',    'billed_alt'    => 'billed',
93                        'done'      => 'done.png',      'done_alt'      => 'done',
94                        'will-call' => 'will-call.png', 'will-call_alt' => 'will-call',
95                        'call'      => 'call.png',      'call_alt'      => 'call',
96                        'ongoing'   => 'ongoing.png',   'ongoing_alt'   => 'ongoing',
97                        'offer'     => 'offer.png',     'offer_alt'     => 'offer' )
98        );
99        var $filters = array(
100                'none'                     => 'no Filter',
101                'done'                     => 'done',
102                'responsible'              => 'responsible',
103                'responsible-open-today'   => 'responsible open',
104                'responsible-open-overdue' => 'responsible overdue',
105                'responsible-upcoming'     => 'responsible upcoming',
106                'delegated'                => 'delegated',
107                'delegated-open-today'     => 'delegated open',
108                'delegated-open-overdue'   => 'delegated overdue',
109                'delegated-upcoming'       => 'delegated upcomming',
110                'own'                      => 'own',
111                'own-open-today'           => 'own open',
112                'own-open-overdue'         => 'own overdue',
113                'own-upcoming'             => 'own upcoming',
114                'open-today'               => 'open',
115                'open-overdue'             => 'overdue',
116                'upcoming'                 => 'upcoming',
117        );
118        var $messages = array(
119                'edit'    => 'resources - Edit',
120                'add'     => 'resources - New',
121                'add_sub' => 'resources - New Subproject',
122                'sp'      => '- Subprojects from',
123                're'      => 'Re:'
124        );
125
126
127var $optionldap;
128
129        /**
130         * Constructor
131         *
132         * @return uiresources
133         */
134
135
136
137                function uiresources()
138                {
139                        $localtime = $GLOBALS['phpgw']->datetime->users_localtime;
140
141                                        $this->year = date('Y',$localtime);
142                                        $this->month = date('m',$localtime);
143                                        $this->day = date('d',$localtime);
144                        $this->today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime);
145
146
147                       
148 
149//print_r($GLOBALS);
150
151                        $GLOBALS['phpgw']->nextmatchs = CreateObject('phpgwapi.nextmatchs');
152                        $this->bo = CreateObject('resources.boresources',1);
153                        $this->cat = &$this->bo->cat;
154                        //echo "pwnre".$this->bo->owner."  ".$this->bo->today."  ".$this->bo->evento;
155                        $this->dbb = CreateObject('class.DBAccess',1);
156                        $this->cat = &$this->bo->cat;
157
158
159                        $this->resources = &$this->bo->resources;
160
161                        $this->project = &$this->bo->project;
162
163$this->tarea = &$this->bo->tarea;
164
165                        print_debug('BO Owner',$this->bo->owner);
166
167                        $this->template = $GLOBALS['phpgw']->template;
168                        $this->template_dir = $GLOBALS['phpgw']->common->get_tpl_dir('resources');
169
170                        $this->cat_id   = $this->bo->cat_id;
171
172                        $this->link_tpl = CreateObject('phpgwapi.Template',$this->template_dir);
173                        $this->link_tpl->set_unknowns('remove');
174                        $this->link_tpl->set_file(
175                                Array(
176                                        'link_picture'  => 'link_pict.tpl'
177                                )
178                        );
179                        $this->link_tpl->set_block('link_picture','link_pict','link_pict');
180                        $this->link_tpl->set_block('link_picture','pict','pict');
181                        $this->link_tpl->set_block('link_picture','link_open','link_open');
182                        $this->link_tpl->set_block('link_picture','link_close','link_close');
183                        $this->link_tpl->set_block('link_picture','link_text','link_text');
184
185
186
187$this->ds = $GLOBALS['phpgw']->common->ldapConnect();
188                        if(!$this->ds)
189                                $this->ds = $GLOBALS['phpgw']->common->ldapConnect();
190                        if(!@is_object($GLOBALS['phpgw']->translation))
191                        {
192                                $GLOBALS['phpgw']->translation = CreateObject('phpgwapi.translation');
193                        }
194                        $this->user_context  = $GLOBALS['phpgw_info']['server']['ldap_context'];
195                        $this->group_context = $GLOBALS['phpgw_info']['server']['ldap_group_context'];
196               
197/*************************************************/
198
199                        $this->always_app_header = $this->bo->prefs['common']['template_set'] == 'idots';
200
201                        //print_debug('UI',$this->_debug_sqsof());
202
203                        if (!is_object($GLOBALS['phpgw']->html))
204                        {
205                                $GLOBALS['phpgw']->html = CreateObject('phpgwapi.html');
206                        }
207                        $this->html = &$GLOBALS['phpgw']->html;
208                }
209
210                /* Public functions */
211
212               
213
214                function index($params='')
215
216                {
217
218                        if (!$params)
219                        {
220                                foreach(array('date','year','month','day') as $field)
221                                {
222                                        if (isset($_GET[$field]))
223                                        {
224                                                $params[$field] = $_REQUEST[$field];
225                                        }
226                                }
227                        }
228//$todos = $this->get_todos($todo_label);
229
230                        $GLOBALS['phpgw']->redirect($this->page('search',$params));
231                       
232                }
233
234
235               
236function page($_page='',$params='')
237                {
238                        if($_page == '')
239                        {
240                                $page_ = explode('.',$this->bo->prefs['resources']['defaultresources']);
241                                $_page = $page_[0];
242
243                                if ($_page=='planner_cat' || $_page=='planner_user')
244                                {
245                                        $_page = 'month';
246                                }
247                                elseif ($_page=='index' || ($_page != 'day' && $_page != 'week' && $_page != 'month' && $_page != 'year' && $_page != 'planner'))
248                                {
249                                        $_page = 'month';
250                                        $GLOBALS['phpgw']->preferences->add('resources','defaultresources','month');
251                                        $GLOBALS['phpgw']->preferences->save_repository();
252                                }
253                        }
254                        if($GLOBALS['phpgw_info']['flags']['currentapp'] == 'home' ||
255                                strstr($GLOBALS['phpgw_info']['flags']['currentapp'],'mail'))   // email, felamimail, ...
256                        {
257                                $page_app = 'resources';
258                        }
259                        else
260                        {
261                                $page_app = $GLOBALS['phpgw_info']['flags']['currentapp'];
262                        }
263                        if (is_array($params))
264                        {
265                                $params['menuaction'] = $page_app.'.ui'.$page_app.'.'.$_page;
266                        }
267                        else
268                        {
269                                $params = 'menuaction='.$page_app.'.ui'.$page_app.'.'.$_page.$params;
270                        }
271                        return $GLOBALS['phpgw']->link('/index.php',$params);
272                }
273
274
275
276// NDEE: printer-friendly
277function printer_friendly($body,$app_header='')
278                {
279                        $_SESSION['resources']['category'] = $this->cat->formated_list('select','all',$this->bo->cat_id,'True');
280$_SESSION['resources']['resources'] = $this->resources->formated_list('select','all',$this->bo->resources_id,'True');
281                        if((!isset($GLOBALS['phpgw_info']['server']['deny_user_granres_access']) || !$GLOBALS['phpgw_info']['server']['deny_user_granres_access']) && count($this->bo->grants) > 0)
282                                $_SESSION['resources']['cals'] = $this->bo->list_cals();
283
284                       
285                                unset($GLOBALS['phpgw_info']['flags']['noheader']);
286                                unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
287                                unset($GLOBALS['phpgw_info']['flags']['noappheader']);
288                                unset($GLOBALS['phpgw_info']['flags']['noappfooter']);
289                                if ($app_header && $this->always_app_header)
290                                {
291                                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['resources']['title'].' - '.$app_header;
292                                }
293                               
294                                $GLOBALS['phpgw']->common->phpgw_header();
295                               
296                        return $new_body;
297                }
298
299
300
301
302
303function normalizeminutes(&$minutes)
304                {
305                        $hour = 0;
306                        $min = (int)$minutes;
307                        if($min >= 60)
308                        {
309                                $hour += $min / 60;
310                                $min %= 60;
311                        }
312                        settype($minutes,'integer');
313                        $minutes = $min;
314                        return $hour;
315                }
316
317                function header()
318                {
319                        $cols = 8;
320                        if($this->bo->check_perms(PHPGW_ACL_PRIVATE) == True)
321                        {
322                                $cols++;
323                        }
324
325                        $tpl = $GLOBALS['phpgw']->template;
326                        $tpl->set_unknowns('remove');
327
328                        if (!file_exists($file = $this->template_dir.'/header.inc.php'))
329                        {
330                                $file = $GLOBALS['phpgw_info']['server']['webserver_url'] . '/resources/templates/default/header.inc.php';
331                        }
332
333                        include($file);
334                        $refer = explode('.',$GLOBALS['HTTP_GET_VARS']['menuaction']);
335                        if($refer[2] != 'view') {
336                        $header = $tpl->fp('out','head');
337                        unset($tpl);
338                        echo $header;
339                }
340                        unset($tpl);
341                }
342
343                function footer()
344                {
345                        $menuaction = $_GET['menuaction'];
346                        list(,,$method) = explode('.',$menuaction);
347
348                        if (@$this->bo->printer_friendly)
349                        {
350                                return;
351                        }
352
353                        $p = $GLOBALS['phpgw']->template;
354
355                        $p->set_file(
356                                Array(
357                                        'footer'        => 'footer.tpl',
358                                        'form_button'   => 'form_button_script.tpl'
359                                )
360                        );
361                        $p->set_block('footer','footer_table','footer_table');
362                        $p->set_block('footer','footer_row','footer_row');
363                        $p->set_block('footer','blank_row','blank_row');
364                        $p->set_block('footer','num_dias','num_dias');
365
366                        $m = $this->bo->month;
367                        $y = $this->bo->year;
368
369                        $hoje = date('Ymd',$GLOBALS['phpgw']->datetime->gmtnow);
370                        $mes_hoje = (int)substr($hoje,4,2);
371                        $mes_footer = (int)substr($_POST['date'],4,2);
372                        if($_GET['sday'])
373                        {
374                                if($_GET['month'] == $mes_hoje)
375                                {
376                                        $day = $this->bo->day;
377                                }
378                                else
379                                {
380                                        $day = $_GET['sday'];
381                                }
382                        }
383                        else
384                        {
385                                $day = $this->bo->day;
386                                $dia_ini = $day;
387                        }
388                        if($mes_footer == $mes_hoje)
389                        {
390                                $dia_ini = (int)substr($hoje,6,2);
391                                $day = $dia_ini;
392                        }
393                       
394                        /********************************************************************************************/
395
396                }
397
398               
399
400
401
402
403/****************************************************************************************/
404
405
406function edit($cd=0,$readsess=0)
407                {
408
409                        $this->today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime);
410
411
412
413
414                        if(!$this->bo->check_perms(PHPGW_ACL_ADD))
415                        {
416                                $this->index();
417                        }
418                       
419                        if($readsess)
420                        {
421
422                                $event = $this->bo->restore_from_appsession;
423                                if(!$event['owner'])
424                                {
425                                        $this->bo->add_attribute('owner',$this->bo->owner);
426                                }
427                                $can_edit = True;
428                        }
429                        else
430                        {
431
432
433                                $this->bo->event_init();
434                                $this->bo->add_attribute('id',0);
435
436                                $can_edit = True;
437                                $participants = (string)(get_var('participants',array('GET'),FALSE));
438                                $starthour = (int)(get_var('hour',array('GET'),$this->bo->prefs['resources']['workdaystarts']));
439                                $startmin  = (int)(get_var('minute',array('GET'),0));
440                                $endmin    = $startmin + (int)$this->bo->prefs['resources']['defaultlength'];
441                                $endhour   = $starthour + $this->bo->normalizeminutes($endmin);
442                               
443                                $subject        = (string)(get_var('title',array('GET'),0));
444                                if ($subject != '0')
445                                {
446                                        $description    = (string)(get_var('description',array('GET'),0));
447                                        $description1   = (string)(get_var('description1',array('GET'),0));
448                                        $location       = (string)(get_var('location',array('GET'),0));
449                                }
450                                else
451                                        unset($subject);
452                               
453                                $this->bo->set_start($this->bo->year,$this->bo->month,$this->bo->day,$starthour,$startmin,0);
454                                $this->bo->set_end($this->bo->year,$this->bo->month,$this->bo->day,$endhour,$endmin,0);
455
456
457                                if(@$this->bo->prefs['resources']['default_private'])
458                                {
459                                        $this->bo->set_class(False);
460                                }
461                                else
462                                {
463                                        $this->bo->set_class(True);
464                                }
465                               
466                                $event = $this->bo->restore_from_appsession;
467                               
468                        }
469if(isset($_REQUEST['error'])){
470$cd=$_REQUEST['error'];
471}
472                        $this->edit_form(
473                                Array(
474                                        'event' => $event,
475                                        'cd' => $cd,
476                                        'plain' => $_GET['plain']
477                                )
478                        );
479                        $GLOBALS['phpgw']->common->phpgw_footer();
480                }
481
482
483function edit_form($param)
484                {
485
486
487if(isset($_REQUEST['id'])){
488                        $event=$this->select($_REQUEST['id']);
489}else{
490$event=$this->select_init();
491}
492
493                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
494
495
496                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
497                       
498       
499$justthese = array("uidnumber", "gidnumber", "uid", "cn", "givenname", "sn", "mail","telephonenumber","gecos","dn");
500                                $sri = @ldap_search($this->ds, "ou=usuarios,ou=cnti,dc=gob,dc=ve", ("(&(sn=*)(mail=*@*)(structuralObjectClass=inetOrgPerson)(deliveryMode=virtual))"), $justthese);
501               
502
503if(!$sri)
504                                return null;
505                        $allValues = ldap_get_entries($this->ds, $sri);
506
507
508
509$ttt=count($allValues);
510
511for($i=0;$i<$ttt;$i++){
512
513                                                        if(isset($allValues[$i]['mail'][0]))
514                                {
515                                                                $option = '    <option  value="' . $allValues[$i]['uidnumber'][0] . '" >'.$allValues[$i]['gecos'][0].'</option>'."\n";
516                                                                $optionldap .= $option;
517                                                                $option2 = '    <option  value="' . $allValues[$i]['uidnumber'][0] . '" >'.$allValues[$i]['gecos'][0].'</option>'."\n";
518                                                                $optionldap2 .= $option2;
519}
520
521
522
523
524}
525
526
527
528
529
530                        if(!is_array($param))
531                        {
532                                $this->index();
533                        }
534                       
535                        if(isset($param['event']))
536                        {
537                                $event = $param['event'];
538                        }
539                       
540                        $hourformat = substr($this->bo->users_timeformat,0,1);
541                       
542                        $jscal = CreateObject('phpgwapi.jscalendar');   // before phpgw_header() !!!
543                       
544                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
545                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
546                        $GLOBALS['phpgw_info']['flags']['noappheader'] = True;
547                        $GLOBALS['phpgw_info']['flags']['noappfooter'] = True;
548                        $GLOBALS['phpgw_info']['flags']['app_header'] = $event['id'] ? lang('Editing event') : lang('Adding resources');
549                        if ($param['plain'] != "True"){
550                                $GLOBALS['phpgw']->common->phpgw_header();
551                        }
552                        else{
553                                $GLOBALS['phpgw_info']['theme']['row_on'] = "F8F8F8";
554                                $GLOBALS['phpgw_info']['theme']['row_off'] = "F8F8F8";
555                        }
556
557                        $p = &$GLOBALS['phpgw']->template;
558                        $p->set_file(
559                                Array(
560                                        'edit'          => 'edit.tpl',
561                                        'form_button'   => 'form_button_script.tpl'
562                                )
563                        );
564                        $p->set_block('edit','edit_entry','edit_entry');
565                        $p->set_block('edit','list','list');
566                        $p->set_block('edit','hr','hr');
567
568                        $vars = Array(
569                                'font'                  => $this->theme['font'],
570                                'bg_color'              => $this->theme['bg_text'],
571                                'action_url'            => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'resources.uiresources.update')),
572                                'accounres_link'                => $GLOBALS['phpgw']->link('/index.php','menuaction=resources.uiresources.accounres_popup'),
573                                'common_hidden' => '<input type="hidden" name="resources[id]" value="'.$event['id'].'">'."\n"
574                                        . '<input type="hidden" name="resources[owner]" value="'.$event['owner'].'">'."\n"
575                                        . (@isset($GLOBALS['phpgw_info']['server']['deny_user_granres_access']) && $GLOBALS['phpgw_info']['server']['deny_user_granres_access']?
576                                        '<input type="hidden" name="participants[]" value="'.$this->bo->owner.'">'."\n":''),
577                                'errormsg'              => ($param['cd']?$GLOBALS['phpgw']->common->check_code($param['cd']):'')
578                        );
579                       
580                        $p->set_var($vars);
581
582// res_type
583        //echo $event['type'];         
584
585
586// Display Categories
587                        if(strpos($event['category'],','))
588                        {
589                                $temp_cats = explode(',',$event['category']);
590                                @reset($temp_cats);
591                                while(list($key,$value) = each($temp_cats))
592                                {
593                                        $check_cats[] = (int)$value;
594                                }
595                        }
596                        elseif($event['category'])
597                        {
598                                $check_cats[] = (int)$event['category'];
599                        }
600                        else
601                        {
602                                $check_cats[] = 0;
603                        }
604                        $var['category'] = Array(
605                                'field' => lang('Category'),
606                                'data'  => '<select name="resources[category]" onchange="javascript:updateTitleField(this)" >'.$this->cat->formated_list('select','all',$check_cats,True).'</select>'
607                        );
608       
609
610
611
612
613// nombre
614                        $var['name'] = Array(
615                                'field' => lang('name'),
616                                'data'  => '<input type="text" name="resources[name]" maxlength="255" value="'.$event['name'].'">'
617                        );
618
619
620// location
621                        $var['location'] = Array(
622                                'field' => lang('location'),
623                                'data'  => '<input type="text" name="resources[location]" maxlength="255" value="'.$event['location'].'">'
624                        );
625
626
627//cantidad
628                        $var['cantidad'] = Array(
629                                'field' => lang('quantity'),
630                                'data'  => '<input type="text" name="resources[cantidad]" maxlength="255" value="'.$event['cantidad'].'">'
631                        );
632
633
634
635
636// Full Description
637                        $var['description'] = Array(
638                                'field' => lang('Description'),
639                                'data'  => '<textarea name="resources[description]" rows="5" cols="40" wrap="virtual" maxlength="2048">'.$event['descripcion'].'</textarea>'
640                        );
641
642
643
644
645//responsable
646                        if(!isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) || !$GLOBALS['phpgw_info']['server']['deny_user_grants_access'])
647                        {
648                               
649                                       
650                                                $str2 = utf8_decode($optionldap2);
651                                               
652                                                $var['administrador'] = array
653                                                (
654                                                        'field' => lang('Responsable'),                                                 
655                                                        'data'  => "
656                                                                        <select id='user_list' name='resources[administrador]' style='width: 220px' ><option value=0>seleccione</option>".$str2."</select>                                                                             
657                                                                                       
658                                                                       
659                                                                        "
660                                                );
661                                                                       
662                                               
663                                               
664                                               
665                                               
666                                }
667
668//email
669                        $var['email'] = Array(
670                                'field' => lang('email'),
671                                'data'  => '<input type="text" name="resources[email]" maxlength="255" value="'.$event['email'].'">'
672                        );
673
674
675$valorfechainicio=$this->bo->time2array($event['fechainicio'],$alarm = 0);
676$start=$valorfechainicio['mday']."/".$valorfechainicio['month']."/".$valorfechainicio['year'];
677                        $var['startdate'] = Array(
678                                'field' => lang('Start Date'),
679
680                                'data' => $jscal->input('start[str]',$start)
681                        );
682
683
684//                      $this->output_template_array($p,'row','list',Array('data' => '<script src="simple_show_hide.js" type="text/javascript"></script>'));
685
686                        if (!isset($this->fields))
687                        {
688                                $this->custom_fields = CreateObject('resources.bocustom_fields');
689                                $this->fields = &$this->custom_fields->fields;
690                                $this->stock_fields = &$this->custom_fields->stock_fields;
691                        }
692                //      $this->output_template_array($p,'row','list',$var['access']);
693                        unset($var['access']);
694
695                        $preserved = False;
696                        foreach($this->fields as $field => $data)
697                        {
698
699                                if (!$data['disabled'])
700                                {
701
702
703                                        if (isset($var[$field]))
704                                        {
705
706
707                                                switch($field)
708                                                {
709                                                        case 'startdate':
710                                                                $this->output_template_array($p,'row','list',$var['startdate']);
711                                                                $this->output_template_array($p,'row','list',$var['starttime']);
712                                                                break;
713                                                        case 'enddate':
714                                                                $this->output_template_array($p,'row','list',$var['enddate']);
715                                                                $this->output_template_array($p,'row','list',$var['endtime']);
716                                                                break;
717                                                        case 'recure_type':
718                                                                $p->set_var('tr_color',$this->theme['th_bg']);
719                                                                $p->set_var('hr_text','<center id="rpt_label"><b>'.lang('Repeating Event Information').'</b></center>');
720                                                                $p->parse('row','hr',True);
721                                                                $this->output_template_array($p,'row','list',$var['recure_type']);
722                                                                $this->output_template_array($p,'row','list',$var['recure_enddate']);
723                                                                $this->output_template_array($p,'row','list',$var['recure_day']);
724                                                                $this->output_template_array($p,'row','list',$var['recure_interval']);
725                                                                break;
726                                                        default:
727                                                                $this->output_template_array($p,'row','list',$var[$field]);
728
729                                                }
730                                        }
731                                        elseif (!isset($this->stock_fields[$field]))    // Custom field
732                                        {
733
734
735                                                $lang = lang($name = substr($field,1));
736                                                $size = 'SIZE='.($data['shown'] ? $data['shown'] : ($data['length'] ? $data['length'] : 30)).
737                                                        ' MAXLENGTH='.($data['length'] ? $data['length'] : 255);
738                                                $v = array(
739                                                        'field' => $lang == $name.'*' ? $name : $lang,
740                                                        'data'  => '<input name="cal['.htmlspecialchars($field).']" '.$size.' value="'.$event['#'.$name].'">'
741                                                );
742                                                if ($data['title'])
743                                                {
744                                                        $v['tr_color'] = $this->theme['th_bg'];
745                                                }
746                                                if (!$data['length'] && $data['title'])
747                                                {
748                                                        $p->set_var('tr_color',$this->theme['th_bg']);
749                                                        $p->set_var('hr_text','<center><b>'.$v['field'].'</b></center>');
750                                                        $p->parse('row','hr',True);
751                                                }
752                                                else
753                                                {
754                                                        $this->output_template_array($p,'row','list',$v);
755                                                }
756                                        }
757                                }
758                                else    // preserve disabled fields
759                                {
760
761
762                                        switch ($field)
763                                        {
764                                                case 'owner':
765                                                        $preserved[$field] = $event['id'] ? $event['participants'][$event['owner']] : 'A';
766                                                        break;
767                                                case 'recure_type':
768                                                        foreach(array('recur_type','recur_enddate','recur_data','recur_interval') as $field)
769                                                        {
770                                                                $preserved[$field] = $event[$field];
771                                                        }
772                                                        break;
773                                                case 'startdate':
774                                                case 'enddate':
775                                                        $field = substr($field,0,-4);
776                                                default:
777                                                        $preserved[$field] = $event[$field];
778                                        }
779                                }
780                        }
781                        unset($var);
782                        if (is_array($preserved))
783                        {
784                                //echo "preserving<pre>"; print_r($preserved); echo "</pre>\n";
785                                $p->set_var('common_hidden',$p->get_var('common_hidden').'<input type="hidden" name="preserved" value="'.htmlspecialchars(serialize($preserved)).'">'."\n");
786                        }
787                        $p->set_var('submit_button',lang('Save'));
788
789                        $delete_button = $cancel_button = '';
790                        if ($event['id'] > 0)
791                        {
792                                $var = Array(
793                                        'action_url_button'     => $this->page('delete','&cal_id='.$event['id']),
794                                        'action_text_button'    => lang('Delete'),
795                                        'action_confirm_button' => "onClick=\"return confirm('".lang('Are you sure want to delete this entry?\\nThis will delete this entry for all users.')."')\"",
796                                        'action_extra_field'    => '',
797                                        'button_id'     =>      'delete_button'
798                                );
799                                $p->set_var($var);
800                                $delete_button = $p->fp('out','form_button');
801                        }
802                        $p->set_var('delete_button',$delete_button);
803                        $p->set_var('alert_msg',lang('Required field (category) is empty'));
804
805                        if ($this->bo->return_to)
806                        {
807                                $var = Array(
808                                        'action_url_button'     => $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to),
809                                        'action_text_button'    => lang('Cancel'),
810                                        'action_confirm_button' => '',
811                                        'action_extra_field'    => '',
812                                        'button_id'     =>      'cancel_button'
813                                );
814                                $p->set_var($var);
815                                $cancel_button = $p->fp('out','form_button');
816                        }
817                        $p->set_var('cancel_button',$cancel_button);
818                        $p->pparse('out','edit_entry');
819                }
820
821        function output_template_array(&$p,$row,$list,$var)
822                {
823                        if (!isset($var['hidden_vars']))
824                        {
825                                $var['hidden_vars'] = '';
826                        }
827                        if (!isset($var['tr_color']))
828                        {
829                                $var['tr_color'] = $GLOBALS['phpgw']->nextmatchs->alternate_row_color();
830                        }
831                        $p->set_var($var);
832                        $p->parse($row,$list,True);
833                }
834
835
836function get_organizations($context, $selected='', $recursive = false)
837                {
838                        $s = CreateObject('phpgwapi.sector_search_ldap');
839                                               
840                        return ($recursive ?
841                                $s->get_organizations($context, $selected, false ,true) :
842                                $s->get_sectors($selected, false, false));
843                }       
844       
845
846
847
848/**********************************************/
849
850
851function _debug_sqsof()
852                {
853                        $data = array(
854                                'filter'     => $this->bo->filter,
855                                'cat_id'     => $this->bo->cat_id,
856                                'owner'      => $this->bo->owner,
857                                'year'       => $this->bo->year,
858                                'month'      => $this->bo->month,
859                                'day'        => $this->bo->day,
860                                'sortby'     => $this->bo->sortby,
861                                'num_months' => $this->bo->num_months
862                        );
863                        Return _debug_array($data,False);
864                }
865
866
867
868
869/***********************************/
870
871
872
873
874function search()
875                {
876
877//print_r($_REQUEST);
878//echo "kkkkkkkkkkk".$_REQUEST['errormsg'];
879
880
881                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
882                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
883                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['resources']['title'].' - '.lang('Search Results');
884                        $GLOBALS['phpgw']->common->phpgw_header();
885
886                        $error = '';
887
888                        $matches = 0;
889
890                //$event = $this->bo->read_entry($res_id);     
891$event = $this->get_event_ids($adicional);
892
893
894                        //$event_ids = $this->bo->search_keywords($_POST['keywords']);
895
896                       
897                        $matches = count($event);
898
899//echo "matches" . $matches;
900
901                        if ($matches == 1)
902                        {
903                                $quantity = lang('1 match found').'.';
904                        }
905                        elseif ($matches > 0)
906                        {
907                                $quantity = lang('%1 matches found',$matches).'.';
908                        }
909                        else
910                        {
911                                echo lang('no matches found');
912                                return;
913                        }
914
915                        $p = $GLOBALS['phpgw']->template;
916                        $p->set_file(
917                                Array(
918                                        'search_form'   => 'search.tpl'
919                                )
920                        );
921                        $p->set_block('search_form','search','search');
922                        $p->set_block('search_form','search_list_header','search_list_header');
923                        $p->set_block('search_form','search_list','search_list');
924                        $p->set_block('search_form','search_list_footer','search_list_footer');
925
926
927$script='';
928
929               
930
931                        if($matches > 0)
932                        {
933                                $p->parse('rows','search_list_header',True);
934                        }
935
936//if($info){
937                        foreach($event  as $id => $data)
938                        {
939
940
941                                $datetime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset;
942
943
944
945
946                                $info = array(
947                                        'tr_color'      => $GLOBALS['phpgw']->nextmatchs->alternate_row_color(),
948                                        'date'          => $GLOBALS['phpgw']->common->show_date($datetime),
949'id'    => $data['id'],
950                                        'name'         => $data['name'],
951                                        'description'         => $data['short_description'],
952                                        'category'         => $data['cat_name'],
953                                        'picture_src' => $data['picture_src'],
954                                        'administrador'=>$data['administrador'],
955                                        'email'=>$data['email'],
956                                        'owner'=>$data['owner'],
957
958
959
960'accionmodificar'       =>'index.php?menuaction=resources.uiresources.edit&id='. $data['id'],
961'accionlistar'  =>'index.php?menuaction=resources.uiresources.search2&id='.  $data['name'],
962                               
963'accionborrar'  =>'index.php?menuaction=resources.uiresources.delete&id='. $data['id'],
964'accionreservar'        =>'index.php?menuaction=calendar.uicalendar.add&location='. $data['name']
965                                );
966
967
968
969//'accionagregar'       =>'index.php?menuaction=resources.uiresources.edit&parent='. $data['id']
970$p->set_var($info);
971                                $p->set_var($data);
972                                $p->parse('rows','search_list',True);
973                        }
974//      }
975                        if($matches > 0)
976                        {
977                                $p->parse('rows','search_list_footer',True);
978                        }
979
980                        $p->pparse('out','search');
981                }
982
983
984function get_event_ids($search)
985                {
986//echo "tamannn".count($search)."  ".$search[0];
987
988$from ="";
989//if (isset($_REQUEST['id'])){
990
991        //              $from = ' and t1.res_id='.$_REQUEST['id'];
992        //              }
993
994                        $sql = "select t1.*,t2.cat_name from   phpgw_resources t1 ,phpgw_categories t2 where t1.cat_id=t2.cat_id and t1.name !='n/a'"
995                                        . $from;
996                                        //.$search;
997                                        //. 'WHERE (phpgw_cal_user.res_id = phpgw_cal.res_id) '
998                                        //. $where . $extra;
999
1000
1001//echo "FULL SQL : ".$sql."<br>\n";
1002
1003
1004                        if($this->debug)
1005                        {
1006                                echo "FULL SQL : ".$sql."<br>\n";
1007                        }
1008
1009 //$resultado=pg_query($this->bo->connect(),$sql) or die("Error al mostrar");
1010
1011
1012$GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);
1013while( $GLOBALS['phpgw']->db->next_record() )
1014                        {
1015                        //     
1016
1017$valorfechaini=$this->bo->time2array($GLOBALS['phpgw']->db->f('res_start'),$alarm = 0);
1018$ini=$valorfechaini['mday']."/".$valorfechaini['month']."/".$valorfechaini['year'];
1019
1020$valorfechaend=$this->bo->time2array($GLOBALS['phpgw']->db->f('res_end'),$alarm = 0);
1021$end=$valorfechaend['mday']."/".$valorfechaend['month']."/".$valorfechaend['year'];
1022
1023$valorfechaend2=$this->bo->time2array($GLOBALS['phpgw']->db->f('res_modified'),$alarm = 0);
1024$end2=$valorfechaend2['mday']."/".$valorfechaend2['month']."/".$valorfechaend2['year'];
1025
1026$imagen2="";
1027if($GLOBALS['phpgw']->db->f('picture_src')!=""){
1028$imagen2="<img src='".$GLOBALS['phpgw_info']['server']['webserver_url']."/resources/templates/default/images/resource_icons/".$GLOBALS['phpgw']->db->f('picture_src')."'>";
1029}
1030
1031
1032
1033$retval[] =  array(
1034
1035'id'    => $GLOBALS['phpgw']->db->f('res_id'),
1036                                        'name'         => $GLOBALS['phpgw']->db->f('name'),
1037                                        'description'         => $GLOBALS['phpgw']->db->f('short_description'),
1038                                        'category'         => $GLOBALS['phpgw']->db->f('cat_name'),
1039                                        'picture_src' => $imagen2,
1040                                        'administrador'=>$GLOBALS['phpgw']->db->f('administrador'),
1041                                        'location'=>$GLOBALS['phpgw']->db->f('location'),
1042                                        'email'=>$GLOBALS['phpgw']->db->f('email'),
1043                                        'owner'=>$GLOBALS['phpgw']->db->f('owner')
1044
1045                                       
1046                                );
1047
1048
1049                        }
1050               
1051
1052
1053                       
1054                        return $retval;
1055                }
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067function update()
1068                {
1069
1070
1071
1072#  $vars = get_defined_vars(); 
1073#   print_r($vars);
1074/*foreach($_POST as $k=>$v){
1075$$k=$v;
1076echo $$k."<br>";
1077}
1078foreach($_POST as $nombre_campo => $valor){
1079   $asignacion = "\$" . $nombre_campo . "='" . $valor . "';";
1080   echo $asignacion."<br>";
1081} */
1082
1083
1084
1085
1086
1087
1088
1089unset($GLOBALS['phpgw_info']['flags']['noheader']);
1090                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
1091                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['resources']['title'].' - '.lang('Search Results');
1092                        $GLOBALS['phpgw']->common->phpgw_header();
1093
1094                        $error = '';
1095
1096                        $matches = 0;
1097
1098
1099
1100
1101
1102list($dia,$mes,$ano)=split("/",$_POST['start']['str']);
1103
1104        $starttime = $this->bo->maketime2($_POST['start']['hour'],$_POST['start']['min'],0,$dia,$mes,$ano,$_POST['start']['ampm']) - $GLOBALS['phpgw']->datetime->tz_offset;
1105//echo $starttime;
1106
1107list($dia2,$mes2,$ano2)=split("/",$_POST['end']['str']);
1108
1109        $endtime = $this->bo->maketime2($_POST['end']['hour'],$_POST['end']['min'],0,$dia2,$mes2,$ano2,$_POST['end']['ampm']) - $GLOBALS['phpgw']->datetime->tz_offset;
1110//echo "gggg".$_POST['end2']['month'];
1111if($_POST['end2']['str']['month']>0){
1112list($dia3,$mes3,$ano3)=split("/",$_POST['end2']['str']);
1113        $endtime2 = $this->bo->maketime2($_POST['end2']['hour'],$_POST['end2']['min'],0,$dia3,$mes3,$ano3,$_POST['end2']['ampm']) - $GLOBALS['phpgw']->datetime->tz_offset;
1114}else{
1115$endtime2=0;
1116}
1117 
1118                        //$starttime = $this->bo->maketime2($starthora,$startmin,0,$startfecha) - $GLOBALS['phpgw']->datetime->tz_offset;
1119//echo "kkkk3".$_POST['exec']['accesso'];
1120if($_REQUEST['resources']['parent']==""){
1121$parent=0;
1122
1123}else{
1124$parent=$_REQUEST['resources']['parent'];
1125
1126}
1127$resources=Array(
1128name=>$_POST['resources']['name'],
1129descripction=>$_POST['resources']['description']
1130);
1131$valores="&name=".$_POST['resources']['name']."&description=".$_POST['resources']['description']."&category=".$_POST['resources']['category']."&cantidad=".$_POST['resources']['cantidad']."&email=".$_POST['resources']['email']."&administrador=".$_POST['resources']['administrador']."&location=".$_POST['resources']['location']."";
1132
1133//$GLOBALS['phpgw']->redirect($this->page($valores,''));
1134if($_POST['resources']['name']==""){
1135$GLOBALS['phpgw']->redirect($this->page('edit&error=44'.$valores,''));
1136}
1137if($_POST['resources']['location']==""){
1138$GLOBALS['phpgw']->redirect($this->page('edit&error=45'.$valores,''));
1139}
1140if($_POST['resources']['cantidad']==""){
1141$GLOBALS['phpgw']->redirect($this->page('edit&error=46'.$valores,''));
1142}
1143if($_POST['resources']['email']==""){
1144$GLOBALS['phpgw']->redirect($this->page('edit&error=47'.$valores,''));
1145}
1146if($_POST['resources']['description']==""){
1147$GLOBALS['phpgw']->redirect($this->page('edit&error=48'.$valores,''));
1148}
1149
1150/*ExecMethod('resources.uiresources.edit',                      Array(
1151                                                        'cd'            => 13,
1152                                                        'readsess'      => 1
1153                                                )
1154                                        );*/
1155
1156//$parms['errormsg']=$GLOBALS['phpgw']->common->check_code(13);
1157//echo $GLOBALS['phpgw']->common->check_code(13);
1158//ExecMethod('resources.uiresources.index',$parms);
1159//      $GLOBALS['phpgw']->common->phpgw_exit();
1160
1161                //      $endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset;
1162if(isset($_POST['resources']['id'])&&$_POST['resources']['id']>0){
1163                        $sql = "update  phpgw_resources set  name='".$_POST['resources']['name']."',short_description='".$_POST['resources']['description']."',cat_id=".$_POST['resources']['category'].",quantity=".$_POST['resources']['cantidad'].",location='".$_POST['resources']['location']."',picture_src='".$_POST['resources']['picture_src']."',  administrador='". $this->get_account_name($_POST['resources']['administrador'],'gecos')."',email='".$_POST['resources']['email']."',owner=".$_POST['resources']['owner']."  where res_id='".$_POST['resources']['id']."'";
1164}else{
1165                        $sql = "insert into  phpgw_resources (name,short_description,cat_id,quantity,location,picture_src,  administrador,email,owner)
1166values ('".$_POST['resources']['name']."','".$_POST['resources']['description']."',".$_POST['resources']['category'].",".$_POST['resources']['cantidad'].",'". $this->get_account_name($_POST['resources']['administrador'],'gecos')."','".$_POST['resources']['picture_src']."','".$_POST['resources']['administrador']."','".$_POST['resources']['email']."',".$_POST['resources']['owner'].")";
1167
1168
1169
1170 
1171}
1172
1173$GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);   
1174$GLOBALS['phpgw']->redirect($this->page('edit&error=14',''));
1175
1176
1177return "";
1178                }
1179
1180
1181
1182
1183function get_account_name($account_id,$valor)
1184                {
1185                        $acct_type = $this->get_type($account_id);
1186
1187                        /* jakjr: using justthese with ldap_search */
1188                        //$justthese = array("cn","uid","givenname","sn","gecos");
1189
1190                        /* search the dn for the given uid */
1191
1192$justthese = array("uidnumber",  "cn",  "mail","gecos","dn");
1193                        //      $sri = @ldap_search($this->ds, "ou=usuarios,ou=cnti,dc=gob,dc=ve", ("(&(sn=*)(mail=*@*)(structuralObjectClass=inetOrgPerson)(deliveryMode=virtual))"), $justthese);
1194
1195                        if(($acct_type == 'g') && $this->group_context)
1196                        {
1197                                $sri = @ldap_search($this->ds, $this->group_context, '(gidnumber=' . (int)$account_id . ')', $justthese);
1198                        }
1199                        else
1200                        {
1201                                $sri = @ldap_search($this->ds, $this->user_context, '(uidnumber=' . (int)$account_id . ')', $justthese);
1202                        }
1203
1204//echo $this->ds.",". $this->user_context.",". '(uidnumber=' . (int)$account_id . ')'.",". $justthese;
1205                        if(!$sri)
1206                                return False;
1207                        $allValues = ldap_get_entries($this->ds, $sri);
1208$retorna="";
1209                        if($acct_type =='g')
1210                        {
1211                                if($valor=='gecos') {
1212                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['gecos'][0],'utf-8');
1213                                }
1214                                if($valor=='uidnumber') {
1215                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['uidnumber'][0],'utf-8');
1216                                }
1217                                if($valor=='cn') {
1218                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['cn'][0],'utf-8');
1219                                }
1220
1221                                if($valor=='mail') {
1222                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['mail'][0],'utf-8');
1223                                }
1224                                if($valor=='dn') {
1225                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['dn'][0],'utf-8');
1226                                }
1227                               
1228                        }
1229                        else
1230                        {
1231                                if($valor=='gecos') {
1232                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['gecos'][0],'utf-8');
1233                                }
1234                                if($valor=='uidnumber') {
1235                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['uidnumber'][0],'utf-8');
1236                                }
1237                                if($valor=='cn') {
1238                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['cn'][0],'utf-8');
1239                                }
1240
1241                                if($valor=='mail') {
1242                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['mail'][0],'utf-8');
1243                                }
1244                                if($valor=='dn') {
1245                                        $retorna=$GLOBALS['phpgw']->translation->convert($allValues[0]['dn'][0],'utf-8');
1246                                }
1247                               
1248
1249
1250
1251                        }
1252                        return $retorna;
1253                }
1254
1255
1256
1257
1258
1259function get_type($account_id)
1260                {
1261                        $allValues = array();
1262                        /* jakjr: using justthese with ldap_search */
1263                        $sri = @ldap_search($this->ds, $this->user_context, '(&(uidnumber=' . (int)$account_id . ')(phpgwaccounttype=u))', array("phpgwaccounttype"));
1264                        if(!$sri)
1265                                return False;
1266                        $allValues = ldap_get_entries($this->ds, $sri);
1267
1268                        if ($allValues[0]['phpgwaccounttype'][0])
1269                        {
1270                                return $allValues[0]['phpgwaccounttype'][0];
1271                        }
1272
1273                        $allValues = array();
1274                        /* jakjr: using justthese with ldap_search */
1275                        $sri = @ldap_search($this->ds, $this->group_context, '(&(gidnumber=' . (int)$account_id . ')(phpgwaccounttype=g))', array("phpgwaccounttype"));
1276                        if(!$sri)
1277                                return False;
1278                        $allValues = ldap_get_entries($this->ds, $sri);
1279
1280                        if ($allValues[0]['phpgwaccounttype'][0])
1281                        {
1282                                return $allValues[0]['phpgwaccounttype'][0];
1283                        }
1284                        return False;
1285                }
1286
1287
1288
1289
1290
1291
1292
1293function select($id)
1294                {
1295
1296
1297                        $sql = "select * from   phpgw_resources where res_id='".$id."'";
1298
1299$GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);   
1300
1301if( $GLOBALS['phpgw']->db->next_record() )
1302                        {
1303
1304
1305
1306
1307$retval =  array(
1308                                        'id'    => $GLOBALS['phpgw']->db->f('res_id'),
1309                                        'name'         => $GLOBALS['phpgw']->db->f('name'),
1310                                        'descripcion'         => $GLOBALS['phpgw']->db->f('short_description'),
1311                                        'category'         => $GLOBALS['phpgw']->db->f('cat_id'),
1312                                        'picture_src' => $GLOBALS['phpgw']->db->f('picture_src'),
1313                                        'administrador'=>$GLOBALS['phpgw']->db->f('administrador'),
1314                                        'email'=>$GLOBALS['phpgw']->db->f('email'),
1315                                        'location'=>$GLOBALS['phpgw']->db->f('location'),
1316                                        'cantidad'=>$GLOBALS['phpgw']->db->f('quantity'),
1317                                        'owner'=>$GLOBALS['phpgw']->db->f('owner')
1318                                );
1319
1320                        }
1321               
1322//echo "iddd".$id."  56666 ".$retval['id'];
1323
1324
1325return $retval;
1326               
1327                }
1328
1329
1330function select_init()
1331                {
1332
1333$id=0;
1334if(isset($_REQUEST['resources[id]'])){
1335$id=$_REQUEST['resources[id]'];
1336}
1337
1338$name="";
1339if(isset($_REQUEST['name'])){
1340$name=$_REQUEST['name'];
1341}
1342
1343
1344$description="";
1345if(isset($_REQUEST['description'])){
1346$description=$_REQUEST['description'];
1347}
1348
1349$catgory=0;
1350if(isset($_REQUEST['category'])){
1351$category=$_REQUEST['category'];
1352}
1353$administrador="";
1354if(isset($_REQUEST['administrador'])){
1355$administrador=$_REQUEST['administrador'];
1356}
1357$email="";
1358if(isset($_REQUEST['email'])){
1359$email=$_REQUEST['email'];
1360}
1361$cantidad=0;
1362if(isset($_REQUEST['cantidad'])){
1363$cantidad=$_REQUEST['cantidad'];
1364}
1365
1366$location="";
1367if(isset($_REQUEST['location'])){
1368$location=$_REQUEST['location'];
1369}
1370                       
1371$retval =  array(
1372
1373                                        'id'    => $id,
1374                                        'name'         => $name,
1375                                        'descripcion'         => $description,
1376                                        'category'         => $category,
1377                                        'picture_src' => 'generic.png',
1378                                        'administrador'=>$administrador,
1379                                        'location'=>$location,
1380                                        'email'=>$email,
1381                                        'cantidad'=>$cantidad,
1382                                        'owner'=>$this->bo->owner
1383
1384
1385                                       
1386                                );
1387
1388
1389
1390
1391
1392
1393                       
1394
1395
1396return $retval;
1397               
1398                }
1399
1400
1401function delete()
1402                {
1403
1404
1405
1406#  $vars = get_defined_vars(); 
1407#   print_r($vars);
1408/*foreach($_POST as $k=>$v){
1409$$k=$v;
1410echo $$k."<br>";
1411}
1412foreach($_POST as $nombre_campo => $valor){
1413   $asignacion = "\$" . $nombre_campo . "='" . $valor . "';";
1414   echo $asignacion."<br>";
1415} */
1416
1417
1418
1419
1420unset($GLOBALS['phpgw_info']['flags']['noheader']);
1421                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
1422                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['infolog']['title'].' - '.lang('Search Results');
1423                        $GLOBALS['phpgw']->common->phpgw_header();
1424
1425                        $error = '';
1426
1427                        $matches = 0;
1428
1429
1430
1431
1432                //      $endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset;
1433
1434                        $sql = "delete from  phpgw_resources   where res_id='".$_GET['id']."'";
1435
1436
1437$GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);   
1438
1439$params['errormsg'] = '';
1440$GLOBALS['phpgw']->redirect($this->page('search',$params));
1441return "";
1442                }
1443
1444
1445 function translate($key,$vars=false, $not_found='*' )
1446          {
1447            if ($this->async)
1448              return $GLOBALS['phpgw']->translation->translate_async($key, $vars);
1449            return lang($key, $vars);
1450          }
1451
1452function maketime($time)
1453                {
1454                        return mktime(intval($time['hour']),intval($time['min']),intval($time['sec']),intval($time['month']),intval($time['mday']),intval($time['year']));
1455                }
1456
1457function search2()
1458                {
1459
1460//print_r($_REQUEST);
1461$this->today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime);
1462
1463
1464
1465                        $jscal = CreateObject('phpgwapi.jscalendar');   // before phpgw_header() !!!
1466
1467                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
1468                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
1469                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['resources']['title'].' - '.lang('Search Results');
1470                        $GLOBALS['phpgw']->common->phpgw_header();
1471
1472                        $error = '';
1473
1474
1475
1476                        $matches = 0;
1477
1478//echo "aaaaa".$GLOBALS['phpgw']->common->show_date(1288884600);
1479
1480//echo "aaaaa".$GLOBALS['phpgw']->common->show_date(1288886400);
1481
1482if (isset($_REQUEST['fecha'])){
1483list($dia,$mes,$ano)=split("/",$_REQUEST['fecha']);
1484if (isset($_REQUEST['fecha2'])){
1485list($dia2,$mes2,$ano2)=split("/",$_REQUEST['fecha2']);
1486}else{
1487        list($dia2,$mes2,$ano2)=split("/",$_REQUEST['fecha']);
1488       
1489}
1490if(isset($_REQUEST['hora'])){
1491list($horai,$minutoi,$horaf,$minutof)=split(":",$_REQUEST['hora']);
1492}else{
1493        $horai=0;
1494        $minutoi=0;
1495        $horaf=23;
1496        $minutof=59;
1497}
1498        $starttimea = $this->bo->maketime2(0,0,0,$dia,$mes,$ano,'am') - $GLOBALS['phpgw']->datetime->tz_offset;
1499
1500
1501}else{
1502        $localtime = $GLOBALS['phpgw']->datetime->users_localtime;
1503        $ano = date('Y',$localtime);
1504        $mes = date('m',$localtime);
1505        $dia = date('d',$localtime);                                   
1506        $ano2 = date('Y',$localtime);
1507        $mes2 = date('m',$localtime);
1508        $dia2 = date('d',$localtime);
1509        $horai=0;
1510        $minutoi=0;
1511        $horaf=23;
1512        $minutof=59;
1513
1514//$starttime = $this->bo->maketime2(0,0,0,$dia,$mes,$ano,'am') - $GLOBALS['phpgw']->datetime->tz_offset;
1515///echo $starttime;
1516//$starttime2 = $this->bo->maketime2(23,59,59,$dia,$mes,$ano,'pm') - $GLOBALS['phpgw']->datetime->tz_offset;
1517///echo $starttime2;
1518
1519}
1520
1521
1522
1523$pm='pm';
1524if($horaf<12){
1525        $pm='am';
1526}else{
1527        $horaf=$horaf-12;
1528}
1529$am='am';
1530if($horai>11){
1531        $am='pm';
1532        $horai=$horai-12;
1533       
1534}
1535
1536
1537//echo $horai."  <br>  ".$starttimea."<br>".$horaf;
1538        $starttime = $this->bo->maketime2($horai,$minutoi,0,$dia,$mes,$ano,$am) - $GLOBALS['phpgw']->datetime->tz_offset;
1539//echo "fff".$starttime;
1540$starttime2 = $this->bo->maketime2($horaf,$minutof,59,$dia2,$mes2,$ano2,$pm) - $GLOBALS['phpgw']->datetime->tz_offset;
1541///echo $starttime2;
1542                //$event = $this->bo->read_entry($res_id);     
1543$location='';
1544if($_GET['id']!=''){
1545$location=$_GET['id'];}else{
1546$location='n/a';}
1547
1548/*$eventtt=$this->bo->store_to_cache(
1549                                Array(
1550                                        'syear'  => $ano,
1551                                        'smonth' => $mes,
1552                                        'sday'   => $dia,
1553                                'shour'   => $horai,
1554                                'smin'   => $minutoi,
1555                                        'eyear'  => $ano,
1556                                        'emonth' => $mes,
1557                                        'eday'   => $dia,
1558                                'fhour'   => $horaf,
1559                                'fmin'   => $minutof,
1560'location'      =>      $location
1561                                )
1562                        );      */
1563                $date_to_eval = sprintf("%04d%02d%02d",$ano,$mes,$dia);
1564               
1565        //      echo "date _to _eval".$date_to_eval."<br>";
1566//$events = $this->bo->cached_events[$date_to_eval];//(5,23,0,22,10,2010)
1567$events=$this->bo->overlap($starttime,$starttime2,Array(),0,0,'False',$location);
1568                                print_debug('Date',$date_to_eval);
1569                                print_debug('Count',count($events));
1570//echo "llll<br>".'Date'.$date_to_eval;
1571//echo "llll<br>".'Count'.count($events);
1572if(count($events)>0){
1573                                foreach($events as $event)
1574                                {
1575                                        if ($this->bo->rejected_no_show($event))
1576                                        {
1577                                                continue;       // user does not want to see rejected events
1578                                        }
1579                                        if ($event['recur_type'])       // calculate start- + end-datetime for recuring events
1580                                        {
1581                                                $this->bo->set_recur_date($event,$date_to_eval);
1582                                        }
1583                                        //$events_to_show[] = array(
1584                                        //      'starttime' => $this->bo->maketime($event['start']),
1585                                        //      'endtime'   => $this->bo->maketime($event['end']),
1586                                        //      'content'   => $this->link_to_entry($event,$mes,$dia,$ano)
1587                                        //);
1588
1589                                }
1590}
1591//echo "eeeevento".count($event)."<br>";
1592                        $date_to_eval = sprintf("%04d%02d%02d",$ano,$mes,$dia);
1593
1594//$event = $this->get_event_ids2($_REQUEST['id'],$starttime,$starttime2);
1595
1596
1597                        //$event_ids = $this->bo->search_keywords($_POST['keywords']);
1598
1599                       
1600                        $matches = count($event);
1601
1602//echo "matches" . $matches."<br>";
1603
1604                        if ($matches == 1)
1605                        {
1606                                $quantity = lang('1 match found').'.';
1607                        }
1608                        elseif ($matches > 0)
1609                        {
1610                                $quantity = lang('%1 matches found',$matches).'.';
1611                        }
1612                        else
1613                        {
1614                                echo lang('no matches found')." para el ".$dia."/".$mes."/".$ano."  en la sala:".$location;
1615                               
1616                                //return;
1617                        }
1618
1619                        if ($matches > 0){
1620                        $p = $GLOBALS['phpgw']->template;
1621                        $p->set_file(
1622                                Array(
1623                                        'search_form'   => 'search2.tpl'
1624                                )
1625                        );
1626                       
1627                }else{
1628                        $p = $GLOBALS['phpgw']->template;
1629                        $p->set_file(
1630                                Array(
1631                                        'search_form'   => 'search3.tpl'
1632                                )
1633                        );
1634                }
1635                $p->set_block('search_form','search','search');
1636                        $p->set_block('search_form','search_list_header','search_list_header');
1637                        $p->set_block('search_form','search_list','search_list');
1638                        $p->set_block('search_form','search_list_footer','search_list_footer');
1639
1640$script='';
1641
1642               
1643
1644                        if($matches > 0)
1645                        {
1646                                $p->parse('rows','search_list_header',True);
1647                        }
1648
1649//if($info){
1650//echo $matches;
1651//for($i=0;$i<$matches;$i++)
1652                //      {
1653//echo "i".$i;
1654if(count($events)>0){
1655                        foreach($events  as $id => $data)
1656                        {
1657
1658//echo "<br>dataaaa".$data['title'];
1659//echo "<br>".$this->get_account_name($data['owner'],'gecos')."  ".$data['owner'];
1660                                $datetime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset;
1661
1662
1663
1664//echo "ffffffeeecha".$GLOBALS['phpgw']->common->show_date($data[$i]['datetime'])."     ".$data[$i]['start']."  ".$this->bo->maketime($data[$i]['start']);
1665//echo $data['location']."  .. ".$data['last_status']."  .. ".$data['is_public'];
1666if($data['public']==1){
1667        $descripcion=$data['description'];
1668        $name=$data['title'];
1669}else{
1670        $descripcion='-';
1671        $name='Privado';
1672}
1673$dueno=$this->get_account_name($data['owner'],'gecos');
1674                                $info = array(
1675                                        'tr_color'      => $GLOBALS['phpgw']->nextmatchs->alternate_row_color(),
1676                                        'date'          => $GLOBALS['phpgw']->common->show_date($datetime),
1677'id'    => $data['id'],
1678                                        'name'         => $name,
1679                                        'description'         => $descripcion,
1680                                        'location'         =>$data['location'],
1681                               
1682                                        'owner'=>$this->get_account_name($data['owner'],'gecos'),
1683                                        'fecha'=> $dia."/".$mes."/".$ano." <br>   ".$GLOBALS['phpgw']->common->show_hour($this->bo->maketime($data['start']))."-".$GLOBALS['phpgw']->common->show_hour($this->bo->maketime($data['end'])),
1684                                        'priority'=>'',
1685                                        'ispublic'=>$data['is_public'],
1686
1687'accionmodificar'       =>'index.php?menuaction=resources.uiresources.edit&id='. $data['id'],
1688'accionlistar'  =>'index.php?menuaction=resources.uiresources.search2&id='. $data['id'],
1689'accionborrar'  =>$data['id'],
1690'accionreservar'        =>'index.php?menuaction=calendar.uicalendar.add&location='. $data['id']
1691                                );
1692
1693
1694
1695//'accionagregar'       =>'index.php?menuaction=resources.uiresources.edit&parent='. $data['id']
1696$p->set_var($info);
1697                                $p->set_var($info);
1698                                $p->parse('rows','search_list',True);
1699                        }
1700//}
1701//      }
1702}
1703                        if($matches > 0)
1704                        {
1705                                $p->parse('rows','search_list_footer',True);
1706                        }
1707
1708                        $p->pparse('out','search');
1709                }
1710
1711               
1712       
1713               
1714               
1715               
1716        function search22()
1717                {
1718
1719//print_r($_REQUEST);
1720
1721                        $jscal = CreateObject('phpgwapi.jscalendar');   // before phpgw_header() !!!
1722
1723                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
1724                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
1725                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['resources']['title'].' - '.lang('Search Results');
1726                        $GLOBALS['phpgw']->common->phpgw_header();
1727
1728                        $error = '';
1729
1730
1731
1732                        $matches = 0;
1733
1734//echo "aaaaa".$GLOBALS['phpgw']->common->show_date(1288884600);
1735
1736//echo "aaaaa".$GLOBALS['phpgw']->common->show_date(1288886400);
1737if (isset($_REQUEST['fecha'])){
1738list($dia,$mes,$ano)=split("/",$_REQUEST['fecha']);
1739
1740        $starttime = $this->bo->maketime2(0,0,0,$dia,$mes,$ano,'am') - $GLOBALS['phpgw']->datetime->tz_offset;
1741///echo $starttime;
1742$starttime2 = $this->bo->maketime2(23,59,59,$dia,$mes,$ano,'pm') - $GLOBALS['phpgw']->datetime->tz_offset;
1743///echo $starttime2;
1744}
1745                //$event = $this->bo->read_entry($res_id);     
1746$event = $this->get_event_ids2($_REQUEST['id'],$starttime,$starttime2);
1747
1748
1749                        //$event_ids = $this->bo->search_keywords($_POST['keywords']);
1750
1751                       
1752                        $matches = count($event);
1753
1754//echo "matches" . $matches;
1755
1756                        if ($matches == 1)
1757                        {
1758                                $quantity = lang('1 match found').'.';
1759                        }
1760                        elseif ($matches > 0)
1761                        {
1762                                $quantity = lang('%1 matches found',$matches).'.';
1763                        }
1764                        else
1765                        {
1766                                echo lang('no matches found');
1767                                return;
1768                        }
1769
1770                        $p = $GLOBALS['phpgw']->template;
1771                        $p->set_file(
1772                                Array(
1773                                        'search_form'   => 'search2.tpl'
1774                                )
1775                        );
1776                        $p->set_block('search_form','search','search');
1777                        $p->set_block('search_form','search_list_header','search_list_header');
1778                        $p->set_block('search_form','search_list','search_list');
1779                        $p->set_block('search_form','search_list_footer','search_list_footer');
1780
1781
1782$script='';
1783
1784               
1785
1786                        if($matches > 0)
1787                        {
1788                                $p->parse('rows','search_list_header',True);
1789                        }
1790
1791//if($info){
1792                        foreach($event  as $id => $data)
1793                        {
1794
1795
1796                                $datetime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset;
1797
1798
1799
1800
1801                                $info = array(
1802                                        'tr_color'      => $GLOBALS['phpgw']->nextmatchs->alternate_row_color(),
1803                                        'date'          => $GLOBALS['phpgw']->common->show_date($datetime),
1804'id'    => $data['id'],
1805                                        'name'         => $data['name'],
1806                                        'description'         => $data['short_description'],
1807                                        'location'         =>$data['namelocation'],
1808                               
1809                                        'owner'=>$this->get_account_name($data['owner'],'gecos'),
1810                                        'fecha'=>$data['fech'],
1811                                        'priority'=>$data['priority'],
1812                                        'ispublic'=>$data['ispublic'],
1813
1814'accionmodificar'       =>'index.php?menuaction=resources.uiresources.edit&id='. $data['id'],
1815'accionlistar'  =>'index.php?menuaction=resources.uiresources.search2&id='. $data['id'],
1816'accionborrar'  =>$data['id'],
1817'accionreservar'        =>'index.php?menuaction=calendar.uicalendar.add&location='. $data['id']
1818                                );
1819
1820
1821
1822//'accionagregar'       =>'index.php?menuaction=resources.uiresources.edit&parent='. $data['id']
1823$p->set_var($info);
1824                                $p->set_var($data);
1825                                $p->parse('rows','search_list',True);
1826                        }
1827//      }
1828                        if($matches > 0)
1829                        {
1830                                $p->parse('rows','search_list_footer',True);
1831                        }
1832
1833                        $p->pparse('out','search');
1834                }
1835
1836       
1837function get_event_ids2($idd,$starttime,$starttime2)
1838                {
1839
1840
1841
1842$from ="";
1843$from ="";
1844if (isset($idd)){
1845
1846                        $from = ' and t1.location=\''.$idd.'\' ';
1847                        }
1848
1849if (isset($starttime)){
1850
1851                        $from =$from .' and t1.datetime>=\''.$starttime.'\'';
1852if (isset($starttime2)){
1853
1854                        $from =$from .'  and t1.datetime<=\''.$starttime2.'\' ';
1855}
1856                        }
1857
1858                        $sql = 'select t1.cal_id ,t1.owner,t1.groups,t1.datetime,t1.edatetime,
1859t1.priority ,t1.cal_type, t1.is_public ,
1860t1.title,t1.description,t1.location ,
1861t2.list_descripcion as publico,t3.list_descripcion as priority ,t4.name as namelocation from   phpgw_cal  t1, phpgw_listas t2, phpgw_listas t3 ,phpgw_resources t4
1862where t1.is_public =t2.list_id and t2.list_name=\'visibility\'
1863and t1.priority=t3.list_id and t3.list_name=\'priority\'
1864and t1.location=t4.name '
1865                                        . $from. "order by t1.datetime desc ";
1866                                        //.$search;
1867                                        //. 'WHERE (phpgw_cal_user.res_id = phpgw_cal.res_id) '
1868                                        //. $where . $extra;
1869
1870
1871//echo $sql;
1872
1873
1874
1875                        if($this->debug)
1876                        {
1877                                echo "FULL SQL : ".$sql."<br>\n";
1878                        }
1879
1880 //$resultado=pg_query($this->bo->connect(),$sql) or die("Error al mostrar");
1881
1882
1883$GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);
1884while( $GLOBALS['phpgw']->db->next_record() )
1885                        {
1886                        //     
1887
1888//$valorfechaini=$this->bo->time2array($GLOBALS['phpgw']->db->f('datetime'),$alarm = 0);
1889//$ini=$valorfechaini['mday']."/".$valorfechaini['month']."/".$valorfechaini['year'];
1890$ini=$GLOBALS['phpgw']->common->show_date($GLOBALS['phpgw']->db->f('datetime'))."-".$GLOBALS['phpgw']->common->show_date($GLOBALS['phpgw']->db->f('edatetime'));
1891
1892
1893
1894$retval[] =  array(
1895
1896'id'    => $GLOBALS['phpgw']->db->f('cat_id'),
1897                                        'name'         => $GLOBALS['phpgw']->db->f('title'),
1898                                        'description'         => $GLOBALS['phpgw']->db->f('description'),                                       
1899                                        'location'=>$GLOBALS['phpgw']->db->f('namelocation'),
1900                                        'groups'=>$GLOBALS['phpgw']->db->f('groups'),
1901                                        'owner'=>$this->get_account_name($GLOBALS['phpgw']->db->f('owner'),'gecos'),
1902                                        'fecha'=>$ini,
1903                                        'priority'=>$GLOBALS['phpgw']->db->f('priority'),
1904                                        'ispublic'=>$GLOBALS['phpgw']->db->f('publico')
1905
1906                                       
1907                                );
1908
1909                        }
1910               
1911
1912
1913                       
1914                        return $retval;
1915                }
1916function link_to_entry($event,$month,$day,$year)
1917                {
1918                        $str = '';
1919                        $is_private = !$event['public'] && !$this->bo->check_perms(PHPGW_ACL_READ,$event);
1920                        $viewable = !$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_READ,$event);
1921
1922                        $starttime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset;
1923                        $endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset;
1924                        $rawdate = mktime(0,0,0,$month,$day,$year);
1925                        $rawdate_offset = $rawdate - $GLOBALS['phpgw']->datetime->tz_offset;
1926                        $nextday = mktime(0,0,0,$month,$day + 1,$year) - $GLOBALS['phpgw']->datetime->tz_offset;
1927                        if ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') && $starttime == $endtime)
1928                        {
1929                                $time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat);
1930                        }
1931                        elseif ($starttime <= $rawdate_offset && $endtime >= $nextday - 60)
1932                        {
1933                                $time = '[ '.lang('All Day').' ]';
1934                        }
1935                        elseif ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') || $starttime != $endtime)
1936                        {
1937                                if($starttime < $rawdate_offset && $event['recur_type'] == MCAL_RECUR_NONE)
1938                                {
1939                                        $start_time = $GLOBALS['phpgw']->common->show_date($rawdate_offset,$this->bo->users_timeformat);
1940                                }
1941                                else
1942                                {
1943                                        $start_time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat);
1944                                }
1945
1946                                if($endtime >= ($rawdate_offset + 86400))
1947                                {
1948                                        $end_time = $GLOBALS['phpgw']->common->show_date(mktime(23,59,59,$month,$day,$year) - $GLOBALS['phpgw']->datetime->tz_offset,$this->bo->users_timeformat);
1949                                }
1950                                else
1951                                {
1952                                        $end_time = $GLOBALS['phpgw']->common->show_date($endtime,$this->bo->users_timeformat);
1953                                }
1954                                $time = $start_time.'-'.$end_time;
1955                        }
1956                        else
1957                        {
1958                                $time = '';
1959                        }
1960                       
1961                        $texttitle = $texttime = $textdesc = $textlocation = $textstatus = '';
1962
1963                       
1964                       
1965                        if(!$is_private)
1966                        {
1967                                //$text .= $this->bo->display_status($event['users_status']);
1968                               
1969                                // split text for better display by templates, also see $texttime $texttitle $textdesc $textlocation   
1970                                $textstatus=$this->bo->display_status($event['users_status']);
1971                               
1972                        }
1973
1974                        /*
1975                        $text = '<nobr>&nbsp;'.$time.'&nbsp;</nobr> '.$this->bo->get_short_field($event,$is_private,'title').$text.
1976                                (!$is_private && $event['description'] ? ': <i>'.$this->bo->get_short_field($event,$is_private,'description').'</i>':'').
1977                                $GLOBALS['phpgw']->browser->br;
1978                        */
1979                       
1980                        $texttime=$time;
1981                        $texttitle=$this->bo->get_short_field($event,$is_private,'title');
1982                        $textdesc=(!$is_private && $event['description'] ? $this->bo->get_short_field($event,$is_private,'description'):'');
1983                        // added $textlocation but this must be activated in the actual pict_link.tpl file of the used template set
1984                        $textlocation=$this->bo->get_short_field($event,$is_private,'location');
1985
1986                        if ($viewable)
1987                        {
1988                                $date = sprintf('%04d%02d%02d',$year,$month,$day);
1989                                $this->link_tpl->set_var('link_link',$this->page('view','&cal_id='.$event['id'].'&date='.$date));
1990                                $this->link_tpl->set_var('lang_view',lang('View this entry'));
1991                                $this->link_tpl->set_var('desc', $textdesc);
1992                                $this->link_tpl->set_var('location', $textlocation);
1993                                $this->link_tpl->parse('picture','link_open',True);
1994                        }
1995                        if (!$is_private)
1996                        {
1997                                if($event['priority'] == 3)
1998                                {
1999                                        $picture[] = Array(
2000                                                'pict'  => $GLOBALS['phpgw']->common->image('calendar','high'),
2001                                                'width' => 16,
2002                                                'height'=> 16,
2003                                                'title' => lang('high priority')
2004                                        );
2005                                }
2006                                if($event['recur_type'] == MCAL_RECUR_NONE)
2007                                {
2008                                        $picture[] = Array(
2009                                                'pict'  => $GLOBALS['phpgw']->common->image('calendar','circle'),
2010                                                'width' => 9,
2011                                                'height'=> 9,
2012                                                'title' => lang('single event')
2013                                        );
2014                                }
2015                                else
2016                                {
2017                                        $picture[] = Array(
2018                                                'pict'  => $GLOBALS['phpgw']->common->image('calendar','recur'),
2019                                                'width' => 12,
2020                                                'height'=> 12,
2021                                                'title' => lang('recurring event')
2022                                        );
2023                                }
2024                        }
2025                       
2026                        if($event['public'] == 0)
2027                        {
2028                                $picture[] = Array(
2029                                        'pict'  => $GLOBALS['phpgw']->common->image('calendar','private'),
2030                                        'width' => 13,
2031                                        'height'=> 13,
2032                                        'title' => lang('private')
2033                                );
2034                        }
2035                /**     if(@isset($event['alarm']) && count($event['alarm']) >= 1 && !$is_private)
2036                        {
2037                                // if the alarm is to go off the day before the event
2038                                // the icon does not show up because of 'alarm_today'
2039                                // - TOM
2040                                if($this->bo->alarm_today($event,$rawdate_offset,$starttime))
2041                                {
2042                                        $picture[] = Array(
2043                                                'pict'  => $GLOBALS['phpgw']->common->image('calendar','alarm'),
2044                                                'width' => 13,
2045                                                'height'=> 13,
2046                                                'title' => lang('alarm')
2047                                        );
2048                                }
2049                        }*/
2050
2051                        $description = $this->bo->get_short_field($event,$is_private,'description');
2052                        for($i=0;$i<count($picture);$i++)
2053                        {
2054                                $var = Array(
2055                                        'pic_image' => $picture[$i]['pict'],
2056                                        'width'     => $picture[$i]['width'],
2057                                        'height'    => $picture[$i]['height'],
2058                                        'title'     => $picture[$i]['title']
2059                                );
2060                                $this->output_template_array($this->link_tpl,'picture','pict',$var);
2061                        }
2062                        if ($texttitle)
2063                        {
2064                                $var = Array(
2065                        //              'text' => $text,
2066                                        'time'=> $texttime,
2067                                        'title'=> $texttitle,
2068                                        'users_status'=>$textstatus,
2069                                        'desc'=> $textdesc,
2070                                        'location'=> "<br><b>Local:</b> ".$textlocation
2071                                );
2072                                $this->output_template_array($this->link_tpl,'picture','link_text',$var);
2073                        }
2074
2075                        if ($viewable)
2076                        {
2077                                $this->link_tpl->parse('picture','link_close',True);
2078                        }
2079                        $str = $this->link_tpl->fp('out','link_pict');
2080                        $this->link_tpl->set_var('picture','');
2081                        $this->link_tpl->set_var('out','');
2082//                      unset($p);
2083                        return $str;
2084                }
2085
2086
2087
2088}
2089
2090?>
Note: See TracBrowser for help on using the repository browser.