# css-javascript-toolbox/9.2/framework/extensions/package/blocks.php

CSS &amp; JavaScript Toolbox, version 9.2. 67 lines.

- Page: https://pluginprobe.com/plugins/css-javascript-toolbox/9.2/code/framework/extensions/package/blocks.php
- Raw: https://pluginprobe.com/plugins/css-javascript-toolbox/9.2/raw/framework/extensions/package/blocks.php
- Modified: 2019-07-27T16:09:00+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/css-javascript-toolbox/9.2/code/framework/extensions/package/blocks.php#L10-L20`.

```php
<?php
/**
* 
*/

/**
* 
*/
class CJT_Framework_Extensions_Package_Blocks {
	
	/**
	* 
	*/
	const ACTIVE = 'active';

	/**
	* 
	*/
	const INACTIVE = 'inactive';
	
	/**
	* put your comment there...
	* 
	* @var mixed
	*/
	protected $statePackage;
	
	/**
	* put your comment there...
	* 
	* @param CJT_Framework_Extensions_Package_State_Packages $statePackages
	* @return {CJT_Framework_Extensions_Package_Blocks|CJT_Framework_Extensions_Package_State_Packages}
	*/
	public function __construct(CJT_Framework_Extensions_Package_State_Packages & $statePackages) {
		# INitialize
		$this->statePackage =& $statePackages;
	}
	
	/**
	* put your comment there...
	* 
	* @param mixed $state
	*/
	public function setState($state) {
		# Initialize
		$dbDriver = cssJSToolbox::getInstance()->getDBDriver();
		$statePackages =& $this->statePackage;
		# Build packages Id SQL  IN-OPERATO list
		$pcksSQLIdList = array();
		foreach ($statePackages->getInstalledPackages() as $name => $pck) {
			# Push Id.
			$pcksSQLIdList[] = $pck['id'];
		}
		$pcksSQLIdList = implode(',', $pcksSQLIdList);
		# Build query
		$query = "UPDATE
								(#__cjtoolbox_packages p RIGHT JOIN #__cjtoolbox_package_objects po ON p.id = po.packageId
								LEFT JOIN #__cjtoolbox_blocks b ON po.objectId = b.id)
								SET state = '{$state}'
								WHERE p.id IN ({$pcksSQLIdList}) AND po.objectType = 'block';";
		# Update state for all blocks associated with all installed packages
		$dbDriver->exec($query);
		# Chain
		return $this;
	}

} # End class
```
