/** * Initialize the listeners for the ActiveRecords */ public static function initListeners() { // Define the ActiveRecord \GO\Files\Model\File \GO\Files\Model\File::model()->addListener('save', 'GO\\Workflow\\WorkflowModule', 'save'); \GO\Files\Model\File::model()->addListener('delete', 'GO\\Workflow\\WorkflowModule', 'delete'); // Define the ActiveRecord \GO\Tasks\Model\Task \GO\Tasks\Model\Task::model()->addListener('save', 'GO\\Workflow\\WorkflowModule', 'save'); \GO\Tasks\Model\Task::model()->addListener('delete', 'GO\\Workflow\\WorkflowModule', 'delete'); // Add trigger for folder in the files module $c = new \GO\Files\Controller\FolderController(); $c->addListener('submit', 'GO\\Workflow\\WorkflowModule', 'checkFolderTrigger'); $c->addListener('load', 'GO\\Workflow\\WorkflowModule', 'loadFolderTrigger'); }
protected function afterSubmit(&$response, &$model, &$params, $modifiedAttributes) { if (!empty($params['comment']) && \GO::modules()->comments) { $comment = new \GO\Comments\Model\Comment(); // $comment->id $comment->model_id = $model->id; $comment->model_type_id = $model->modelTypeId(); $comment->user_id = \GO::user()->id; // $comment->ctime // $comment->mtime $comment->comments = $params['comment']; $comment->save(); } if (\GO::modules()->files) { $f = new \GO\Files\Controller\FolderController(); $f->processAttachments($response, $model, $params); } return parent::afterSubmit($response, $model, $params, $modifiedAttributes); }
private function _processFilesDisplay($model, $response) { if (isset(\GO::modules()->files) && $model->hasFiles() && $response['data']['files_folder_id'] > 0) { $fc = new \GO\Files\Controller\FolderController(); $listResponse = $fc->run("list", array('skip_fs_sync' => true, 'folder_id' => $response['data']['files_folder_id'], "limit" => 20, "sort" => 'mtime', "dir" => 'DESC'), false); $response['data']['files'] = $listResponse['results']; } else { $response['data']['files'] = array(); } return $response; }
protected function afterSubmit(&$response, &$model, &$params, $modifiedAttributes) { $isNewEvent = empty($params['id']); if (!$model->isResource()) { $this->_saveParticipants($params, $model, $response); $this->_saveResources($params, $model, $isNewEvent, $modifiedAttributes); } if (\GO::modules()->files) { //handle attachment when event is saved from an email. $f = new \GO\Files\Controller\FolderController(); $f->processAttachments($response, $model, $params); } // Send the status and status background color with the response $response['status_color'] = $model->getStatusColor(); $response['status'] = $model->status; $response['is_organizer'] = $model->is_organizer ? true : false; $response['background'] = $model->background; if ($model->is_organizer) { //$model->sendMeetingRequest(); if ($model->hasOtherParticipants()) { $response['isNewEvent'] = $isNewEvent; if ($isNewEvent) { $response['askForMeetingRequest'] = true; $response['is_update'] = false; } else { //only ask to send email if a relevant attribute has been altered $attr = $model->getRelevantMeetingAttributes(); foreach ($modifiedAttributes as $key => $value) { if (in_array($key, $attr)) { $response['askForMeetingRequest'] = true; $response['is_update'] = true; break; } } } } } $allParticipantsStmt = \GO\Calendar\Model\Participant::model()->findByAttributes(array('event_id' => $model->id, 'is_organizer' => 0)); $allParticipantIds = array(); foreach ($allParticipantsStmt as $participantModel) { $allParticipantIds[] = $participantModel->user_id; } $newParticipantIds = !empty(\GO::session()->values['new_participant_ids']) ? \GO::session()->values['new_participant_ids'] : array(); $oldParticipantsIds = array_diff($allParticipantIds, $newParticipantIds); if (!empty($newParticipantIds) && !empty($oldParticipantsIds)) { $response['askForMeetingRequestForNewParticipants'] = true; } return parent::afterSubmit($response, $model, $params, $modifiedAttributes); }