phpBB

Code Changes

File: phpbb/db/migration/tool/permission.php

  Unmodified   Added   Modified   Removed
Line 238Line 238
		// Purge the auth cache
$this->cache->destroy('_acl_options');
$this->auth->acl_clear_prefetch();

		// Purge the auth cache
$this->cache->destroy('_acl_options');
$this->auth->acl_clear_prefetch();

 
	}

/**
* Check if a permission role exists
*
* @param string $role_name The role name
*
* @return int The id of the role if it exists, 0 otherwise
*/
public function role_exists($role_name)
{
$sql = 'SELECT role_id
FROM ' . ACL_ROLES_TABLE . "
WHERE role_name = '" . $this->db->sql_escape($role_name) . "'";
$result = $this->db->sql_query($sql);
$role_id = (int) $this->db->sql_fetchfield('role_id');
$this->db->sql_freeresult($result);

return $role_id;

	}

/**

	}

/**

Line 251Line 270
	*/
public function role_add($role_name, $role_type, $role_description = '')
{

	*/
public function role_add($role_name, $role_type, $role_description = '')
{

		$sql = 'SELECT role_id
FROM ' . ACL_ROLES_TABLE . "
WHERE role_name = '" . $this->db->sql_escape($role_name) . "'";
$this->db->sql_query($sql);
$role_id = (int) $this->db->sql_fetchfield('role_id');

if ($role_id)

		if ($this->role_exists($role_name))







		{
return;
}

		{
return;
}

Line 290Line 303
	*/
public function role_update($old_role_name, $new_role_name)
{

	*/
public function role_update($old_role_name, $new_role_name)
{

		$sql = 'SELECT role_id
FROM ' . ACL_ROLES_TABLE . "
WHERE role_name = '" . $this->db->sql_escape($old_role_name) . "'";
$this->db->sql_query($sql);
$role_id = (int) $this->db->sql_fetchfield('role_id');

if (!$role_id)

		if (!$this->role_exists($old_role_name))







		{
throw new \phpbb\db\migration\exception('ROLE_NOT_EXIST', $old_role_name);
}

		{
throw new \phpbb\db\migration\exception('ROLE_NOT_EXIST', $old_role_name);
}

Line 315Line 322
	*/
public function role_remove($role_name)
{

	*/
public function role_remove($role_name)
{

		$sql = 'SELECT role_id
FROM ' . ACL_ROLES_TABLE . "
WHERE role_name = '" . $this->db->sql_escape($role_name) . "'";
$this->db->sql_query($sql);
$role_id = (int) $this->db->sql_fetchfield('role_id');

if (!$role_id)

		if (!($role_id = $this->role_exists($role_name)))







		{
return;
}

		{
return;
}

Line 381Line 382
		switch ($type)
{
case 'role':

		switch ($type)
{
case 'role':

				$sql = 'SELECT role_id
FROM ' . ACL_ROLES_TABLE . "
WHERE role_name = '" . $this->db->sql_escape($name) . "'";
$this->db->sql_query($sql);
$role_id = (int) $this->db->sql_fetchfield('role_id');

if (!$role_id)

				if (!($role_id = $this->role_exists($name)))







				{
throw new \phpbb\db\migration\exception('ROLE_NOT_EXIST', $name);
}

				{
throw new \phpbb\db\migration\exception('ROLE_NOT_EXIST', $name);
}

Line 539Line 534
		switch ($type)
{
case 'role':

		switch ($type)
{
case 'role':

				$sql = 'SELECT role_id
FROM ' . ACL_ROLES_TABLE . "
WHERE role_name = '" . $this->db->sql_escape($name) . "'";
$this->db->sql_query($sql);
$role_id = (int) $this->db->sql_fetchfield('role_id');

if (!$role_id)

				if (!($role_id = $this->role_exists($name)))







				{
throw new \phpbb\db\migration\exception('ROLE_NOT_EXIST', $name);
}

				{
throw new \phpbb\db\migration\exception('ROLE_NOT_EXIST', $name);
}