function add_activities($user, $type = 'sugar') { global $timedate; if ($this->view == 'week' || $this->view == 'shared') { $end_date_time = $this->date_time->get("+7 days"); } else { $end_date_time = $this->date_time; } $acts_arr = array(); if ($type == 'vfb') { $acts_arr = CalendarActivity::get_freebusy_activities($user, $this->date_time, $end_date_time); } else { $acts_arr = CalendarActivity::get_activities($user->id, $this->show_tasks, $this->date_time, $end_date_time, $this->view); } // loop thru each activity for this user foreach ($acts_arr as $act) { // get "hashed" time slots for the current activity we are looping through $start = $timedate->tzUser($act->start_time); $end = $timedate->tzUser($act->end_time); $hash_list = SugarDateTime::getHashList($this->view, $start, $end); for ($j = 0; $j < count($hash_list); $j++) { if (!isset($this->slice_hash[$hash_list[$j]]) || !isset($this->slice_hash[$hash_list[$j]]->acts_arr[$user->id])) { $this->slice_hash[$hash_list[$j]]->acts_arr[$user->id] = array(); } $this->slice_hash[$hash_list[$j]]->acts_arr[$user->id][] = $act; } } }