/** * run the task */ function run($request) { $approvedCustomerGroup = EcommerceCorporateGroupGroupDecorator::get_approved_customer_group(); if ($approvedCustomerGroup) { $groups = DataObject::get("Group", "ParentID = " . $approvedCustomerGroup->ID, "\"Title\" ASC"); $sort = 0; foreach ($groups as $group) { $sort = $sort + 10; $group->Sort = $sort; $group->write(); } } }
/** * Tells us whether this member is allowed to purchase a product. * NOTE: it returns TRUE (can purchase) if no approved customer group * has been setup yet. * @return Boolean */ public function isApprovedCorporateCustomer() { $outcome = false; if (!$this->owner->exists()) { return false; } $approvedCustomerGroup = EcommerceCorporateGroupGroupDecorator::get_approved_customer_group(); if ($approvedCustomerGroup) { if ($this->owner->inGroup($approvedCustomerGroup, false)) { //exception - customer is approved $outcome = true; } elseif ($this->owner->IsShopAdmin() || $this->owner->IsAdmin()) { //exception - administrator $outcome = true; } else { //return false; } } else { //exception - Group not setup yet. $outcome = true; } //standard answer.... return $outcome; }
static function set_permission_code($s) { self::$permission_code = $s; }