Skip to content
Snippets Groups Projects
Select Git revision
  • c57e87eee41111248b11537997e8c5799681ebc0
  • master default
  • develop
  • git-fixes
  • 4.1_templates-symlink
  • 4.0_templates
6 results

start.php

Blame
  • ApprovalActionsQueue.php 1.70 KiB
    <?php
    
    require_once 'ApprovalActionTable/Interface.php';
    
    class ApprovalActionsQueue extends Nmc_Db_Table
                               implements Application_ApprovalActionTable_Interface
    {
        protected $_primary = 'approvalActionId';
        protected $_rowClass = 'ApprovalActionQueue';
    
        /**
         * The one true instance
         *
         * @var ApprovalActionsQueue
         */
        static protected $_instance;
    
        /**
         * Return the one true instance
         *
         * @return ApprovalActionsQueue
         */
        static public function getInstance($config = array())
        {
            if (!self::$_instance) {
                self::$_instance = new ApprovalActionsQueue($config);
            }
            return self::$_instance;
        }
    
        public function getActionName()
        {
            return 'Queue';
        }
    
        public function getResultStatusStrings()
        {
            return array('Approved' => 'Approved',
                         'Denied' => 'Denied');
        }
    
        public function getEditTemplate()
        {
            return 'approval_actions/ApprovalActionQueue.xhtml';
        }
    
        public function fetchNew($formData = null)
        {
            if (!$formData) {
                return parent::fetchNew();
            }
    
            $new = parent::fetchNew();
            $new->className = 'ApprovalActionQueue';
    
            return $new;
        }
    
        static public function advanceQueues()
        {
            $datesTable = ApprovalActionsQueueDates::getInstance();
            $db = $datesTable->getAdapter();
    
            $where = $db->quoteInto('date <= ?', time());
            $requestQueues = $datesTable->fetchAll($where);
    
            foreach ($requestQueues as $requestQueue) {
                $requestQueue->approvalAction->advanceQueue($requestQueue->date);
                $requestQueue->delete();
            }
        }
    
    
    }