Esempio n. 1
0
 /**
  * execute 
  * 
  * @param mixed $date 
  * @access public
  * @return void
  */
 function execute($date) {
   $delta = $this->jobDelta - 1;
   $end_time = new Of_Date($date + $this->jobDelta);
   $this->logger->debug('Getting vacation to enable before '.$end_time->getIso());
   $enable = $this->getVacationToInsert($end_time);
   $this->logger->debug('Getting vacation to disable before '.$end_time->getIso());
   $date = new Of_Date($date);
   $disable = $this->getVacationToRemove($date);
   $intersec = array_intersect(array_keys($enable),array_keys($disable));
   if(count($intersec) != 0) {
     $this->logger->warn(count($intersec).' vacation messages are set to be enabled AND disabled in the same job : '.implode(',',$intersec));
     foreach($intersec as $id) {
       unset($enable[$id]);
     }
   }
   $this->enableVacation($enable);
   $this->disableVacation($disable);
   
 }
Esempio n. 2
0
File: ICS.php Progetto: Kervinou/OBM
  /**
   * parseDate
   *
   * @param mixed $value
   * @param mixed $options
   * @access public
   * @return void
   */
  function parseDate($value, $options=array()) {
    if(isset($options['TZID']) && !preg_match('/^[^Z]*Z$/',$value)) {
      $date = new Of_Date($value, $options['TZID']);
      if ($date->error() == Of_Date::ERR_INVALID_DATE) { // Bad timezone
        $date = new Of_Date($value, 'GMT');
      }
    } else {
      $date = new Of_Date($value, null, false);
    }

    return $date;
  }
Esempio n. 3
0
 /**
  * Generate an attribute and it's potential dependencies
  * @param  array  $generated    array of all generated attributes
  * @param  string $attribute    the name of the attribute to generate
  * @access protected
  **/
 protected function generate_extra(&$generated, $attribute)
 {
     if ($attribute == 'domain') {
         $generated[$attribute] = $GLOBALS['obm']['domain_name'];
     } else {
         if (substr($attribute, 0, 5) == 'today') {
             $date = new Of_Date();
             $add = intval(substr($attribute, 5));
             $date->addDay($add);
             $generated[$attribute] = $date->getInputDate();
         }
     }
 }
Esempio n. 4
0
    <th><label for='public_fb'>$GLOBALS[l_set_public_fb]</label></th>
    <td><input type='checkbox' name='public_fb' id='public_fb' value='yes' ".(($_SESSION['set_public_fb'] == 'yes')?"checked='checked'":"")." /></td>
  </tr>  
";
}

$timezone_identifiers = DateTimeZone::listIdentifiers();
foreach($timezone_identifiers as $tz) {
  if($tz == Of_Date::getOption('timezone')) {
    $timezones .= "<option selected='selected' value='$tz'>$tz</option>";
  } else {
    $timezones .= "<option value='$tz'>$tz</option>";
  }
}

${'_'.Of_Date::getOption('timeformat')} = "selected='selected'";
$sel_timeformat = "
  <select name='timeformat'>
    <option value='12H' $_12H>1:00pm</option>
    <option value='24H' $_24H>13:00</option>
  </select>";

$display['detail'] .= "
  <tr id='settings_csvSeparator'>
  <th>$l_set_csv_sep</th>
  <td>
    <span class=\"NW\"><label><input type=\"radio\" class=\"box\" name=\"csv_sep\" value=\"$ccsvd_sc\" $csvd_sc />$l_csvd_sc</label></span>
    <span class=\"NW\"><label><input type=\"radio\" class=\"box\" name=\"csv_sep\" value=\"$ccsvd_tab\" $csvd_tab />$l_csvd_tab</label></span>
  </td>
  </tr>
  $dis_debug
Esempio n. 5
0
File: OBM.php Progetto: Kervinou/OBM
  /**
   * @param Vcalendar_Element $vevent
   */
  function parseEventData(&$vevent) {
    $entities = array();
    $states = array();
    $attendees = $vevent->get('attendee');
    if(!is_null($attendees)) {
      if(is_array($attendees) && !array_key_exists('entity',$attendees)) {
        foreach($attendees as $attendee) {
          $this->createUnknownContact($attendee);
          $entities[$attendee['entity']][] = $attendee['id'];
          $states[$attendee['entity']][$attendee['id']] = $attendee['state'];
        }
      } elseif(!is_null($attendees)) {
        $this->createUnknownContact($attendees);
        $entities[$attendees['entity']][] = $attendees['id'];
        $states[$attendees['entity']][$attendees['id']] = $attendees['state'];
      }
    }
    $entities['user'][] = $GLOBALS['obm']['uid'];
    $entities['user'] = array_unique($entities['user']);
    $event['ext_id'] = $vevent->get('uid');
    $event['owner'] = $this->parseOrganizer($vevent->get('organizer'));
    $event['title'] = addslashes($vevent->get('summary'));
    $dtstart = $vevent->get('dtstart');
    $event['date_begin'] = $dtstart;

    // if no startdate, we consider that it's not an event and we don't insert it
    if (!is_null($dtstart)){
      if ($dtstart->getOriginalTimeZone())
        $event['timezone'] = $dtstart->getOriginalTimeZone();

      $event['date_end'] = $vevent->get('dtend');
      $event['event_duration'] = $vevent->get('duration');
      $event['duration'] = $vevent->get('duration');
      $event['opacity'] = $vevent->get('transp') ? $vevent->get('transp') : "OPAQUE";

      $event['date_exception'] = array();
      $exdates = $vevent->get('exdate');

      $dates_exception = array();

      if (is_array($exdates))
        foreach($exdates as $exdate) {
          if (is_array($exdate)) {
            foreach($exdate as $exdate2) {
              $dates_exception[] = $exdate2;
            }
          } else {
            $dates_exception[] = $exdate;
          }
        }

      $event['date_exception'] = $dates_exception;

      // BEGIN one exception for each day

      foreach ($dates_exception as $k => $v) {
        $dates_exception[$k] = $v->get(Of_Date::DATE_ISO);
      }

      $dates_exception = array_unique($dates_exception);

      foreach ($dates_exception as $k => $v) {
        $date = new Of_Date($v);
        $dates_exception[$k] = $date->setHour($dtstart->getHour())->setMinute($dtstart->getMinute())->setSecond($dtstart->getSecond());
      }

      $event['date_exception'] = $dates_exception;

      // END one exception for each day

      $event['description'] = addslashes($vevent->get('description'));
      $event['location'] = addslashes($vevent->get('location'));
      $event['category1'] = $this->parseCategories($vevent->get('categories'));
      $event['priority'] = $this->parsePriority($vevent->get('priority'));
      $event['privacy'] = $this->parsePrivacy($vevent->get('class')) ;
      $event = array_merge($event, $this->parseRrule($vevent->get('rrule'), $vevent));
      $event['all_day'] = $vevent->isAllDay();
      $event['color'] = $vevent->get('x-obm-color');
      $event['properties'] = $vevent->get('x-obm-properties');
      return array('event' => $event, 'entities' => $entities, 'states' => $states);
    }
    else {
      return null;
    }
  }
Esempio n. 6
0
  /**
   * build and return the SQL query to get users data
   * 
   * @param DB_OBM $obm_q
   * @access private
   * @return string
   */
  private static function build_user_query($obm_q) {
    $date = new Of_Date();
    $date->subMonth(3);
    $query =  "SELECT
    U.userobm_id,
    U.userobm_domain_id,
    domain_name AS userobm_domain_name,
    U.userobm_timecreate,
    U.userobm_timeupdate,
    U.userobm_usercreate AS userobm_usercreate_id,
    A.userobm_login AS userobm_usercreate_login,
    U.userobm_userupdate AS userobm_userupdate_id,
    B.userobm_login AS userobm_userupdate_login,
    U.userobm_local,
    U.userobm_ext_id,
    U.userobm_system,
    U.userobm_archive,
    U.userobm_status,
    U.userobm_timelastaccess,
    U.userobm_login,
    U.userobm_nb_login_failed,
    U.userobm_password_type,
    U.userobm_password_dateexp,
    U.userobm_account_dateexp,
    U.userobm_perms,
    U.userobm_delegation_target,
    U.userobm_delegation,
    U.userobm_calendar_version,
    U.userobm_uid,
    U.userobm_gid,
    U.userobm_datebegin,
    U.userobm_hidden,
    U.userobm_kind,
    U.userobm_lastname,
    U.userobm_firstname,
    U.userobm_title,
    U.userobm_sound,
    U.userobm_company,
    U.userobm_direction,
    U.userobm_service,
    U.userobm_address1,
    U.userobm_address2,
    U.userobm_address3,
    U.userobm_zipcode,
    U.userobm_town,
    U.userobm_expresspostal,
    U.userobm_country_iso3166,
    U.userobm_phone,
    U.userobm_phone2,
    U.userobm_mobile,
    U.userobm_fax,
    U.userobm_fax2,
    U.userobm_web_perms,
    U.userobm_web_list,
    U.userobm_web_all,
    U.userobm_mail_perms,
    U.userobm_mail_ext_perms,
    U.userobm_email,
    U.userobm_mail_server_id,
    host_name AS userobm_mail_server_name,
    U.userobm_mail_quota,
    U.userobm_mail_quota_use,
    U.userobm_mail_login_date,
    U.userobm_nomade_perms,
    U.userobm_nomade_enable,
    U.userobm_nomade_local_copy,
    U.userobm_email_nomade,
    U.userobm_vacation_enable,
    U.userobm_vacation_datebegin,
    U.userobm_vacation_dateend,
    U.userobm_vacation_message,
    U.userobm_samba_perms,
    U.userobm_samba_home,
    U.userobm_samba_home_drive,
    U.userobm_samba_logon_script,
    U.userobm_host_id,
    U.userobm_description,
    U.userobm_location,
    U.userobm_education,
    (U.userobm_photo_id IS NOT NULL) AS userobm_has_photo,
    count(EventLink.eventlink_event_id) as groupware_usage
    FROM UserObm as U
    INNER JOIN Domain ON domain_id = U.userobm_domain_id
    INNER JOIN UserEntity ON userentity_user_id = userobm_id
    LEFT JOIN Host ON U.userobm_mail_server_id=host_id
    LEFT JOIN UserObm as A ON U.userobm_usercreate=A.userobm_id
    LEFT JOIN EventLink ON (eventlink_entity_id = userentity_entity_id AND eventlink_state != 'NEEDS-ACTION' AND (eventlink_timeupdate > '$date' OR eventlink_timecreate > '$date'))
      OR (eventlink_userupdate = U.userobm_id AND eventlink_timeupdate > '$date') OR (eventlink_usercreate = U.userobm_id AND eventlink_timecreate > '$date')
    LEFT JOIN UserObm as B ON U.userobm_userupdate=B.userobm_id 
    GROUP BY  
    U.userobm_id,
    U.userobm_domain_id,
    userobm_domain_name,
    U.userobm_timecreate,
    U.userobm_timeupdate,
    userobm_usercreate_id,
    userobm_usercreate_login,
    userobm_userupdate_id,
    userobm_userupdate_login,
    U.userobm_local,
    U.userobm_ext_id,
    U.userobm_system,
    U.userobm_archive,
    U.userobm_status,
    U.userobm_timelastaccess,
    U.userobm_login,
    U.userobm_nb_login_failed,
    U.userobm_password_type,
    U.userobm_password_dateexp,
    U.userobm_account_dateexp,
    U.userobm_perms,
    U.userobm_delegation_target,
    U.userobm_delegation,
    U.userobm_calendar_version,
    U.userobm_uid,
    U.userobm_gid,
    U.userobm_datebegin,
    U.userobm_hidden,
    U.userobm_kind,
    U.userobm_lastname,
    U.userobm_firstname,
    U.userobm_title,
    U.userobm_sound,
    U.userobm_company,
    U.userobm_direction,
    U.userobm_service,
    U.userobm_address1,
    U.userobm_address2,
    U.userobm_address3,
    U.userobm_zipcode,
    U.userobm_town,
    U.userobm_expresspostal,
    U.userobm_country_iso3166,
    U.userobm_phone,
    U.userobm_phone2,
    U.userobm_mobile,
    U.userobm_fax,
    U.userobm_fax2,
    U.userobm_web_perms,
    U.userobm_web_list,
    U.userobm_web_all,
    U.userobm_mail_perms,
    U.userobm_mail_ext_perms,
    U.userobm_email,
    U.userobm_mail_server_id,
    userobm_mail_server_name,
    U.userobm_mail_quota,
    U.userobm_mail_quota_use,
    U.userobm_mail_login_date,
    U.userobm_nomade_perms,
    U.userobm_nomade_enable,
    U.userobm_nomade_local_copy,
    U.userobm_email_nomade,
    U.userobm_vacation_enable,
    U.userobm_vacation_datebegin,
    U.userobm_vacation_dateend,
    U.userobm_vacation_message,
    U.userobm_samba_perms,
    U.userobm_samba_home,
    U.userobm_samba_home_drive,
    U.userobm_samba_logon_script,
    U.userobm_host_id,
    U.userobm_description,
    U.userobm_location,
    U.userobm_education,
    userobm_has_photo    
    ORDER BY 
    U.userobm_lastname,
    U.userobm_firstname
    ";

    return $query;
  }
Esempio n. 7
0
          if ($params['others_attendees'] != "") {
            $others_attendees = run_query_insert_others_attendees($params);
            $entities['contact'] = array_merge($entities['contact'], $others_attendees);
          }
          // Insert "other files" as private documents
          if (count($params['other_files']) > 0) {
            $other_files = run_query_insert_other_files($params);
            if (!$other_files) {
              $display['msg'] .= display_warn_msg("$l_event : $l_warn_file_upload");
            } else {
              $entities['document'] = array_merge($entities['document'], $other_files);
            }
          }
          $event_id = run_query_calendar_add_event($params, $entities);
          $params["calendar_id"] = $event_id;
          if ($params['date_begin']->compare(Of_Date::today()) <= 0) {
            $display['msg'] .= display_warn_msg("$l_event : $l_warn_date_past");
          }

          if ($params['show_user_calendar']) $current_view->set_users($params['sel_user_id']);
          if ($params['show_resource_calendar'])  $current_view->set_resources($params['sel_resource_id']);

          $current_view->set_date($params["date_begin"]);
          $detailurl = basename($_SERVER['SCRIPT_NAME'])."?action=detailconsult&amp;calendar_id=$event_id";
          $detail = "<a class='B' href='$detailurl'>".phpStringToJsString($GLOBALS[l_details])."</a>";
          if($GLOBALS['display']['warm_add_organizer'] == true){
            redirect_warn($params, "$l_event: $l_insert_ok - $l_event_add_organizer - $detail");
	  } else {
            redirect_ok($params, "$l_event: $l_insert_ok - $detail");
          }
        }
Esempio n. 8
0
File: OBM.php Progetto: Kervinou/OBM
 function parseRrule($data) {
   $rrule = array();
    switch ($data['event_repeatkind']) {
      case 'daily' :
      case 'yearly' :
        $rrule['kind'] = $data['event_repeatkind'];
        break;
      case 'monthlybydate' :
        $rrule['kind'] = 'monthly';
        break;
      case 'monthlybyday' :
        $rrule['kind'] = 'monthly';
        $date = new Of_Date($data['event_date'], 'GMT');
        $day = $date->get(Of_Date::WEEKDAY_ICS);
        
        $num =  ceil($date->getDay()/7);
        $rrule['byday'] = array($num.$day);
        break;
      case 'weekly' :
        $rrule['kind'] = 'weekly';
        foreach($this->weekDays as $longDay => $shortDay) {
          $index = date('w', strtotime($longDay));
          if($data['event_repeatdays'][$index] == '1') {
            $days[] = $shortDay;
          }           
        }
        $rrule['byday'] = $days;
        break;
    }
    if ($data['event_endrepeat'])
      $rrule['until'] = $this->parseDate($data['event_endrepeat']);
    $rrule['interval'] = $data['event_repeatfrequence'];
    return $rrule;
 }
Esempio n. 9
0
File: ICS.php Progetto: Kervinou/OBM
 /**
  * Parse a date with the given format, preferably with ICS_DATETIME if possible.
  *
  * @param Of_Date $date
  * @param string $format Date format. Can be Of_Date::ICS_DATETIME or Of_Date::ICS_DATE.
  */
 function parseTZIDedDate($date, $format=Of_Date::ICS_DATETIME) {
   if ($date->getOriginalTimeZone() && $format == Of_Date::ICS_DATETIME) {
     $date->setTimezone(new DateTimeZone($date->getOriginalTimeZone()));
     $res = ';TZID='. $date->getOriginalTimeZone().':'. $date->get($format);
     $date->setDefaultTimezone();
   } else {
     $res = ':'. $this->parseDate($date, $format);
   }
   
   return $res;
 }
Esempio n. 10
0
 /**
   * Tell if the mail must be sent or not.
   *  For exemple a mail will not be sent if the concerned event is in
   *  the past.
  */
 private function mustBeSent($old, $new) {
   $today = Of_Date::today();
   $willBeSent = false;
   if(isset($new) && $new instanceof OBM_Event) {
     if($new->date_end->compare($today) > 0) {
       $willBeSent = true;
     }
     if($new->repeat_kind != 'none' && $new->repeat_end->compare($today) > 0) {
       $willBeSent = true;
     }
   }
   if(isset($old) && $old instanceof OBM_Event) {
     if($old->date_end->compare($today) > 0) {
       $willBeSent = true;
     }
     if($old->repeat_kind != 'none' && $old->repeat_end->compare($today) > 0) {
       $willBeSent = true;
     }
   }
   return $willBeSent;
 }
Esempio n. 11
0
 /**
  * getReccurentAlerts 
  * 
  * @param mixed $start 
  * @param mixed $end 
  * @access public
  * @return void
  */
 function getReccurentAlerts($start, $end) {
   $of = &OccurrenceFactory::getInstance();
   $this->logger->debug("Getting alerts on reccurent events between $start and $end");
   $r_q = run_query_calendar_repeat_alerts($start,$end);
   $this->logger->debug($r_q->nf().' potentials alerts founded on reccurent events');
   while ($r_q->next_record()) {
     $id = $r_q->f('event_id');
     $title = $r_q->f('event_title');
     $privacy = $r_q->f('event_privacy');
     $description = $r_q->f('event_description');
     $properties = $r_q->f('event_properties');
     $location = $r_q->f('event_location'); 
     $category1 = $r_q->f('eventcategory1_label');
     $date = new Of_Date($r_q->f('event_date'), 'GMT');
     $duration = $r_q->f('event_duration');
     $repeatkind = $r_q->f('event_repeatkind');
     $endrepeat = new Of_Date($r_q->f('event_endrepeat'),'GMT');
     $entity = $r_q->f('eventlink_entity');
     $all_day = $r_q->f('event_allday');
     $color = $r_q->f('event_color');
     $repeatfrequence = $r_q->f('event_repeatfrequence');
     $repeatdays = $r_q->f('event_repeatdays');
     $entity_id = $r_q->f('eventlink_entity_id');    
     $entity_state = $r_q->f('eventlink_state');
     $owner = $r_q->f('event_owner');
     $entity_label = $r_q->f('userobm_lastname') .' '.$r_q->f('userobm_firstname');
     $state = $r_q->f('eventlink_state');
     $timezone = $r_q->f('event_timezone');
     $opacity = $r_q->f('event_opacity');
     $tag = $r_q->f('eventtag_id');
     if ($endrepeat->error() == Of_Date::WARN_EMPTY_DATE) {
       $endrepeat = $end;
     }
     if (isset($of->events[$id])) {
       $event = $of->events[$id];
     } else {
       $event = new Event($id,$duration,$title,$location,$category1,$privacy,$description,$properties,$all_day,$repeatkind,$owner,'',$color,$opacity,$tag);
       $event->setTimezone($timezone);
     }
     $this->logger->debug("$entity $entity_id ($entity_label) added on event ".$event->id);
     $tz = new DateTimeZone($timezone);
     $date->setTimezone($tz);
     $event->addAttendee($entity,$entity_id,$entity_label,$state);      
     $event_start = clone $start;
     $event_start->setTimezone($tz); 
     $event_start->subSecond($duration)->setHour($date)->setMinute($date)->setSecond($date);
     $event_end = ($end->compare($endrepeat) > 0)? clone $endrepeat: clone $end; 
     $event_end->setTimezone($tz);
     $event_end->setHour($date)->setMinute($date)->setSecond($date)->addSecond($duration);
     switch ($repeatkind) {
     case 'daily' :
       calendar_daily_repeatition($date,$event_start,$event_end,$repeatfrequence,$event,$entity_id,$entity, $entity_state);
       break;
     case 'weekly' :
       calendar_weekly_repeatition($date,$event_start,$event_end,$repeatdays,$repeatfrequence,$event,$entity_id,$entity, $entity_state);
       break;
     case 'monthlybyday' :
       $stored = calendar_monthlybyday_repeatition($date,$event_start,$event_end,$repeatfrequence,$event,$entity_id,$entity, $entity_state);
       break;
     case 'monthlybydate' :
       $stored = calendar_monthlybydate_repeatition($date,$event_start,$event_end,$repeatfrequence,$event,$entity_id,$entity, $entity_state);
       break;
     case 'yearly' :
       $stored = calendar_yearly_repeatition($date,$event_start,$event_end,$repeatfrequence,$event,$entity_id,$entity, $entity_state);
       break;
     }
   }
   $this->logger->debug("Removing exceptions");
   if (count($of->events) > 0) {
     $exception_q = run_query_get_events_exception(array_keys($of->events),$start,NULL);
     $this->logger->debug($exception_q->nf()." exceptions founded");
     while($exception_q->next_record()) {
       $of->removeOccurrences($exception_q->f('eventexception_parent_id'), new Of_Date($exception_q->f('eventexception_date'), 'GMT'));
     }
   }
 }    
Esempio n. 12
0
  public function getCalendar() {
    global $cremote_calendar_ics_ttl;
    if (is_array($this->website)) {
      foreach($this->website as $website) {
        if ($website['label'][0] == 'CALURI') {
          $url = $website['url'];
          $file = "/tmp/".str_replace("/", "_", $url);
          $now = new Of_Date();
          if (file_exists($file) && ($now->getTimestamp() - filectime($file)) < $cremote_calendar_ics_ttl) {
            // get ics from stored file
            $f = fopen($file, 'r');
            $d = stream_get_contents($f);
            fclose($f);
          } else {
            // get ics from url
            $handle = @fopen($url, "r");
            if ($handle) {
              $d = stream_get_contents($handle);
              fclose($handle);

              // store ics file in filesystem
              $f = fopen($file, 'w');
              fwrite($f, $d);
              fclose($f);
            } else {
              return false;
            }
          }
          return Vpdi::decodeOne($d);
        }
      }
    }
    return false;
  }