/**
  * @return array of all policies data
  */
 public static function getAllModulePoliciesDataByPermitable(Permitable $permitable)
 {
     $data = array();
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         if ($module instanceof SecurableModule) {
             $moduleClassName = get_class($module);
             $policies = $moduleClassName::getPolicyNames();
             $policyLabels = $moduleClassName::getTranslatedPolicyLabels();
             $reflectionClass = new ReflectionClass($moduleClassName);
             $constants = $reflectionClass->getConstants();
             if (!empty($policies)) {
                 foreach ($policies as $policy) {
                     if (!isset($policyLabels[$policy])) {
                         throw new NotSupportedException();
                     }
                     $explicit = $permitable->getExplicitActualPolicy($moduleClassName, $policy);
                     $inherited = $permitable->getInheritedActualPolicy($moduleClassName, $policy);
                     $effective = $permitable->getEffectivePolicy($moduleClassName, $policy);
                     $constantId = array_search($policy, $constants);
                     $data[$moduleClassName][$constantId] = array('displayName' => $policyLabels[$policy], 'explicit' => $explicit, 'inherited' => $inherited, 'effective' => $effective);
                 }
             }
         }
     }
     return $data;
 }
 protected function renderContent()
 {
     $placedViewTypes = Portlet::getPlacedViewTypesByLayoutIdAndUser($this->uniqueLayoutId, Yii::app()->user->userModel->id);
     $content = '<ul class="available-portlets">';
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         if ($module->isEnabled()) {
             $p = $module->getParentModule();
             $viewClassNames = $module::getViewClassNames();
             foreach ($viewClassNames as $className) {
                 $viewReflectionClass = new ReflectionClass($className);
                 if (!$viewReflectionClass->isAbstract()) {
                     $portletRules = PortletRulesFactory::createPortletRulesByView($className);
                     if ($portletRules != null && $portletRules->allowOnDashboard()) {
                         if ($portletRules->allowMultiplePlacementOnDashboard() && PortletsSecurityUtil::doesCurrentUserHavePermissionToAddPortlet($portletRules) === true || !$portletRules->allowMultiplePlacementOnDashboard() && !in_array($portletRules->getType(), $placedViewTypes) && PortletsSecurityUtil::doesCurrentUserHavePermissionToAddPortlet($portletRules) === true) {
                             $metadata = $className::getMetadata();
                             $url = Yii::app()->createUrl($this->moduleId . '/defaultPortlet/add', array('uniqueLayoutId' => $this->uniqueLayoutId, 'dashboardId' => $this->dashboardId, 'portletType' => $portletRules->getType()));
                             $onClick = 'window.location.href = "' . $url . '"';
                             $content .= '<li>';
                             $title = $metadata['perUser']['title'];
                             MetadataUtil::resolveEvaluateSubString($title);
                             $label = '<span>\\</span>' . $title;
                             $content .= ZurmoHtml::link(Zurmo::t('HomeModule', $label), null, array('onclick' => $onClick));
                             $content .= '</li>';
                         }
                     }
                 }
             }
         }
     }
     $content .= '</ul>';
     return $content;
 }
 protected function renderContent()
 {
     $placedViewTypes = $this->getPlacedViewTypes();
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         if ($module->isEnabled()) {
             $p = $module->getParentModule();
             $viewClassNames = $module::getViewClassNames();
             foreach ($viewClassNames as $className) {
                 $viewReflectionClass = new ReflectionClass($className);
                 if (!$viewReflectionClass->isAbstract()) {
                     $portletRules = PortletRulesFactory::createPortletRulesByView($className);
                     if ($portletRules != null && $portletRules->allowOnDashboard()) {
                         if ($portletRules->allowMultiplePlacementOnDashboard() && PortletsSecurityUtil::doesCurrentUserHavePermissionToAddPortlet($portletRules) === true || !$portletRules->allowMultiplePlacementOnDashboard() && !in_array($portletRules->getType(), $placedViewTypes) && PortletsSecurityUtil::doesCurrentUserHavePermissionToAddPortlet($portletRules) === true) {
                             $metadata = $className::getMetadata();
                             $url = Yii::app()->createUrl($this->moduleId . '/defaultPortlet/add', array('uniqueLayoutId' => $this->uniqueLayoutId, 'dashboardId' => $this->dashboardId, 'portletType' => $portletRules->getType()));
                             if (isset($metadata['perUser']['title'])) {
                                 $title = $metadata['perUser']['title'];
                             } else {
                                 continue;
                             }
                             MetadataUtil::resolveEvaluateSubString($title);
                             $sortablePortlets[$title] = array('url' => $url, 'title' => $title, 'portletRules' => $portletRules);
                         }
                     }
                 }
             }
         }
     }
     return PortletUtil::renderAddPortletsContent($sortablePortlets);
 }
Esempio n. 4
0
 /**
  * @return array of all module rights data
  */
 public static function getAllModuleRightsDataByPermitable(Permitable $permitable)
 {
     $data = array();
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         if ($module instanceof SecurableModule) {
             $moduleClassName = get_class($module);
             $rights = $moduleClassName::getRightsNames();
             $rightLabels = $moduleClassName::getTranslatedRightsLabels();
             $reflectionClass = new ReflectionClass($moduleClassName);
             if (!empty($rights)) {
                 $rightsData = array();
                 foreach ($rights as $right) {
                     if (!isset($rightLabels[$right])) {
                         throw new NotSupportedException($right);
                     }
                     $explicit = $permitable->getExplicitActualRight($moduleClassName, $right);
                     $inherited = $permitable->getInheritedActualRight($moduleClassName, $right);
                     $effective = $permitable->getEffectiveRight($moduleClassName, $right);
                     $constants = $reflectionClass->getConstants();
                     $constantId = array_search($right, $constants);
                     $rightsData[$constantId] = array('displayName' => $rightLabels[$right], 'explicit' => RightsUtil::getRightStringFromRight($explicit), 'inherited' => RightsUtil::getRightStringFromRight($inherited), 'effective' => RightsUtil::getRightStringFromRight($effective));
                 }
                 $data[$moduleClassName] = ArrayUtil::subValueSort($rightsData, 'displayName', 'asort');
             }
         }
     }
     return $data;
 }
 protected function renderContent()
 {
     $content = $this->renderTitleContent();
     $content .= '<ul class="configuration-list">';
     $modules = Module::getModuleObjects();
     $moduleClassNamesAndLabels = array();
     foreach ($modules as $module) {
         $moduleTreeMenuItems = $module->getDesignerMenuItems();
         if ($module->isEnabled() && !empty($moduleTreeMenuItems)) {
             $moduleClassNamesAndLabels[get_class($module)] = $module::getModuleLabelByTypeAndLanguage('Plural');
         }
     }
     asort($moduleClassNamesAndLabels);
     foreach ($moduleClassNamesAndLabels as $moduleClassName => $label) {
         if (RightsUtil::canUserAccessModule($moduleClassName, Yii::app()->user->userModel)) {
             $route = $this->moduleId . '/' . $this->controllerId . '/modulesMenu/';
             $content .= ZurmoHtml::openTag('li');
             $content .= '<h4>' . $label . '</h4>';
             $content .= ZurmoHtml::link(ZurmoHtml::wrapLabel(Zurmo::t('Core', 'Configure')), Yii::app()->createUrl($route, array('moduleClassName' => $moduleClassName)), array('class' => 'white-button'));
             $content .= ZurmoHtml::closeTag('li');
         }
     }
     $content .= '</ul>';
     return $content;
 }
 /**
  * Based on the current user, return the importRules types and their display labels.  Only include import rules
  * that the user has a right to access its corresponding module.
  * @return array of import rules types and display labels.
  */
 public static function getImportRulesTypesForCurrentUser()
 {
     //todo: cache results to improve performance if needed.
     $importRulesTypes = array();
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         $rulesClassNames = $module::getAllClassNamesByPathFolder('rules');
         foreach ($rulesClassNames as $ruleClassName) {
             $classToEvaluate = new ReflectionClass($ruleClassName);
             if (is_subclass_of($ruleClassName, 'ImportRules') && !$classToEvaluate->isAbstract()) {
                 $moduleClassNames = $ruleClassName::getModuleClassNames();
                 $addToArray = true;
                 foreach ($moduleClassNames as $moduleClassNameToCheckAccess) {
                     if (!RightsUtil::canUserAccessModule($moduleClassNameToCheckAccess, Yii::app()->user->userModel) || !RightsUtil::doesUserHaveAllowByRightName($moduleClassNameToCheckAccess, $moduleClassNameToCheckAccess::getCreateRight(), Yii::app()->user->userModel)) {
                         $addToArray = false;
                     }
                 }
                 if ($addToArray) {
                     $importRulesTypes[$ruleClassName::getType()] = $ruleClassName::getDisplayLabel();
                 }
             }
         }
     }
     return $importRulesTypes;
 }
 protected function renderContent()
 {
     $placedViewTypes = Portlet::getPlacedViewTypesByLayoutIdAndUser($this->uniqueLayoutId, Yii::app()->user->userModel->id);
     $modules = Module::getModuleObjects();
     $sortablePortlets = array();
     foreach ($modules as $module) {
         if ($module->isEnabled()) {
             $p = $module->getParentModule();
             $viewClassNames = $module::getViewClassNames();
             foreach ($viewClassNames as $className) {
                 $viewReflectionClass = new ReflectionClass($className);
                 if (!$viewReflectionClass->isAbstract()) {
                     $portletRules = PortletRulesFactory::createPortletRulesByView($className);
                     if ($viewReflectionClass->implementsInterface('RelatedPortletViewInterface')) {
                         if ($this->resolveLayoutIdInAllowedOnPortletViewClassNames($className) && $className::allowMultiplePlacement() == false && !in_array($portletRules->getType(), $placedViewTypes) && PortletsSecurityUtil::doesCurrentUserHavePermissionToAddPortlet($portletRules) === true) {
                             $metadata = $className::getMetadata();
                             $url = Yii::app()->createUrl($this->moduleId . '/defaultPortlet/add', array('uniqueLayoutId' => $this->uniqueLayoutId, 'modelId' => $this->modelId, 'portletType' => $portletRules->getType()));
                             $title = $metadata['perUser']['title'];
                             MetadataUtil::resolveEvaluateSubString($title);
                             $sortablePortlets[$title] = array('url' => $url, 'title' => $title, 'portletRules' => $portletRules);
                         }
                     }
                 }
             }
         }
     }
     if (empty($sortablePortlets)) {
         $messageView = new NoPortletsToPlaceView();
         return $messageView->render();
     }
     //Sort by title
     ksort($sortablePortlets);
     return PortletUtil::renderAddPortletsContent($sortablePortlets);
 }
 /**
  * @return array of module class names that are available for
  * module permissions administration through the user interface
  */
 public static function getAdministrableModuleClassNames()
 {
     $moduleClassNames = array();
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         $classToEvaluate = new ReflectionClass($module);
         if (is_subclass_of($module, 'SecurableModule') && !$classToEvaluate->isAbstract() && $module::hasPermissions()) {
             $moduleClassNames[] = get_class($module);
         }
     }
     return $moduleClassNames;
 }
Esempio n. 9
0
 /**
  * Loads all module demo data based on a dependency tree loading the dependent module data first.
  * @param object $messageLogger
  */
 public static function load(&$messageLogger, $loadMagnitude = null)
 {
     assert('$messageLogger instanceof MessageLogger');
     assert('$loadMagnitude == null || is_int($loadMagnitude)');
     Yii::import('application.extensions.zurmoinc.framework.data.*');
     $loadedModules = array();
     $demoDataHelper = new DemoDataHelper();
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         static::loadByModule($module, $messageLogger, $demoDataHelper, $loadMagnitude);
     }
 }
Esempio n. 10
0
 public static function getAdminTabMenuItems($user = null)
 {
     $tabMenuItems = array(array('label' => "eval:Zurmo::t('DesignerModule', 'Designer')", 'url' => array('/designer/default'), 'right' => self::RIGHT_ACCESS_DESIGNER));
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         $moduleTreeMenuItems = $module->getDesignerMenuItems();
         if ($module->isEnabled() && !empty($moduleTreeMenuItems)) {
             $tabMenuItems[0]['items'][] = array('label' => Zurmo::t('DesignerModule', $module::getModuleLabelByTypeAndLanguage('Plural')), 'url' => array('/designer/default/modulesMenu', 'moduleClassName' => get_class($module)));
         }
     }
     return $tabMenuItems;
 }
 protected static function findGlobalSearchScopingModuleNamesAndLabelsDataByUser(User $user)
 {
     assert('$user->id > 0');
     $moduleNamesAndLabels = array();
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         $globalSearchFormClassName = $module::getGlobalSearchFormClassName();
         if (GlobalSearchUtil::resolveIfModuleShouldBeGloballySearched($module) && $globalSearchFormClassName != null && RightsUtil::canUserAccessModule(get_class($module), $user)) {
             $moduleNamesAndLabels[$module->getName()] = $module::getModuleLabelByTypeAndLanguage('Plural');
         }
     }
     return $moduleNamesAndLabels;
 }
Esempio n. 12
0
 protected static function getAcceptableModelsForAttributeNames()
 {
     $modules = Module::getModuleObjects();
     $modelNames = array();
     foreach ($modules as $module) {
         if (get_class($module) != 'UsersModule') {
             try {
                 $modelNames[] = $module::getPrimaryModelName();
             } catch (NotSupportedException $e) {
             }
         }
     }
     return $modelNames;
 }
 public static function findReadSubscriptionModelClassNames()
 {
     $readPermissionsSubscriptionModelClassNames = array();
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         $modelClassNames = $module::getModelClassNames();
         foreach ($modelClassNames as $modelClassName) {
             if (is_subclass_of($modelClassName, 'OwnedSecurableItem') && $modelClassName::hasReadPermissionsSubscriptionOptimization()) {
                 $readPermissionsSubscriptionModelClassNames[] = $modelClassName;
             }
         }
     }
     return $readPermissionsSubscriptionModelClassNames;
 }
Esempio n. 14
0
 /**
  * @return array of available badge rule class names
  */
 public static function getBadgeRulesData()
 {
     $badgeRulesData = array();
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         $rulesClassNames = $module::getAllClassNamesByPathFolder('rules.badges');
         foreach ($rulesClassNames as $ruleClassName) {
             $classToEvaluate = new ReflectionClass($ruleClassName);
             if (!$classToEvaluate->isAbstract()) {
                 $badgeRulesData[] = $ruleClassName;
             }
         }
     }
     return $badgeRulesData;
 }
 /**
  * @return array of data for jobs that are not the monitor job.  Includes information such as the display label,
  * whether it is running or not, and the last completion time.
  */
 public static function getNonMonitorJobsData()
 {
     $jobsData = array();
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         $jobsClassNames = $module::getAllClassNamesByPathFolder('jobs');
         foreach ($jobsClassNames as $jobClassName) {
             $classToEvaluate = new ReflectionClass($jobClassName);
             if (is_subclass_of($jobClassName, 'BaseJob') && !$classToEvaluate->isAbstract() && $jobClassName != 'MonitorJob') {
                 $jobsData[$jobClassName::getType()] = self::getJobDataByType($jobClassName::getType());
             }
         }
     }
     return $jobsData;
 }
Esempio n. 16
0
 protected static function getStarredModels($interfaceClassName)
 {
     assert('is_string($interfaceClassName)');
     $interfaceModelClassNames = array();
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         $modelClassNames = $module::getModelClassNames();
         foreach ($modelClassNames as $modelClassName) {
             $classToEvaluate = new ReflectionClass($modelClassName);
             if ($classToEvaluate->implementsInterface($interfaceClassName) && !$classToEvaluate->isAbstract()) {
                 $interfaceModelClassNames[] = $modelClassName;
             }
         }
     }
     return $interfaceModelClassNames;
 }
 /**
  * @depends testAutoBuildDatabase
  */
 public function testColumnType()
 {
     $rootModels = array();
     foreach (Module::getModuleObjects() as $module) {
         $moduleAndDependenciesRootModelNames = $module->getRootModelNamesIncludingDependencies();
         $rootModels = array_merge($rootModels, array_diff($moduleAndDependenciesRootModelNames, $rootModels));
     }
     foreach ($rootModels as $model) {
         $meta = $model::getDefaultMetadata();
         if (isset($meta[$model]['rules'])) {
             $tableName = $model::getTableName();
             $columns = ZurmoRedBean::$writer->getColumns($tableName);
             foreach ($meta[$model]['rules'] as $rule) {
                 if (is_array($rule) && count($rule) >= 3) {
                     $attributeName = $rule[0];
                     $validatorName = $rule[1];
                     $validatorParameters = array_slice($rule, 2);
                     switch ($validatorName) {
                         case 'type':
                             if (isset($validatorParameters['type'])) {
                                 $type = $validatorParameters['type'];
                                 $field = strtolower($attributeName);
                                 $columnType = false;
                                 if (isset($columns[$field])) {
                                     $columnType = $columns[$field];
                                 }
                                 $compareType = null;
                                 $compareTypes = $this->getDatabaseTypesByType($type);
                                 // Remove brackets from database type
                                 $bracketPosition = stripos($columnType, '(');
                                 if ($bracketPosition !== false) {
                                     $columnType = substr($columnType, 0, $bracketPosition);
                                 }
                                 $databaseColumnType = strtoupper(trim($columnType));
                                 $compareTypeString = implode(',', $compareTypes);
                                 // Not Coding Standard
                                 if (!in_array($databaseColumnType, $compareTypes)) {
                                     $this->fail("Actual database type {$databaseColumnType} not in expected types: {$compareTypeString}.");
                                 }
                             }
                             break;
                     }
                 }
             }
         }
     }
 }
 /**
  * Initialize the observer if enabled.  Attaches events to model classes as needed.
  */
 public function init()
 {
     if ($this->enabled) {
         $observedModels = array();
         $modules = Module::getModuleObjects();
         foreach ($modules as $module) {
             try {
                 $modelClassName = $module->getPrimaryModelName();
                 if ($modelClassName != null && is_subclass_of($modelClassName, 'OwnedSecurableItem') && $modelClassName::hasReadPermissionsSubscriptionOptimization() === true && !in_array($modelClassName, $observedModels)) {
                     $observedModels[] = $modelClassName;
                     $this->attachEventsByModelClassName($modelClassName);
                 }
             } catch (NotSupportedException $e) {
             }
         }
     }
 }
Esempio n. 19
0
 protected function renderContent()
 {
     $content = $this->renderTitleContent();
     $content .= '<ul class="configuration-list">';
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         $moduleTreeMenuItems = $module->getDesignerMenuItems();
         if ($module->isEnabled() && !empty($moduleTreeMenuItems)) {
             $route = $this->moduleId . '/' . $this->controllerId . '/modulesMenu/';
             $content .= '<li>';
             $content .= '<h4>' . Zurmo::t('DesignerModule', $module::getModuleLabelByTypeAndLanguage('Plural')) . '</h4>';
             $content .= ZurmoHtml::link(ZurmoHtml::wrapLabel(Zurmo::t('DesignerModule', 'Configure')), Yii::app()->createUrl($route, array('moduleClassName' => get_class($module))));
             $content .= '</li>';
         }
     }
     $content .= '</ul>';
     return $content;
 }
 public function init()
 {
     if ($this->enabled) {
         $observedModels = array();
         $modules = Module::getModuleObjects();
         foreach ($modules as $module) {
             try {
                 $modelClassName = $module->getPrimaryModelName();
                 if ($modelClassName != null && $module::canHaveWorkflow() && is_subclass_of($modelClassName, 'Item') && !in_array($modelClassName, $observedModels)) {
                     $observedModels[] = $modelClassName;
                     $modelClassName::model()->attachEventHandler('onBeforeSave', array($this, 'processWorkflowBeforeSave'));
                     $modelClassName::model()->attachEventHandler('onAfterSave', array($this, 'processWorkflowAfterSave'));
                 }
             } catch (NotSupportedException $e) {
             }
         }
     }
 }
 /**
  * Use this function to ascertain if a particular customFieldData model is used by more than one attribute
  * in the application.  An example is a pick list that is shared by two separate attributes in two different
  * models.
  * @return array of model plural label / attribute label pairings.
  *
  * Important Limitations to understand!!
  * Only supports up to one attribute per model that uses the same customFieldData.
  * Only searches primary models of the modules in the system.
  */
 public static function getModelPluralNameAndAttributeLabelsByName($name)
 {
     $data = array();
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         try {
             $modelClassName = $module->getPrimaryModelName();
             $metadata = $modelClassName::getMetadata();
             if (isset($metadata[$modelClassName]['customFields']) && in_array($name, $metadata[$modelClassName]['customFields'])) {
                 $model = new $modelClassName();
                 $attributeName = array_search($name, $metadata[$modelClassName]['customFields']);
                 $data[$module::getModuleLabelByTypeAndLanguage('Plural')] = $model->getAttributeLabel($attributeName);
             }
         } catch (NotSupportedException $e) {
         }
     }
     return $data;
 }
 protected function renderContent()
 {
     $placedViewTypes = Portlet::getPlacedViewTypesByLayoutIdAndUser($this->uniqueLayoutId, Yii::app()->user->userModel->id);
     $content = '<ul class="available-portlets">';
     $modules = Module::getModuleObjects();
     $sortablePortlets = array();
     foreach ($modules as $module) {
         if ($module->isEnabled()) {
             $p = $module->getParentModule();
             $viewClassNames = $module::getViewClassNames();
             foreach ($viewClassNames as $className) {
                 $viewReflectionClass = new ReflectionClass($className);
                 if (!$viewReflectionClass->isAbstract()) {
                     $portletRules = PortletRulesFactory::createPortletRulesByView($className);
                     if ($viewReflectionClass->implementsInterface('RelatedPortletViewInterface')) {
                         if ($this->resolveLayoutIdInAllowedOnPortletViewClassNames($className) && $className::allowMultiplePlacement() == false && !in_array($portletRules->getType(), $placedViewTypes) && PortletsSecurityUtil::doesCurrentUserHavePermissionToAddPortlet($portletRules) === true) {
                             $metadata = $className::getMetadata();
                             $url = Yii::app()->createUrl($this->moduleId . '/defaultPortlet/add', array('uniqueLayoutId' => $this->uniqueLayoutId, 'modelId' => $this->modelId, 'portletType' => $portletRules->getType()));
                             $title = $metadata['perUser']['title'];
                             MetadataUtil::resolveEvaluateSubString($title);
                             $sortablePortlets[$title] = $url;
                         }
                     }
                 }
             }
         }
     }
     if (empty($sortablePortlets)) {
         $messageView = new NoPortletsToPlaceView();
         return $messageView->render();
     }
     //Sort by title
     ksort($sortablePortlets);
     foreach ($sortablePortlets as $title => $url) {
         $onClick = 'window.location.href = "' . $url . '"';
         $content .= '<li>';
         $label = '<span>\\</span>' . $title;
         $content .= ZurmoHtml::link(Zurmo::t('HomeModule', $label), null, array('onclick' => $onClick));
         $content .= '</li>';
     }
     $content .= '</ul>';
     return $content;
 }
 public static function getAvailableModelNamesArray()
 {
     $modules = Module::getModuleObjects();
     $availableModels = array();
     foreach ($modules as $module) {
         $moduleClassName = get_class($module);
         if ($moduleClassName::canHaveContentTemplates() && RightsUtil::canUserAccessModule($moduleClassName, Yii::app()->user->userModel) && method_exists($moduleClassName, 'getPrimaryModelName')) {
             try {
                 $modelClassName = $moduleClassName::getPrimaryModelName();
                 if (!isset($availableModels[$modelClassName])) {
                     $availableModels[$modelClassName] = $modelClassName::getModelLabelByTypeAndLanguage('Plural');
                 }
             } catch (NotSupportedException $e) {
             }
         }
     }
     asort($availableModels);
     return $availableModels;
 }
 /**
  * Returns list of available designer types including
  * attribute types available for creating custom fields
  * and designer types for standard collection attributes that
  * are not necessarily available types for custom fields.
  *
  */
 public static function getAvailableDesignerTypes()
 {
     if (self::$availableDesignerTypes != null) {
         return self::$availableDesignerTypes;
     }
     $modules = Module::getModuleObjects();
     $designerTypes = array();
     foreach ($modules as $module) {
         $formsClassNames = $module::getAllClassNamesByPathFolder('forms');
         foreach ($formsClassNames as $formClassName) {
             $classToEvaluate = new ReflectionClass($formClassName);
             if (is_subclass_of($formClassName, 'AttributeForm') && !$classToEvaluate->isAbstract()) {
                 $designerTypes[] = substr($formClassName, 0, strlen($formClassName) - strlen('AttributeForm'));
             }
         }
     }
     self::$availableDesignerTypes = $designerTypes;
     return self::$availableDesignerTypes;
 }
 protected function getCategoryData()
 {
     $categories = array();
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         $moduleSubMenuItems = MenuUtil::getAccessibleConfigureSubMenuByCurrentUser(get_class($module));
         if ($module->isEnabled() && count($moduleSubMenuItems) > 0) {
             foreach ($moduleSubMenuItems as $subMenuItem) {
                 if (!empty($subMenuItem['category']) && $subMenuItem['category'] == ZurmoModule::ADMINISTRATION_CATEGORY_PLUGINS) {
                     assert('isset($subMenuItem["titleLabel"])');
                     assert('isset($subMenuItem["descriptionLabel"])');
                     assert('isset($subMenuItem["route"])');
                     $categories[$subMenuItem['category']][] = $subMenuItem;
                 }
             }
         }
     }
     return $categories;
 }
 public static function load(&$messageLogger)
 {
     assert('$messageLogger instanceof MessageLogger');
     Yii::import('application.core.data.*');
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         $parentModule = $module->getParentModule();
         if ($parentModule != null) {
             Yii::import('application.modules.' . $parentModule::getDirectoryName() . '.data.*');
         } else {
             Yii::import('application.modules.' . $module::getDirectoryName() . '.data.*');
         }
         $defaultDataMakerClassName = $module::getDefaultDataMakerClassName();
         if ($defaultDataMakerClassName != null) {
             $dataMaker = new $defaultDataMakerClassName();
             $dataMaker->make();
             $messageLogger->addInfoMessage(Zurmo::t('Core', 'Default data loaded for {moduleName}', array('{moduleName}' => $module::getModuleLabelByTypeAndLanguage('Plural'))));
         }
     }
 }
 /**
  * Initialize the observer if gamification is enabled.  Attachs scoring events to model classes as needed.
  */
 public function init()
 {
     if ($this->enabled) {
         $observedModels = array();
         $modules = Module::getModuleObjects();
         foreach ($modules as $module) {
             try {
                 $modelClassName = $module->getPrimaryModelName();
                 if ($modelClassName != null && is_subclass_of($modelClassName, 'Item') && $modelClassName::getGamificationRulesType() != null && !in_array($modelClassName, $observedModels)) {
                     $observedModels[] = $modelClassName;
                     $gamificationRulesType = $modelClassName::getGamificationRulesType();
                     $gamificationRulesClassName = $gamificationRulesType . 'Rules';
                     $rules = new $gamificationRulesClassName();
                     $rules->attachScoringEventsByModelClassName($modelClassName);
                 }
             } catch (NotSupportedException $e) {
             }
         }
     }
 }
 public static function getNonMonitorJobClassNames()
 {
     try {
         $jobClassNames = GeneralCache::getEntry(self::NON_MONITOR_JOBS_CACHE_ID);
     } catch (NotFoundException $e) {
         $jobClassNames = array();
         $modules = Module::getModuleObjects();
         foreach ($modules as $module) {
             $jobsClassNames = $module::getAllClassNamesByPathFolder('jobs');
             foreach ($jobsClassNames as $jobClassName) {
                 $classToEvaluate = new ReflectionClass($jobClassName);
                 if (is_subclass_of($jobClassName, 'BaseJob') && !$classToEvaluate->isAbstract() && $jobClassName != 'MonitorJob') {
                     $jobClassNames[] = $jobClassName;
                 }
             }
         }
         GeneralCache::cacheEntry(self::NON_MONITOR_JOBS_CACHE_ID, $jobClassNames);
     }
     return $jobClassNames;
 }
Esempio n. 29
0
 /**
  * @param String $interfaceClassName The name of the interface to check model implementation
  * @return Array Contains the modelClassNames of models that implements the interface
  */
 public static function getModelDataForCurrentUserByInterfaceName($interfaceClassName, $includeHavingRelatedItems = true)
 {
     assert('is_string($interfaceClassName)');
     $interfaceModelClassNames = array();
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         $modelClassNames = $module::getModelClassNames();
         foreach ($modelClassNames as $modelClassName) {
             $classToEvaluate = new ReflectionClass($modelClassName);
             if ($classToEvaluate->implementsInterface($interfaceClassName) && !$classToEvaluate->isAbstract()) {
                 if (RightsUtil::canUserAccessModule(get_class($module), Yii::app()->user->userModel)) {
                     if (!$includeHavingRelatedItems && !$modelClassName::hasRelatedItems()) {
                         continue;
                     }
                     $interfaceModelClassNames[$modelClassName] = $modelClassName::getModelLabelByTypeAndLanguage('Plural');
                 }
             }
         }
     }
     return $interfaceModelClassNames;
 }
 protected function getCategoryData()
 {
     $categories = array();
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         $moduleMenuItems = MenuUtil::getAccessibleConfigureMenuByCurrentUser(get_class($module));
         if ($module->isEnabled() && count($moduleMenuItems) > 0) {
             foreach ($moduleMenuItems as $menuItem) {
                 if (!empty($menuItem['category'])) {
                     assert('isset($menuItem["titleLabel"])');
                     assert('isset($menuItem["descriptionLabel"])');
                     assert('isset($menuItem["route"])');
                     $categories[$menuItem['category']][] = $menuItem;
                 } else {
                     throw new NotSupportedException();
                 }
             }
         }
     }
     return $categories;
 }