- Timestamp:
- 04/13/12 17:25:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/prototype/modules/calendar/interceptors/Notifications.php
r5804 r5947 9 9 10 10 public function formatNotification(&$uri , &$params , &$data , $original){ 11 12 13 14 15 16 17 18 11 switch ($params['type']) { 12 case 'suggestion': 13 self::formatSuggestion($params); 14 break; 15 case 'suggestionResponse': 16 self::formatSuggestionResponse($params); 17 break; 18 } 19 19 } 20 20 … … 78 78 $organizer = isset( $organizers[$pCreated['schedulable']] ) ? $organizers[ $pCreated['schedulable'] ] : self::getOrganizer( $pCreated['schedulable'] ); 79 79 80 81 82 83 80 if($pCreated['delegatedFrom'] != 0){ 81 self::participantDelegated( $pCreated , $schedulable , $organizer); 82 continue; 83 } 84 84 85 85 switch ($pCreated['status']) … … 89 89 break; 90 90 case STATUS_UNANSWERED: 91 self::participantCreated( $pCreated['id'] , $schedulable );91 self::participantCreated( $pCreated['id'] , $schedulable, false, false, $organizer ); 92 92 break; 93 93 } … … 108 108 109 109 if($pUpdated['delegatedFrom'] != 0){ 110 110 self::participantDelegatedStatusChange( $pUpdated , $schedulable , $organizer , $pUpdated['status'] ); 111 111 }else if( $pUpdated['status'] != STATUS_UNANSWERED && $pUpdated['status'] != STATUS_DELEGATED) 112 112 self::participantStatusChange( $pUpdated['id'] , $schedulable , $organizer , $pUpdated['status'] ); 113 113 } 114 114 } … … 117 117 public function formatSuggestion(&$params){ 118 118 119 120 121 119 $schedulable = Controller::read( array( 'concept' => 'schedulable' , 'id' => $params['schedulable'] ) , null , array('deepness' => '2') ) ; 120 121 foreach ($schedulable['participants'] as $i => $v) //salva em $organizer as informações do organizador 122 122 if(($v['isOrganizer'] === '1') && ($organizer = $v) ) break; 123 123 … … 227 227 } 228 228 229 229 /** 230 230 * Monta o email de resposta que sera enviado ao delegatedFrom 231 231 * … … 239 239 public static function participantDelegatedStatusChange( &$partID , &$schedulable, $organizer, &$type = false){ 240 240 241 242 243 244 245 246 241 $delegatedParams = array(); 242 243 $delegated = self::_getAttendeeById($partID['id'], $schedulable); 244 $delegatedParams['delegated'] = $delegated['user']['uid']; 245 246 switch($partID['status']){ 247 247 case STATUS_ACCEPTED: 248 248 $delegatedParams['status'] = 'aceitou'; … … 254 254 $delegatedParams['status'] = 'rejeitou'; 255 255 break; 256 257 256 case STATUS_DELEGATED: 257 $delegatedParams['status'] = 'delegou para um novo participante'; 258 258 break; 259 259 } 260 261 262 263 264 265 266 267 268 260 //notifica o organizador a resposta do delegado 261 self::participantStatusChange( $partID['delegatedFrom'] , $schedulable , $organizer , $type, $delegatedParams ); 262 263 $method = 'REQUEST'; 264 $notificationType = 'Resposta Delegação'; 265 $part = 'attendees'; 266 self::mountStruture($partID['delegatedFrom'], $schedulable, $type , $data, $subject, $ical, $part, $method, $notificationType ); 267 268 $data = array_merge($data, $delegatedParams); 269 269 270 270 self::sendMail($data, $ical , $part['user']['mail'] , $subject , 'notify_response_delegated_status_body'); … … 305 305 $temp = $part; 306 306 $part = false; 307 307 308 switch($temp){ 308 309 case 'attendees': … … 352 353 * @access public 353 354 */ 354 public static function participantCreated( &$partID , &$schedulable, $type = false, $delegatedParams = false )355 public static function participantCreated( &$partID , &$schedulable, $type = false, $delegatedParams = false, $organizer = false) 355 356 { 356 357 358 359 360 361 362 363 364 self::sendMail($data, $ical , $part['user']['mail'] , $subject , !$delegatedParams ? 'notify_create_body' : 'notify_create_delegated_body');357 $method = 'REQUEST'; 358 $notificationType = 'Convite de Calendario'; 359 $part = 'attendees'; 360 self::mountStruture($partID, $schedulable, $type , $data, $subject, $ical, $part, $method, $notificationType, true); 361 362 if($delegatedParams) 363 $data = array_merge($data, $delegatedParams); 364 365 self::sendMail($data, $ical , $part['user']['mail'] , $subject , !$delegatedParams ? 'notify_create_body' : 'notify_create_delegated_body', $organizer ); 365 366 366 367 } … … 379 380 { 380 381 $method = 'REPLY'; 381 382 383 384 385 386 387 388 389 382 $notificationType = 'Convite Aceito'; 383 $part = 'me'; 384 385 self::mountStruture($partID, $schedulable, $type , $data, $subject, $ical, $part, $method, $notificationType, true ); 386 387 if($delegatedParams){ 388 $data = array_merge($data, $delegatedParams); 389 $tplDelegated = 'notify_delegated_status_body'; 390 } 390 391 391 392 switch($type) … … 403 404 $subject['notificationType'] = 'Convite rejeitado'; 404 405 break; 405 406 407 406 case STATUS_DELEGATED: 407 if($delegatedParams) 408 $data = array_merge($data, $delegatedParams); 408 409 $tpl = 'notify_delegated_body'; 409 410 $subject['notificationType'] = 'Convite delegado'; … … 412 413 } 413 414 414 self::sendMail($data, $ical , $organizer['user']['mail'] , $subject , $tpl );415 self::sendMail($data, $ical , $organizer['user']['mail'] , $subject , $tpl, false); 415 416 } 416 417 … … 425 426 * @access public 426 427 */ 427 private static function sendMail(&$data , &$ical , $to , &$subject , $template )428 private static function sendMail(&$data , &$ical , $to , &$subject , $template, $from = false ) 428 429 { 429 430 $ical2 = $ical; … … 435 436 $mail['body'] = parseTPL::load_tpl( $data ,ROOTPATH.'/modules/calendar/templates/'.$template.'.tpl'); 436 437 $mail['subject'] = parseTPL::load_tpl( $subject ,ROOTPATH.'/modules/calendar/templates/notify_subject.tpl');; 437 $mail['from'] = '"'.Config::me('cn').'" <'.Config::me('mail').'>';438 $mail['from'] = $from ? ('"'.$from['user']['name'].'" <'.$from['user']['mail'].'>') : ('"'.Config::me('cn').'" <'.Config::me('mail').'>'); 438 439 $mail['to'] = $to; 439 440 Controller::create( array( 'service' => 'SMTP' ), $mail ); … … 456 457 if((Config::regGet('noAlarm') === false) && (self::futureEvent( $schedulable['startTime'] , $schedulable['rangeEnd']))) 457 458 { 458 459 460 461 459 $method = 'CANCEL'; 460 $notificationType = 'Cancelamento de Calendario'; 461 $part = 'othersAttendees'; 462 self::mountStruture($uri['id'], $schedulable, false , $data, $subject, $ical, $part, $method, $notificationType ); 462 463 463 464 464 if(count($part) > 0) 465 self::sendMail($data, $ical , implode(',' , $part) ,$subject, 'notify_cancel_body'); 465 466 } 466 467 } … … 484 485 if((Config::regGet('noAlarm') === false) && (self::futureEvent( $schedulable['startTime'] , $schedulable['rangeEnd']))) 485 486 { 486 487 488 489 490 491 487 $method = 'CANCEL'; 488 $notificationType = 'Cancelamento de Calendario'; 489 $part = 'others'; 490 self::mountStruture(false, $schedulable, false , $data, $subject, $ical, $part, $method, $notificationType ); 491 492 self::sendMail($data, $ical , $participant['user']['mail'] , $subject , 'notify_cancel_body'); 492 493 } 493 494 } … … 518 519 if ( ($alt === true) && (Config::regGet('noAlarm') === false) && (self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd'])) ) 519 520 { 520 521 522 523 521 $method = 'REQUEST'; 522 $notificationType = 'Modificação de Calendario'; 523 $part = 'othersAttendees'; 524 self::mountStruture($partID, $schedulable, $type , $data, $subject, $ical, $part, $method, $notificationType); 524 525 525 526 if ( isset($part) && count($part) > 0)
Note: See TracChangeset
for help on using the changeset viewer.