| @@ 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). |
|
| @@ 459-477 (lines=19) @@ | ||
| 456 | * @param mixed $contentId |
|
| 457 | * @param mixed $roleId |
|
| 458 | */ |
|
| 459 | public function removeRole($contentId, $roleId) |
|
| 460 | { |
|
| 461 | $query = $this->handler->createDeleteQuery(); |
|
| 462 | $query |
|
| 463 | ->deleteFrom($this->handler->quoteTable('ezuser_role')) |
|
| 464 | ->where( |
|
| 465 | $query->expr->lAnd( |
|
| 466 | $query->expr->eq( |
|
| 467 | $this->handler->quoteColumn('contentobject_id'), |
|
| 468 | $query->bindValue($contentId, null, \PDO::PARAM_INT) |
|
| 469 | ), |
|
| 470 | $query->expr->eq( |
|
| 471 | $this->handler->quoteColumn('role_id'), |
|
| 472 | $query->bindValue($roleId, null, \PDO::PARAM_INT) |
|
| 473 | ) |
|
| 474 | ) |
|
| 475 | ); |
|
| 476 | $query->prepare()->execute(); |
|
| 477 | } |
|
| 478 | ||
| 479 | /** |
|
| 480 | * Remove role from user or user group, by assignment ID. |
|
| @@ 1187-1205 (lines=19) @@ | ||
| 1184 | * |
|
| 1185 | * @return int[] |
|
| 1186 | */ |
|
| 1187 | public function listVersionNumbers($contentId) |
|
| 1188 | { |
|
| 1189 | $query = $this->dbHandler->createSelectQuery(); |
|
| 1190 | $query->selectDistinct( |
|
| 1191 | $this->dbHandler->quoteColumn('version') |
|
| 1192 | )->from( |
|
| 1193 | $this->dbHandler->quoteTable('ezcontentobject_version') |
|
| 1194 | )->where( |
|
| 1195 | $query->expr->eq( |
|
| 1196 | $this->dbHandler->quoteColumn('contentobject_id'), |
|
| 1197 | $query->bindValue($contentId, null, \PDO::PARAM_INT) |
|
| 1198 | ) |
|
| 1199 | ); |
|
| 1200 | ||
| 1201 | $statement = $query->prepare(); |
|
| 1202 | $statement->execute(); |
|
| 1203 | ||
| 1204 | return $statement->fetchAll(\PDO::FETCH_COLUMN); |
|
| 1205 | } |
|
| 1206 | ||
| 1207 | /** |
|
| 1208 | * Returns last version number for content identified by $contentId. |
|
| @@ 1241-1259 (lines=19) @@ | ||
| 1238 | * |
|
| 1239 | * @return int[] |
|
| 1240 | */ |
|
| 1241 | public function getAllLocationIds($contentId) |
|
| 1242 | { |
|
| 1243 | $query = $this->dbHandler->createSelectQuery(); |
|
| 1244 | $query->select( |
|
| 1245 | $this->dbHandler->quoteColumn('node_id') |
|
| 1246 | )->from( |
|
| 1247 | $this->dbHandler->quoteTable('ezcontentobject_tree') |
|
| 1248 | )->where( |
|
| 1249 | $query->expr->eq( |
|
| 1250 | $this->dbHandler->quoteColumn('contentobject_id'), |
|
| 1251 | $query->bindValue($contentId, null, \PDO::PARAM_INT) |
|
| 1252 | ) |
|
| 1253 | ); |
|
| 1254 | ||
| 1255 | $statement = $query->prepare(); |
|
| 1256 | $statement->execute(); |
|
| 1257 | ||
| 1258 | return $statement->fetchAll(\PDO::FETCH_COLUMN); |
|
| 1259 | } |
|
| 1260 | ||
| 1261 | /** |
|
| 1262 | * Returns all field IDs of $contentId grouped by their type. |
|
| @@ 2036-2053 (lines=18) @@ | ||
| 2033 | * |
|
| 2034 | * @return int[] |
|
| 2035 | */ |
|
| 2036 | public function getContentIdsByContentTypeId($contentTypeId) |
|
| 2037 | { |
|
| 2038 | $query = $this->dbHandler->createSelectQuery(); |
|
| 2039 | $query |
|
| 2040 | ->select($this->dbHandler->quoteColumn('id')) |
|
| 2041 | ->from($this->dbHandler->quoteTable('ezcontentobject')) |
|
| 2042 | ->where( |
|
| 2043 | $query->expr->eq( |
|
| 2044 | $this->dbHandler->quoteColumn('contentclass_id'), |
|
| 2045 | $query->bindValue($contentTypeId, null, PDO::PARAM_INT) |
|
| 2046 | ) |
|
| 2047 | ); |
|
| 2048 | ||
| 2049 | $statement = $query->prepare(); |
|
| 2050 | $statement->execute(); |
|
| 2051 | ||
| 2052 | return $statement->fetchAll(PDO::FETCH_COLUMN); |
|
| 2053 | } |
|
| 2054 | ||
| 2055 | /** |
|
| 2056 | * Load name data for set of content id's and corresponding version number. |
|