<commit_before><?php

App::import('Libs', 'Sites.sites');

class MultisiteComponent extends Object {

	function _setLookupFields(&$controller) {
		$controller->set('sites', ClassRegistry::init('Sites.Site')->find('list'));
	}

	function _setupNodeRelationships(&$controller) {
/*
		$controller->Node->bindModel( array(
			'hasMany' => array(
				'Publisher' => array(
					'className' => 'Sites.SitesNode',
					'alias' => 'SitesNode',
					'foreignKey' => 'node_id',
					),
				),
			),
			false
		);
*/

		$controller->Node->bindModel( array(
			'hasAndBelongsToMany' => array(
				'Site' => array(
					'className' => 'Sites.Site',
					'joinTable' => 'sites_nodes',
					'foreignKey' => 'node_id',
					'associationForeignKey' => 'site_id',
					'unique' => true,
					),
				),
			),
			false
		);

	}

	function startup(&$controller) {
		$this->_setLookupFields($controller);
		$this->_setupNodeRelationships($controller);
	}

	function initialize(&$controller, $settings = array()) {
		if (1 == $controller->Auth->user('role_id')) {
			$controller->Node->Behaviors->detach('Sites.SiteFilter');
		}
		$site = Sites::currentSite();
	}

}<commit_msg>detach site_filter only when in /admin<commit_after><?php

App::import('Libs', 'Sites.sites');

class MultisiteComponent extends Object {

	function _setLookupFields(&$controller) {
		$controller->set('sites', ClassRegistry::init('Sites.Site')->find('list'));
	}

	function _setupNodeRelationships(&$controller) {
/*
		$controller->Node->bindModel( array(
			'hasMany' => array(
				'Publisher' => array(
					'className' => 'Sites.SitesNode',
					'alias' => 'SitesNode',
					'foreignKey' => 'node_id',
					),
				),
			),
			false
		);
*/

		$controller->Node->bindModel( array(
			'hasAndBelongsToMany' => array(
				'Site' => array(
					'className' => 'Sites.Site',
					'joinTable' => 'sites_nodes',
					'foreignKey' => 'node_id',
					'associationForeignKey' => 'site_id',
					'unique' => true,
					),
				),
			),
			false
		);

	}

	function startup(&$controller) {
		$this->_setLookupFields($controller);
		$this->_setupNodeRelationships($controller);
	}

	function initialize(&$controller, $settings = array()) {
		if (1 == $controller->Auth->user('role_id') && isset($controller->params['admin'])) {
			$controller->Node->Behaviors->detach('Sites.SiteFilter');
		}
		$site = Sites::currentSite();
	}

}
{'fraction_non_alphanumeric': 0.1971356360572873, 'fraction_numerical': 0.0008424599831508003, 'mean_word_length': 3.90702479338843, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 54, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6522780', 'n_tokens_mistral': 973, 'n_tokens_neox': 788, 'n_words': 120}