コード例 #1
0
 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();
 }
コード例 #2
0
 /**
  * Method to help us simulate Controller::makeRedBeanDataProviderByDataCollection method.
  */
 public static function makeRedBeanDataProvider($searchModel, $listModelClassName, $pageSize, $userId, $stateMetadataAdapterClassName = null)
 {
     assert('is_int($pageSize)');
     assert('$stateMetadataAdapterClassName == null || is_string($stateMetadataAdapterClassName)');
     $metadataAdapter = new SearchDataProviderMetadataAdapter($searchModel, $userId, array());
     return RedBeanModelDataProviderUtil::makeDataProvider($metadataAdapter->getAdaptedMetadata(), $listModelClassName, 'RedBeanModelDataProvider', null, false, $pageSize, $stateMetadataAdapterClassName);
 }
コード例 #3
0
 /**
  * @param   string
  * @param   bollean     Return an empty listView
  * @return  View
  */
 public function getListView($moduleName, $forceEmptyResults = false)
 {
     assert('is_string($moduleName)');
     $pageSize = $this->pageSize;
     $module = Yii::app()->findModule($moduleName);
     $searchFormClassName = $module::getGlobalSearchFormClassName();
     $modelClassName = $module::getPrimaryModelName();
     $model = new $modelClassName(false);
     $searchForm = new $searchFormClassName($model);
     $sanitizedSearchAttributes = MixedTermSearchUtil::getGlobalSearchAttributeByModuleAndPartialTerm($module, $this->term);
     $metadataAdapter = new SearchDataProviderMetadataAdapter($searchForm, $this->user->id, $sanitizedSearchAttributes);
     $listViewClassName = $module::getPluralCamelCasedName() . 'ListView';
     $sortAttribute = SearchUtil::resolveSortAttributeFromGetArray($modelClassName);
     $sortDescending = SearchUtil::resolveSortDescendingFromGetArray($modelClassName);
     if ($forceEmptyResults) {
         $dataProviderClass = 'EmptyRedBeanModelDataProvider';
         $emptyText = '';
     } else {
         $dataProviderClass = 'RedBeanModelDataProvider';
         $emptyText = null;
     }
     $dataProvider = RedBeanModelDataProviderUtil::makeDataProvider($metadataAdapter->getAdaptedMetadata(false), $modelClassName, $dataProviderClass, $sortAttribute, $sortDescending, $pageSize, $module->getStateMetadataAdapterClassName());
     $listView = new $listViewClassName('default', $module->getId(), $modelClassName, $dataProvider, GetUtil::resolveSelectedIdsFromGet(), '-' . $moduleName, array('route' => '', 'class' => 'SimpleListLinkPager', 'firstPageLabel' => '<span>first</span>', 'prevPageLabel' => '<span>previous</span>', 'nextPageLabel' => '<span>next</span>', 'lastPageLabel' => '<span>last</span>'));
     $listView->setRowsAreSelectable(false);
     $listView->setEmptyText($emptyText);
     return $listView;
 }
コード例 #4
0
ファイル: Controller.php プロジェクト: youprofit/Zurmo
 /**
  * Utilizes information from the dataCollection object to
  * make a RedBeanDataProvider.  Either looks at saved search information or params in the $_GET array.
  * variables:
  *  modelName_sort
  *  modelName
  *  where modelName is Account for example.
  * Typically utilized by a listView action.
  */
 public function makeRedBeanDataProviderByDataCollection($searchModel, $pageSize, $stateMetadataAdapterClassName = null, $dataCollection = null)
 {
     assert('is_int($pageSize)');
     assert('$stateMetadataAdapterClassName == null || is_string($stateMetadataAdapterClassName)');
     assert('$dataCollection instanceof SearchAttributesDataCollection || $dataCollection == null');
     $listModelClassName = get_class($searchModel->getModel());
     if ($dataCollection == null) {
         $dataCollection = new SearchAttributesDataCollection($searchModel);
     }
     $searchAttributes = $dataCollection->resolveSearchAttributesFromSourceData();
     $dataCollection->resolveAnyMixedAttributesScopeForSearchModelFromSourceData();
     $dataCollection->resolveSelectedListAttributesForSearchModelFromSourceData();
     $sanitizedSearchAttributes = GetUtil::sanitizePostByDesignerTypeForSavingModel($searchModel, $searchAttributes);
     $sortAttribute = SearchUtil::resolveSortAttributeFromGetArray($listModelClassName);
     $sortDescending = SearchUtil::resolveSortDescendingFromGetArray($listModelClassName);
     $metadataAdapter = new SearchDataProviderMetadataAdapter($searchModel, Yii::app()->user->userModel->id, $sanitizedSearchAttributes);
     $metadata = static::resolveDynamicSearchMetadata($searchModel, $metadataAdapter->getAdaptedMetadata(), $dataCollection);
     return RedBeanModelDataProviderUtil::makeDataProvider($metadata, $listModelClassName, 'RedBeanModelDataProvider', $sortAttribute, $sortDescending, $pageSize, $stateMetadataAdapterClassName);
 }
コード例 #5
0
 /**
  * Get the content for displaying recent notifications information via an ajax call.
  * @see HeaderLinksView->renderNotificationsLinkContent()
  * @param User $user
  */
 public static function getRecentAjaxContentByUser(User $user, $count)
 {
     assert('is_int($count)');
     $content = null;
     $notification = new Notification(false);
     $searchAttributes = array('owner' => array('id' => Yii::app()->user->userModel->id));
     $metadataAdapter = new SearchDataProviderMetadataAdapter($notification, Yii::app()->user->userModel->id, $searchAttributes);
     $dataProvider = RedBeanModelDataProviderUtil::makeDataProvider($metadataAdapter->getAdaptedMetadata(), 'Notification', 'RedBeanModelDataProvider', 'createdDateTime', true, 10);
     $notifications = $dataProvider->getData();
     if (count($notifications) > 0) {
         foreach ($notifications as $notification) {
             $content .= '<div class="single-notification">';
             $content .= self::renderShortenedListViewContent($notification);
             $content .= ZurmoHtml::link("Delete<span class='icon'></span>", "#", array("class" => "remove", "onclick" => "deleteNotificationFromAjaxListView(this, " . $notification->id . ", event)"));
             $content .= '</div>';
         }
     } else {
         $content .= '<div class="single-notification">' . Zurmo::t('NotificationsModule', 'There are no recent notifications.') . '</div>';
     }
     return $content;
 }
 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;
 }
コード例 #7
0
 protected function getDataProviderByGet()
 {
     $modelClassName = $this->resolveModelClassName();
     $filterBy = ArrayUtil::getArrayValue(GetUtil::getData(), 'filterBy');
     $sortAttribute = null;
     $sortDescending = false;
     if ($filterBy == static::FILTER_BY_PREVIOUSLY_CREATED_TEMPLATES) {
         $searchAttributeData = EmailTemplate::getPreviouslyCreatedBuilderTemplateSearchAttributeData($modelClassName, false);
         $sortAttribute = 'isFeatured';
         $sortDescending = true;
     } else {
         $searchAttributeData = EmailTemplate::getPredefinedBuilderTemplatesSearchAttributeData();
         $sortAttribute = 'id';
     }
     $dataProvider = RedBeanModelDataProviderUtil::makeDataProvider($searchAttributeData, 'EmailTemplate', 'RedBeanModelDataProvider', $sortAttribute, $sortDescending, 10);
     return $dataProvider;
 }
コード例 #8
0
 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();
 }
コード例 #9
0
 /**
  * Get latest activity feed list view
  * @return ListView
  */
 public static function getProjectsLatestActivityFeedView($controller, $pageSize)
 {
     $project = new Project(false);
     $searchForm = new ProjectsSearchForm($project);
     $dataProvider = RedBeanModelDataProviderUtil::makeDataProvider(array(), 'ProjectAuditEvent', 'RedBeanModelDataProvider', 'dateTime', true, $pageSize);
     $listView = new ProjectsFeedListView($controller->id, $controller->getModule()->getId(), get_class($searchForm->getModel()), $dataProvider, GetUtil::resolveSelectedIdsFromGet(), null, array(), $searchForm->getListAttributesSelector(), $searchForm->getKanbanBoard());
     return $listView;
 }
コード例 #10
0
ファイル: MissionsUtil.php プロジェクト: youprofit/Zurmo
 /**
  * @param Mission $mission
  * @param int $type
  * @param int $pageSize
  * @return RedBeanModelDataProvider'
  */
 public static function makeDataProviderByType(Mission $mission, $type, $pageSize)
 {
     if ($type == null) {
         $type = MissionsListConfigurationForm::LIST_TYPE_AVAILABLE;
     }
     $searchAttributes = array();
     $metadataAdapter = new MissionsSearchDataProviderMetadataAdapter($mission, Yii::app()->user->userModel->id, $searchAttributes, $type);
     $dataProvider = RedBeanModelDataProviderUtil::makeDataProvider($metadataAdapter->getAdaptedMetadata(), 'Mission', 'RedBeanModelDataProvider', 'latestDateTime', true, $pageSize);
     return $dataProvider;
 }
コード例 #11
0
 public function getListView($option, $filteredBy = MashableInboxForm::FILTERED_BY_ALL, $searchTerm = null, $starred = false)
 {
     $modelClassName = $this->getModelClassName();
     $orderBy = $this->getMachableInboxOrderByAttributeName();
     $pageSize = Yii::app()->pagination->resolveActiveForCurrentUserByType('listPageSize', get_class(Yii::app()->controller->module));
     $metadataByOptionAndFilter = MashableUtil::mergeMetadata($this->getMetadataFilteredByOption($option), $this->getMetadataFilteredByFilteredBy($filteredBy));
     $metadata = MashableUtil::mergeMetadata($metadataByOptionAndFilter, $this->getSearchAttributeData($searchTerm));
     $dataProviderClassName = 'RedBeanModelDataProvider';
     if ($starred) {
         $dataProviderClassName = 'StarredModelDataProvider';
     }
     $dataProvider = RedBeanModelDataProviderUtil::makeDataProvider($metadata, $modelClassName, $dataProviderClassName, $orderBy, true, $pageSize);
     $listViewClassName = $this->getListViewClassName();
     $listView = new $listViewClassName(Yii::app()->controller->id, Yii::app()->controller->module->id, $modelClassName, $dataProvider, array());
     return $listView;
 }
コード例 #12
0
 public function actionRebuildSecurityCache($User_page = 1, $continue = false)
 {
     if (!Group::isUserASuperAdministrator(Yii::app()->user->userModel)) {
         $failureMessageContent = Zurmo::t('Core', 'You must be a super administrator to rebuild the security cache.');
         $messageView = new AccessFailureView($failureMessageContent);
         $view = new AccessFailurePageView($messageView);
         echo $view->render();
         Yii::app()->end(0, false);
     }
     if ($User_page == 1) {
         //to more quickly show the view to the user. To give a better indication of what is happening.
         $pageSize = 1;
     } else {
         $pageSize = 25;
     }
     $namedSecurableItems = array();
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         if ($module instanceof SecurableModule) {
             $namedSecurableItems[] = NamedSecurableItem::getByName(get_class($module));
         }
     }
     if ($continue) {
         $page = static::getMassActionProgressStartFromGet('User_page', $pageSize);
     } else {
         $page = 1;
     }
     $title = Zurmo::t('ZurmoModule', 'Rebuilding Cache');
     $searchAttributeData['clauses'] = array(1 => array('attributeName' => 'isSystemUser', 'operatorType' => 'equals', 'value' => 0), 2 => array('attributeName' => 'isSystemUser', 'operatorType' => 'isNull', 'value' => null));
     $searchAttributeData['structure'] = '1 or 2';
     $dataProvider = RedBeanModelDataProviderUtil::makeDataProvider($searchAttributeData, 'User', 'RedBeanModelDataProvider', null, false, $pageSize);
     $selectedRecordCount = $dataProvider->getTotalItemCount();
     $users = $dataProvider->getData();
     foreach ($users as $user) {
         if (!$user->isSuperAdministrator()) {
             foreach ($namedSecurableItems as $namedSecurableItem) {
                 $namedSecurableItem->getActualPermissions($user);
             }
         }
         RightsUtil::cacheAllRightsByPermitable($user);
     }
     $rebuildView = new RebuildSecurityCacheProgressView($this->getId(), $this->getModule()->getId(), new User(), $selectedRecordCount, $page, $pageSize, $User_page, 'rebuildSecurityCache', $title);
     if (!$continue) {
         $view = new ZurmoPageView(ZurmoDefaultAdminViewUtil::makeStandardViewForCurrentUser($this, $rebuildView));
         echo $view->render();
         Yii::app()->end(0, false);
     } else {
         echo $rebuildView->renderRefreshJSONScript();
     }
 }