| @@ 339-355 (lines=17) @@ | ||
| 336 | * @param int $oldStateId |
|
| 337 | * @param int $newStateId |
|
| 338 | */ |
|
| 339 | public function updateObjectStateLinks($oldStateId, $newStateId) |
|
| 340 | { |
|
| 341 | $query = $this->dbHandler->createUpdateQuery(); |
|
| 342 | $query->update( |
|
| 343 | $this->dbHandler->quoteTable('ezcobj_state_link') |
|
| 344 | )->set( |
|
| 345 | $this->dbHandler->quoteColumn('contentobject_state_id'), |
|
| 346 | $query->bindValue($newStateId, null, \PDO::PARAM_INT) |
|
| 347 | )->where( |
|
| 348 | $query->expr->eq( |
|
| 349 | $this->dbHandler->quoteColumn('contentobject_state_id'), |
|
| 350 | $query->bindValue($oldStateId, null, \PDO::PARAM_INT) |
|
| 351 | ) |
|
| 352 | ); |
|
| 353 | ||
| 354 | $query->prepare()->execute(); |
|
| 355 | } |
|
| 356 | ||
| 357 | /** |
|
| 358 | * Deletes object state links identified by $stateId. |
|
| @@ 624-640 (lines=17) @@ | ||
| 621 | * @param mixed $stateId |
|
| 622 | * @param int $priority |
|
| 623 | */ |
|
| 624 | public function updateObjectStatePriority($stateId, $priority) |
|
| 625 | { |
|
| 626 | $query = $this->dbHandler->createUpdateQuery(); |
|
| 627 | $query->update( |
|
| 628 | $this->dbHandler->quoteTable('ezcobj_state') |
|
| 629 | )->set( |
|
| 630 | $this->dbHandler->quoteColumn('priority'), |
|
| 631 | $query->bindValue($priority, null, \PDO::PARAM_INT) |
|
| 632 | )->where( |
|
| 633 | $query->expr->eq( |
|
| 634 | $this->dbHandler->quoteColumn('id'), |
|
| 635 | $query->bindValue($stateId, null, \PDO::PARAM_INT) |
|
| 636 | ) |
|
| 637 | ); |
|
| 638 | ||
| 639 | $query->prepare()->execute(); |
|
| 640 | } |
|
| 641 | ||
| 642 | /** |
|
| 643 | * Creates a generalized query for fetching object state(s). |
|
| @@ 308-324 (lines=17) @@ | ||
| 305 | * @param int $sectionId |
|
| 306 | * @param int $contentId |
|
| 307 | */ |
|
| 308 | public function assignSectionToContent($sectionId, $contentId) |
|
| 309 | { |
|
| 310 | $query = $this->dbHandler->createUpdateQuery(); |
|
| 311 | $query->update( |
|
| 312 | $this->dbHandler->quoteTable('ezcontentobject') |
|
| 313 | )->set( |
|
| 314 | $this->dbHandler->quoteColumn('section_id'), |
|
| 315 | $query->bindValue($sectionId, null, \PDO::PARAM_INT) |
|
| 316 | )->where( |
|
| 317 | $query->expr->eq( |
|
| 318 | $this->dbHandler->quoteColumn('id'), |
|
| 319 | $query->bindValue($contentId, null, \PDO::PARAM_INT) |
|
| 320 | ) |
|
| 321 | ); |
|
| 322 | ||
| 323 | $query->prepare()->execute(); |
|
| 324 | } |
|
| 325 | } |
|
| 326 | ||
| @@ 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). |
|
| @@ 835-852 (lines=18) @@ | ||
| 832 | * @param int $typeId |
|
| 833 | * @param int $typeStatus |
|
| 834 | */ |
|
| 835 | protected function deleteTypeNameData($typeId, $typeStatus) |
|
| 836 | { |
|
| 837 | $query = $this->dbHandler->createDeleteQuery(); |
|
| 838 | $query->deleteFrom('ezcontentclass_name') |
|
| 839 | ->where( |
|
| 840 | $query->expr->lAnd( |
|
| 841 | $query->expr->eq( |
|
| 842 | $this->dbHandler->quoteColumn('contentclass_id'), |
|
| 843 | $query->bindValue($typeId, null, \PDO::PARAM_INT) |
|
| 844 | ), |
|
| 845 | $query->expr->eq( |
|
| 846 | $this->dbHandler->quoteColumn('contentclass_version'), |
|
| 847 | $query->bindValue($typeStatus, null, \PDO::PARAM_INT) |
|
| 848 | ) |
|
| 849 | ) |
|
| 850 | ); |
|
| 851 | $query->prepare()->execute(); |
|
| 852 | } |
|
| 853 | ||
| 854 | /** |
|
| 855 | * Update a type with $updateStruct. |
|
| @@ 1087-1105 (lines=19) @@ | ||
| 1084 | * @param mixed $typeId |
|
| 1085 | * @param int $status |
|
| 1086 | */ |
|
| 1087 | public function deleteFieldDefinitionsForType($typeId, $status) |
|
| 1088 | { |
|
| 1089 | $q = $this->dbHandler->createDeleteQuery(); |
|
| 1090 | $q->deleteFrom( |
|
| 1091 | $this->dbHandler->quoteTable('ezcontentclass_attribute') |
|
| 1092 | )->where( |
|
| 1093 | $q->expr->lAnd( |
|
| 1094 | $q->expr->eq( |
|
| 1095 | $this->dbHandler->quoteColumn('contentclass_id'), |
|
| 1096 | $q->bindValue($typeId, null, \PDO::PARAM_INT) |
|
| 1097 | ), |
|
| 1098 | $q->expr->eq( |
|
| 1099 | $this->dbHandler->quoteColumn('version'), |
|
| 1100 | $q->bindValue($status, null, \PDO::PARAM_INT) |
|
| 1101 | ) |
|
| 1102 | ) |
|
| 1103 | ); |
|
| 1104 | $q->prepare()->execute(); |
|
| 1105 | } |
|
| 1106 | ||
| 1107 | /** |
|
| 1108 | * Deletes a Type completely. |
|
| @@ 1129-1147 (lines=19) @@ | ||
| 1126 | * @param mixed $typeId |
|
| 1127 | * @param int $status |
|
| 1128 | */ |
|
| 1129 | public function deleteType($typeId, $status) |
|
| 1130 | { |
|
| 1131 | $q = $this->dbHandler->createDeleteQuery(); |
|
| 1132 | $q->deleteFrom( |
|
| 1133 | $this->dbHandler->quoteTable('ezcontentclass') |
|
| 1134 | )->where( |
|
| 1135 | $q->expr->lAnd( |
|
| 1136 | $q->expr->eq( |
|
| 1137 | $this->dbHandler->quoteColumn('id'), |
|
| 1138 | $q->bindValue($typeId, null, \PDO::PARAM_INT) |
|
| 1139 | ), |
|
| 1140 | $q->expr->eq( |
|
| 1141 | $this->dbHandler->quoteColumn('version'), |
|
| 1142 | $q->bindValue($status, null, \PDO::PARAM_INT) |
|
| 1143 | ) |
|
| 1144 | ) |
|
| 1145 | ); |
|
| 1146 | $q->prepare()->execute(); |
|
| 1147 | } |
|
| 1148 | ||
| 1149 | /** |
|
| 1150 | * Deletes all group assignments for a Type. |
|
| @@ 1155-1173 (lines=19) @@ | ||
| 1152 | * @param mixed $typeId |
|
| 1153 | * @param int $status |
|
| 1154 | */ |
|
| 1155 | public function deleteGroupAssignmentsForType($typeId, $status) |
|
| 1156 | { |
|
| 1157 | $q = $this->dbHandler->createDeleteQuery(); |
|
| 1158 | $q->deleteFrom( |
|
| 1159 | $this->dbHandler->quoteTable('ezcontentclass_classgroup') |
|
| 1160 | )->where( |
|
| 1161 | $q->expr->lAnd( |
|
| 1162 | $q->expr->eq( |
|
| 1163 | $this->dbHandler->quoteColumn('contentclass_id'), |
|
| 1164 | $q->bindValue($typeId, null, \PDO::PARAM_INT) |
|
| 1165 | ), |
|
| 1166 | $q->expr->eq( |
|
| 1167 | $this->dbHandler->quoteColumn('contentclass_version'), |
|
| 1168 | $q->bindValue($status, null, \PDO::PARAM_INT) |
|
| 1169 | ) |
|
| 1170 | ) |
|
| 1171 | ); |
|
| 1172 | $q->prepare()->execute(); |
|
| 1173 | } |
|
| 1174 | ||
| 1175 | /** |
|
| 1176 | * Publishes the Type with $typeId from $sourceVersion to $targetVersion, |
|
| @@ 449-467 (lines=19) @@ | ||
| 446 | * @param mixed $contentId |
|
| 447 | * @param mixed $roleId |
|
| 448 | */ |
|
| 449 | public function removeRole($contentId, $roleId) |
|
| 450 | { |
|
| 451 | $query = $this->handler->createDeleteQuery(); |
|
| 452 | $query |
|
| 453 | ->deleteFrom($this->handler->quoteTable('ezuser_role')) |
|
| 454 | ->where( |
|
| 455 | $query->expr->lAnd( |
|
| 456 | $query->expr->eq( |
|
| 457 | $this->handler->quoteColumn('contentobject_id'), |
|
| 458 | $query->bindValue($contentId, null, \PDO::PARAM_INT) |
|
| 459 | ), |
|
| 460 | $query->expr->eq( |
|
| 461 | $this->handler->quoteColumn('role_id'), |
|
| 462 | $query->bindValue($roleId, null, \PDO::PARAM_INT) |
|
| 463 | ) |
|
| 464 | ) |
|
| 465 | ); |
|
| 466 | $query->prepare()->execute(); |
|
| 467 | } |
|
| 468 | ||
| 469 | /** |
|
| 470 | * Remove role from user or user group, by assignment ID. |
|