protected function afterLoad(&$response, &$model, &$params) { if (!empty($model->rrule)) { $rRule = new \GO\Base\Util\Icalendar\Rrule(); $rRule->readIcalendarRruleString($model->due_time, $model->rrule); $createdRule = $rRule->createJSONOutput(); $response['data'] = array_merge($response['data'], $createdRule); } $settings = \GO\Tasks\Model\Settings::model()->findByPk(\GO::user()->id); $response['data']['remind_before'] = $settings->reminder_days; if (!empty($response['data']['reminder'])) { $response['data']['remind'] = 1; $response['data']['remind_date'] = date(\GO::user()->completeDateFormat, $model->reminder); $response['data']['remind_time'] = date(\GO::user()->time_format, $model->reminder); } else { $response['data']['remind_date'] = date(\GO::user()->completeDateFormat, $model->getDefaultReminder($model->start_time)); $response['data']['remind_time'] = date(\GO::user()->time_format, $model->getDefaultReminder($model->start_time)); } if (!empty($params['project_id']) && empty($params['id'])) { $findParams = \GO\Base\Db\FindParams::newInstance()->select('count(*) AS count')->single(); $findParams->getCriteria()->addCondition('project_id', $params['project_id']); $record = \GO\Tasks\Model\Task::model()->find($findParams); $response['data']['name'] = '[' . ($record->count + 1) . '] '; } //$response['data']['remind_time']=date(\GO::user()->time_format, strtotime($response['data']['reminder'])); return parent::afterLoad($response, $model, $params); }
public function afterLoad(&$response, &$model, &$params) { // if (isset($response['data']['name'])) // $response['data']['subject'] = $response['data']['name']; $response = self::reminderSecondsToForm($response); $response['data']['start_time'] = date(\GO::user()->time_format, $model->start_time); $response['data']['end_time'] = date(\GO::user()->time_format, $model->end_time); if (isset($response['data']['rrule']) && !empty($response['data']['rrule'])) { $rRule = new \GO\Base\Util\Icalendar\Rrule(); $rRule->readIcalendarRruleString($model->start_time, $model->rrule); $createdRule = $rRule->createJSONOutput(); $response['data'] = array_merge($response['data'], $createdRule); } $response['data']['start_date'] = \GO\Base\Util\Date::get_timestamp($model->start_time, false); $response['data']['end_date'] = \GO\Base\Util\Date::get_timestamp($model->end_time, false); if (\GO::modules()->customfields) { $response['customfields'] = \GO\Customfields\Controller\CategoryController::getEnabledCategoryData("GO\\Calendar\\Model\\Event", $model->calendar->group_id); } $response['group_id'] = $model->calendar->group_id; if (!$model->id) { $days = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA'); $response['data'][$days[date('w', $model->start_time)]] = 1; } if (!$model->isResource() && $model->id > 0) { $this->_loadResourceEvents($model, $response); } // $response['data']['has_other_participants']=$model->hasOtherParticipants(\GO::user()->id); $response['data']['user_name'] = $model->user ? $model->user->name : "Unknown"; if (empty($params['id'])) { $participantModel = $model->getDefaultOrganizerParticipant(); $response['participants'] = array('results' => array($participantModel->toJsonArray($model->start_time, $model->end_time)), 'total' => 1, 'success' => true); if (!empty($params['linkModelNameAndId'])) { $arr = explode(':', $params['linkModelNameAndId']); if ($arr[0] == 'GO\\Addressbook\\Model\\Contact') { $contact = \GO\Addressbook\Model\Contact::model()->findByPk($arr[1]); if ($contact) { $participantModel = new \GO\Calendar\Model\Participant(); $participantModel->setContact($contact); $response['participants']['results'][] = $participantModel->toJsonArray($model->start_time, $model->end_time); $response['participants']['total'] = 2; } } } } else { $particsStmt = \GO\Calendar\Model\Participant::model()->findByAttribute('event_id', $params['id']); $response['participants'] = array('results' => array(), 'total' => 0, 'success' => true); while ($participantModel = $particsStmt->fetch()) { $record = $participantModel->toJsonArray($model->start_time, $model->end_time); if (!empty($params['exception_date'])) { unset($record['id']); } $response['participants']['results'][] = $record; $response['participants']['total'] += 1; } if ($response['participants']['total'] == 0) { $participantModel = $model->getDefaultOrganizerParticipant(); $response['participants'] = array('results' => array($participantModel->toJsonArray($model->start_time, $model->end_time)), 'total' => 1, 'success' => true); } } return parent::afterLoad($response, $model, $params); }