for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
*
* 2FA extension for the phpBB Forum Software package.
* @copyright (c) 2015 Paul Sohier
* @license GNU General Public License, version 2 (GPL-2.0)
*/
namespace paul999\tfa\migrations;
use phpbb\db\migration\migration;
class set_role_data extends migration
{
static public function depends_on()
return array(
'\paul999\tfa\migrations\initial_permissions',
);
}
public function update_data()
$data = array();
if ($this->role_exists('ROLE_ADMIN_FULL'))
$data[] = array('permission.permission_set', array('ROLE_ADMIN_FULL', 'a_tfa'));
return $data;
* Checks whether the given role does exist or not.
* @param String $role the name of the role
* @return true if the role exists, false otherwise.
protected function role_exists($role)
$sql = 'SELECT role_id
FROM ' . ACL_ROLES_TABLE . "
WHERE role_name = '" . $this->db->sql_escape($role) . "'";
$result = $this->db->sql_query_limit($sql, 1);
$role_id = $this->db->sql_fetchfield('role_id');
$this->db->sql_freeresult($result);
return $role_id;