/** * @param string $name * @return IMarketPlaceType */ public function buildMarketplaceType($name) { $marketplace_type = new MarketPlaceType(); $marketplace_type->setName($name); $marketplace_type->activate(); $slug = str_replace(' ', '-', strtolower($name)); $marketplace_type->setSlug($slug); $g = $marketplace_type->createSecurityGroup(); $marketplace_type->setAdminGroup($g); return $marketplace_type; }
function getAdminPermissionSet(array &$res) { $marketplace_types = MarketPlaceType::get(); foreach ($marketplace_types as $mp) { $group = $mp->AdminGroup(); if (!$group) { continue; } foreach ($group->Permissions() as $p) { array_push($res, $p->Code); } } }
public function updateCMSFields(FieldList $fields) { $oldFields = $fields->toArray(); foreach ($oldFields as $field) { $fields->remove($field); } $fields->push(new TextField("MaxInstances", "Max. Instances")); $companies = Company::get(); if ($companies) { $fields->push($ddl = new DropdownField('CompanyID', 'Company', $companies->map("ID", "Name"))); $ddl->setEmptyString("Please Select a Company"); } $market_place_types = MarketPlaceType::get(); if ($market_place_types) { $fields->push($ddl = new DropdownField('MarketPlaceTypeID', 'MarketPlaceType', $market_place_types->map("ID", "Name"))); $ddl->setEmptyString("Please Select a Market Place Type"); } return $fields; }
/** * @param string $type * @return IMarketPlaceType */ public function getByType($type) { return MarketPlaceType::get()->filter('Name', $type)->first(); }
/** * @return IMarketPlaceType */ protected function getDefaultMarketPlaceType() { $name = ITraining::MarketPlaceType; return MarketPlaceType::get()->filter('Name', $name)->first(); }
/** * @return FieldList */ public function getCMSFields() { $fields = parent::getCMSFields(); $fields->push(new DropdownField('MarketPlaceTypeID', 'MarketPlaceType', MarketPlaceType::get()->map("ID", "Name"))); return $fields; }