/**
  * Returns founded customer or preset entity
  * @return Mage_Customer_Model_Customer | Varien_Object
  */
 public function getCustomer(AW_Helpdeskultimate_Model_Proto $proto)
 {
     $customer = Mage::getModel('customer/customer')->load($proto->getFrom());
     if ($customer->getId()) {
         return $customer;
     } else {
         Mage::throwException("Can not load customer. Reason: customer is missing");
         return null;
     }
 }
 /**
  * Initializes gateway=>department links
  * @return array
  */
 protected function _initGatewaysDepartments()
 {
     if (!self::$_gatewaysDepartments) {
         $gateways = array();
         $globalDeps = array();
         $departments = Mage::getModel('helpdeskultimate/department')->getCollection()->addActiveFilter();
         foreach ($departments as $department) {
             if (!$department->usesAllGateways()) {
                 foreach ($department->getGateways() as $gw) {
                     @($gateways[$gw][] = $department->getId());
                 }
             } else {
                 //department uses all gateways
                 $globalDeps[] = $department->getId();
             }
         }
         if (sizeof($globalDeps)) {
             foreach (Mage::getModel('helpdeskultimate/gateway')->getCollection()->addActiveFilter() as $gateway) {
                 foreach ($globalDeps as $gdId) {
                     @($gateways[$gateway->getId()][] = $gdId);
                 }
             }
         }
         self::$_gatewaysDepartments = $gateways;
     }
 }