if (in_array($cal->f('id'), $_POST['calendars'])) {
             if (!$cal2->event_is_subscribed($event_id, $cal->f('id'))) {
                 $cal2->subscribe_event($event_id, $cal->f('id'));
             }
         } else {
             if ($cal2->event_is_subscribed($event_id, $cal->f('id'))) {
                 $cal2->unsubscribe_event($event_id, $cal->f('id'));
             }
         }
     }
 }
 //set the reminder
 if ($_POST['reminder'] > 0) {
     $next_recurrence_time = $cal->get_next_recurrence_time($event_id);
     $remind_time = $next_recurrence_time - $_POST['reminder'];
     $cal->insert_reminder($GO_SECURITY->user_id, $event_id, $remind_time);
 }
 if (trim($_POST['to']) != '' && $send_invitation) {
     //remove participants and add them if invitation is sent succesfully
     $cal->remove_participants($event_id);
     $send_invitation = false;
     //send an invitation mail to all participants
     $participants = cut_address($_POST['to'], $charset);
     $mail_body = '<html><body>' . $sc_invited . '<br /><br />';
     $mail_body .= '<table border="0"><tr><td>' . $sc_title . ':</td><td>' . $name . '</td></tr>';
     if ($_POST['contact_id'] > 0) {
         $mail_body .= '<tr><td>' . $sc_client . ':</td>';
         $mail_body .= '<td>' . show_contact($_POST['contact_id']) . '</td></tr>';
     }
     if ($_POST['description'] != '') {
         $mail_body .= '<tr><td valign="top">' . $strDescription . ':</td>';