public static function getModules() { if (!($modules =& self::$modules)) { $default = array('ACTIVE' => !ModuleManager::isModuleInstalled('sale')); foreach (array(AttributeManager::getTypesInternal(), CounterManager::getTypesInternal(), RateManager::getTypesInternal()) as $types) { foreach ($types as $type) { $modules[$type['MODULE']] = $default; } } if ($modules['sale']) { $modules['sale']['ACTIVE'] = true; } $modules = unserialize(Option::get('conversion', 'MODULES', 'a:0:{}')) + $modules; // TODO all modules with attributes must be active $modules['conversion'] = $modules['abtest'] = $modules['sender'] = $modules['seo'] = array('ACTIVE' => true); ksort($modules); } return $modules; }
} // SITES $sites = array(); $result = SiteTable::getList(array('select' => array('LID', 'NAME'), 'order' => array('DEF' => 'DESC', 'SORT' => 'ASC'))); while ($row = $result->fetch()) { $sites[$row['LID']] = $row['NAME']; } if (!$sites) { die('No sites available!'); } $site = $_GET['site'] ?: $userOptions['site']; if (!($siteName = $sites[$site])) { list($site, $siteName) = each($sites); } // ATTRIBUTES if (!($attributeTypes = AttributeManager::getTypes())) { die('No attributes!'); } unset($attributeTypes['conversion_site']); $attributeName = $_GET['split']; // different split in $userOptions from summary page! if (!($attributeType = $attributeTypes[$attributeName])) { list($attributeName, $attributeType) = each($attributeTypes); } $attributeGroupTypes = AttributeGroupManager::getTypes(); // FILTER $filter = array('from' => $from->toString(), 'to' => $to->toString(), 'site' => $site); CUserOptions::SetOption('conversion', 'filter', array_merge($userOptions, $filter)); $filter['rate'] = $rateName; $filter['split'] = $attributeName; $filter['lang'] = LANGUAGE_ID;
/** Save context & attributes to database */ protected function save() { if (($id =& $this->id) !== null) { throw new SystemException('Cannot save existent context!'); } $id = self::EMPTY_CONTEXT_ID; if ($attributes = $this->attributes) { // leave only one attribute in group static $groupedTypes; if (!$groupedTypes) { $groupedTypes = AttributeManager::getGroupedTypes(); unset($groupedTypes[null]); } foreach ($groupedTypes as $types) { $intersection = array_intersect_key($types, $attributes); if (count($intersection) > 1) { array_shift($intersection); foreach ($intersection as $name => $type) { unset($attributes[$name]); } } } // save to database $snapshot = self::getSnapshot($attributes); $query = array('limit' => 1, 'select' => array('ID'), 'filter' => array('=SNAPSHOT' => $snapshot)); if ($row = ContextTable::getList($query)->fetch()) { $id = (int) $row['ID']; } elseif (Option::get('conversion', 'CONTEXT_TABLE') != 'locked') { try { $result = ContextTable::add(array('SNAPSHOT' => $snapshot)); if ($result->isSuccess()) { $id = $result->getId(); foreach ($attributes as $name => $value) { // TODO resetContext if not success and return null!!! $result = ContextAttributeTable::add(array('CONTEXT_ID' => $id, 'NAME' => $name, 'VALUE' => (string) $value)); } } else { throw new DB\SqlQueryException(); } } catch (DB\SqlQueryException $e) { if ($row = ContextTable::getList($query)->fetch()) { $id = (int) $row['ID']; } } } } }
$userOptions = CUserOptions::GetOption('conversion', 'filter', array()); // PERIOD $from = ($d = $_GET['from'] ?: $userOptions['from']) && Date::isCorrect($d) ? new Date($d) : Date::createFromPhp(new DateTime('first day of last month')); $to = ($d = $_GET['to'] ?: $userOptions['to']) && Date::isCorrect($d) ? new Date($d) : Date::createFromPhp(new DateTime('last day of this month')); // SITES $sites = array(); $result = SiteTable::getList(array('select' => array('LID', 'NAME'), 'order' => array('DEF' => 'DESC', 'SORT' => 'ASC'))); while ($row = $result->fetch()) { $sites[$row['LID']] = $row['NAME']; } $site = $_GET['site'] ?: $userOptions['site']; if (!($siteName = $sites[$site])) { list($site, $siteName) = each($sites); } // SPLITS $groupedAttributeTypes = \Bitrix\Conversion\AttributeManager::getGroupedTypes(); // $splitGroups unset($groupedAttributeTypes[null]); $attributeGroupName = $_GET['split'] ?: $userOptions['split']; // $splitGroupKey if (!($attributeTypes = $groupedAttributeTypes[$attributeGroupName])) { list($attributeGroupName, $attributeTypes) = each($groupedAttributeTypes); } $attributeGroupTypes = \Bitrix\Conversion\AttributeGroupManager::getTypes(); $splits = array(); foreach ($attributeTypes as $name => $type) { $splits[$name] = array('NAME' => $name, 'TITLE' => $type['NAME'] ?: $name, 'SPLIT_BY' => $type['SPLIT_BY'], 'BG_COLOR' => $type['BG_COLOR'] ?: '#4b9ec1'); } $splits += array('other' => array('TITLE' => Loc::getMessage('CONVERSION_SPLIT_OTHER'), 'BG_COLOR' => '#96c023'), 'total' => array('TITLE' => Loc::getMessage('CONVERSION_SPLIT_TOTAL'), 'BG_COLOR' => '#33ade1')); // RATES if ($rateTypes = RateManager::getTypes(array('ACTIVE' => true))) {