| @@ 317-335 (lines=19) @@ | ||
| 314 | * @param mixed $contentId |
|
| 315 | * @param mixed $roleId |
|
| 316 | */ |
|
| 317 | public function removeRole($contentId, $roleId) |
|
| 318 | { |
|
| 319 | $query = $this->handler->createDeleteQuery(); |
|
| 320 | $query |
|
| 321 | ->deleteFrom($this->handler->quoteTable('ezuser_role')) |
|
| 322 | ->where( |
|
| 323 | $query->expr->lAnd( |
|
| 324 | $query->expr->eq( |
|
| 325 | $this->handler->quoteColumn('contentobject_id'), |
|
| 326 | $query->bindValue($contentId, null, \PDO::PARAM_INT) |
|
| 327 | ), |
|
| 328 | $query->expr->eq( |
|
| 329 | $this->handler->quoteColumn('role_id'), |
|
| 330 | $query->bindValue($roleId, null, \PDO::PARAM_INT) |
|
| 331 | ) |
|
| 332 | ) |
|
| 333 | ); |
|
| 334 | $query->prepare()->execute(); |
|
| 335 | } |
|
| 336 | ||
| 337 | /** |
|
| 338 | * Remove role from user or user group, by assignment ID. |
|
| @@ 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). |
|
| @@ 340-356 (lines=17) @@ | ||
| 337 | * @param int $oldStateId |
|
| 338 | * @param int $newStateId |
|
| 339 | */ |
|
| 340 | public function updateObjectStateLinks($oldStateId, $newStateId) |
|
| 341 | { |
|
| 342 | $query = $this->dbHandler->createUpdateQuery(); |
|
| 343 | $query->update( |
|
| 344 | $this->dbHandler->quoteTable('ezcobj_state_link') |
|
| 345 | )->set( |
|
| 346 | $this->dbHandler->quoteColumn('contentobject_state_id'), |
|
| 347 | $query->bindValue($newStateId, null, \PDO::PARAM_INT) |
|
| 348 | )->where( |
|
| 349 | $query->expr->eq( |
|
| 350 | $this->dbHandler->quoteColumn('contentobject_state_id'), |
|
| 351 | $query->bindValue($oldStateId, null, \PDO::PARAM_INT) |
|
| 352 | ) |
|
| 353 | ); |
|
| 354 | ||
| 355 | $query->prepare()->execute(); |
|
| 356 | } |
|
| 357 | ||
| 358 | /** |
|
| 359 | * Deletes object state links identified by $stateId. |
|
| @@ 625-641 (lines=17) @@ | ||
| 622 | * @param mixed $stateId |
|
| 623 | * @param int $priority |
|
| 624 | */ |
|
| 625 | public function updateObjectStatePriority($stateId, $priority) |
|
| 626 | { |
|
| 627 | $query = $this->dbHandler->createUpdateQuery(); |
|
| 628 | $query->update( |
|
| 629 | $this->dbHandler->quoteTable('ezcobj_state') |
|
| 630 | )->set( |
|
| 631 | $this->dbHandler->quoteColumn('priority'), |
|
| 632 | $query->bindValue($priority, null, \PDO::PARAM_INT) |
|
| 633 | )->where( |
|
| 634 | $query->expr->eq( |
|
| 635 | $this->dbHandler->quoteColumn('id'), |
|
| 636 | $query->bindValue($stateId, null, \PDO::PARAM_INT) |
|
| 637 | ) |
|
| 638 | ); |
|
| 639 | ||
| 640 | $query->prepare()->execute(); |
|
| 641 | } |
|
| 642 | ||
| 643 | /** |
|
| 644 | * Creates a generalized query for fetching object state(s). |
|
| @@ 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 | ||
| @@ 1079-1097 (lines=19) @@ | ||
| 1076 | * @param mixed $typeId |
|
| 1077 | * @param int $status |
|
| 1078 | */ |
|
| 1079 | public function deleteFieldDefinitionsForType($typeId, $status) |
|
| 1080 | { |
|
| 1081 | $q = $this->dbHandler->createDeleteQuery(); |
|
| 1082 | $q->deleteFrom( |
|
| 1083 | $this->dbHandler->quoteTable('ezcontentclass_attribute') |
|
| 1084 | )->where( |
|
| 1085 | $q->expr->lAnd( |
|
| 1086 | $q->expr->eq( |
|
| 1087 | $this->dbHandler->quoteColumn('contentclass_id'), |
|
| 1088 | $q->bindValue($typeId, null, \PDO::PARAM_INT) |
|
| 1089 | ), |
|
| 1090 | $q->expr->eq( |
|
| 1091 | $this->dbHandler->quoteColumn('version'), |
|
| 1092 | $q->bindValue($status, null, \PDO::PARAM_INT) |
|
| 1093 | ) |
|
| 1094 | ) |
|
| 1095 | ); |
|
| 1096 | $q->prepare()->execute(); |
|
| 1097 | } |
|
| 1098 | ||
| 1099 | /** |
|
| 1100 | * Deletes a Type completely. |
|
| @@ 1121-1139 (lines=19) @@ | ||
| 1118 | * @param mixed $typeId |
|
| 1119 | * @param int $status |
|
| 1120 | */ |
|
| 1121 | public function deleteType($typeId, $status) |
|
| 1122 | { |
|
| 1123 | $q = $this->dbHandler->createDeleteQuery(); |
|
| 1124 | $q->deleteFrom( |
|
| 1125 | $this->dbHandler->quoteTable('ezcontentclass') |
|
| 1126 | )->where( |
|
| 1127 | $q->expr->lAnd( |
|
| 1128 | $q->expr->eq( |
|
| 1129 | $this->dbHandler->quoteColumn('id'), |
|
| 1130 | $q->bindValue($typeId, null, \PDO::PARAM_INT) |
|
| 1131 | ), |
|
| 1132 | $q->expr->eq( |
|
| 1133 | $this->dbHandler->quoteColumn('version'), |
|
| 1134 | $q->bindValue($status, null, \PDO::PARAM_INT) |
|
| 1135 | ) |
|
| 1136 | ) |
|
| 1137 | ); |
|
| 1138 | $q->prepare()->execute(); |
|
| 1139 | } |
|
| 1140 | ||
| 1141 | /** |
|
| 1142 | * Deletes all group assignments for a Type. |
|
| @@ 1147-1165 (lines=19) @@ | ||
| 1144 | * @param mixed $typeId |
|
| 1145 | * @param int $status |
|
| 1146 | */ |
|
| 1147 | public function deleteGroupAssignmentsForType($typeId, $status) |
|
| 1148 | { |
|
| 1149 | $q = $this->dbHandler->createDeleteQuery(); |
|
| 1150 | $q->deleteFrom( |
|
| 1151 | $this->dbHandler->quoteTable('ezcontentclass_classgroup') |
|
| 1152 | )->where( |
|
| 1153 | $q->expr->lAnd( |
|
| 1154 | $q->expr->eq( |
|
| 1155 | $this->dbHandler->quoteColumn('contentclass_id'), |
|
| 1156 | $q->bindValue($typeId, null, \PDO::PARAM_INT) |
|
| 1157 | ), |
|
| 1158 | $q->expr->eq( |
|
| 1159 | $this->dbHandler->quoteColumn('contentclass_version'), |
|
| 1160 | $q->bindValue($status, null, \PDO::PARAM_INT) |
|
| 1161 | ) |
|
| 1162 | ) |
|
| 1163 | ); |
|
| 1164 | $q->prepare()->execute(); |
|
| 1165 | } |
|
| 1166 | ||
| 1167 | /** |
|
| 1168 | * Publishes the Type with $typeId from $sourceVersion to $targetVersion, |
|
| @@ 1981-1998 (lines=18) @@ | ||
| 1978 | * |
|
| 1979 | * @return int[] |
|
| 1980 | */ |
|
| 1981 | public function getContentIdsByContentTypeId($contentTypeId) |
|
| 1982 | { |
|
| 1983 | $query = $this->dbHandler->createSelectQuery(); |
|
| 1984 | $query |
|
| 1985 | ->select($this->dbHandler->quoteColumn('id')) |
|
| 1986 | ->from($this->dbHandler->quoteTable('ezcontentobject')) |
|
| 1987 | ->where( |
|
| 1988 | $query->expr->eq( |
|
| 1989 | $this->dbHandler->quoteColumn('contentclass_id'), |
|
| 1990 | $query->bindValue($contentTypeId, null, PDO::PARAM_INT) |
|
| 1991 | ) |
|
| 1992 | ); |
|
| 1993 | ||
| 1994 | $statement = $query->prepare(); |
|
| 1995 | $statement->execute(); |
|
| 1996 | ||
| 1997 | return $statement->fetchAll(PDO::FETCH_COLUMN); |
|
| 1998 | } |
|
| 1999 | ||
| 2000 | /** |
|
| 2001 | * Load name data for set of content id's and corresponding version number. |
|
| @@ 1174-1192 (lines=19) @@ | ||
| 1171 | * |
|
| 1172 | * @return int[] |
|
| 1173 | */ |
|
| 1174 | public function listVersionNumbers($contentId) |
|
| 1175 | { |
|
| 1176 | $query = $this->dbHandler->createSelectQuery(); |
|
| 1177 | $query->selectDistinct( |
|
| 1178 | $this->dbHandler->quoteColumn('version') |
|
| 1179 | )->from( |
|
| 1180 | $this->dbHandler->quoteTable('ezcontentobject_version') |
|
| 1181 | )->where( |
|
| 1182 | $query->expr->eq( |
|
| 1183 | $this->dbHandler->quoteColumn('contentobject_id'), |
|
| 1184 | $query->bindValue($contentId, null, \PDO::PARAM_INT) |
|
| 1185 | ) |
|
| 1186 | ); |
|
| 1187 | ||
| 1188 | $statement = $query->prepare(); |
|
| 1189 | $statement->execute(); |
|
| 1190 | ||
| 1191 | return $statement->fetchAll(\PDO::FETCH_COLUMN); |
|
| 1192 | } |
|
| 1193 | ||
| 1194 | /** |
|
| 1195 | * Returns last version number for content identified by $contentId. |
|
| @@ 1228-1246 (lines=19) @@ | ||
| 1225 | * |
|
| 1226 | * @return int[] |
|
| 1227 | */ |
|
| 1228 | public function getAllLocationIds($contentId) |
|
| 1229 | { |
|
| 1230 | $query = $this->dbHandler->createSelectQuery(); |
|
| 1231 | $query->select( |
|
| 1232 | $this->dbHandler->quoteColumn('node_id') |
|
| 1233 | )->from( |
|
| 1234 | $this->dbHandler->quoteTable('ezcontentobject_tree') |
|
| 1235 | )->where( |
|
| 1236 | $query->expr->eq( |
|
| 1237 | $this->dbHandler->quoteColumn('contentobject_id'), |
|
| 1238 | $query->bindValue($contentId, null, \PDO::PARAM_INT) |
|
| 1239 | ) |
|
| 1240 | ); |
|
| 1241 | ||
| 1242 | $statement = $query->prepare(); |
|
| 1243 | $statement->execute(); |
|
| 1244 | ||
| 1245 | return $statement->fetchAll(\PDO::FETCH_COLUMN); |
|
| 1246 | } |
|
| 1247 | ||
| 1248 | /** |
|
| 1249 | * Returns all field IDs of $contentId grouped by their type. |
|