Example #1
0
 public function checkCustomerGroupAccess(Varien_Object $item)
 {
     $access = true;
     if ($item->getIsActive() == self::STATUS_DISABLED) {
         return false;
     }
     $groups = $item->getCustomerGroups();
     if (is_null($groups) && $item->getAllowGuests()) {
         $groups = '0';
     }
     if (!empty($groups) && is_string($groups)) {
         $groups = explode(',', $groups);
     }
     if (empty($groups)) {
         $access = true;
     } else {
         if (is_array($groups) && !in_array(Mage::getSingleton('customer/session')->getCustomerGroupId(), $groups)) {
             $access = false;
         }
     }
     $limit = $item->getDownloadsLimit();
     if ($limit) {
         if ($item->getDownloads() >= $limit) {
             $access = false;
         }
     }
     return $access;
 }