$value) { if (is_string($value)) { $subject[$key] = str_replace($search, $replace, $value); } elseif (is_array($value)) { $subject[$key] = self::recursiveReplace($search, $replace, $value); } } return $subject; } /** * In Byte * @param int $fileSize * @param null|string|bool|int|Mage_Core_Model_Store $store * * @return bool */ public function isAllowFileSize($fileSize, $store = null) { if (($fileSize / 1024 / 1024) <= AW_Helpdesk3_Helper_Config::getMaxUploadFileSizeOnFrontend($store)) { return true; } return false; } /** * @param string $filename * @param null|string|bool|int|Mage_Core_Model_Store $store * * @return bool */ public function isAllowFileExtension($filename, $store = null) { $allowedFileExtension = AW_Helpdesk3_Helper_Config::getAllowFileExtension($store); if (!$allowedFileExtension) { return true; } $allowedFileExtension = explode(',', $allowedFileExtension); $allowedFileExtension = array_map('strtolower', $allowedFileExtension); $fileExt = pathinfo($filename, PATHINFO_EXTENSION); if (in_array(strtolower($fileExt), $allowedFileExtension)) { return true; } return false; } public function escapeFilename($fileName) { return preg_replace('/([#=\/*:\?<>\| \\\"\'])+/i', '', $fileName); } public function getCustomerCollectionByEmail($email, $limit) { $collection = Mage::getModel('customer/customer')->getCollection() ->addNameToSelect() ->addAttributeToSelect('email') ->addAttributeToSelect('firstname') ->addAttributeToSelect('lastname') ->setPageSize($limit) ; $collection->addAttributeToFilter( array( array('attribute' => 'email', 'like' => '%' . $email . '%') ) ); return $collection; } public function validateAttach($filename, $content, $storeId = null) { if (null === $storeId) { $storeId = Mage::app()->getStore()->getId(); } if (!$this->isAllowFileSize(strlen($content), $storeId)) { throw new Exception('Attachment can\'t be saved because is too large'); } if (!$this->isAllowFileExtension($filename, $storeId)) { throw new Exception('Attachment can\'t be saved because is not allowed extension'); } return true; } }