|
@@ 135-194 (lines=60) @@
|
| 132 |
|
* |
| 133 |
|
* @return array |
| 134 |
|
*/ |
| 135 |
|
public function loadRole($roleId, $status = Role::STATUS_DEFINED) |
| 136 |
|
{ |
| 137 |
|
$query = $this->handler->createSelectQuery(); |
| 138 |
|
if ($status === Role::STATUS_DEFINED) { |
| 139 |
|
$draftCondition = $query->expr->eq( |
| 140 |
|
$this->handler->quoteColumn('version', 'ezrole'), |
| 141 |
|
$query->bindValue($status, null, \PDO::PARAM_INT) |
| 142 |
|
); |
| 143 |
|
} else { |
| 144 |
|
$draftCondition = $query->expr->neq( |
| 145 |
|
$this->handler->quoteColumn('version', 'ezrole'), |
| 146 |
|
$query->bindValue(Role::STATUS_DEFINED, null, \PDO::PARAM_INT) |
| 147 |
|
); |
| 148 |
|
} |
| 149 |
|
|
| 150 |
|
$query->select( |
| 151 |
|
$this->handler->aliasedColumn($query, 'id', 'ezrole'), |
| 152 |
|
$this->handler->aliasedColumn($query, 'name', 'ezrole'), |
| 153 |
|
$this->handler->aliasedColumn($query, 'version', 'ezrole'), |
| 154 |
|
$this->handler->aliasedColumn($query, 'id', 'ezpolicy'), |
| 155 |
|
$this->handler->aliasedColumn($query, 'function_name', 'ezpolicy'), |
| 156 |
|
$this->handler->aliasedColumn($query, 'module_name', 'ezpolicy'), |
| 157 |
|
$this->handler->aliasedColumn($query, 'original_id', 'ezpolicy'), |
| 158 |
|
$this->handler->aliasedColumn($query, 'identifier', 'ezpolicy_limitation'), |
| 159 |
|
$this->handler->aliasedColumn($query, 'value', 'ezpolicy_limitation_value') |
| 160 |
|
)->from( |
| 161 |
|
$this->handler->quoteTable('ezrole') |
| 162 |
|
)->leftJoin( |
| 163 |
|
$this->handler->quoteTable('ezpolicy'), |
| 164 |
|
$query->expr->eq( |
| 165 |
|
$this->handler->quoteColumn('role_id', 'ezpolicy'), |
| 166 |
|
$this->handler->quoteColumn('id', 'ezrole') |
| 167 |
|
) |
| 168 |
|
)->leftJoin( |
| 169 |
|
$this->handler->quoteTable('ezpolicy_limitation'), |
| 170 |
|
$query->expr->eq( |
| 171 |
|
$this->handler->quoteColumn('policy_id', 'ezpolicy_limitation'), |
| 172 |
|
$this->handler->quoteColumn('id', 'ezpolicy') |
| 173 |
|
) |
| 174 |
|
)->leftJoin( |
| 175 |
|
$this->handler->quoteTable('ezpolicy_limitation_value'), |
| 176 |
|
$query->expr->eq( |
| 177 |
|
$this->handler->quoteColumn('limitation_id', 'ezpolicy_limitation_value'), |
| 178 |
|
$this->handler->quoteColumn('id', 'ezpolicy_limitation') |
| 179 |
|
) |
| 180 |
|
)->where( |
| 181 |
|
$query->expr->lAnd( |
| 182 |
|
$query->expr->eq( |
| 183 |
|
$this->handler->quoteColumn('id', 'ezrole'), |
| 184 |
|
$query->bindValue($roleId, null, \PDO::PARAM_INT) |
| 185 |
|
), |
| 186 |
|
$draftCondition |
| 187 |
|
) |
| 188 |
|
); |
| 189 |
|
|
| 190 |
|
$statement = $query->prepare(); |
| 191 |
|
$statement->execute(); |
| 192 |
|
|
| 193 |
|
return $statement->fetchAll(\PDO::FETCH_ASSOC); |
| 194 |
|
} |
| 195 |
|
|
| 196 |
|
/** |
| 197 |
|
* Loads a specified role by $identifier. |
|
@@ 204-263 (lines=60) @@
|
| 201 |
|
* |
| 202 |
|
* @return array |
| 203 |
|
*/ |
| 204 |
|
public function loadRoleByIdentifier($identifier, $status = Role::STATUS_DEFINED) |
| 205 |
|
{ |
| 206 |
|
$query = $this->handler->createSelectQuery(); |
| 207 |
|
if ($status === Role::STATUS_DEFINED) { |
| 208 |
|
$roleVersionCondition = $query->expr->eq( |
| 209 |
|
$this->handler->quoteColumn('version', 'ezrole'), |
| 210 |
|
$query->bindValue($status, null, \PDO::PARAM_INT) |
| 211 |
|
); |
| 212 |
|
} else { |
| 213 |
|
$roleVersionCondition = $query->expr->neq( |
| 214 |
|
$this->handler->quoteColumn('version', 'ezrole'), |
| 215 |
|
$query->bindValue($status, null, \PDO::PARAM_INT) |
| 216 |
|
); |
| 217 |
|
} |
| 218 |
|
|
| 219 |
|
$query->select( |
| 220 |
|
$this->handler->aliasedColumn($query, 'id', 'ezrole'), |
| 221 |
|
$this->handler->aliasedColumn($query, 'name', 'ezrole'), |
| 222 |
|
$this->handler->aliasedColumn($query, 'version', 'ezrole'), |
| 223 |
|
$this->handler->aliasedColumn($query, 'id', 'ezpolicy'), |
| 224 |
|
$this->handler->aliasedColumn($query, 'function_name', 'ezpolicy'), |
| 225 |
|
$this->handler->aliasedColumn($query, 'module_name', 'ezpolicy'), |
| 226 |
|
$this->handler->aliasedColumn($query, 'original_id', 'ezpolicy'), |
| 227 |
|
$this->handler->aliasedColumn($query, 'identifier', 'ezpolicy_limitation'), |
| 228 |
|
$this->handler->aliasedColumn($query, 'value', 'ezpolicy_limitation_value') |
| 229 |
|
)->from( |
| 230 |
|
$this->handler->quoteTable('ezrole') |
| 231 |
|
)->leftJoin( |
| 232 |
|
$this->handler->quoteTable('ezpolicy'), |
| 233 |
|
$query->expr->eq( |
| 234 |
|
$this->handler->quoteColumn('role_id', 'ezpolicy'), |
| 235 |
|
$this->handler->quoteColumn('id', 'ezrole') |
| 236 |
|
) |
| 237 |
|
)->leftJoin( |
| 238 |
|
$this->handler->quoteTable('ezpolicy_limitation'), |
| 239 |
|
$query->expr->eq( |
| 240 |
|
$this->handler->quoteColumn('policy_id', 'ezpolicy_limitation'), |
| 241 |
|
$this->handler->quoteColumn('id', 'ezpolicy') |
| 242 |
|
) |
| 243 |
|
)->leftJoin( |
| 244 |
|
$this->handler->quoteTable('ezpolicy_limitation_value'), |
| 245 |
|
$query->expr->eq( |
| 246 |
|
$this->handler->quoteColumn('limitation_id', 'ezpolicy_limitation_value'), |
| 247 |
|
$this->handler->quoteColumn('id', 'ezpolicy_limitation') |
| 248 |
|
) |
| 249 |
|
)->where( |
| 250 |
|
$query->expr->lAnd( |
| 251 |
|
$query->expr->eq( |
| 252 |
|
$this->handler->quoteColumn('name', 'ezrole'), |
| 253 |
|
$query->bindValue($identifier, null, \PDO::PARAM_STR) |
| 254 |
|
), |
| 255 |
|
$roleVersionCondition |
| 256 |
|
) |
| 257 |
|
); |
| 258 |
|
|
| 259 |
|
$statement = $query->prepare(); |
| 260 |
|
$statement->execute(); |
| 261 |
|
|
| 262 |
|
return $statement->fetchAll(\PDO::FETCH_ASSOC); |
| 263 |
|
} |
| 264 |
|
|
| 265 |
|
/** |
| 266 |
|
* Loads a role draft by the original role ID. |