Changeset 5741


Ignore:
Timestamp:
03/16/12 15:02:14 (12 years ago)
Author:
natan
Message:

Ticket #2434 - Desenvolvimento do backend de suporte a excessoes nas repeticoes

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoCalendar/setup/setup.inc.php

    r5715 r5741  
    1313        $setup_info['expressoCalendar']['title']        = 'Expresso Calendar'; 
    1414        /* Ao incrementar versão, não esquecer de declarar função do tables_update.inc.php*/ 
    15         $setup_info['expressoCalendar']['version']      = '1.002'; 
     15        $setup_info['expressoCalendar']['version']      = '1.003'; 
    1616        $setup_info['expressoCalendar']['app_order']    = 10; 
    1717         
  • trunk/expressoCalendar/setup/tables_current.inc.php

    r5715 r5741  
    229229                'bysetpos' => array(  'type' => 'varchar','precision' => '50', 'nullable' => True), 
    230230                'wkst' => array(  'type' => 'varchar','precision' => '50', 'nullable' => True), 
     231                'exceptions' => array(  'type' => 'varchar','precision' => '50', 'nullable' => True), 
    231232                'interval' => array(  'type' => 'int', 'precision' => '8', 'nullable' => True) 
    232233            ), 
     
    254255                'id' => array( 'type' => 'auto', 'nullable' => False), 
    255256                'occurrence' => array(  'type' => 'bigint','precision' => '16', 'nullable' => False), 
    256                 'repeat_id' => array(  'type' => 'int', 'precision' => '8', 'nullable' => False) 
     257                'exception' => array(  'type' => 'smallint','precision' => '1', 'nullable' => False), 
     258                'repeat_id' => array(  'type' => 'int', 'precision' => '8', 'nullable' => False) 
    257259            ), 
    258260 
  • trunk/expressoCalendar/setup/tables_update.inc.php

    r5715 r5741  
    7070                ); 
    7171 
    72                 $oProc->query("ALTER TABLE calendar_repeat_occurrence ADD CONSTRAINT fk_calendar_repeat_to_calendar_repeat_occurrence FOREIGN KEY (repeat_id) REFERENCES calendar_repeat (id) MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE;");       
     72                $oProc->query("ALTER TABLE calendar_participant ADD COLUMN receive_notification smallint not null DEFAULT 1 ");  
    7373 
    7474                $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.002'; 
    7575        return $GLOBALS['setup_info']['expressoCalendar']['currentver']; 
    7676        } 
     77 
     78        $test[] = '1.002'; 
     79        function expressoCalendar_upgrade1_002() { 
     80 
     81                $oProc = $GLOBALS['phpgw_setup']->oProc; 
     82 
     83                $oProc->query("ALTER TABLE calendar_repeat_occurrence ADD COLUMN exception smallint DEFAULT 0;"); 
     84 
     85                $GLOBALS['setup_info']['expressoCalendar']['currentver'] = '1.003'; 
     86        return $GLOBALS['setup_info']['expressoCalendar']['currentver']; 
     87        } 
    7788?> 
  • trunk/prototype/config/repeatOccurrence.ini

    r5715 r5741  
    88occurrence = occurrence 
    99repeat = repeat_id 
     10exception = exception 
    1011id = id 
  • trunk/prototype/modules/calendar/interceptors/DBMapping.php

    r5737 r5741  
    120120 
    121121         $params = Controller::service('PostgreSQL')->execResultSql($sql); 
     122 
     123         $params = array_merge( $params, $occ ); 
    122124         $params = self::deepnessFindEvent( &$uri , &$params , &$criteria , $original); 
    123   
    124          $params = array_merge( $params, $occ ); 
    125125 
    126126         return false; 
     
    166166        unset( $repeat['id'] ); 
    167167 
    168         $params = self::decodeRepeat( $repeat, $ranges[0]['rangeStart'], $ranges[0]['rangeEnd'] ); 
     168        $exceptions = array(); 
     169 
     170        if( isset( $repeat['exceptions'] ) ) 
     171        { 
     172            $exceptions = explode( ',', $repeat['exceptions'] ); 
     173            unset( $repeat['exceptions'] ); 
     174        } 
     175 
     176        $params = array_diff( self::decodeRepeat( $repeat, $ranges[0]['rangeStart'], $ranges[0]['rangeEnd'] ), $exceptions ); 
    169177 
    170178        Controller::delete( array( 'concept' => 'repeatOccurrence' ), false, array( 'filter' => array( '=', 'repeat', $id ) ) ); 
    171179 
    172180        if( !empty($params) ) 
    173             Controller::service('PostgreSQL')->execResultSql( "INSERT INTO calendar_repeat_occurrence(repeat_id,occurrence)VALUES('".$id."', '".implode( "'),('".$id."','", $params )."')" ); 
     181            Controller::service('PostgreSQL')->execResultSql( "INSERT INTO calendar_repeat_occurrence(repeat_id,exception,occurrence)VALUES('".$id."','0','".implode( "'),('".$id."','0','", $params )."')".( empty($exceptions) ? "" : ",('".$id."','1','".implode( "'),('".$id."','0','", $exceptions )."')" ) ); 
    174182 
    175183    } 
     
    244252        } 
    245253 
    246         $return = Controller::find( array( 'concept' => 'repeatOccurrence' ), false, array( 'filter' => array( 'AND', array( '>=', 'occurrence', $origStart ), array( '<=', 'occurrence', $origEnd ), array( 'IN', 'repeat', $ids ) ), 'deepness' => $deep ) ); 
     254//      $return = Controller::find( array( 'concept' => 'repeatOccurrence' ), false, array( 'filter' => array( 'AND', array( '>=', 'occurrence', $origStart ), array( '<=', 'occurrence', $origEnd ), array( 'IN', 'repeat', $ids ) ), 'deepness' => $deep ) ); 
     255 
     256        $return = Controller::service('PostgreSQL')->execResultSql( 'SELECT calendar_repeat_occurrence.occurrence as "occurrence", calendar_repeat.object_id as "schedulable" FROM calendar_repeat, calendar_repeat_occurrence WHERE calendar_repeat_occurrence.occurrence >= \''.$origStart.'\' AND calendar_repeat_occurrence.occurrence <= \''.$origEnd.'\' AND calendar_repeat_occurrence.repeat_id IN (\''.implode( '\',\'', $ids ).'\') AND calendar_repeat.id = calendar_repeat_occurrence.repeat_id AND calendar_repeat_occurrence.exception != 1' ); 
    247257 
    248258        if( !is_array( $return ) ) 
     
    254264        foreach( $return as $ret ) 
    255265        { 
    256               $currentId = $ret['repeat']['schedulable']['id']; 
     266              $currentId = $ret['schedulable']; 
    257267 
    258268              if( !isset( $result[ $currentId ] ) ) 
    259269              { 
    260                     $result[ $currentId ] = $ret['repeat']['schedulable']; 
    261                     $result[ $currentId ]['repeat']['schedulable'] = $currentId; 
    262  
     270                    $result[ $currentId ] = Controller::read( array( 'concept' => 'schedulable', 'id' => $currentId ) ); 
    263271                    $result[ $currentId ][ 'occurrences' ] = array(); 
    264272 
    265273                    $calendarToCalendarObj = self::schedulable2calendarToObject( $currentId ); 
    266  
    267                     $result[ $currentId ]['calendar'] = $calendarToCalendarObj[0]['calendar_id'];   
     274                    $result[ $currentId ]['calendar'] = $calendarToCalendarObj[0]['calendar_id']; 
    268275              } 
    269276       
     
    527534                    $repeat = Controller::find( array( 'concept' => 'repeat' ), false, array( 'filter' => array( '=', 'schedulable', $v['id'] ) ) ); 
    528535 
     536                    unset( $result[$i]['repeat'] ); 
     537 
    529538                    if( is_array($repeat) ) 
    530539                        $result[$i]['repeat'] = $repeat[0]; 
Note: See TracChangeset for help on using the changeset viewer.