protected function actionGroupsWithResources($params) { $stmt = \GO\Calendar\Model\Group::model()->find(\GO\Base\Db\FindParams::newInstance()->order('t.name')->criteria(\GO\Base\Db\FindCriteria::newInstance()->addCondition('id', 1, '>'))); $response['results'] = array(); $response['total'] = 0; while ($group = $stmt->fetch()) { $record = $group->getAttributes('formatted'); if (\GO::modules()->customfields) { $record['customfields'] = \GO\Customfields\Controller\CategoryController::getEnabledCategoryData("GO\\Calendar\\Model\\Event", $group->id); } else { $record['customfields'] = array(); } $record['resources'] = array(); $calStmt = \GO\Calendar\Model\Calendar::model()->find(\GO\Base\Db\FindParams::newInstance()->permissionLevel(\GO\Base\Model\Acl::READ_PERMISSION)->joinCustomFields()->order('t.name')->criteria(\GO\Base\Db\FindCriteria::newInstance()->addCondition('group_id', $group->id))); while ($resource = $calStmt->fetch()) { $resourceRecord = $resource->getAttributes('formatted'); $record['resources'][] = $resourceRecord; } $num_resources = count($record['resources']); if ($num_resources > 0) { $response['results'][] = $record; $response['total'] += $num_resources; } } return $response; }
public function formatStoreRecord($record, $model, $store) { $record['user_name'] = $model->user ? $model->user->name : 'unknown'; if (\GO::modules()->customfields) { $record['contactCustomfields'] = \GO\Customfields\Controller\CategoryController::getEnabledCategoryData("GO\\Addressbook\\Model\\Contact", $model->id); $record['companyCustomfields'] = \GO\Customfields\Controller\CategoryController::getEnabledCategoryData("GO\\Addressbook\\Model\\Company", $model->id); } return parent::formatStoreRecord($record, $model, $store); }
protected function afterLoad(&$response, &$model, &$params) { if (\GO::modules()->customfields) { $response['customfields'] = \GO\Customfields\Controller\CategoryController::getEnabledCategoryData("GO\\Addressbook\\Model\\Contact", $model->addressbook_id); } $response['data']['photo_url'] = $model->photoThumbURL; $response['data']['original_photo_url'] = $model->photoURL; if ($model->action_date > 0) { $response['data']['action_date'] = \GO\Base\Util\Date::get_timestamp($model->action_date, false); } $stmt = $model->addresslists(); while ($addresslist = $stmt->fetch()) { $response['data']['addresslist_' . $addresslist->id] = 1; } return parent::afterLoad($response, $model, $params); }
protected function afterLoad(&$response, &$model, &$params) { if (\GO::modules()->customfields) { $response['customfields'] = \GO\Customfields\Controller\CategoryController::getEnabledCategoryData("GO\\Addressbook\\Model\\Company", $model->addressbook_id); } $response['data']['photo_url'] = $model->photoThumbURL; $response['data']['original_photo_url'] = $model->photoURL; $stmt = $model->addresslists(); while ($addresslist = $stmt->fetch()) { $response['data']['addresslist_' . $addresslist->id] = 1; } $response['data']['name_and_name2'] = $model->name; if (!empty($model->name2)) { $response['data']['name_and_name2'] .= ' - ' . $model->name2; } return parent::afterLoad($response, $model, $params); }
protected function afterLoad(&$response, &$model, &$params) { $response['data']['path'] = $model->path; $response['data']['size'] = \GO\Base\Util\Number::formatSize($model->fsFile->size()); $response['data']['extension'] = strtolower($model->fsFile->extension()); $response['data']['type'] = \GO::t($response['data']['extension'], 'base', 'filetypes'); $response['data']['name'] = $model->fsFile->nameWithoutExtension(); if (!empty($model->user)) { $response['data']['username'] = $model->user->name; } if (!empty($model->mUser)) { $response['data']['musername'] = $model->mUser->name; } $response['data']['locked_user_name'] = $model->lockedByUser ? $model->lockedByUser->name : ''; if (\GO::modules()->customfields) { $response['customfields'] = \GO\Customfields\Controller\CategoryController::getEnabledCategoryData("GO\\Files\\Model\\File", $model->folder_id); } $fh = \GO\Files\Model\FileHandler::model()->findByPk(array('extension' => $model->extension, 'user_id' => \GO::user()->id)); if ($fh) { $fileHandler = new $fh->cls(); $response['data']['handlerCls'] = $fh->cls; $response['data']['handlerName'] = $fileHandler->getName(); } else { $response['data']['handlerCls'] = ""; $response['data']['handlerName'] = ""; } 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); }
public function formatStoreRecord($record, $model, $store) { $record['group_name'] = !empty($model->group) ? $model->group->name : ''; if (\GO::modules()->customfields) { $record['customfields'] = \GO\Customfields\Controller\CategoryController::getEnabledCategoryData("GO\\Calendar\\Model\\Event", $model->group_id); } return $record; }