public function actionDetails($id)
 {
     $contact = static::getModelAndCatchNotFoundAndDisplayError('Contact', intval($id));
     ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($contact);
     if (!LeadsUtil::isStateALead($contact->state)) {
         $urlParams = array('/contacts/' . $this->getId() . '/details', 'id' => $contact->id);
         $this->redirect($urlParams);
     } else {
         AuditEvent::logAuditEvent('ZurmoModule', ZurmoModule::AUDIT_EVENT_ITEM_VIEWED, array(strval($contact), 'LeadsModule'), $contact);
         $getData = GetUtil::getData();
         $isKanbanBoardInRequest = ArrayUtil::getArrayValue($getData, 'kanbanBoard');
         if ($isKanbanBoardInRequest == 0 || $isKanbanBoardInRequest == null || Yii::app()->userInterface->isMobile() === true) {
             $breadCrumbView = StickySearchUtil::resolveBreadCrumbViewForDetailsControllerAction($this, 'LeadsSearchView', $contact);
             $detailsAndRelationsView = $this->makeDetailsAndRelationsView($contact, 'LeadsModule', 'LeadDetailsAndRelationsView', Yii::app()->request->getRequestUri(), $breadCrumbView);
             $view = new LeadsPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $detailsAndRelationsView));
         } else {
             $kanbanItem = new KanbanItem();
             $kanbanBoard = new TaskKanbanBoard($kanbanItem, 'type', $contact, get_class($contact));
             $kanbanBoard->setIsActive();
             $params['relationModel'] = $contact;
             $params['relationModuleId'] = $this->getModule()->getId();
             $params['redirectUrl'] = null;
             $listView = new TasksForLeadKanbanView($this->getId(), 'tasks', 'Task', null, $params, null, array(), $kanbanBoard);
             $view = new LeadsPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $listView));
         }
         echo $view->render();
     }
 }
 public function actionDetails($id)
 {
     $animal = static::getModelAndCatchNotFoundAndDisplayError('Animal', intval($id));
     $breadCrumbView = StickySearchUtil::resolveBreadCrumbViewForDetailsControllerAction($this, 'AnimalsSearchView', $animal);
     ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($animal);
     AuditEvent::logAuditEvent('ZurmoModule', ZurmoModule::AUDIT_EVENT_ITEM_VIEWED, array(strval($animal), 'AnimalsModule'), $animal);
     $titleBarAndEditView = $this->makeEditAndDetailsView($animal, 'Details');
     $view = new AnimalsPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $titleBarAndEditView));
     echo $view->render();
 }
 public function actionDetails($id)
 {
     $account = static::getModelAndCatchNotFoundAndDisplayError('Account', intval($id));
     ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($account);
     AuditEvent::logAuditEvent('ZurmoModule', ZurmoModule::AUDIT_EVENT_ITEM_VIEWED, array(strval($account), 'AccountsModule'), $account);
     $breadCrumbView = StickySearchUtil::resolveBreadCrumbViewForDetailsControllerAction($this, 'AccountsSearchView', $account);
     $detailsAndRelationsView = $this->makeDetailsAndRelationsView($account, 'AccountsModule', 'AccountDetailsAndRelationsView', Yii::app()->request->getRequestUri(), $breadCrumbView);
     $view = new AccountsPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $detailsAndRelationsView));
     echo $view->render();
 }
Exemple #4
0
 /**
  * @param CController $controller
  * @param $stickySearchKey
  * @param RedBeanModel $model
  * @return mixed
  */
 public static function resolveBreadCrumbViewForDetailsControllerAction(CController $controller, $stickySearchKey, RedBeanModel $model)
 {
     assert('is_string($stickySearchKey)');
     if (ArrayUtil::getArrayValue(GetUtil::getData(), 'stickyOffset') !== null && StickySearchUtil::getDataByKey($stickySearchKey) != null) {
         $stickyLoadUrl = Yii::app()->createUrl($controller->getModule()->getId() . '/' . $controller->getId() . '/renderStickyListBreadCrumbContent', array('stickyKey' => $stickySearchKey, 'stickyOffset' => ArrayUtil::getArrayValue(GetUtil::getData(), 'stickyOffset'), 'stickyModelId' => $model->id));
     } else {
         $stickyLoadUrl = null;
     }
     $className = static::resolveStickyDetailsAndRelationsBreadCrumbViewClassName();
     return new $className($controller->getId(), $controller->getModule()->getId(), static::resolveBreadcrumbLinks($model), $controller->getModule()->getModuleLabelByTypeAndLanguage('Plural'), $stickyLoadUrl);
 }
 public function actionDetails($id)
 {
     $contact = static::getModelAndCatchNotFoundAndDisplayError('Contact', intval($id));
     ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($contact);
     AuditEvent::logAuditEvent('ZurmoModule', ZurmoModule::AUDIT_EVENT_ITEM_VIEWED, array(strval($contact), 'ContactsModule'), $contact);
     if (KanbanUtil::isKanbanRequest() === false) {
         $breadCrumbView = StickySearchUtil::resolveBreadCrumbViewForDetailsControllerAction($this, 'ContactsSearchView', $contact);
         $detailsAndRelationsView = $this->makeDetailsAndRelationsView($contact, 'ContactsModule', 'ContactDetailsAndRelationsView', Yii::app()->request->getRequestUri(), $breadCrumbView);
         $view = new ContactsPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $detailsAndRelationsView));
     } else {
         $view = TasksUtil::resolveTaskKanbanViewForRelation($contact, $this->getModule()->getId(), $this, 'TasksForContactKanbanView', 'ContactsPageView');
     }
     echo $view->render();
 }
 public function actionDetails($id)
 {
     $contact = static::getModelAndCatchNotFoundAndDisplayError('Contact', intval($id));
     ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($contact);
     if (!LeadsUtil::isStateALead($contact->state)) {
         $urlParams = array('/contacts/' . $this->getId() . '/details', 'id' => $contact->id);
         $this->redirect($urlParams);
     } else {
         AuditEvent::logAuditEvent('ZurmoModule', ZurmoModule::AUDIT_EVENT_ITEM_VIEWED, array(strval($contact), 'LeadsModule'), $contact);
         $breadCrumbView = StickySearchUtil::resolveBreadCrumbViewForDetailsControllerAction($this, 'LeadsSearchView', $contact);
         $detailsAndRelationsView = $this->makeDetailsAndRelationsView($contact, 'LeadsModule', 'LeadDetailsAndRelationsView', Yii::app()->request->getRequestUri(), $breadCrumbView);
         $view = new LeadsPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $detailsAndRelationsView));
         echo $view->render();
     }
 }
 public function testResolveBreadCrumbViewForDetailsControllerAction()
 {
     TestHelpers::createControllerAndModuleByRoute('accounts/default');
     $controller = Yii::app()->getController();
     $model = new Account();
     //Test when there is not a stickyLoadUrl
     $stickySearchKey = 'abc';
     $view = StickySearchUtil::resolveBreadCrumbViewForDetailsControllerAction($controller, $stickySearchKey, $model);
     $this->assertTrue($view instanceof StickyDetailsAndRelationsBreadCrumbView);
     $content = $view->render();
     $this->assertNotContains('stickyModelId', $content);
     //Test when there is a stickyLoadUrl
     $stickySearchKey = 'abc';
     Yii::app()->user->setState($stickySearchKey, serialize(array('a', 'b')));
     $_GET['stickyOffset'] = '5';
     $view = StickySearchUtil::resolveBreadCrumbViewForDetailsControllerAction($controller, $stickySearchKey, $model);
     $this->assertTrue($view instanceof StickyDetailsAndRelationsBreadCrumbView);
     $content = $view->render();
     $this->assertContains('stickyListLoadingArea', $content);
 }
 /**
  * @depends testSuperUserCreateAction
  */
 public function testStickySearchActions()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     StickySearchUtil::clearDataByKey('GameRewardsSearchView');
     $value = StickySearchUtil::getDataByKey('GameRewardsSearchView');
     $this->assertNull($value);
     //Sort order desc
     $this->setGetArray(array('GameRewardsSearchForm' => array('anyMixedAttributes' => 'xyz', SearchForm::SELECTED_LIST_ATTRIBUTES => array('quantity', 'name')), 'GameReward_sort' => 'name.desc'));
     $this->runControllerWithNoExceptionsAndGetContent('gameRewards/default/');
     $data = StickySearchUtil::getDataByKey('GameRewardsSearchView');
     $compareData = array('dynamicClauses' => array(), 'dynamicStructure' => null, 'anyMixedAttributes' => 'xyz', 'anyMixedAttributesScope' => null, SearchForm::SELECTED_LIST_ATTRIBUTES => array('quantity', 'name'), 'sortAttribute' => 'name', 'sortDescending' => true);
     $this->assertEquals($compareData, $data);
     //Sort order asc
     StickySearchUtil::clearDataByKey('GameRewardsSearchView');
     $this->setGetArray(array('GameRewardsSearchForm' => array('anyMixedAttributes' => 'xyz', SearchForm::SELECTED_LIST_ATTRIBUTES => array('quantity', 'name')), 'GameReward_sort' => 'quantity'));
     $this->runControllerWithNoExceptionsAndGetContent('gameRewards/default/');
     $data = StickySearchUtil::getDataByKey('GameRewardsSearchView');
     $compareData = array('dynamicClauses' => array(), 'dynamicStructure' => null, 'anyMixedAttributes' => 'xyz', 'anyMixedAttributesScope' => null, SearchForm::SELECTED_LIST_ATTRIBUTES => array('quantity', 'name'), 'sortAttribute' => 'quantity', 'sortDescending' => false);
     $this->assertEquals($compareData, $data);
     $this->setGetArray(array('clearingSearch' => true));
     $this->runControllerWithNoExceptionsAndGetContent('gameRewards/default');
     $data = StickySearchUtil::getDataByKey('GameRewardsSearchView');
     $compareData = array('dynamicClauses' => array(), 'dynamicStructure' => null, 'anyMixedAttributesScope' => null, SearchForm::SELECTED_LIST_ATTRIBUTES => array('name', 'cost', 'quantity'));
     $this->assertEquals($compareData, $data);
 }
 /**
  * @depends testListForMarketingAction
  */
 public function testStickySearchActions()
 {
     StickySearchUtil::clearDataByKey('EmailTemplatesSearchView');
     $value = StickySearchUtil::getDataByKey('EmailTemplatesSearchView');
     $this->assertNull($value);
     $this->setGetArray(array('EmailTemplatesSearchForm' => array('anyMixedAttributes' => 'xyz')));
     $content = $this->runControllerWithNoExceptionsAndGetContent('emailTemplates/default/listForMarketing');
     $this->assertContains('No results found', $content);
     $data = StickySearchUtil::getDataByKey('EmailTemplatesSearchView');
     $compareData = array('dynamicClauses' => array(), 'dynamicStructure' => null, 'anyMixedAttributes' => 'xyz', 'anyMixedAttributesScope' => null, 'selectedListAttributes' => null);
     $this->assertEquals($compareData, $data);
     $this->setGetArray(array('EmailTemplatesSearchForm' => array('anyMixedAttributes' => 'Test')));
     $content = $this->runControllerWithNoExceptionsAndGetContent('emailTemplates/default/listForMarketing');
     $this->assertContains('1 result(s)', $content);
     $data = StickySearchUtil::getDataByKey('EmailTemplatesSearchView');
     $compareData = array('dynamicClauses' => array(), 'dynamicStructure' => null, 'anyMixedAttributes' => 'Test', 'anyMixedAttributesScope' => null, 'selectedListAttributes' => null, 'savedSearchId' => null);
     $this->assertEquals($compareData, $data);
     $this->setGetArray(array('clearingSearch' => true));
     $this->runControllerWithNoExceptionsAndGetContent('emailTemplates/default/listForMarketing');
     $data = StickySearchUtil::getDataByKey('EmailTemplatesSearchView');
     $compareData = array('dynamicClauses' => array(), 'dynamicStructure' => null, 'anyMixedAttributesScope' => null, 'selectedListAttributes' => null);
     $this->assertEquals($compareData, $data);
 }
 /**
  * @param string $key
  * @param SearchAttributesDataCollection $dataCollection
  * @param array $stickyData
  */
 public static function setDataByKeyAndDataCollection($key, SearchAttributesDataCollection $dataCollection, $stickyData)
 {
     assert('is_string($key)');
     assert('is_array($stickyData)');
     $stickyData['dynamicClauses'] = $dataCollection->getSanitizedDynamicSearchAttributes();
     $stickyData['dynamicStructure'] = $dataCollection->getDynamicStructure();
     if ($dataCollection->getFilterByStarred() != null) {
         $stickyData['filterByStarred'] = $dataCollection->getFilterByStarred();
     }
     if ($dataCollection->getFilteredBy() != null) {
         $stickyData['filteredBy'] = $dataCollection->getFilteredBy();
     }
     $anyMixedAttributes = $dataCollection->resolveSearchAttributesFromSourceData();
     if (isset($anyMixedAttributes['anyMixedAttributes'])) {
         $stickyData['anyMixedAttributes'] = $anyMixedAttributes['anyMixedAttributes'];
     } else {
         unset($stickyData['anyMixedAttributes']);
     }
     $dataCollection->resolveAnyMixedAttributesScopeForSearchModelFromSourceData();
     $dataCollection->resolveSelectedListAttributesForSearchModelFromSourceData();
     $dataCollection->resolveKanbanBoardOptionsForSearchModelFromSourceData();
     $stickyData['anyMixedAttributesScope'] = $dataCollection->getAnyMixedAttributesScopeFromModel();
     $stickyData[SearchForm::SELECTED_LIST_ATTRIBUTES] = $dataCollection->getSelectedListAttributesFromModel();
     static::resolveKanbanBoardDataByCollection($dataCollection, $stickyData);
     if ($dataCollection instanceof SavedSearchAttributesDataCollection) {
         $stickyData['savedSearchId'] = $dataCollection->getSavedSearchId();
     }
     // Resolve the sort and desc attribute from source data and set it in sticky array
     $listSortModel = get_class($dataCollection->getModel()->getModel());
     $sortAttribute = $dataCollection->resolveSortAttributeFromSourceData($listSortModel);
     //There are two cases
     //a) When user clicks on sorting in grid view, at that time Model Class inside form is used
     //b) When user save the search, sort attributes are in form model
     if ($sortAttribute == null) {
         $sortAttribute = $dataCollection->resolveSortAttributeFromSourceData(get_class($dataCollection->getModel()));
     }
     if (!empty($sortAttribute)) {
         $stickyData['sortAttribute'] = $sortAttribute;
         if ($dataCollection->resolveSortDescendingFromSourceData($listSortModel)) {
             $stickyData['sortDescending'] = true;
         } else {
             $sortDescending = $dataCollection->resolveSortDescendingFromSourceData(get_class($dataCollection->getModel()));
             if ($sortDescending === true) {
                 $stickyData['sortDescending'] = true;
             } else {
                 $stickyData['sortDescending'] = false;
             }
         }
     }
     StickySearchUtil::setDataByKeyAndData($key, $stickyData);
 }
 public function testStickySearchByKeyWithSortDesc()
 {
     $dataArray = $this->getSearchDataForSort();
     $dataCollection = $dataArray['dataCollection'];
     $savedSearch = $dataArray['savedSearch'];
     //Set the sort in $_GET to set the sticky key for it.
     $_GET['AAA_sort'] = 'aaaMember2.desc';
     SavedSearchUtil::setDataByKeyAndDataCollection('abc', $dataCollection, array());
     $stickyData = StickySearchUtil::getDataByKey('abc');
     $compareData = array('dynamicClauses' => array('a', 'b'), 'dynamicStructure' => '1 and 5', 'anyMixedAttributes' => 'abcdef', 'anyMixedAttributesScope' => 'xyz', 'savedSearchId' => $savedSearch->id, SearchForm::SELECTED_LIST_ATTRIBUTES => array('aaaMember', 'aaaMember2'), 'sortAttribute' => 'aaaMember2', 'sortDescending' => true);
     $this->assertEquals($compareData, $stickyData);
     $searchModel = new AAASavedDynamicSearchFormTestModel(new AAA(false));
     $listAttributesSelector = new ListAttributesSelector('AListView', 'TestModule');
     $searchModel->setListAttributesSelector($listAttributesSelector);
     unset($_GET['AAA_sort']);
     SavedSearchUtil::resolveSearchFormByStickyDataAndModel($stickyData, $searchModel);
     $this->assertEquals('aaaMember2', $searchModel->sortAttribute);
     $this->assertNotNull($searchModel->sortDescending);
 }
 public function actionRenderStickyListBreadCrumbContent($stickyOffset, $stickyKey, $stickyModelId)
 {
     if ($stickyOffset == null) {
         Yii::app()->end(0, false);
     }
     $pageSize = Yii::app()->pagination->resolveActiveForCurrentUserByType('listPageSize', get_class($this->getModule()));
     $modelClassName = $this->getModule()->getPrimaryModelName();
     $searchFormClassName = static::getSearchFormClassName();
     $model = new $modelClassName(false);
     $searchForm = new $searchFormClassName($model);
     $dataProvider = $this->resolveSearchDataProvider($searchForm, $pageSize, null, $stickyKey, false);
     $totalCount = $dataProvider->calculateTotalItemCount();
     $finalOffset = StickySearchUtil::resolveFinalOffsetForStickyList((int) $stickyOffset, (int) $pageSize, (int) $totalCount);
     $dataProvider->setOffset($finalOffset);
     $dataList = $dataProvider->getData();
     if (count($dataList) > 0) {
         $menuItems = array('label' => '÷');
         //char code is ÷
         foreach ($dataList as $row => $data) {
             $url = Yii::app()->createUrl($this->getModule()->getId() . '/' . $this->getId() . '/details', array('id' => $data->id, 'stickyOffset' => $row + $finalOffset));
             if ($data->id == $stickyModelId) {
                 $menuItems['items'][] = array('label' => strval($data), 'url' => $url, 'itemOptions' => array('class' => 'strong'));
             } else {
                 $menuItems['items'][] = array('label' => strval($data), 'url' => $url);
             }
         }
         $cClipWidget = new CClipWidget();
         $cClipWidget->beginClip("StickyList");
         $cClipWidget->widget('application.core.widgets.MbMenu', array('htmlOptions' => array('id' => 'StickyListMenu'), 'items' => array($menuItems)));
         $cClipWidget->endClip();
         echo $cClipWidget->getController()->clips['StickyList'];
     }
 }
 private function makeDataCollectionAndResolveSavedSearch($searchModel, $stickySearchKey = null, $setSticky = true)
 {
     $dataCollection = new SearchAttributesDataCollection($searchModel);
     if ($searchModel instanceof SavedDynamicSearchForm) {
         $getData = GetUtil::getData();
         if ($stickySearchKey != null && isset($getData['clearingSearch']) && $getData['clearingSearch']) {
             StickySearchUtil::clearDataByKey($stickySearchKey);
         }
         if ($stickySearchKey != null && null != ($stickySearchData = StickySearchUtil::getDataByKey($stickySearchKey))) {
             SavedSearchUtil::resolveSearchFormByStickyDataAndModel($stickySearchData, $searchModel);
             SavedSearchUtil::resolveSearchFormByStickySortData($getData, $searchModel, $stickySearchData);
             SearchUtil::resolveSearchFormByStickyFilterByStarredData($getData, $searchModel, $stickySearchData);
             SearchUtil::resolveSearchFormByStickyFilteredByData($getData, $searchModel, $stickySearchData);
             SearchUtil::resolveSearchFormByStickyFilteredByData($getData, $searchModel, $stickySearchData);
             $dataCollection = new SavedSearchAttributesDataCollection($searchModel);
         } else {
             SavedSearchUtil::resolveSearchFormByData($getData, $searchModel);
             if ($searchModel->savedSearchId != null) {
                 $dataCollection = new SavedSearchAttributesDataCollection($searchModel);
             }
         }
         if ($stickySearchKey != null && ($setSticky || $searchModel->getKanbanBoard() != null && $searchModel->getKanbanBoard()->getClearSticky())) {
             if ($stickySearchData == null) {
                 $stickySearchData = array();
             }
             SavedSearchUtil::setDataByKeyAndDataCollection($stickySearchKey, $dataCollection, $stickySearchData);
         }
         $searchModel->loadSavedSearchUrl = Yii::app()->createUrl($this->getModule()->getId() . '/' . $this->getId() . '/list/');
     }
     return $dataCollection;
 }
 public function actionClearStickySearch($key)
 {
     StickySearchUtil::clearDataByKey($key);
 }