/** @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('modResource', 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('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 array Menu Actions fields */ public function getMenuActions() { $key = $this->MlmSystem->namespace; $options = array('cache_key' => $key . '/menu_actions', 'cacheTime' => 0); if (!($actions = $this->MlmSystem->getCache($options))) { $q = $this->modx->newQuery('modMenu', array('parent' => $key)); $q->select('text,action'); if ($q->prepare() && $q->stmt->execute()) { $arr = $q->stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($arr as $i) { $i['text'] = str_replace($key . '_', '', $i['text']); $actions[$i['text']] = $i['action']; } } $this->MlmSystem->setCache($actions, $options); } return (array) $actions; }