/** * Create inline task check item using ajax * @param int $id * @param string $uniquePageId */ public function actionInlineCreateTaskCheckItemFromAjax($id, $uniquePageId) { $taskCheckListItem = new TaskCheckListItem(); $redirectUrl = Yii::app()->createUrl('/tasks/taskCheckItems/inlineCreateTaskCheckItemFromAjax', array('id' => $id, 'uniquePageId' => $uniquePageId)); $urlParameters = array('relatedModelId' => $id, 'relatedModelClassName' => 'Task', 'relatedModelRelationName' => 'checkListItems', 'redirectUrl' => $redirectUrl); //After save, the url to go to. $inlineView = new TaskCheckItemInlineEditView($taskCheckListItem, 'taskCheckItems', 'tasks', 'inlineCreateTaskCheckItemSave', $urlParameters, $uniquePageId); $view = new AjaxPageView($inlineView); echo $view->render(); }
/** * Used by my list portlets to do pagination and sort order changes. * @param integer $id */ public function actionMyListDetails() { $portlet = Portlet::getById(intval($_GET['portletId'])); $portletView = $portlet->getView(); if (!RightsUtil::canUserAccessModule($portletView::getModuleClassName(), Yii::app()->user->userModel)) { $messageView = new AccessFailureView(); $view = new AccessFailurePageView($messageView); echo $view->render(); Yii::app()->end(0, false); } $view = new AjaxPageView($portletView); echo $view->render(); }
public function actionDetails($id, $runReport = false) { $savedReport = SavedReport::getById((int) $id); ControllerSecurityUtil::resolveCanCurrentUserAccessModule($savedReport->moduleClassName); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($savedReport, true); $report = SavedReportToReportAdapter::makeReportBySavedReport($savedReport); $portlet = Portlet::getById(intval($_GET['portletId'])); $portlet->params = array('controllerId' => 'default', 'relationModuleId' => $this->getModule()->getId(), 'relationModel' => $report, 'redirectUrl' => Yii::app()->request->getRequestUri(), 'dataProvider' => $this->getDataProvider($report, $report->getId(), (bool) $runReport)); $portletView = $portlet->getView(); if (!RightsUtil::canUserAccessModule($portletView::getModuleClassName(), Yii::app()->user->userModel)) { $messageView = new AccessFailureView(); $view = new AccessFailurePageView($messageView); echo $view->render(); Yii::app()->end(0, false); } $view = new AjaxPageView($portletView); echo $view->render(); }
public function actionDeleteViaAjax($id) { $getData = GetUtil::getData(); $relatedModelId = ArrayUtil::getArrayValue($getData, 'relatedModelId'); $relatedModelClassName = ArrayUtil::getArrayValue($getData, 'relatedModelClassName'); $comment = Comment::getById(intval($id)); $relatedModel = $relatedModelClassName::getById(intval($relatedModelId)); if ($comment->createdByUser->id != Yii::app()->user->userModel->id && $relatedModel->owner->id != Yii::app()->user->userModel->id && $relatedModel->createdByUser->id != Yii::app()->user->userModel->id) { $messageView = new AccessFailureAjaxView(); $view = new AjaxPageView($messageView); echo $view->render(); Yii::app()->end(0, false); } $deleted = $comment->delete(); if (!$deleted) { throw new FailedToDeleteModelException(); } }
public static function renderDynamicSearchRowContent($viewClassName, $modelClassName, $formModelClassName, $rowNumber, $attributeIndexOrDerivedType, $inputContent, $suffix = null, $renderAsAjax = false) { assert('is_string($viewClassName)'); assert('is_string($modelClassName)'); assert('is_string($formModelClassName)'); assert('is_int($rowNumber)'); assert('is_string($attributeIndexOrDerivedType) || $attributeIndexOrDerivedType == null'); assert('is_string($suffix) || $suffix == null'); assert('is_bool($renderAsAjax)'); $searchableAttributeIndicesAndDerivedTypes = DynamicSearchUtil::getSearchableAttributesAndLabels($viewClassName, $modelClassName); $ajaxOnChangeUrl = Yii::app()->createUrl("zurmo/default/dynamicSearchAttributeInput", array('viewClassName' => $viewClassName, 'modelClassName' => $modelClassName, 'formModelClassName' => $formModelClassName, 'rowNumber' => $rowNumber, 'suffix' => $suffix)); $rowView = new DynamicSearchRowView($searchableAttributeIndicesAndDerivedTypes, (int) $rowNumber, $suffix, $formModelClassName, $ajaxOnChangeUrl, $attributeIndexOrDerivedType, $inputContent); if (!$renderAsAjax) { $view = $rowView; } else { $view = new AjaxPageView($rowView); } return ZurmoHtml::tag('div', array('class' => 'dynamic-search-row'), $view->render()); }
/** * Example of a sequential process. * @see TestCompleteSequentialProcessView * @see TestSequentialProcess * @param string $step */ function actionSequentialProcess($step) { if (isset($_GET['nextParams'])) { $nextParams = $_GET['nextParams']; } else { $nextParams = null; } Yii::import('application.core.tests.unit.models.*'); Yii::import('application.core.tests.unit.components.*'); Yii::import('application.core.tests.unit.views.*'); assert('$step == null || is_string($step)'); assert('$nextParams == null || is_array($nextParams)'); //////Do setup logic here if needed $a = new A(); $b = new B(); $sequentialProcess = new TestSequentialProcess($a, $b); $sequentialProcess->run($step, $nextParams); $nextStep = $sequentialProcess->getNextStep(); $route = $this->getModule()->getId() . '/' . $this->getId() . '/sequentialProcess'; if ($sequentialProcess->isComplete()) { //////Do completion logic here if needed $sequenceView = new TestCompleteSequentialProcessView($a, $b); } else { $sequenceView = SequentialProcessViewFactory::makeBySequentialProcess($sequentialProcess, $route); } if ($step == null) { $gridView = new GridView(2, 1); $titleBarView = new TitleBarView('Zurmo', 'Test Sequential Process'); $wrapperView = new SequentialProcessContainerView($sequenceView, $sequentialProcess->getAllStepsMessage()); $gridView->setView($titleBarView, 0, 0); $gridView->setView($wrapperView, 1, 0); $view = new ZurmoConfigurationPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $gridView)); } else { $view = new AjaxPageView($sequenceView); } echo $view->render(); }
public function actionDeleteViaAjax($id) { $socialItem = SocialItem::getById(intval($id)); if (!$socialItem->canUserDelete(Yii::app()->user->userModel) && $socialItem->owner->id != Yii::app()->user->userModel->id && $socialItem->toUser->id != Yii::app()->user->userModel->id) { $messageView = new AccessFailureAjaxView(); $view = new AjaxPageView($messageView); echo $view->render(); Yii::app()->end(0, false); } $deleted = $socialItem->delete(); if (!$deleted) { throw new FailedToDeleteModelException(); } }
public function actionGameDashboard($id) { $user = User::getById(intval($id)); UserAccessUtil::resolveAccessingASystemUser($user); $title = Zurmo::t('ZurmoModule', 'Dashboard'); $badgeData = GameBadge::getAllByPersonIndexedByType($user); $generalLevelData = GameLevelUtil::getStatisticsDataForAGivenLevelType($user, GameLevel::TYPE_GENERAL); $rankingData = GamePointUtil::getUserRankingData($user); $statisticsData = GameLevelUtil::getUserStatisticsData($user); $collectionData = GameCollection::resolvePersonAndAvailableTypes($user, GameCollection::getAvailableTypes()); $dashboardView = new UserGameDashboardView($this, $user, $generalLevelData, $badgeData, $rankingData, $statisticsData, $collectionData); $view = new AjaxPageView($dashboardView); echo $view->render(); }
/** * Refresh portlet contents within a dashboard or details relation view. In the case of details relation view * detect if the relationModelId is populated, in which case resolve and populate the relationModel. * Resets controller back to default. * @param string $portletId * @param string $uniqueLayoutId * @param string $redirectUrl * @param array $portletParams - optional argument which allows you to override the standard parameters. * @param bool $portletsAreRemovable */ public function actionModalRefresh($portletId, $uniqueLayoutId, $redirectUrl, array $portletParams = array(), $portletsAreRemovable = true) { $portlet = Portlet::getById(intval($portletId)); $portlet->params = array_merge(array('controllerId' => 'default', 'moduleId' => $this->getModule()->getId(), 'redirectUrl' => $redirectUrl), $portletParams); if (isset($portlet->params['relationModelId']) && $portlet->params['relationModelId'] != '') { assert('$portlet->params["relationModuleId"] != ""'); $modelClassName = Yii::app()->findModule($portlet->params["relationModuleId"])->getPrimaryModelName(); $portlet->params['relationModel'] = $modelClassName::getById((int) $portlet->params['relationModelId']); } $view = new AjaxPageView(new PortletRefreshView($portlet, $uniqueLayoutId, $this->getModule()->getId(), (bool) $portletsAreRemovable)); echo $view->render(); }
public function actionInlineCreateCommentFromAjax($id, $uniquePageId) { $comment = new Comment(); $redirectUrl = Yii::app()->createUrl('/conversations/default/inlineCreateCommentFromAjax', array('id' => $id, 'uniquePageId' => $uniquePageId)); $urlParameters = array('relatedModelId' => (int) $id, 'relatedModelClassName' => 'Conversation', 'relatedModelRelationName' => 'comments', 'redirectUrl' => $redirectUrl); //After save, the url to go to. $uniquePageId = 'CommentInlineEditForModelView'; echo ZurmoHtml::tag('h2', array(), Zurmo::t('CovnersationsModule', 'Add Comment')); $inlineView = new CommentInlineEditView($comment, 'default', 'comments', 'inlineCreateSave', $urlParameters, $uniquePageId); $view = new AjaxPageView($inlineView); echo $view->render(); }
/** * Step 4 ajax process. When you click the 'Add Field' button in the user interface, this ajax action * is called and makes an extra row to display for mapping. */ public function actionMappingAddExtraMappingRow($id, $columnCount) { $import = Import::getById((int) $_GET['id']); $importWizardForm = ImportWizardUtil::makeFormByImport($import); $importRulesClassName = ImportRulesUtil::getImportRulesClassNameByType($importWizardForm->importRulesType); $mappableAttributeIndicesAndDerivedTypes = $importRulesClassName::getMappableAttributeIndicesAndDerivedTypes(); $extraColumnName = ImportMappingUtil::makeExtraColumnNameByColumnCount((int) $columnCount); $mappingDataMetadata = ImportWizardMappingViewUtil::makeExtraColumnMappingDataForViewByColumnName($extraColumnName); $extraColumnView = new ImportWizardMappingExtraColumnView($importWizardForm, $mappingDataMetadata, $mappableAttributeIndicesAndDerivedTypes); $view = new AjaxPageView($extraColumnView); echo $view->render(); }
/** * Render the listView to update after ajax request is made * @param MashableInboxForm $mashableInboxForm * @param string $modelClassName * @param array $getData */ private function renderListViewForAjax($mashableInboxForm, $modelClassName) { if ($modelClassName !== null) { $mashableUtilRules = MashableUtil::createMashableInboxRulesByModel($modelClassName); $listView = $mashableUtilRules->getListView($mashableInboxForm->optionForModel, $mashableInboxForm->filteredBy, $mashableInboxForm->searchTerm, $mashableInboxForm->filterByStarred); } else { $listView = $this->getMashableInboxListView($mashableInboxForm, $this->pageSize); } $view = new AjaxPageView($listView); echo $view->render(); }