public function actionLeaderboard($type = null)
 {
     if ($type == null) {
         $type = GamePointUtil::LEADERBOARD_TYPE_WEEKLY;
     }
     if ($type == GamePointUtil::LEADERBOARD_TYPE_WEEKLY) {
         $activeActionElementType = 'LeaderboardWeeklyMenu';
     } elseif ($type == GamePointUtil::LEADERBOARD_TYPE_MONTHLY) {
         $activeActionElementType = 'LeaderboardMonthlyMenu';
     } elseif ($type == GamePointUtil::LEADERBOARD_TYPE_OVERALL) {
         $activeActionElementType = 'LeaderboardOverallMenu';
     } else {
         throw new NotSupportedException();
     }
     $metadata = array();
     //can put the typing information here easily. from the type.
     $pageSize = Yii::app()->pagination->resolveActiveForCurrentUserByType('listPageSize', get_class($this->getModule()));
     $gameLevel = new GameLevel(false);
     $dataProvider = RedBeanModelDataProviderUtil::makeDataProvider($metadata, get_class($gameLevel), 'LeaderboardDataProvider', 'notUsed', true, $pageSize);
     $dataProvider->setType($type);
     if (isset($_GET['ajax']) && $_GET['ajax'] == 'list-view') {
         $listView = new LeaderboardListView($this->getId(), $this->getModule()->getId(), get_class($gameLevel), $dataProvider, array());
         $view = new AccountsPageView($listView);
     } else {
         $mixedView = new LeaderboardActionBarAndListView($this->getId(), $this->getModule()->getId(), $gameLevel, 'GamificationModule', $dataProvider, $activeActionElementType);
         $view = new AccountsPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $mixedView));
     }
     echo $view->render();
 }
 public function actionEdit($id, $redirectUrl = null)
 {
     $mission = Mission::getById(intval($id));
     MissionAccessUtil::resolveCanCurrentUserWriteOrDeleteMission($mission);
     ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($mission);
     $editView = new MissionEditView($this->getId(), $this->getModule()->getId(), $this->attemptToSaveModelFromPost($mission), strval($mission));
     $missionsMashableInboxUrl = Yii::app()->createUrl('mashableInbox/default/list', array('modelClassName' => 'Mission'));
     $breadCrumbLinks = array(Zurmo::t('MissionsModule', 'Missions') => $missionsMashableInboxUrl, StringUtil::getChoppedStringContent(strval($mission), 25) => array('default/details', 'id' => $id), Zurmo::t('Core', 'Edit'));
     $view = new MissionsPageView(ZurmoDefaultViewUtil::makeViewWithBreadcrumbsForCurrentUser($this, $editView, $breadCrumbLinks, 'MissionBreadCrumbView'));
     echo $view->render();
 }
Пример #3
0
 public function actionMassDelete()
 {
     $pageSize = Yii::app()->pagination->resolveActiveForCurrentUserByType('massDeleteProgressPageSize');
     $deptReference = new DepartmentReference(false);
     $activeAttributes = $this->resolveActiveAttributesFromMassDeletePost();
     $dataProvider = $this->getDataProviderByResolvingSelectAllFromGet(new DepartmentReferencesSearchForm($deptReference), $pageSize, Yii::app()->user->userModel->id, null, 'DepartmentReferencesSearchView');
     $selectedRecordCount = $this->getSelectedRecordCountByResolvingSelectAllFromGet($dataProvider);
     $deptReference = $this->processMassDelete($pageSize, $activeAttributes, $selectedRecordCount, 'DepartmentReferencesPageView', $deptReference, DepartmentReferencesModule::getModuleLabelByTypeAndLanguage('Plural'), $dataProvider);
     $massDeleteView = $this->makeMassDeleteView($deptReference, $activeAttributes, $selectedRecordCount, DepartmentReferencesModule::getModuleLabelByTypeAndLanguage('Plural'));
     $view = new DepartmentReferencesPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $massDeleteView));
     echo $view->render();
 }
 protected function preFilter($filterChain)
 {
     if (isset($_POST['ajax'])) {
         return true;
     }
     if (Yii::app()->emailHelper->outboundHost != null) {
         return true;
     }
     $messageView = new NoGlobalEmailConfigurationYetView();
     $pageViewClassName = $this->controller->getModule()->getPluralCamelCasedName() . 'PageView';
     $view = new $pageViewClassName(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this->controller, $messageView));
     echo $view->render();
     return false;
 }
 protected function preFilter($filterChain)
 {
     if (isset($_POST['ajax'])) {
         return true;
     }
     $isLdapExtensionLoaded = InstallUtil::isLdapInstalled();
     if ($isLdapExtensionLoaded) {
         return true;
     }
     $messageView = new NoLdapExtensionLoadedView();
     $pageViewClassName = $this->controller->getModule()->getPluralCamelCasedName() . 'PageView';
     $view = new $pageViewClassName(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this->controller, $messageView));
     echo $view->render();
     return false;
 }
Пример #6
0
 public function actionLeaderboard($type = null)
 {
     if ($type == null) {
         $type = GamePointUtil::LEADERBOARD_TYPE_WEEKLY;
     }
     if ($type == GamePointUtil::LEADERBOARD_TYPE_WEEKLY) {
         $activeActionElementType = 'LeaderboardWeeklyLink';
     } elseif ($type == GamePointUtil::LEADERBOARD_TYPE_MONTHLY) {
         $activeActionElementType = 'LeaderboardMonthlyLink';
     } elseif ($type == GamePointUtil::LEADERBOARD_TYPE_OVERALL) {
         $activeActionElementType = 'LeaderboardOverallLink';
     } else {
         throw new NotSupportedException();
     }
     $view = new TitleBarAndLeaderboardView($this->getId(), $this->getModule()->getId(), GamePointUtil::getUserLeaderboardData($type), $activeActionElementType);
     $view = new LeaderboardPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $view));
     echo $view->render();
 }
 /**
  * Check if user set their primary email address.
  * @param CFilterChain $filterChain
  * @return bool
  * @throws NotFoundException
  * @throws NotSupportedException
  */
 protected function preFilter($filterChain)
 {
     if ($this->userId != null) {
         $user = User::getById($this->userId);
     } else {
         throw new NotSupportedException();
     }
     if (isset($_POST['ajax'])) {
         return true;
     }
     if ($user->primaryEmail->emailAddress != null) {
         return true;
     }
     $messageView = new NoPrimaryEmailAddressForLoggedUserYetView($this->userId);
     $pageViewClassName = $this->controller->getModule()->getPluralCamelCasedName() . 'PageView';
     $view = new $pageViewClassName(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this->controller, $messageView));
     echo $view->render();
     return false;
 }
 public function actionList()
 {
     $pageSize = new resolveActiveForCurrentUserByType('listPageSize', get_class($this->getModule()));
     $savedReport = new SavedReport(false);
     $searchForm = new ReportsSearchForm($savedReport);
     $listAttributesSelector = new ListAttributesSelector('ReportsListView', get_class($this->getModule()));
     $searchForm->setListAttributesSelector($listAttributesSelector);
     $dataProvider = $this->resolveSearchDataProvider($searchForm, $pageSize, null, 'ReportsSearchView');
     $title = Zurmo::t('ReportsModule', 'Reports');
     $breadCrumbLinks = array($title);
     if (isset($_GET['ajax']) && $_GET['ajax'] == 'list-view') {
         $mixedView = $this->makeListView($searchForm, $dataProvider);
         $view = new ReportsPageView($mixedView);
     } else {
         $mixedView = $this->makeActionBarSearchAndListView($searchForm, $dataProvider, 'SecuredActionBarForReportsSearchAndListView');
         $view = new ReportsPageView(ZurmoDefaultViewUtil::makeViewWithBreadcrumbsForCurrentUser($this, $mixedView, $breadCrumbLinks, 'ReportBreadCrumbView'));
     }
     echo $view->render();
 }
 protected function preFilter($filterChain)
 {
     if (isset($_POST['ajax'])) {
         return true;
     }
     //Added some logic for watching there is last unmatched mail deleted
     $pageSize = null;
     $emailMessage = new EmailMessage(false);
     $searchAttributes = array();
     $metadataAdapter = new ArchivedEmailMatchingSearchDataProviderMetadataAdapter($emailMessage, Yii::app()->user->userModel->id, $searchAttributes);
     $dataProvider = RedBeanModelDataProviderUtil::makeDataProvider($metadataAdapter->getAdaptedMetadata(), 'EmailMessage', 'RedBeanModelDataProvider', 'createdDateTime', true, $pageSize);
     $data = $dataProvider->getData();
     if (count($data) > 0) {
         return true;
     }
     $messageView = new ZeroEmailMessagesRequiringArchivingView();
     $pageViewClassName = $this->controller->getModule()->getPluralCamelCasedName() . 'PageView';
     $view = new $pageViewClassName(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this->controller, $messageView));
     echo $view->render();
     return false;
 }
 protected function preFilter($filterChain)
 {
     $getData = GetUtil::getData();
     $modelClassName = ArrayUtil::getArrayValue($getData, 'modelClassName');
     if ($modelClassName == null) {
         return true;
     }
     if ($modelClassName::getCount() != 0) {
         return true;
     }
     $moduleClassName = $modelClassName::getModuleClassName();
     $mashableRules = MashableUtil::createMashableInboxRulesByModel($modelClassName);
     if ($mashableRules->getZeroModelViewClassName() == null) {
         return true;
     }
     $messageViewClassName = $mashableRules->getZeroModelViewClassName();
     $messageView = new $messageViewClassName($this->controller->getId(), $moduleClassName::getDirectoryName(), $modelClassName);
     $pageViewClassName = $this->controller->getModule()->getPluralCamelCasedName() . 'PageView';
     $view = new $pageViewClassName(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this->controller, $messageView));
     echo $view->render();
     return false;
 }
 /**
  * Action for displaying a mass delete form and also action when that form is first submitted.
  * When the form is submitted, in the event that the quantity of models to delete is greater
  * than the pageSize, then once the pageSize quantity has been reached, the user will be
  * redirected to the makeMassDeleteProgressView.
  * In the mass delete progress view, a javascript refresh will take place that will call a refresh
  * action, usually makeMassDeleteProgressView.
  * If there is no need for a progress view, then a flash message will be added and the user will
  * be redirected to the list view for the model.  A flash message will appear providing information
  * on the delete records.
  * @see Controller->makeMassDeleteProgressView
  * @see Controller->processMassDelete
  * @see
  */
 public function actionMassDelete()
 {
     $pageSize = Yii::app()->pagination->resolveActiveForCurrentUserByType('massDeleteProgressPageSize');
     $queueItem = new WorkflowMessageInQueue(false);
     $activeAttributes = $this->resolveActiveAttributesFromMassDeletePost();
     $dataProvider = $this->getDataProviderByResolvingSelectAllFromGet(new WorkflowMessageInQueuesSearchForm($queueItem), $pageSize, Yii::app()->user->userModel->id, null, 'WorkflowMessageInQueuesSearchView');
     $selectedRecordCount = static::getSelectedRecordCountByResolvingSelectAllFromGet($dataProvider);
     $queueItem = $this->processMassDelete($pageSize, $activeAttributes, $selectedRecordCount, 'WorkflowsPageView', $queueItem, Zurmo::t('WorkflowsModule', 'Message Queue'), $dataProvider, array($this->getId() . '/list'));
     $massDeleteView = $this->makeMassDeleteView($queueItem, $activeAttributes, $selectedRecordCount, Zurmo::t('WorkflowsModule', 'Message Queue'), 'MassDeleteView', false);
     $view = new WorkflowsPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $massDeleteView));
     echo $view->render();
 }
 public function actionEdit($id, $isBeingCopied = false)
 {
     $savedReport = SavedReport::getById((int) $id);
     ControllerSecurityUtil::resolveCanCurrentUserAccessModule($savedReport->moduleClassName);
     if (!$isBeingCopied) {
         ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($savedReport);
     }
     $breadCrumbLinks = array(strval($savedReport));
     $report = SavedReportToReportAdapter::makeReportBySavedReport($savedReport);
     $progressBarAndStepsView = ReportWizardViewFactory::makeStepsAndProgressBarViewFromReport($report);
     $reportWizardView = ReportWizardViewFactory::makeViewFromReport($report, (bool) $isBeingCopied);
     $view = new ReportsPageView(ZurmoDefaultViewUtil::makeTwoViewsWithBreadcrumbsForCurrentUser($this, $progressBarAndStepsView, $reportWizardView, $breadCrumbLinks, 'ReportBreadCrumbView'));
     echo $view->render();
 }
 public function actionPushLayout($id)
 {
     $modelClassName = $this->getModelName();
     $model = $modelClassName::getById(intval($id));
     if (isset($_POST[$modelClassName])) {
         $groupsAndUsers = PushDashboardUtil::resolveGroupsAndUsersFromPost($_POST[$modelClassName]);
         PushDashboardUtil::pushLayoutToUsers($model, $groupsAndUsers);
         Yii::app()->user->setFlash('notification', Zurmo::t('ZurmoModule', 'Layout pushed successfully'));
         $this->redirect(array($this->getId() . '/details', 'id' => $id));
     }
     $editView = new PushDashboardEditView($this->getId(), $this->getModule()->getId(), $model, Zurmo::t('ZurmoModule', 'Push Layout'));
     $view = new ZurmoPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $editView));
     echo $view->render();
 }
Пример #14
0
 /**
  * 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();
 }
Пример #15
0
 protected function actionCreateByModel(Conversation $conversation, $redirectUrl)
 {
     $editView = new ConversationEditView($this->getId(), $this->getModule()->getId(), $this->attemptToSaveModelFromPost($conversation, $redirectUrl), Zurmo::t('ConversationsModule', 'Create Conversation'));
     $view = new ConversationsPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $editView));
     echo $view->render();
 }
 /**
  * @param Activity $activity
  * @param null $redirectUrl
  */
 protected function processEdit(Activity $activity, $redirectUrl = null)
 {
     $pageViewClassName = $this->getPageViewClassName();
     $view = new $pageViewClassName(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $this->makeEditAndDetailsView($this->attemptToSaveModelFromPost($activity, $redirectUrl), 'Edit')));
     echo $view->render();
 }
Пример #17
0
 /**
  * Process the editing of product
  * @param Product $product
  * @param string $redirectUrl
  */
 protected function processEdit(Product $product, $redirectUrl = null)
 {
     $view = new ProductsPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $this->makeEditAndDetailsView($this->attemptToSaveModelFromPost($product, $redirectUrl), 'Edit')));
     echo $view->render();
 }
 protected function resolveShouldRenderActionBarLinksForKanbanBoard()
 {
     if ($this->shouldRenderActionBarLinksForKanbanBoard()) {
         return ZurmoDefaultViewUtil::renderActionBarLinksForKanbanBoard($this->controllerId, $this->params['relationModuleId'], (int) $this->params['relationModel']->id, true);
     }
 }
 public function actionMatchingList()
 {
     $userCanAccessContacts = RightsUtil::canUserAccessModule('ContactsModule', Yii::app()->user->userModel);
     $userCanAccessLeads = RightsUtil::canUserAccessModule('LeadsModule', Yii::app()->user->userModel);
     EmailMessagesControllerSecurityUtil::resolveCanUserProperlyMatchMessage($userCanAccessContacts, $userCanAccessLeads);
     $pageSize = Yii::app()->pagination->resolveActiveForCurrentUserByType('listPageSize', get_class($this->getModule()));
     $emailMessage = new EmailMessage(false);
     $searchAttributes = array();
     $metadataAdapter = new ArchivedEmailMatchingSearchDataProviderMetadataAdapter($emailMessage, Yii::app()->user->userModel->id, $searchAttributes);
     $dataProvider = RedBeanModelDataProviderUtil::makeDataProvider($metadataAdapter->getAdaptedMetadata(), 'EmailMessage', 'RedBeanModelDataProvider', 'createdDateTime', true, $pageSize);
     $titleBarAndListView = new TitleBarAndListView($this->getId(), $this->getModule()->getId(), $emailMessage, 'EmailMessage', $dataProvider, 'ArchivedEmailMatchingListView', Zurmo::t('EmailMessagesModule', 'Unmatched Archived Emails'), array(), false);
     $view = new EmailMessagesPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $titleBarAndListView));
     echo $view->render();
 }
 protected function processMassAction($pageSize, $selectedRecordCount, $pageViewClassName, $listModel, $title, $actionId, $dataProvider = null)
 {
     // TODO: @Shoaibi/@Jason: Low: Candidate for MassActionController
     assert('$dataProvider == null || $dataProvider instanceof CDataProvider');
     $postSelectedRecordCount = Yii::app()->request->getPost('selectedRecordCount');
     $modelClassName = get_class($listModel);
     $postModelClassName = Yii::app()->request->getPost($modelClassName);
     if (isset($postSelectedRecordCount) || isset($postModelClassName)) {
         $page = static::resolvePageValueForMassAction($modelClassName);
         $insufficientPermissionSkipSavingUtil = static::resolveInsufficientPermissionSkipSavingUtilByMassActionId($actionId);
         $start = $selectedRecordCount > $pageSize ? 1 : $selectedRecordCount;
         $skipCount = $selectedRecordCount > $pageSize ? null : 0;
         $massActionSuccessful = static::processModelsForMassAction($listModel, $modelClassName, $selectedRecordCount, $dataProvider, $page, $pageSize, $insufficientPermissionSkipSavingUtil, $postModelClassName, $actionId);
         if ($massActionSuccessful) {
             $progressView = $this->makeMassActionProgressView($listModel, 1, $selectedRecordCount, $start, $pageSize, $title, $skipCount, $actionId);
             if ($selectedRecordCount > $pageSize) {
                 $view = new $pageViewClassName(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $progressView));
                 echo $view->render();
             } else {
                 $refreshScript = $progressView->renderRefreshScript();
                 Yii::app()->user->setFlash('notification', $refreshScript['message']);
                 $this->redirect($this->resolveReturnUrlForMassAction());
             }
             Yii::app()->end(0, false);
         }
     }
     return $listModel;
 }
 /**
  * Combined details for the calendar.
  */
 public function actionCombinedDetails()
 {
     $dataProvider = CalendarUtil::getCalendarItemsDataProvider(Yii::app()->user->userModel);
     $interactiveCalendarView = new CombinedCalendarView($dataProvider, $this->getId(), $this->getModule()->getId());
     $view = new CalendarsPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $interactiveCalendarView));
     echo $view->render();
 }
 /**
  * Resolves portlet configurable parameters
  * @param boolean $portletsAreMovable
  * @param boolean $portletsAreRemovable
  */
 protected function resolvePortletConfigurableParams(&$portletsAreMovable, &$portletsAreRemovable)
 {
     assert('is_bool($portletsAreMovable)');
     assert('is_bool($portletsAreRemovable)');
     $getData = GetUtil::getData();
     if (isset($getData['lockPortlets'])) {
         $lockPortlets = (bool) $getData['lockPortlets'];
         if ($lockPortlets) {
             ZurmoDefaultViewUtil::setLockKeyForDetailsAndRelationsView('lockPortletsForDetailsAndRelationsView', true);
         } else {
             ZurmoDefaultViewUtil::setLockKeyForDetailsAndRelationsView('lockPortletsForDetailsAndRelationsView', false);
         }
     }
     $isViewLocked = ZurmoDefaultViewUtil::getLockKeyForDetailsAndRelationsView('lockPortletsForDetailsAndRelationsView');
     //Default case for the first time
     if ($isViewLocked === null) {
         ZurmoDefaultViewUtil::setLockKeyForDetailsAndRelationsView('lockPortletsForDetailsAndRelationsView', true);
         $isViewLocked = true;
     }
     if ($isViewLocked == true) {
         $portletsAreRemovable = false;
         $portletsAreMovable = false;
     }
 }
Пример #23
0
 /**
  * Action for displaying a mass delete form and also action when that form is first submitted.
  * When the form is submitted, in the event that the quantity of models to delete is greater
  * than the pageSize, then once the pageSize quantity has been reached, the user will be
  * redirected to the makeMassDeleteProgressView.
  * In the mass delete progress view, a javascript refresh will take place that will call a refresh
  * action, usually makeMassDeleteProgressView.
  * If there is no need for a progress view, then a flash message will be added and the user will
  * be redirected to the list view for the model.  A flash message will appear providing information
  * on the delete records.
  * @see Controler->makeMassDeleteProgressView
  * @see Controller->processMassDelete
  * @see
  */
 public function actionMassDelete()
 {
     $pageSize = Yii::app()->pagination->resolveActiveForCurrentUserByType('massDeleteProgressPageSize');
     $contact = new Contact(false);
     $activeAttributes = $this->resolveActiveAttributesFromMassDeletePost();
     $dataProvider = $this->getDataProviderByResolvingSelectAllFromGet(new ContactsSearchForm($contact), $pageSize, Yii::app()->user->userModel->id, 'ContactsStateMetadataAdapter', 'ContactsSearchView');
     $selectedRecordCount = static::getSelectedRecordCountByResolvingSelectAllFromGet($dataProvider);
     $contact = $this->processMassDelete($pageSize, $activeAttributes, $selectedRecordCount, 'ContactsPageView', $contact, ContactsModule::getModuleLabelByTypeAndLanguage('Plural'), $dataProvider);
     $massDeleteView = $this->makeMassDeleteView($contact, $activeAttributes, $selectedRecordCount, ContactsModule::getModuleLabelByTypeAndLanguage('Plural'));
     $view = new ContactsPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $massDeleteView));
     echo $view->render();
 }
Пример #24
0
 public function actionAssemblyStep3($id)
 {
     if (empty($_SERVER['HTTP_REFERER'])) {
         $this->redirect(array('/costbook/default/Assembly'));
     }
     $Costbook = static::getModelAndCatchNotFoundAndDisplayError("Costbook", intval($id));
     $editAndDetailsView = new CostbookAssemblyStep3View('Edit', $this->getId(), $this->getModule()->getId(), $this->attemptToSaveModelFromPost($Costbook));
     $view = new CostbookPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $editAndDetailsView));
     echo $view->render();
 }
Пример #25
0
 protected function processEdit(AccountContactAffiliation $accountContactAffiliation, $redirectUrl = null)
 {
     $view = new AccountContactAffiliationsPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $this->makeEditAndDetailsView($this->attemptToSaveModelFromPost($accountContactAffiliation, $redirectUrl), 'Edit')));
     echo $view->render();
 }
 public function actionConvertFinal($id)
 {
     assert('!empty($id)');
     $accountPostData = LeadsUtil::getFromSession(LeadsUtil::LEAD_CONVERSION_ACCOUNT_DATA_SESSION_KEY);
     if (empty($accountPostData)) {
         $urlParams = array('/leads/' . $this->getId() . '/convert', 'id' => $id);
         $this->redirect($urlParams);
     }
     $contact = Contact::getById(intval($id));
     if (!LeadsUtil::isStateALead($contact->state)) {
         $urlParams = array('/contacts/' . $this->getId() . '/details', 'id' => $contact->id);
         $this->redirect($urlParams);
     }
     $convertToAccountSetting = LeadsModule::getConvertToAccountSetting();
     $convertToOpportunitySetting = LeadsModule::getConvertToOpportunitySetting();
     $opportunity = new Opportunity();
     ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($contact);
     $userCanAccessContacts = RightsUtil::canUserAccessModule('ContactsModule', Yii::app()->user->userModel);
     $userCanAccessAccounts = RightsUtil::canUserAccessModule('AccountsModule', Yii::app()->user->userModel);
     $userCanAccessOpportunities = RightsUtil::canUserAccessModule('OpportunitiesModule', Yii::app()->user->userModel);
     $userCanCreateOpportunity = RightsUtil::doesUserHaveAllowByRightName('OpportunitiesModule', OpportunitiesModule::RIGHT_CREATE_OPPORTUNITIES, Yii::app()->user->userModel);
     LeadsControllerSecurityUtil::resolveCanUserProperlyConvertLead($userCanAccessContacts, $userCanAccessAccounts, $convertToAccountSetting);
     LeadsControllerSecurityUtil::resolveCanUserProperlyConvertLeadFinalStep($userCanAccessContacts, $userCanAccessOpportunities, $convertToOpportunitySetting);
     if (isset($_POST['Opportunity'])) {
         $controllerUtil = static::getZurmoControllerUtil();
         $savedSuccessfully = false;
         $modelToStringValue = null;
         $postData = $_POST['Opportunity'];
         $opportunity = $controllerUtil->saveModelFromPost($postData, $opportunity, $savedSuccessfully, $modelToStringValue, false);
         if ($savedSuccessfully) {
             $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($contact);
             ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($opportunity, $explicitReadWriteModelPermissions);
             $account = LeadsUtil::createAccountForLeadConversionFromAccountPostData($accountPostData, $contact, $controllerUtil);
             $opportunity->account = $account;
             if (!$opportunity->save()) {
                 throw new NotSupportedException();
             }
             LeadsUtil::removeFromSession(LeadsUtil::LEAD_CONVERSION_ACCOUNT_DATA_SESSION_KEY);
             $this->actionSaveConvertedContact($contact, $account, $opportunity);
         }
     } elseif (isset($_POST['OpportunitySkip']) || $convertToOpportunitySetting == LeadsModule::CONVERT_NO_OPPORTUNITY || $convertToOpportunitySetting == LeadsModule::CONVERT_OPPORTUNITY_NOT_REQUIRED && !$userCanAccessOpportunities) {
         $controllerUtil = static::getZurmoControllerUtil();
         $account = LeadsUtil::createAccountForLeadConversionFromAccountPostData($accountPostData, $contact, $controllerUtil);
         LeadsUtil::removeFromSession(LeadsUtil::LEAD_CONVERSION_ACCOUNT_DATA_SESSION_KEY);
         $this->actionSaveConvertedContact($contact, $account, null);
     }
     $progressBarAndStepsView = new LeadConversionStepsAndProgressBarForWizardView(1);
     $convertView = new LeadConvertOpportunityView($this->getId(), $this->getModule()->getId(), $contact->id, strval($contact), $opportunity, $convertToOpportunitySetting, $userCanCreateOpportunity);
     $view = new LeadsPageView(ZurmoDefaultViewUtil::makeTwoStandardViewsForCurrentUser($this, $progressBarAndStepsView, $convertView));
     echo $view->render();
 }
 /**
  * In a detail view, after you hit select from a sub view a modal listview will appear. If you select a row
  * in that view, then this action is called. This action will relate the selected model to the detail view model.
  * Then it will redirect to a portlet action that refreshes the portlet. Some parameters are passed to that
  * redirect that ensure continuity on futher actions that rely on existing $_GET information.
  * @param string $modelId
  * @param string $portletId
  * @param string $uniqueLayoutId
  * @param string $relationAttributeName
  * @param string $relationModelId
  * @param string $relationModuleId
  * @param null|string $relationModelClassName
  */
 public function actionSelectFromRelatedListSave($modelId, $portletId, $uniqueLayoutId, $relationAttributeName, $relationModelId, $relationModuleId, $relationModelClassName = null)
 {
     if ($relationModelClassName == null) {
         $relationModelClassName = Yii::app()->getModule($relationModuleId)->getPrimaryModelName();
     }
     $relationModel = $relationModelClassName::getById((int) $relationModelId);
     $modelClassName = $this->getModule()->getPrimaryModelName();
     $model = $modelClassName::getById((int) $modelId);
     $redirectUrl = $this->createUrl('/' . $relationModuleId . '/default/details', array('id' => $relationModelId));
     if (!$model->{$relationAttributeName}->contains($relationModel)) {
         $model->{$relationAttributeName}->add($relationModel);
         if (!$model->save()) {
             $this->processSelectFromRelatedListSaveFails($model);
         }
     } else {
         $this->processSelectFromRelatedListSaveAlreadyConnected($model);
     }
     $isViewLocked = ZurmoDefaultViewUtil::getLockKeyForDetailsAndRelationsView('lockPortletsForDetailsAndRelationsView');
     $this->redirect(array('/' . $relationModuleId . '/defaultPortlet/modalRefresh', 'id' => $relationModelId, 'portletId' => $portletId, 'uniqueLayoutId' => $uniqueLayoutId, 'redirectUrl' => $redirectUrl, 'portletParams' => array('relationModuleId' => $relationModuleId, 'relationModelId' => $relationModelId), 'portletsAreRemovable' => !$isViewLocked));
 }
 public static function makeViewWithBreadcrumbsForCurrentUser(CController $controller, View $containedView, $breadcrumbLinks, $breadcrumbViewClassName, $cssClasses = array('AdministrativeArea'))
 {
     return parent::makeViewWithBreadcrumbsForCurrentUser($controller, $containedView, $breadcrumbLinks, $breadcrumbViewClassName, $cssClasses);
 }
 public function __construct(View $view)
 {
     parent::__construct(ZurmoDefaultViewUtil::makeErrorViewForCurrentUser(Yii::app()->controller, $view));
 }
Пример #30
0
 /**
  * Depending on the user interface, the user views should utilize the admin or regular view.  This especially
  * important for mobile, since for mobile there are no admin views available yet.
  * @param $containedView
  * @param $breadCrumbLinks
  * @param $breadcrumbViewClassName
  * @return GridView
  */
 protected function resolveZurmoDefaultOrAdminView(View $containedView, $breadCrumbLinks, $breadcrumbViewClassName)
 {
     assert('is_array($breadCrumbLinks)');
     assert('is_string($breadcrumbViewClassName)');
     if (Yii::app()->userInterface->isMobile()) {
         return ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $containedView);
     } else {
         return ZurmoDefaultAdminViewUtil::makeViewWithBreadcrumbsForCurrentUser($this, $containedView, $breadCrumbLinks, $breadcrumbViewClassName);
     }
 }