/** {@inheritDoc} */ public function initialize() { /** @var mlmsystem $mlmsystem */ $this->MlmSystem = $this->modx->getService('mlmsystem'); $this->MlmSystem->initialize($this->getProperty('context', $this->modx->context->key)); return parent::initialize(); }
/** {@inheritDoc} */ public function afterRemove() { /* удаляем event */ if (!$this->modx->getCount($this->classKey, array('event' => $this->object->get('event')))) { $this->MlmSystem->setPluginEvent($this->object->get('event'), 'remove'); } return true; }
/** {@inheritDoc} */ public function initialize() { if (!$this->modx->hasPermission($this->permission)) { return $this->modx->lexicon('access_denied'); } /** @var mlmsystem $mlmsystem */ $this->MlmSystem = $this->modx->getService('mlmsystem'); $this->MlmSystem->initialize($this->getProperty('context', $this->modx->context->key)); return parent::initialize(); }
public function beforeSave() { /* проверка на кружева */ if ($this->parent != $this->getProperty('parent', $this->object->get('parent'))) { if (!$this->MlmSystem->Tools->checkClientParent($this->object, $this->getProperty('parent'))) { $this->addFieldError('parent', $this->MlmSystem->lexicon('err_parent')); } } return parent::beforeSave(); }
public function afterSave() { if ($client = $this->modx->getObject('MlmSystemClient', array('id' => $this->object->get('id')))) { $clientStatus = $this->getProperty('status', $client->getStatusCreate()); $this->MlmSystem->Tools->changeClientStatus($client, $clientStatus); $parent = $this->getProperty('parent', $this->MlmSystem->getOption('referrer_default_client', null, 0)); if (!empty($parent)) { $this->MlmSystem->Tools->changeClientParent($client, $parent); } } return parent::afterSave(); }
/** {@inheritDoc} */ public function afterSave() { /* удаляем старый event */ if ($this->object->get('event') != $this->event and !$this->modx->getCount($this->classKey, array('event' => $this->event))) { $this->MlmSystem->setPluginEvent($this->event, 'remove'); } if ($this->object->get('active')) { $this->MlmSystem->setPluginEvent($this->object->get('event'), 'create'); } elseif (!$this->modx->getCount($this->classKey, array('event' => $this->object->get('event'), 'active' => 1))) { $this->MlmSystem->setPluginEvent($this->object->get('event'), 'remove'); } return true; }
/** @inheritdoc} */ public function getProfitResourceGroups($id = 0) { $groups = array(); $key = $this->MlmSystem->namespace; $options = array('cache_key' => $key . '/profit/group/' . __CLASS__ . '/resource/' . $id, 'cacheTime' => 0); if ($resource = $this->modx->getObject('msProduct', array('id' => $id)) and !($groups = $this->MlmSystem->getCache($options))) { $ids = $this->modx->getParentIds($id, 10, array('context' => $resource->get('context_key'))); $ids[] = $id; $ids = array_unique($ids); $q = $this->modx->newQuery('msCategoryMember', array('product_id' => $id)); $q->select('category_id'); $tstart = microtime(true); if ($q->prepare() && $q->stmt->execute()) { $this->modx->queryTime += microtime(true) - $tstart; $this->modx->executedQueries++; if ($tmp = $q->stmt->fetchAll(PDO::FETCH_COLUMN)) { $ids = array_merge($ids, $tmp); } } $ids = array_unique($ids); $q = $this->modx->newQuery('modResourceGroupResource', array('document:IN' => $ids)); $q->leftJoin('MlmSystemProfitGroup', 'MlmSystemProfitGroup', 'MlmSystemProfitGroup.group = modResourceGroupResource.document_group'); $q->where(array('MlmSystemProfitGroup.class' => 'modResourceGroup')); $q->select('document_group,profit'); $q->sortby('profit'); $q->groupby('MlmSystemProfitGroup.group'); $tstart = microtime(true); if ($q->prepare() && $q->stmt->execute()) { $this->modx->queryTime += microtime(true) - $tstart; $this->modx->executedQueries++; while ($row = $q->stmt->fetch(PDO::FETCH_ASSOC)) { $groups[$row['document_group']] = $row['profit']; } } $this->MlmSystem->setCache($groups, $options); } return $groups; }
/** * @return void */ public function initialize() { $corePath = $this->modx->getOption('mlmsystem_core_path', null, $this->modx->getOption('core_path') . 'components/mlmsystem/'); require_once $corePath . 'model/mlmsystem/mlmsystem.class.php'; $this->MlmSystem = new MlmSystem($this->modx); $this->MlmSystem->initialize($this->modx->context->key); $this->addCss($this->MlmSystem->config['cssUrl'] . 'mgr/main.css'); $this->addCss($this->MlmSystem->config['cssUrl'] . 'mgr/bootstrap.buttons.css'); $this->addCss($this->MlmSystem->config['assetsUrl'] . 'vendor/fontawesome/css/font-awesome.min.css'); $this->addJavascript($this->MlmSystem->config['jsUrl'] . 'mgr/mlmsystem.js'); $config = $this->MlmSystem->config; $config['connector_url'] = $this->MlmSystem->config['connectorUrl']; $config['menu_actions'] = $this->MlmSystem->Tools->getMenuActions(); $config['client_status'] = $this->MlmSystem->Tools->getClientStatus(); $config['client_grid_fields'] = $this->MlmSystem->Tools->getClientFields(); $config['client_window_update_tabs'] = $this->MlmSystem->Tools->getClientWindowUpdateTabs(); $config['profit_grid_fields'] = $this->MlmSystem->Tools->getProfitFields(); $config['profit_window_update_tabs'] = $this->MlmSystem->Tools->getProfitWindowUpdateTabs(); $config['operation_grid_fields'] = $this->MlmSystem->Tools->getOperationFields(); $config['log_grid_fields'] = $this->MlmSystem->Tools->getLogFields(); $config['log_window_view_tabs'] = $this->MlmSystem->Tools->getLogWindowViewTabs(); $this->addHtml("<script type='text/javascript'>mlmsystem.config={$this->modx->toJSON($config)}</script>"); parent::initialize(); }
/** @inheritdoc} */ public function printLog($message = '', $show = false) { return $this->MlmSystem->printLog($message, $show); }
/** @inheritdoc} */ public function formatClassName($class) { return $this->MlmSystem->lexicon('class_' . $class); }
/** {@inheritDoc} */ public function afterSave() { $this->MlmSystem->setPluginEvent($this->object->get('event'), 'create'); return true; }