Changeset 518 for trunk/lib/App.inc.php


Ignore:
Timestamp:
May 1, 2015 1:15:16 AM (9 years ago)
Author:
anonymous
Message:

Non-breaking function changes to App and Utilities.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/App.inc.php

    r505 r518  
    6161    protected $_carry_queries = array();
    6262
     63    // Array of raised message counters.
     64    protected $_raised_msg_counter = array(MSG_NOTICE => 0, MSG_SUCCESS => 0, MSG_WARNING => 0, MSG_ERR => 0);
     65
    6366    // Dictionary of global application parameters.
    6467    protected $_params = array();
     
    514517        if (!in_array($type, array(MSG_NOTICE, MSG_SUCCESS, MSG_WARNING, MSG_ERR))) {
    515518            $this->logMsg(sprintf('Invalid MSG_* type: %s', $type), LOG_NOTICE, __FILE__, __LINE__);
     519        }
     520
     521        // Increment the counter for this message type.
     522        $this->_raised_msg_counter[$type] += 1;
     523    }
     524
     525    /*
     526    * Returns the number of raised message (all, or by type) for the current script execution (this number may not match the total number of messages stored in session for multiple script executions)
     527    *
     528    * @access   public
     529    * @param
     530    * @return
     531    * @author   Quinn Comendant <quinn@strangecode.com>
     532    * @version  1.0
     533    * @since    30 Apr 2015 17:13:03
     534    */
     535    public function getRaisedMessageCount($type='all')
     536    {
     537        if ('all' == $type) {
     538            return array_sum($this->_raised_msg_counter);
     539        } else if (isset($this->_raised_msg_counter[$type])) {
     540            return $this->_raised_msg_counter[$type];
     541        } else {
     542            $this->logMsg(sprintf('Cannot return count of unknown raised message type: %s', $type), LOG_WARNING, __FILE__, __LINE__);
     543            return false;
    516544        }
    517545    }
Note: See TracChangeset for help on using the changeset viewer.