示例#1
0
 /**
  * Trigger joomla content plugins on the category contents and clears the route cache
  *
  * @param  AppEvent $event The event triggered
  */
 public static function stateChanged($event)
 {
     $category = $event->getSubject();
     $old_state = $event['old_state'];
     JPluginHelper::importPlugin('content');
     JDispatcher::getInstance()->trigger('onContentChangeState', array($category->app->component->self->name . '.category', array($category->id), $category->published));
     $category->app->route->clearCache();
 }
示例#2
0
 /**
  * Placeholder for the configParams event
  *
  * @param  AppEvent $event The event triggered
  */
 public static function configParams($event)
 {
     $application = $event->getSubject();
     // set events ReturnValue after modifying $params
     $params = $event->getReturnValue();
     $params[] = '<application><params group="application-config"><param name="test" type="text" size="3" default="15" label="Test Param" description="Test Param Description" /></params></application>';
     $event->setReturnValue($params);
 }
示例#3
0
 /**
  * Function for the deleted event
  *
  * @param  AppEvent $event The event triggered
  */
 public static function deleted($event)
 {
     $application = $event->getSubject();
     $name = $application->getAssetName();
     $asset = JTable::getInstance('Asset');
     if ($asset->loadByName($name)) {
         $asset->delete();
     }
 }
示例#4
0
 /**
  * Function for the deleted event
  *
  * @param  AppEvent $event The event triggered
  */
 public static function deleted($event)
 {
     $application = $event->getSubject();
     $name = $application->getAssetName();
     $asset = JTable::getInstance('Asset');
     if ($asset->loadByName($name)) {
         if (!$asset->delete()) {
             $this->setError($asset->getError());
             return false;
         }
     }
 }
示例#5
0
 /**
  * On type deleted
  * @param AppEvent $event
  */
 public static function deleted($event)
 {
     $app = self::app();
     $type = $event->getSubject();
     $config = JBModelConfig::model();
     $elements = $app->jbprice->getTypePrices($type);
     $tableName = $app->jbtables->getIndexTable($type->id);
     $app->jbtables->dropTable($tableName);
     if (!empty($elements)) {
         foreach ($elements as $id => $element) {
             $config->removeGroup('cart.' . JBCart::ELEMENT_TYPE_PRICE . '.' . $id);
             $config->removeGroup('cart.' . JBCart::CONFIG_PRICE_TMPL . '.' . $id);
             $config->removeGroup('cart.' . JBCart::CONFIG_PRICE_TMPL_FILTER . '.' . $id);
         }
     }
 }
示例#6
0
    /**
     * Placeholder for the configParams event
     *
     * @param  AppEvent $event
     *        The event triggered
     */
    public static function configParams($event)
    {
        jimport('joomla.filesystem.file');
        if (!JFile::exists(JPATH_SITE . '/components/com_quick2cart/quick2cart.php')) {
            return true;
        }
        $lang = JFactory::getLanguage();
        $lang->load('com_quick2cart', JPATH_ADMINISTRATOR);
        $application = $event->getSubject();
        // set events ReturnValue after modifying $params
        $params = $event->getReturnValue();
        $params[] = '
		 <application>
			<params group="item-config">
				<param name="qtc_params" type="quick2cart" label="' . JText::_('QTC_OPTS') . '" description="' . JText::_('QTC_OPTS_DESC') . '" />
			</params>
		 </application>';
    }
示例#7
0
 /**
  * On submission saved
  * @param AppEvent $event
  */
 public static function saved($event)
 {
     $app = self::app();
     $params = $event->getParameters();
     $item = $params['item'];
     // add advert to cart
     if ($request = $item->getElementsByType('jbadvert')) {
         $redirect = false;
         foreach ($request as $element) {
             $request = $app->jbrequest->getArray('elements');
             $elemId = $element->identifier;
             if (isset($request[$elemId]['gotocart']) && (int) $request[$elemId]['gotocart']) {
                 $element->addToCart();
                 $redirect = true;
             }
         }
         if ($redirect) {
             JFactory::getApplication()->redirect($app->jbrouter->basket());
         }
     }
 }
示例#8
0
 /**
  * Execute all elements for system event (zoo trigger)
  * @param AppEvent $event
  * @return void
  */
 public function fireElements(AppEvent $event)
 {
     $eventName = $this->app->jbvars->lower($event->getName(), true);
     // simple check
     if (!$eventName || !isset($this->_eventList[$eventName])) {
         return;
     }
     // prepare vars
     $eventData = $this->_eventList[$eventName];
     $order = $event->getSubject();
     $params = $event->getParameters();
     // system events
     $cartConf = JBModelConfig::model()->getGroup('cart.' . JBCart::CONFIG_NOTIFICATION);
     $elements = $cartConf->get($eventData['name'], array());
     $this->_execElements($event, $elements, $order, $params);
     // status events
     if (isset($eventData['status']) && $eventData['status']) {
         $cartConf = JBModelConfig::model()->getGroup('cart.' . JBCart::CONFIG_STATUS_EVENTS);
         $elements = $cartConf->get($eventData['status'] . '__' . $params['newStatus'], array());
         $this->_execElements($event, $elements, $order, $params);
     }
 }
示例#9
0
 /**
  * Add extra layouts from modules and plugins
  *
  * @param  AppEvent $event The event object
  */
 public static function init($event)
 {
     $app = $event->getSubject();
     $extensions = $event->getReturnValue();
     // get modules
     foreach ($app->path->dirs('modules:') as $module) {
         if ($app->path->path("modules:{$module}/renderer")) {
             $name = ($xml = simplexml_load_file($app->path->path("modules:{$module}/{$module}.xml"))) && $xml->getName() == 'extension' ? (string) $xml->name : $module;
             $extensions[$name] = array('type' => 'modules', 'name' => $name, 'path' => $app->path->path("modules:{$module}"));
         }
     }
     // get plugins
     foreach ($app->path->dirs('plugins:') as $plugin_type) {
         foreach ($app->path->dirs('plugins:' . $plugin_type) as $plugin) {
             if ($app->path->path("plugins:{$plugin_type}/{$plugin}/renderer")) {
                 $resource = "plugins:{$plugin_type}/{$plugin}/{$plugin}.xml";
                 $name = ($xml = simplexml_load_file($app->path->path($resource))) && $xml->getName() == 'extension' ? (string) $xml->name : $plugin;
                 $name = rtrim($name, ' - ZOO');
                 $extensions[$name] = array('type' => 'plugin', 'name' => $name, 'path' => $app->path->path("plugins:{$plugin_type}/{$plugin}"));
             }
         }
     }
     $event->setReturnValue($extensions);
 }
示例#10
0
 public function create($aData)
 {
     $oConnection = Propel::getConnection(AppEventPeer::DATABASE_NAME);
     try {
         $oAppEvent = new AppEvent();
         $oAppEvent->fromArray($aData, BasePeer::TYPE_FIELDNAME);
         if ($oAppEvent->validate()) {
             $oConnection->begin();
             $iResult = $oAppEvent->save();
             $oConnection->commit();
             return true;
         } else {
             $sMessage = '';
             $aValidationFailures = $oAppEvent->getValidationFailures();
             foreach ($aValidationFailures as $oValidationFailure) {
                 $sMessage .= $oValidationFailure->getMessage() . '<br />';
             }
             throw new Exception('The registry cannot be created!<br />' . $sMessage);
         }
     } catch (Exception $oError) {
         $oConnection->rollback();
         throw $oError;
     }
 }
示例#11
0
 function createAppEvents($PRO_UID, $APP_UID, $DEL_INDEX, $TAS_UID)
 {
     $aRows = array();
     $aEventsRows = $this->getBy($PRO_UID, array('TAS_UID' => $TAS_UID));
     if ($aEventsRows !== false) {
         $aRows = array_merge($aRows, $aEventsRows);
     }
     $aEventsRows = $this->getBy($PRO_UID, array('EVN_TAS_UID_FROM' => $TAS_UID));
     if ($aEventsRows !== false) {
         $aRows = array_merge($aRows, $aEventsRows);
     }
     foreach ($aRows as $aData) {
         // if the events has a condition
         if (trim($aData['EVN_CONDITIONS']) != '') {
             G::LoadClass('case');
             $oCase = new Cases();
             $aFields = $oCase->loadCase($APP_UID);
             $Fields = $aFields['APP_DATA'];
             $conditionContents = trim($aData['EVN_CONDITIONS']);
             //$sContent    = G::unhtmlentities($sContent);
             $iAux = 0;
             $iOcurrences = preg_match_all('/\\@(?:([\\>])([a-zA-Z\\_]\\w*)|([a-zA-Z\\_][\\w\\-\\>\\:]*)\\(((?:[^\\\\\\)]*(?:[\\\\][\\w\\W])?)*)\\))((?:\\s*\\[[\'"]?\\w+[\'"]?\\])+)?/', $conditionContents, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
             if ($iOcurrences) {
                 for ($i = 0; $i < $iOcurrences; $i++) {
                     preg_match_all('/@>' . $aMatch[2][$i][0] . '([\\w\\W]*)' . '@<' . $aMatch[2][$i][0] . '/', $conditionContents, $aMatch2, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
                     $sGridName = $aMatch[2][$i][0];
                     $sStringToRepeat = $aMatch2[1][0][0];
                     if (isset($Fields[$sGridName])) {
                         if (is_array($Fields[$sGridName])) {
                             $sAux = '';
                             foreach ($Fields[$sGridName] as $aRow) {
                                 $sAux .= G::replaceDataField($sStringToRepeat, $aRow);
                             }
                         }
                     }
                     $conditionContents = str_replace('@>' . $sGridName . $sStringToRepeat . '@<' . $sGridName, $sAux, $conditionContents);
                 }
             }
             $sCondition = G::replaceDataField($conditionContents, $Fields);
             $evalConditionResult = false;
             $sCond = 'try{ $evalConditionResult=(' . $sCondition . ')? true: false; } catch(Exception $e){$evalConditionResult=false;}';
             @eval($sCond);
             if (!$evalConditionResult) {
                 continue;
             }
         }
         $appEventData['APP_UID'] = $APP_UID;
         $appEventData['DEL_INDEX'] = $DEL_INDEX;
         $appEventData['EVN_UID'] = $aData['EVN_UID'];
         $appEventData['APP_EVN_ACTION_DATE'] = $this->toCalculateTime($aData);
         $appEventData['APP_EVN_ATTEMPTS'] = 3;
         $appEventData['APP_EVN_LAST_EXECUTION_DATE'] = null;
         $appEventData['APP_EVN_STATUS'] = 'OPEN';
         $oAppEvent = new AppEvent();
         $oAppEvent->create($appEventData);
     }
 }
示例#12
0
 /**
  * Filters a value by calling all listeners of a given event.
  *
  * @param AppEvent $event A AppEvent instance
  * @param mixed $value The value to be filtered
  *
  * @return AppEvent The AppEvent instance
  * 
  * @since 1.0.0
  */
 public function filter(AppEvent $event, $value)
 {
     foreach ($this->getListeners($event->getName()) as $listener) {
         $value = call_user_func_array($listener, array($event, $value));
     }
     $event->setReturnValue($value);
     return $event;
 }
示例#13
0
文件: item.php 项目: Jougito/DynWeb
 /**
  * Placeholder for the beforeSaveCategoryRelations event
  *
  * @param  AppEvent $event The event triggered
  */
 public static function beforeSaveCategoryRelations($event)
 {
     // The item
     $item = $event->getSubject();
     // The list of category ids
     $categories = $event['categories'];
 }
示例#14
0
 /**
  * On after edit view display
  * @param AppEvent $event
  */
 public static function afterEdit($event)
 {
     $params = $event->getParameters();
     if (isset($params['html'][0])) {
         $element = $event->getSubject();
         $find = 'element-' . $element->getElementType();
         $params['html'][0] = JString::str_ireplace($find, $find . ' element-' . $element->identifier, $params['html'][0]);
     }
     $event->setReturnValue($params);
 }
示例#15
0
 /**
  * After render some item layout (experemental)
  * @param AppEvent $event
  */
 public static function afterRenderLayout($event)
 {
     $item = $event->getSubject();
     $params = $event->getParameters();
     $app = self::app();
     if ($params['layout'] == 'full') {
         $app->jbviewed->add($item);
     }
 }
示例#16
0
 /**
  * Placeholder for the editDisplay event
  *
  * @param  AppEvent $event The event triggered
  */
 public static function editDisplay($event)
 {
     $type = $event->getSubject();
     $html = $event['html'];
 }
示例#17
0
 /**
  * Placeholder for the afterEdit event
  *
  * @param  AppEvent $event The event triggered
  */
 public static function afterEdit($event)
 {
     $element = $event->getSubject();
     // set $event['html'] after modifying the html
     $html = $event['html'];
     $event['html'] = $html;
 }
示例#18
0
 /**
  * InitApp event handler - hack for custom JBZoo controllers
  * @param AppEvent $event
  */
 public static function initApp($event)
 {
     $zoo = App::getInstance('zoo');
     $params = $event->getParameters();
     $curApp = $params['application'];
     $currentCtrl = strtolower($zoo->request->getCmd('controller'));
     $jbzooCtrls = array('autocomplete', 'basket', 'compare', 'favorite', 'payment', 'search', 'viewed');
     if (empty($curApp) || $curApp->getGroup() != JBZOO_APP_GROUP && in_array($currentCtrl, $jbzooCtrls)) {
         $jbzooApp = $zoo->table->application->first(array('conditions' => array('application_group="' . JBZOO_APP_GROUP . '"')));
         if ($jbzooApp) {
             $params['application'] = $jbzooApp;
             $event->setReturnValue($params);
         }
     }
 }
示例#19
0
     $oCriteria = new Criteria('dbarray');
     $oCriteria->setDBArrayTable('virtualtable');
     $G_PUBLISH = new Publisher();
     $G_PUBLISH->AddContent('propeltable', 'paged-table', 'events/dynavarsList', $oCriteria);
     G::RenderPage('publish', 'raw');
     break;
 case 'eventList':
     $start = isset($_REQUEST['start']) ? $_REQUEST['start'] : '0';
     $limit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : '25';
     $proUid = isset($_REQUEST['process']) ? $_REQUEST['process'] : '';
     $evenType = isset($_REQUEST['type']) ? $_REQUEST['type'] : '';
     $evenStatus = isset($_REQUEST['status']) ? $_REQUEST['status'] : '';
     $sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : '';
     $dir = isset($_REQUEST['dir']) ? $_REQUEST['dir'] : 'ASC';
     require_once 'classes/model/AppEvent.php';
     $oAppEvent = new AppEvent();
     // Initialize response object
     $response = new stdclass();
     $response->status = 'OK';
     $criteria = new Criteria();
     $criteria = $oAppEvent->getAppEventsCriteria($proUid, $evenStatus, $evenType);
     $result = AppEventPeer::doSelectRS($criteria);
     $result->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $data = array();
     while ($result->next()) {
         $data[] = $result->getRow();
     }
     $totalCount = count($data);
     $criteria = new Criteria();
     $criteria = $oAppEvent->getAppEventsCriteria($proUid, $evenStatus, $evenType);
     if ($sort != '') {
示例#20
0
 * ProcessMaker Open Source Edition
 * Copyright (C) 2004 - 2008 Colosa Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
 * Coral Gables, FL, 33134, USA, or email info@colosa.com.
 */
global $RBAC;
if ($RBAC->userCanAccess('PM_SETUP') != 1) {
    G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
    G::header('location: ../login/login');
    die;
}
require_once 'classes/model/AppEvent.php';
$oAppEvent = new AppEvent();
global $G_PUBLISH;
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent('propeltable', 'paged-table', 'events/appEventsList', $oAppEvent->getAppEventsCriteria($_GET['PRO_UID'], 'PENDING', $_GET['EVN_TYPE']));
G::RenderPage('publish', 'raw');
示例#21
0
文件: order.php 项目: camigreen/ttop
 /**
  * Placeholder for the deleted event
  *
  * @param  AppEvent $event The event triggered
  */
 public static function paymentFailed($event)
 {
     $order = $event->getSubject();
     $response = $event['response'];
     $app = $order->app;
     $app->log->createLogger('email', array('*****@*****.**'));
     foreach ($response as $key => $value) {
         if ($key == 'response') {
             continue;
         }
         $value = is_bool($value) ? $value ? 'True' : 'False' : $value;
         $data[] = $key . ': ' . $value;
     }
     foreach ($order->elements->get('items.', array()) as $key => $value) {
         $data[] = $value->name . "\n";
     }
     $message = implode("\n", $data);
     $app->log->notice($message, 'Process Payment Failed');
 }
示例#22
0
 * Copyright (C) 2004 - 2008 Colosa Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
 * Coral Gables, FL, 33134, USA, or email info@colosa.com.
 *
 */
global $RBAC;
if ($RBAC->userCanAccess('PM_SETUP') != 1) {
    G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
    G::header('location: ../login/login');
    die;
}
require_once 'classes/model/AppEvent.php';
$oAppEvent = new AppEvent();
global $G_PUBLISH;
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent('propeltable', 'paged-table', 'events/appEventsListCompleted', $oAppEvent->getAppEventsCriteria($_GET['PRO_UID'], 'COMPLETED', $_GET['EVN_TYPE']));
G::RenderPage('publish', 'raw');
示例#23
0
 /**
  * joomlaMenuItems
  * 
  * @param AppEvent $event The event triggered
  */
 public function joomlaMenuItems($event)
 {
     // set views
     $views = array();
     $views[] = array('name' => 'cart', 'title' => 'ZOOcart Cart', 'path' => 'zoocart:views/site/cart/params.json');
     $views[] = array('name' => 'orders', 'title' => 'ZOOcart Orders', 'path' => 'zoocart:views/site/orders/params.json');
     $views[] = array('name' => 'addresses', 'title' => 'ZOOcart Addresses', 'path' => 'zoocart:views/site/addresses/params.json');
     $views[] = array('name' => 'subscriptions', 'title' => 'ZOOcart Subscriptions', 'path' => 'zoocart:views/site/subscriptions/params.json');
     // add to list
     $list = (array) $event->getReturnValue();
     $list[] = array('name' => 'zoocart', 'views' => $views);
     // save
     $event->setReturnValue($list);
 }
示例#24
0
 /**
  * Placeholder for the deleted event
  *
  * @param  AppEvent $event The event triggered
  */
 public static function deleted($event)
 {
     $submission = $event->getSubject();
 }
示例#25
0
 /**
  * After adminmenu items added
  * @param AppEvent $event
  */
 public static function addMenuItems($event)
 {
     $app = self::app();
     $params = $event->getParameters();
     $controller = $app->jbrequest->getCtrl();
     if (strpos($controller, 'jb') === 0) {
         $params['tab']->setAttribute('data-href-replace', 'controller=' . $controller);
     }
     $event->setReturnValue($params);
 }
示例#26
0
function executeEvents($sLastExecution, $sNow = null)
{
    global $sFilter;
    global $sNow;
    $log = array();
    if ($sFilter != '' && strpos($sFilter, 'events') === false) {
        return false;
    }
    setExecutionMessage("Executing events");
    setExecutionResultMessage('PROCESSING');
    try {
        $oAppEvent = new AppEvent();
        saveLog('executeEvents', 'action', "Executing Events {$sLastExecution}, {$sNow} ");
        $n = $oAppEvent->executeEvents($sNow, false, $log, 1);
        foreach ($log as $value) {
            $arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron")));
            $arrayCron["processcTimeStart"] = time();
            @file_put_contents(PATH_DATA . "cron", serialize($arrayCron));
            saveLog('executeEvents', 'action', "Execute Events : {$value}, {$sNow} ");
        }
        setExecutionMessage("|- End Execution events");
        setExecutionResultMessage("Processed {$n}");
        //saveLog('executeEvents', 'action', $res );
    } catch (Exception $oError) {
        setExecutionResultMessage('WITH ERRORS', 'error');
        eprintln("  '-" . $oError->getMessage(), 'red');
        saveLog('calculateAlertsDueDate', 'Error', 'Error Executing Events: ' . $oError->getMessage());
    }
}
示例#27
0
 /**
  * Placeholder for the deleted event
  *
  * @param  AppEvent $event The event triggered
  */
 public static function deleted($event)
 {
     $account = $event->getSubject();
 }
示例#28
0
 /**
  * Triggers joomla content plugins on the comment
  *
  * @param  AppEvent $event The event triggered
  */
 public static function stateChanged($event)
 {
     $comment = $event->getSubject();
     JPluginHelper::importPlugin('content');
     JDispatcher::getInstance()->trigger('onContentChangeState', array($comment->app->component->self->name . '.comment', array($comment->id), $comment->state));
 }
示例#29
0
 /**
  * Placeholder for the deleted event
  *
  * @param  AppEvent $event The event triggered
  */
 public static function deleted($event)
 {
     $tags = (array) $event->getSubject();
     $application = $event['application'];
 }
示例#30
0
 /**
  * Parse current url (usually) and fix some urls bugs (from classical Zoo)
  * @param AppEvent $event
  */
 public function sefParseRoute($event)
 {
     $this->_jbdebug->mark('jbzoo-sef::sefParseRoute::start');
     $params = $event->getParameters();
     // parse category or item by priority order
     if ($this->_config->get('parse_priority', 'item') == 'category') {
         // try to find category
         if (empty($params['vars']) || isset($params['vars']['category_id']) && $params['vars']['category_id'] == 0) {
             $params = $this->_parseCategoryUrl($params);
         }
         // try to find item
         if (empty($params['vars']) || isset($params['vars']['item_id']) && $params['vars']['item_id'] == 0) {
             $params = $this->_parseItemUrl($params);
         }
     } else {
         // try to find item
         if (empty($params['vars']) || isset($params['vars']['item_id']) && $params['vars']['item_id'] == 0) {
             $params = $this->_parseItemUrl($params);
         }
         // try to find category
         if (empty($params['vars']) || isset($params['vars']['category_id']) && $params['vars']['category_id'] == 0) {
             $params = $this->_parseCategoryUrl($params);
         }
     }
     // feed
     if (empty($params['vars']) && $this->_config->get('fix_feed', 0)) {
         $params = $this->_parseFeedUrl($params);
     }
     // redirect to correct url
     if ($this->_config->get('redirect', 0)) {
         $this->_checkRedirect($params);
     }
     // set new params
     $event->setReturnValue($params);
     $this->_jbdebug->mark('jbzoo-sef::sefParseRoute::finish');
 }