Example #1
0
 public function addTransientJobService($sName, $mixedService)
 {
     if (is_array($mixedService)) {
         $mixedService = call_user_func_array('BxDolService::getSerializedService', $mixedService);
     }
     if (!BxDolService::isSerializedService($mixedService)) {
         return false;
     }
     $sQuery = $this->prepare("INSERT INTO `sys_cron_jobs` SET `name`=?, `time`='transient', `service_call`=?", $sName, $mixedService);
     return (int) $this->query($sQuery) > 0;
 }
 public function updateCache()
 {
     $aWidgets = array();
     $this->oDb->getWidgets(array('type' => 'all_with_notices'), $aWidgets, false);
     $aResult = array();
     foreach ($aWidgets as $aWidget) {
         if (BxDolService::isSerializedService($aWidget['cnt_notices'])) {
             $aService = unserialize($aWidget['cnt_notices']);
             $sNotices = BxDolService::call($aService['module'], $aService['method'], array_merge(array($aWidget), $aService['params']), $aService['class']);
         }
         $aResult[$aWidget['id']] = $sNotices;
     }
     $oCache = $this->oDb->getDbCacheObject();
     $sCacheKey = $this->oDb->genDbCacheKey($this->sCacheKeyNotices);
     return $oCache->setData($sCacheKey, $aResult);
 }
Example #3
0
 /**
  * * * * Static methods for work with template injections * * *
  *
  * Static method is used to add/replace the content of some key in the template.
  * It's usefull when you don't want to modify existing template but need to add some data to existing template key.
  *
  * @param  integer $iPageIndex - page index where injections would processed. Use 0 if you want it to be done on all the pages.
  * @param  string  $sKey       - template key.
  * @param  string  $sValue     - the data to be added.
  * @return string  the result of operation.
  */
 function processInjection($iPageIndex, $sKey, $sValue = "")
 {
     if ($iPageIndex != 0 && isset($this->aPage['injections']['page_0'][$sKey]) && isset($this->aPage['injections']['page_' . $iPageIndex][$sKey])) {
         $aSelection = @array_merge($this->aPage['injections']['page_0'][$sKey], $this->aPage['injections']['page_' . $iPageIndex][$sKey]);
     } else {
         if (isset($this->aPage['injections']['page_0'][$sKey])) {
             $aSelection = $this->aPage['injections']['page_0'][$sKey];
         } else {
             if (isset($this->aPage['injections']['page_' . $iPageIndex][$sKey])) {
                 $aSelection = $this->aPage['injections']['page_' . $iPageIndex][$sKey];
             } else {
                 $aSelection = array();
             }
         }
     }
     if (is_array($aSelection)) {
         foreach ($aSelection as $aInjection) {
             if (isset($GLOBALS['bx_profiler'])) {
                 $GLOBALS['bx_profiler']->beginInjection($sRand = time() . rand());
             }
             $sInjData = '';
             switch ($aInjection['type']) {
                 case 'text':
                     $sInjData = $aInjection['data'];
                     break;
                 case 'service':
                     if (BxDolService::isSerializedService($aInjection['data'])) {
                         $sInjData = BxDolService::callSerialized($aInjection['data']);
                     }
                     break;
             }
             if ((int) $aInjection['replace'] == 1) {
                 $sValue = $sInjData;
             } else {
                 $sValue .= $sInjData;
             }
             if (isset($GLOBALS['bx_profiler'])) {
                 $GLOBALS['bx_profiler']->endInjection($sRand, $aInjection);
             }
         }
     }
     return $sValue != '__' . $sKey . '__' ? str_replace('__' . $sKey . '__', '', $sValue) : $sValue;
 }
Example #4
0
 /**
  * Notifies the necessary handlers about the alert.
  */
 public function alert()
 {
     if (isset($this->_aAlerts[$this->sUnit]) && isset($this->_aAlerts[$this->sUnit][$this->sAction])) {
         foreach ($this->_aAlerts[$this->sUnit][$this->sAction] as $iHandlerId) {
             $aHandler = $this->_aHandlers[$iHandlerId];
             if (isset($GLOBALS['bx_profiler']) && 'bx_profiler' != $aHandler['name']) {
                 $GLOBALS['bx_profiler']->beginAlert($this->sUnit, $this->sAction, $aHandler['name']);
             }
             if (!empty($aHandler['file']) && !empty($aHandler['class']) && file_exists(BX_DIRECTORY_PATH_ROOT . $aHandler['file'])) {
                 if (!class_exists($aHandler['class'], false)) {
                     require_once BX_DIRECTORY_PATH_ROOT . $aHandler['file'];
                 }
                 $oHandler = new $aHandler['class']();
                 $oHandler->response($this);
             } else {
                 if (!empty($aHandler['service_call']) && BxDolService::isSerializedService($aHandler['service_call'])) {
                     $aService = unserialize($aHandler['service_call']);
                     $aParams = array($this);
                     if (isset($aService['params']) && is_array($aService['params'])) {
                         $aParams = array_merge($aParams, $aService['params']);
                     }
                     BxDolService::call($aService['module'], $aService['method'], $aParams, isset($aService['class']) ? $aService['class'] : 'Module');
                 }
             }
             if (isset($GLOBALS['bx_profiler']) && 'bx_profiler' != $aHandler['name']) {
                 $GLOBALS['bx_profiler']->endAlert($this->sUnit, $this->sAction, $aHandler['name']);
             }
         }
     }
 }
Example #5
0
 protected function _getRequestedDataBySystem($aSystem, $iCachedData = 0)
 {
     if (!BxDolService::isSerializedService($aSystem['service_call'])) {
         return false;
     }
     $aResponce = BxDolService::callSerialized($aSystem['service_call'], array('count' => (int) $iCachedData));
     if (empty($aResponce) || !is_array($aResponce) || !isset($aResponce['count'], $aResponce['method'])) {
         return false;
     }
     return $aResponce;
 }
Example #6
0
function runJob($aJob)
{
    if (!empty($aJob['file']) && !empty($aJob['class']) && file_exists(BX_DIRECTORY_PATH_ROOT . $aJob['file'])) {
        if (!class_exists($aJob['class'])) {
            require_once BX_DIRECTORY_PATH_ROOT . $aJob['file'];
        }
        $oHandler = new $aJob['class']();
        $oHandler->processing();
    } else {
        if (!empty($aJob['service_call']) && BxDolService::isSerializedService($aJob['service_call'])) {
            BxDolService::callSerialized($aJob['service_call']);
        }
    }
}
 protected function field($aItem)
 {
     $aField = array();
     switch ($aItem['type']) {
         case 'digit':
             $aField = array('type' => 'text', 'name' => $aItem['name'], 'caption' => _t($aItem['caption']), 'value' => $aItem['value'], 'db' => array('pass' => 'Xss'));
             break;
         case 'text':
             $aField = array('type' => 'textarea', 'name' => $aItem['name'], 'caption' => _t($aItem['caption']), 'value' => $aItem['value'], 'db' => array('pass' => 'XssHtml'));
             break;
         case 'checkbox':
             $aField = array('type' => 'checkbox', 'name' => $aItem['name'], 'caption' => _t($aItem['caption']), 'value' => 'on', 'checked' => $aItem['value'] == 'on', 'db' => array('pass' => 'Xss'));
             break;
         case 'list':
         case 'rlist':
             $aField = array('type' => 'checkbox_set', 'name' => $aItem['name'], 'caption' => _t($aItem['caption']), 'value' => !empty($aItem['value']) ? explode(',', $aItem['value']) : array(), 'reverse' => $aItem['type'] == 'rlist', 'db' => array('pass' => 'Xss'));
             if (BxDolService::isSerializedService($aItem['extra'])) {
                 $aField['values'] = BxDolService::callSerialized($aItem['extra']);
             } else {
                 foreach (explode(',', $aItem['extra']) as $sValue) {
                     $aField['values'][$sValue] = $sValue;
                 }
             }
             break;
         case 'select':
             $aField = array('type' => 'select', 'name' => $aItem['name'], 'caption' => _t($aItem['caption']), 'value' => $aItem['value'], 'values' => array(), 'db' => array('pass' => 'Xss'));
             if (BxDolService::isSerializedService($aItem['extra'])) {
                 $aField['values'] = BxDolService::callSerialized($aItem['extra']);
             } else {
                 foreach (explode(',', $aItem['extra']) as $sValue) {
                     $aField['values'][] = array('key' => $sValue, 'value' => $sValue);
                 }
             }
             break;
         case 'file':
             $aField = array('type' => 'file', 'name' => $aItem['name'], 'caption' => _t($aItem['caption']), 'value' => $aItem['value'], 'db' => array('pass' => 'Xss'));
             break;
     }
     return $aField;
 }
Example #8
0
 protected function _getRequestedData($iIndex = 0, $bIndexCheck = false)
 {
     $aResult = array();
     foreach ($this->_aSystems as $aSystem) {
         if (empty($aSystem) || !is_array($aSystem) || (int) $aSystem['active'] != 1) {
             continue;
         }
         if ($bIndexCheck && $iIndex % (int) $aSystem['frequency'] != 0) {
             continue;
         }
         if (!BxDolService::isSerializedService($aSystem['service_call'])) {
             continue;
         }
         $aResponce = BxDolService::callSerialized($aSystem['service_call']);
         if (empty($aResponce) || !is_array($aResponce) || !isset($aResponce['count'], $aResponce['method'])) {
             continue;
         }
         $aResult[$aSystem['name']] = $aResponce;
     }
     return $aResult;
 }
Example #9
0
 protected function getEmptyValue($aOption)
 {
     $mixedValue = '';
     switch ($aOption['type']) {
         case 'digit':
             $mixedValue = 0;
             break;
         case 'select':
             if (BxDolService::isSerializedService($aOption['extra'])) {
                 $aValues = BxDolService::callSerialized($aOption['extra']);
             } else {
                 $aValues = explode(',', $aOption['extra']);
             }
             $mixedValue = $aValues[0];
             break;
         case 'text':
         case 'checkbox':
         case 'file':
             $mixedValue = "";
             break;
     }
     return $mixedValue;
 }