public function setAssetRules($element, $rules)
	{
		if ($this->baseDb->tableExists('#__assets'))
		{
			$asset = \Hubzero\Access\Asset::oneByName($element);
			if (!$asset || !$asset->get('id'))
			{
				return false;
			}

			// Loop through and map textual groups to ids (if applicable)
			foreach ($rules as $idx => $rule)
			{
				foreach ($rule as $group => $value)
				{
					if (!is_numeric($group))
					{
						$query = "SELECT `id` FROM `#__usergroups` WHERE `title` = " . $this->baseDb->quote($group);
						$this->baseDb->setQuery($query);
						if ($id = $this->baseDb->loadResult())
						{
							unset($rules[$idx][$group]);
							$rules[$idx][$id] = $value;
						}
					}
				}
			}

			$asset->set('rules', json_encode($rules));
			$asset->save();
		}
	}
public function setAssetRules($element, $rules)
	{
		if ($this->baseDb->tableExists('#__assets'))
		{
			$asset = \Hubzero\Access\Asset::oneByName($element);
			if (!$asset || !$asset->get('id'))
			{
				return false;
			}

			// Loop through and map textual groups to ids (if applicable)
			foreach ($rules as $idx => $rule)
			{
				foreach ($rule as $group => $value)
				{
					if (!is_numeric($group))
					{
						$query = "SELECT `id` FROM `#__usergroups` WHERE `title` = " . $this->baseDb->quote($group);
						$this->baseDb->setQuery($query);
						if ($id = $this->baseDb->loadResult())
						{
							unset($rules[$idx][$group]);
							$rules[$idx][$id] = $value;
						}
					}
				}
			}

			$asset->set('rules', json_encode($rules));
			$asset->save();
		}
	}
public function setAssetRules ( $ element , $ rules ) { if ( $ this -> baseDb -> tableExists ( '#__assets' ) ) { $ asset = \ Hubzero \ Access \ Asset :: oneByName ( $ element ) ; if ( ! $ asset || ! $ asset -> get ( 'id' ) ) { return false ; } // Loop through and map textual groups to ids (if applicable) foreach ( $ rules as $ idx => $ rule ) { foreach ( $ rule as $ group => $ value ) { if ( ! is_numeric ( $ group ) ) { $ query = "SELECT `id` FROM `#__usergroups` WHERE `title` = " . $ this -> baseDb -> quote ( $ group ) ; $ this -> baseDb -> setQuery ( $ query ) ; if ( $ id = $ this -> baseDb -> loadResult ( ) ) { unset ( $ rules [ $ idx ] [ $ group ] ) ; $ rules [ $ idx ] [ $ id ] = $ value ; } } } } $ asset -> set ( 'rules' , json_encode ( $ rules ) ) ; $ asset -> save ( ) ; } }
Sets the asset rules

@param   string  $element  The element to which the rules apply
@param   array   $rules    The incoming rules to set
@return  void
Sets the asset rules