| @@ 75-94 (lines=20) @@ | ||
| 72 | * @param string $name |
|
| 73 | * @param string $identifier |
|
| 74 | */ |
|
| 75 | public function updateSection($id, $name, $identifier) |
|
| 76 | { |
|
| 77 | $query = $this->dbHandler->createUpdateQuery(); |
|
| 78 | $query->update( |
|
| 79 | $this->dbHandler->quoteTable('ezsection') |
|
| 80 | )->set( |
|
| 81 | $this->dbHandler->quoteColumn('name'), |
|
| 82 | $query->bindValue($name) |
|
| 83 | )->set( |
|
| 84 | $this->dbHandler->quoteColumn('identifier'), |
|
| 85 | $query->bindValue($identifier) |
|
| 86 | )->where( |
|
| 87 | $query->expr->eq( |
|
| 88 | $this->dbHandler->quoteColumn('id'), |
|
| 89 | $query->bindValue($id, null, \PDO::PARAM_INT) |
|
| 90 | ) |
|
| 91 | ); |
|
| 92 | ||
| 93 | $query->prepare()->execute(); |
|
| 94 | } |
|
| 95 | ||
| 96 | /** |
|
| 97 | * Loads data for section with $id. |
|
| @@ 183-206 (lines=24) @@ | ||
| 180 | * |
|
| 181 | * @return int |
|
| 182 | */ |
|
| 183 | public function countContentObjectsInSection($id) |
|
| 184 | { |
|
| 185 | $query = $this->dbHandler->createSelectQuery(); |
|
| 186 | $query->select( |
|
| 187 | $query->alias( |
|
| 188 | $query->expr->count( |
|
| 189 | $this->dbHandler->quoteColumn('id') |
|
| 190 | ), |
|
| 191 | 'content_count' |
|
| 192 | ) |
|
| 193 | )->from( |
|
| 194 | $this->dbHandler->quoteTable('ezcontentobject') |
|
| 195 | )->where( |
|
| 196 | $query->expr->eq( |
|
| 197 | $this->dbHandler->quoteColumn('section_id'), |
|
| 198 | $query->bindValue($id, null, \PDO::PARAM_INT) |
|
| 199 | ) |
|
| 200 | ); |
|
| 201 | ||
| 202 | $statement = $query->prepare(); |
|
| 203 | $statement->execute(); |
|
| 204 | ||
| 205 | return (int)$statement->fetchColumn(); |
|
| 206 | } |
|
| 207 | ||
| 208 | /** |
|
| 209 | * Counts the number of role policies using section with $id in their limitations. |
|
| @@ 187-210 (lines=24) @@ | ||
| 184 | * |
|
| 185 | * @return int |
|
| 186 | */ |
|
| 187 | public function countTypesInGroup($groupId) |
|
| 188 | { |
|
| 189 | $q = $this->dbHandler->createSelectQuery(); |
|
| 190 | $q->select( |
|
| 191 | $q->alias( |
|
| 192 | $q->expr->count( |
|
| 193 | $this->dbHandler->quoteColumn('contentclass_id') |
|
| 194 | ), |
|
| 195 | 'count' |
|
| 196 | ) |
|
| 197 | )->from( |
|
| 198 | $this->dbHandler->quoteTable('ezcontentclass_classgroup') |
|
| 199 | )->where( |
|
| 200 | $q->expr->eq( |
|
| 201 | $this->dbHandler->quoteColumn('group_id'), |
|
| 202 | $q->bindValue($groupId, null, \PDO::PARAM_INT) |
|
| 203 | ) |
|
| 204 | ); |
|
| 205 | ||
| 206 | $stmt = $q->prepare(); |
|
| 207 | $stmt->execute(); |
|
| 208 | ||
| 209 | return (int)$stmt->fetchColumn(); |
|
| 210 | } |
|
| 211 | ||
| 212 | /** |
|
| 213 | * Returns the number of Groups the type is assigned to. |
|
| @@ 1048-1071 (lines=24) @@ | ||
| 1045 | * |
|
| 1046 | * @return int |
|
| 1047 | */ |
|
| 1048 | public function countInstancesOfType($typeId) |
|
| 1049 | { |
|
| 1050 | $q = $this->dbHandler->createSelectQuery(); |
|
| 1051 | $q->select( |
|
| 1052 | $q->alias( |
|
| 1053 | $q->expr->count( |
|
| 1054 | $this->dbHandler->quoteColumn('id') |
|
| 1055 | ), |
|
| 1056 | 'count' |
|
| 1057 | ) |
|
| 1058 | )->from( |
|
| 1059 | $this->dbHandler->quoteTable('ezcontentobject') |
|
| 1060 | )->where( |
|
| 1061 | $q->expr->eq( |
|
| 1062 | $this->dbHandler->quoteColumn('contentclass_id'), |
|
| 1063 | $q->bindValue($typeId, null, \PDO::PARAM_INT) |
|
| 1064 | ) |
|
| 1065 | ); |
|
| 1066 | ||
| 1067 | $stmt = $q->prepare(); |
|
| 1068 | $stmt->execute(); |
|
| 1069 | ||
| 1070 | return (int)$stmt->fetchColumn(); |
|
| 1071 | } |
|
| 1072 | ||
| 1073 | /** |
|
| 1074 | * Deletes all field definitions of a Type. |
|
| @@ 1201-1219 (lines=19) @@ | ||
| 1198 | * |
|
| 1199 | * @return int |
|
| 1200 | */ |
|
| 1201 | public function getLastVersionNumber($contentId) |
|
| 1202 | { |
|
| 1203 | $query = $this->dbHandler->createSelectQuery(); |
|
| 1204 | $query->select( |
|
| 1205 | $query->expr->max($this->dbHandler->quoteColumn('version')) |
|
| 1206 | )->from( |
|
| 1207 | $this->dbHandler->quoteTable('ezcontentobject_version') |
|
| 1208 | )->where( |
|
| 1209 | $query->expr->eq( |
|
| 1210 | $this->dbHandler->quoteColumn('contentobject_id'), |
|
| 1211 | $query->bindValue($contentId, null, \PDO::PARAM_INT) |
|
| 1212 | ) |
|
| 1213 | ); |
|
| 1214 | ||
| 1215 | $statement = $query->prepare(); |
|
| 1216 | $statement->execute(); |
|
| 1217 | ||
| 1218 | return (int)$statement->fetchColumn(); |
|
| 1219 | } |
|
| 1220 | ||
| 1221 | /** |
|
| 1222 | * Returns all IDs for locations that refer to $contentId. |
|