| @@ 632-654 (lines=23) @@ | ||
| 629 | * |
|
| 630 | * @return array |
|
| 631 | */ |
|
| 632 | public function updateRole(RoleUpdateStruct $role) |
|
| 633 | { |
|
| 634 | $query = $this->handler->createUpdateQuery(); |
|
| 635 | $query |
|
| 636 | ->update($this->handler->quoteTable('ezrole')) |
|
| 637 | ->set( |
|
| 638 | $this->handler->quoteColumn('name'), |
|
| 639 | $query->bindValue($role->identifier) |
|
| 640 | )->where( |
|
| 641 | $query->expr->eq( |
|
| 642 | $this->handler->quoteColumn('id'), |
|
| 643 | $query->bindValue($role->id, null, \PDO::PARAM_INT) |
|
| 644 | ) |
|
| 645 | ); |
|
| 646 | $statement = $query->prepare(); |
|
| 647 | $statement->execute(); |
|
| 648 | ||
| 649 | // Commented due to EZP-24698: Role update leads to NotFoundException |
|
| 650 | // Should be fixed with PDO::MYSQL_ATTR_FOUND_ROWS instead |
|
| 651 | /*if ($statement->rowCount() < 1) { |
|
| 652 | throw new NotFoundException('role', $role->id); |
|
| 653 | }*/ |
|
| 654 | } |
|
| 655 | ||
| 656 | /** |
|
| 657 | * Delete the specified role (draft). |
|
| @@ 309-325 (lines=17) @@ | ||
| 306 | * @param int $sectionId |
|
| 307 | * @param int $contentId |
|
| 308 | */ |
|
| 309 | public function assignSectionToContent($sectionId, $contentId) |
|
| 310 | { |
|
| 311 | $query = $this->dbHandler->createUpdateQuery(); |
|
| 312 | $query->update( |
|
| 313 | $this->dbHandler->quoteTable('ezcontentobject') |
|
| 314 | )->set( |
|
| 315 | $this->dbHandler->quoteColumn('section_id'), |
|
| 316 | $query->bindValue($sectionId, null, \PDO::PARAM_INT) |
|
| 317 | )->where( |
|
| 318 | $query->expr->eq( |
|
| 319 | $this->dbHandler->quoteColumn('id'), |
|
| 320 | $query->bindValue($contentId, null, \PDO::PARAM_INT) |
|
| 321 | ) |
|
| 322 | ); |
|
| 323 | ||
| 324 | $query->prepare()->execute(); |
|
| 325 | } |
|
| 326 | } |
|
| 327 | ||
| @@ 349-365 (lines=17) @@ | ||
| 346 | * @param int $oldStateId |
|
| 347 | * @param int $newStateId |
|
| 348 | */ |
|
| 349 | public function updateObjectStateLinks($oldStateId, $newStateId) |
|
| 350 | { |
|
| 351 | $query = $this->dbHandler->createUpdateQuery(); |
|
| 352 | $query->update( |
|
| 353 | $this->dbHandler->quoteTable('ezcobj_state_link') |
|
| 354 | )->set( |
|
| 355 | $this->dbHandler->quoteColumn('contentobject_state_id'), |
|
| 356 | $query->bindValue($newStateId, null, \PDO::PARAM_INT) |
|
| 357 | )->where( |
|
| 358 | $query->expr->eq( |
|
| 359 | $this->dbHandler->quoteColumn('contentobject_state_id'), |
|
| 360 | $query->bindValue($oldStateId, null, \PDO::PARAM_INT) |
|
| 361 | ) |
|
| 362 | ); |
|
| 363 | ||
| 364 | $query->prepare()->execute(); |
|
| 365 | } |
|
| 366 | ||
| 367 | /** |
|
| 368 | * Deletes object state links identified by $stateId. |
|
| @@ 642-658 (lines=17) @@ | ||
| 639 | * @param mixed $stateId |
|
| 640 | * @param int $priority |
|
| 641 | */ |
|
| 642 | public function updateObjectStatePriority($stateId, $priority) |
|
| 643 | { |
|
| 644 | $query = $this->dbHandler->createUpdateQuery(); |
|
| 645 | $query->update( |
|
| 646 | $this->dbHandler->quoteTable('ezcobj_state') |
|
| 647 | )->set( |
|
| 648 | $this->dbHandler->quoteColumn('priority'), |
|
| 649 | $query->bindValue($priority, null, \PDO::PARAM_INT) |
|
| 650 | )->where( |
|
| 651 | $query->expr->eq( |
|
| 652 | $this->dbHandler->quoteColumn('id'), |
|
| 653 | $query->bindValue($stateId, null, \PDO::PARAM_INT) |
|
| 654 | ) |
|
| 655 | ); |
|
| 656 | ||
| 657 | $query->prepare()->execute(); |
|
| 658 | } |
|
| 659 | ||
| 660 | /** |
|
| 661 | * Creates a generalized query for fetching object state(s). |
|
| @@ 329-347 (lines=19) @@ | ||
| 326 | * @param mixed $contentId |
|
| 327 | * @param mixed $roleId |
|
| 328 | */ |
|
| 329 | public function removeRole($contentId, $roleId) |
|
| 330 | { |
|
| 331 | $query = $this->handler->createDeleteQuery(); |
|
| 332 | $query |
|
| 333 | ->deleteFrom($this->handler->quoteTable('ezuser_role')) |
|
| 334 | ->where( |
|
| 335 | $query->expr->lAnd( |
|
| 336 | $query->expr->eq( |
|
| 337 | $this->handler->quoteColumn('contentobject_id'), |
|
| 338 | $query->bindValue($contentId, null, \PDO::PARAM_INT) |
|
| 339 | ), |
|
| 340 | $query->expr->eq( |
|
| 341 | $this->handler->quoteColumn('role_id'), |
|
| 342 | $query->bindValue($roleId, null, \PDO::PARAM_INT) |
|
| 343 | ) |
|
| 344 | ) |
|
| 345 | ); |
|
| 346 | $query->prepare()->execute(); |
|
| 347 | } |
|
| 348 | ||
| 349 | /** |
|
| 350 | * Remove role from user or user group, by assignment ID. |
|
| @@ 1312-1330 (lines=19) @@ | ||
| 1309 | * |
|
| 1310 | * @return int[] |
|
| 1311 | */ |
|
| 1312 | public function listVersionNumbers($contentId) |
|
| 1313 | { |
|
| 1314 | $query = $this->dbHandler->createSelectQuery(); |
|
| 1315 | $query->selectDistinct( |
|
| 1316 | $this->dbHandler->quoteColumn('version') |
|
| 1317 | )->from( |
|
| 1318 | $this->dbHandler->quoteTable('ezcontentobject_version') |
|
| 1319 | )->where( |
|
| 1320 | $query->expr->eq( |
|
| 1321 | $this->dbHandler->quoteColumn('contentobject_id'), |
|
| 1322 | $query->bindValue($contentId, null, \PDO::PARAM_INT) |
|
| 1323 | ) |
|
| 1324 | ); |
|
| 1325 | ||
| 1326 | $statement = $query->prepare(); |
|
| 1327 | $statement->execute(); |
|
| 1328 | ||
| 1329 | return $statement->fetchAll(\PDO::FETCH_COLUMN); |
|
| 1330 | } |
|
| 1331 | ||
| 1332 | /** |
|
| 1333 | * Returns last version number for content identified by $contentId. |
|
| @@ 1366-1384 (lines=19) @@ | ||
| 1363 | * |
|
| 1364 | * @return int[] |
|
| 1365 | */ |
|
| 1366 | public function getAllLocationIds($contentId) |
|
| 1367 | { |
|
| 1368 | $query = $this->dbHandler->createSelectQuery(); |
|
| 1369 | $query->select( |
|
| 1370 | $this->dbHandler->quoteColumn('node_id') |
|
| 1371 | )->from( |
|
| 1372 | $this->dbHandler->quoteTable('ezcontentobject_tree') |
|
| 1373 | )->where( |
|
| 1374 | $query->expr->eq( |
|
| 1375 | $this->dbHandler->quoteColumn('contentobject_id'), |
|
| 1376 | $query->bindValue($contentId, null, \PDO::PARAM_INT) |
|
| 1377 | ) |
|
| 1378 | ); |
|
| 1379 | ||
| 1380 | $statement = $query->prepare(); |
|
| 1381 | $statement->execute(); |
|
| 1382 | ||
| 1383 | return $statement->fetchAll(\PDO::FETCH_COLUMN); |
|
| 1384 | } |
|
| 1385 | ||
| 1386 | /** |
|
| 1387 | * Returns all field IDs of $contentId grouped by their type. |
|
| @@ 2119-2136 (lines=18) @@ | ||
| 2116 | * |
|
| 2117 | * @return int[] |
|
| 2118 | */ |
|
| 2119 | public function getContentIdsByContentTypeId($contentTypeId) |
|
| 2120 | { |
|
| 2121 | $query = $this->dbHandler->createSelectQuery(); |
|
| 2122 | $query |
|
| 2123 | ->select($this->dbHandler->quoteColumn('id')) |
|
| 2124 | ->from($this->dbHandler->quoteTable('ezcontentobject')) |
|
| 2125 | ->where( |
|
| 2126 | $query->expr->eq( |
|
| 2127 | $this->dbHandler->quoteColumn('contentclass_id'), |
|
| 2128 | $query->bindValue($contentTypeId, null, PDO::PARAM_INT) |
|
| 2129 | ) |
|
| 2130 | ); |
|
| 2131 | ||
| 2132 | $statement = $query->prepare(); |
|
| 2133 | $statement->execute(); |
|
| 2134 | ||
| 2135 | return $statement->fetchAll(PDO::FETCH_COLUMN); |
|
| 2136 | } |
|
| 2137 | ||
| 2138 | /** |
|
| 2139 | * Load name data for set of content id's and corresponding version number. |
|