Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_AdminNotification_Helper_Data
  • Mage_AdminNotification_Model_Feed
  • Mage_AdminNotification_Model_Inbox
  • Mage_AdminNotification_Model_Mysql4_Inbox
  • Mage_AdminNotification_Model_Mysql4_Inbox_Collection
  • Mage_AdminNotification_Model_Observer
  • Mage_AdminNotification_Model_Resource_Inbox
  • Mage_AdminNotification_Model_Resource_Inbox_Collection
  • Mage_AdminNotification_Model_Survey
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_AdminNotification
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: 
 28: /**
 29:  * AdminNotification Inbox model
 30:  *
 31:  * @category    Mage
 32:  * @package     Mage_AdminNotification
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_AdminNotification_Model_Resource_Inbox extends Mage_Core_Model_Resource_Db_Abstract
 36: {
 37:     /**
 38:      * AdminNotification Resource initialization
 39:      *
 40:      */
 41:     protected function _construct()
 42:     {
 43:         $this->_init('adminnotification/inbox', 'notification_id');
 44:     }
 45: 
 46:     /**
 47:      * Load latest notice
 48:      *
 49:      * @param Mage_AdminNotification_Model_Inbox $object
 50:      * @return Mage_AdminNotification_Model_Resource_Inbox
 51:      */
 52:     public function loadLatestNotice(Mage_AdminNotification_Model_Inbox $object)
 53:     {
 54:         $adapter = $this->_getReadAdapter();
 55:         $select = $adapter->select()
 56:             ->from($this->getMainTable())
 57:             ->order($this->getIdFieldName() . ' DESC')
 58:             ->where('is_read != 1')
 59:             ->where('is_remove != 1')
 60:             ->limit(1);
 61:         $data = $adapter->fetchRow($select);
 62: 
 63:         if ($data) {
 64:             $object->setData($data);
 65:         }
 66: 
 67:         $this->_afterLoad($object);
 68: 
 69:         return $this;
 70:     }
 71: 
 72:     /**
 73:      * Get notifications grouped by severity
 74:      *
 75:      * @param Mage_AdminNotification_Model_Inbox $object
 76:      * @return array
 77:      */
 78:     public function getNoticeStatus(Mage_AdminNotification_Model_Inbox $object)
 79:     {
 80:         $adapter = $this->_getReadAdapter();
 81:         $select = $adapter->select()
 82:             ->from($this->getMainTable(), array(
 83:                 'severity'     => 'severity',
 84:                 'count_notice' => new Zend_Db_Expr('COUNT(' . $this->getIdFieldName() . ')')))
 85:             ->group('severity')
 86:             ->where('is_remove=?', 0)
 87:             ->where('is_read=?', 0);
 88:         $return = $adapter->fetchPairs($select);
 89:         return $return;
 90:     }
 91: 
 92:     /**
 93:      * Save notifications (if not exists)
 94:      *
 95:      * @param Mage_AdminNotification_Model_Inbox $object
 96:      * @param array $data
 97:      */
 98:     public function parse(Mage_AdminNotification_Model_Inbox $object, array $data)
 99:     {
100:         $adapter = $this->_getWriteAdapter();
101:         foreach ($data as $item) {
102:             $select = $adapter->select()
103:                 ->from($this->getMainTable())
104:                 ->where('title = ?', $item['title']);
105: 
106:             if (empty($item['url'])) {
107:                 $select->where('url IS NULL');
108:             } else {
109:                 $select->where('url = ?', $item['url']);
110:             }
111: 
112:             if (isset($item['internal'])) {
113:                 $row = false;
114:                 unset($item['internal']);
115:             } else {
116:                 $row = $adapter->fetchRow($select);
117:             }
118: 
119:             if (!$row) {
120:                 $adapter->insert($this->getMainTable(), $item);
121:             }
122:         }
123:     }
124: }
125: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0