Ignore:
Timestamp:
05/24/12 16:26:24 (12 years ago)
Author:
acoutinho
Message:

Ticket #2795 - Problema ao tentar aceitar convite da agenda para a conta compartilhada

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/prototype/services/iCal.php

    r6248 r6295  
    248248                                    $calendarToSchedulable['schedulable'] = $schedulable['id']; 
    249249                                    $interation['calendarToSchedulable://' . mt_rand() . '(Formatter)'] = $calendarToSchedulable; 
    250  
     250     
    251251                                    if (isset($params['status'])) { 
    252                                         $pID = self::_getParticipantByMail(Config::me('mail'), $schedulable['participants']); 
     252                                        if(isset($params['fromPermission'])){                                        
     253                                            $signaturesOfOwner = Controller::Read(array('concept' => 'calendarSignature'), false, array('filter' => array('AND', array('=', 'calendar', $params['fromPermission']) , array('=','isOwner','1')), 'deepness' => 2 ));                                          
     254                                            $pID = self::_getParticipantByMail($signaturesOfOwner[0]['user']['mail'], $schedulable['participants']); 
     255                                        }else 
     256                                            $pID = self::_getParticipantByMail(Config::me('mail'), $schedulable['participants']); 
    253257                                        $interation['participant://' . $pID]['status'] = $params['status']; 
    254258                                    } 
     
    265269 
    266270                                    if (isset($params['status'])) { 
    267                                         $pID = self::_getParticipantByMail(Config::me('mail'), $schedulable['participants']); 
     271                                        if(isset($params['fromPermission'])){                                        
     272                                            $signaturesOfOwner = Controller::Read(array('concept' => 'calendarSignature'), false, array('filter' => array('AND', array('=', 'calendar', $params['fromPermission']) , array('=','isOwner','1')), 'deepness' => 2 )); 
     273                                            $pID = self::_getParticipantByMail($signaturesOfOwner[0]['user']['mail'], $schedulable['participants']); 
     274                                        }else 
     275                                            $pID = self::_getParticipantByMail(Config::me('mail'), $schedulable['participants']); 
    268276                                        //Verifica a importação de eventos em que não participo 
    269277                                        if ($pID) { 
     
    566574                                            $interation = ($isOrganizer) ? ICAL_ACTION_ORGANIZER_NONE : ICAL_ACTION_NONE; 
    567575                                    } 
    568                                 if (!$isParticipant) 
    569                                     $interation = ICAL_ACTION_ORGANIZER_NONE; 
     576                                if (!$isParticipant){ 
     577                                      $interation = self::_checkParticipantByPermissions($schedulable); 
     578                                    } 
    570579                            }else 
    571580                                $interation = ICAL_ACTION_IMPORT; 
     
    651660    } 
    652661 
     662    private static function _checkParticipantByPermissions($schedulable) { 
     663 
     664        $calendarIds = Controller::find(array('concept' => 'calendarSignature'), array('calendar'), array('filter' => array('AND', array('=','isOwner','0'), array('=', 'user', Config::me("uidNumber"))))); 
     665 
     666        if($calendarIds && isset($calendarIds[0])){ 
     667            $ids = array(); 
     668            foreach($calendarIds as $value) 
     669                    array_push($ids, $value['calendar']); 
     670 
     671            $signaturesOfOwners = Controller::find(array('concept' => 'calendarSignature'), false, array('filter' => array('AND', array('IN', 'calendar', $ids) , array('=','isOwner','1')), 'deepness' => 2 )); 
     672             
     673            foreach($signaturesOfOwners as $value){ 
     674                if(self::_getParticipantByMail($value['user']['mail'], $schedulable['participants'])){ 
     675                    $eventoFromCalendar = Controller::read( array( 'concept' => 'calendarToSchedulable') , false, array('filter' => array('AND', array('=','schedulable',$schedulable['id']), array('=','calendar', $value['calendar']['id'])))); 
     676 
     677                    return  ($eventoFromCalendar && isset($eventoFromCalendar[0])) ? ICAL_ACTION_NONE_FROM_PERMISSION : array('action' => ICAL_ACTION_IMPORT_FROM_PERMISSION, 'calendar' => $value['calendar']['id'] ); 
     678                } 
     679            }     
     680        } 
     681        return ICAL_ACTION_ORGANIZER_NONE; 
     682    } 
     683     
     684     
    653685    private static function _getParticipantByMail($mail, &$participants) { 
    654686        if ($participants && $participants != '') 
Note: See TracChangeset for help on using the changeset viewer.