@@ -35,143 +35,143 @@ |
||
| 35 | 35 | * @since 11.0.0 |
| 36 | 36 | */ |
| 37 | 37 | interface ILDAPProvider { |
| 38 | - /** |
|
| 39 | - * Translate a user id to LDAP DN. |
|
| 40 | - * @param string $uid user id |
|
| 41 | - * @return string |
|
| 42 | - * @since 11.0.0 |
|
| 43 | - */ |
|
| 44 | - public function getUserDN($uid); |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * Translate a group id to LDAP DN. |
|
| 48 | - * @param string $gid group id |
|
| 49 | - * @return string |
|
| 50 | - * @since 13.0.0 |
|
| 51 | - */ |
|
| 52 | - public function getGroupDN($gid); |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * Translate a LDAP DN to an internal user name. |
|
| 56 | - * @param string $dn LDAP DN |
|
| 57 | - * @return string with the internal user name |
|
| 58 | - * @throws \Exception if translation was unsuccessful |
|
| 59 | - * @since 11.0.0 |
|
| 60 | - */ |
|
| 61 | - public function getUserName($dn); |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Convert a stored DN so it can be used as base parameter for LDAP queries. |
|
| 65 | - * @param string $dn the DN |
|
| 66 | - * @return string |
|
| 67 | - * @since 11.0.0 |
|
| 68 | - */ |
|
| 69 | - public function DNasBaseParameter($dn); |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * Sanitize a DN received from the LDAP server. |
|
| 73 | - * @param array $dn the DN in question |
|
| 74 | - * @return array the sanitized DN |
|
| 75 | - * @since 11.0.0 |
|
| 76 | - */ |
|
| 77 | - public function sanitizeDN($dn); |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Return a new LDAP connection resource for the specified user. |
|
| 81 | - * @param string $uid user id |
|
| 82 | - * @return \LDAP\Connection|resource |
|
| 83 | - * @since 11.0.0 |
|
| 84 | - */ |
|
| 85 | - public function getLDAPConnection($uid); |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * Return a new LDAP connection resource for the specified group. |
|
| 89 | - * @param string $gid group id |
|
| 90 | - * @return \LDAP\Connection|resource |
|
| 91 | - * @since 13.0.0 |
|
| 92 | - */ |
|
| 93 | - public function getGroupLDAPConnection($gid); |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * Get the LDAP base for users. |
|
| 97 | - * @param string $uid user id |
|
| 98 | - * @return string the base for users |
|
| 99 | - * @throws \Exception if user id was not found in LDAP |
|
| 100 | - * @since 11.0.0 |
|
| 101 | - */ |
|
| 102 | - public function getLDAPBaseUsers($uid); |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * Get the LDAP base for groups. |
|
| 106 | - * @param string $uid user id |
|
| 107 | - * @return string the base for groups |
|
| 108 | - * @throws \Exception if user id was not found in LDAP |
|
| 109 | - * @since 11.0.0 |
|
| 110 | - */ |
|
| 111 | - public function getLDAPBaseGroups($uid); |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * Check whether a LDAP DN exists |
|
| 115 | - * @param string $dn LDAP DN |
|
| 116 | - * @return bool whether the DN exists |
|
| 117 | - * @since 11.0.0 |
|
| 118 | - */ |
|
| 119 | - public function dnExists($dn); |
|
| 120 | - |
|
| 121 | - /** |
|
| 122 | - * Clear the cache if a cache is used, otherwise do nothing. |
|
| 123 | - * @param string $uid user id |
|
| 124 | - * @since 11.0.0 |
|
| 125 | - */ |
|
| 126 | - public function clearCache($uid); |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * Clear the cache if a cache is used, otherwise do nothing. |
|
| 130 | - * @param string $gid group id |
|
| 131 | - * @since 13.0.0 |
|
| 132 | - */ |
|
| 133 | - public function clearGroupCache($gid); |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * Get the LDAP attribute name for the user's display name |
|
| 137 | - * @param string $uid user id |
|
| 138 | - * @return string the display name field |
|
| 139 | - * @throws \Exception if user id was not found in LDAP |
|
| 140 | - * @since 12.0.0 |
|
| 141 | - */ |
|
| 142 | - public function getLDAPDisplayNameField($uid); |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * Get the LDAP attribute name for the email |
|
| 146 | - * @param string $uid user id |
|
| 147 | - * @return string the email field |
|
| 148 | - * @throws \Exception if user id was not found in LDAP |
|
| 149 | - * @since 12.0.0 |
|
| 150 | - */ |
|
| 151 | - public function getLDAPEmailField($uid); |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * Get the LDAP attribute name for the type of association between users and groups |
|
| 155 | - * @param string $gid group id |
|
| 156 | - * @return string the configuration, one of: 'memberUid', 'uniqueMember', 'member', 'gidNumber', '' |
|
| 157 | - * @throws \Exception if group id was not found in LDAP |
|
| 158 | - * @since 13.0.0 |
|
| 159 | - */ |
|
| 160 | - public function getLDAPGroupMemberAssoc($gid); |
|
| 161 | - |
|
| 162 | - /** |
|
| 163 | - * Get an LDAP attribute for a nextcloud user |
|
| 164 | - * |
|
| 165 | - * @throws \Exception if user id was not found in LDAP |
|
| 166 | - * @since 21.0.0 |
|
| 167 | - */ |
|
| 168 | - public function getUserAttribute(string $uid, string $attribute): ?string; |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * Get a multi-value LDAP attribute for a nextcloud user |
|
| 172 | - * |
|
| 173 | - * @throws \Exception if user id was not found in LDAP |
|
| 174 | - * @since 22.0.0 |
|
| 175 | - */ |
|
| 176 | - public function getMultiValueUserAttribute(string $uid, string $attribute): array; |
|
| 38 | + /** |
|
| 39 | + * Translate a user id to LDAP DN. |
|
| 40 | + * @param string $uid user id |
|
| 41 | + * @return string |
|
| 42 | + * @since 11.0.0 |
|
| 43 | + */ |
|
| 44 | + public function getUserDN($uid); |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * Translate a group id to LDAP DN. |
|
| 48 | + * @param string $gid group id |
|
| 49 | + * @return string |
|
| 50 | + * @since 13.0.0 |
|
| 51 | + */ |
|
| 52 | + public function getGroupDN($gid); |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * Translate a LDAP DN to an internal user name. |
|
| 56 | + * @param string $dn LDAP DN |
|
| 57 | + * @return string with the internal user name |
|
| 58 | + * @throws \Exception if translation was unsuccessful |
|
| 59 | + * @since 11.0.0 |
|
| 60 | + */ |
|
| 61 | + public function getUserName($dn); |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Convert a stored DN so it can be used as base parameter for LDAP queries. |
|
| 65 | + * @param string $dn the DN |
|
| 66 | + * @return string |
|
| 67 | + * @since 11.0.0 |
|
| 68 | + */ |
|
| 69 | + public function DNasBaseParameter($dn); |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * Sanitize a DN received from the LDAP server. |
|
| 73 | + * @param array $dn the DN in question |
|
| 74 | + * @return array the sanitized DN |
|
| 75 | + * @since 11.0.0 |
|
| 76 | + */ |
|
| 77 | + public function sanitizeDN($dn); |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Return a new LDAP connection resource for the specified user. |
|
| 81 | + * @param string $uid user id |
|
| 82 | + * @return \LDAP\Connection|resource |
|
| 83 | + * @since 11.0.0 |
|
| 84 | + */ |
|
| 85 | + public function getLDAPConnection($uid); |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * Return a new LDAP connection resource for the specified group. |
|
| 89 | + * @param string $gid group id |
|
| 90 | + * @return \LDAP\Connection|resource |
|
| 91 | + * @since 13.0.0 |
|
| 92 | + */ |
|
| 93 | + public function getGroupLDAPConnection($gid); |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * Get the LDAP base for users. |
|
| 97 | + * @param string $uid user id |
|
| 98 | + * @return string the base for users |
|
| 99 | + * @throws \Exception if user id was not found in LDAP |
|
| 100 | + * @since 11.0.0 |
|
| 101 | + */ |
|
| 102 | + public function getLDAPBaseUsers($uid); |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * Get the LDAP base for groups. |
|
| 106 | + * @param string $uid user id |
|
| 107 | + * @return string the base for groups |
|
| 108 | + * @throws \Exception if user id was not found in LDAP |
|
| 109 | + * @since 11.0.0 |
|
| 110 | + */ |
|
| 111 | + public function getLDAPBaseGroups($uid); |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * Check whether a LDAP DN exists |
|
| 115 | + * @param string $dn LDAP DN |
|
| 116 | + * @return bool whether the DN exists |
|
| 117 | + * @since 11.0.0 |
|
| 118 | + */ |
|
| 119 | + public function dnExists($dn); |
|
| 120 | + |
|
| 121 | + /** |
|
| 122 | + * Clear the cache if a cache is used, otherwise do nothing. |
|
| 123 | + * @param string $uid user id |
|
| 124 | + * @since 11.0.0 |
|
| 125 | + */ |
|
| 126 | + public function clearCache($uid); |
|
| 127 | + |
|
| 128 | + /** |
|
| 129 | + * Clear the cache if a cache is used, otherwise do nothing. |
|
| 130 | + * @param string $gid group id |
|
| 131 | + * @since 13.0.0 |
|
| 132 | + */ |
|
| 133 | + public function clearGroupCache($gid); |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * Get the LDAP attribute name for the user's display name |
|
| 137 | + * @param string $uid user id |
|
| 138 | + * @return string the display name field |
|
| 139 | + * @throws \Exception if user id was not found in LDAP |
|
| 140 | + * @since 12.0.0 |
|
| 141 | + */ |
|
| 142 | + public function getLDAPDisplayNameField($uid); |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * Get the LDAP attribute name for the email |
|
| 146 | + * @param string $uid user id |
|
| 147 | + * @return string the email field |
|
| 148 | + * @throws \Exception if user id was not found in LDAP |
|
| 149 | + * @since 12.0.0 |
|
| 150 | + */ |
|
| 151 | + public function getLDAPEmailField($uid); |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * Get the LDAP attribute name for the type of association between users and groups |
|
| 155 | + * @param string $gid group id |
|
| 156 | + * @return string the configuration, one of: 'memberUid', 'uniqueMember', 'member', 'gidNumber', '' |
|
| 157 | + * @throws \Exception if group id was not found in LDAP |
|
| 158 | + * @since 13.0.0 |
|
| 159 | + */ |
|
| 160 | + public function getLDAPGroupMemberAssoc($gid); |
|
| 161 | + |
|
| 162 | + /** |
|
| 163 | + * Get an LDAP attribute for a nextcloud user |
|
| 164 | + * |
|
| 165 | + * @throws \Exception if user id was not found in LDAP |
|
| 166 | + * @since 21.0.0 |
|
| 167 | + */ |
|
| 168 | + public function getUserAttribute(string $uid, string $attribute): ?string; |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * Get a multi-value LDAP attribute for a nextcloud user |
|
| 172 | + * |
|
| 173 | + * @throws \Exception if user id was not found in LDAP |
|
| 174 | + * @since 22.0.0 |
|
| 175 | + */ |
|
| 176 | + public function getMultiValueUserAttribute(string $uid, string $attribute): array; |
|
| 177 | 177 | } |
@@ -48,110 +48,110 @@ |
||
| 48 | 48 | * @since 7.0.0 |
| 49 | 49 | */ |
| 50 | 50 | interface IJobList { |
| 51 | - /** |
|
| 52 | - * Add a job to the list |
|
| 53 | - * |
|
| 54 | - * @param IJob|class-string<IJob> $job |
|
| 55 | - * @param mixed $argument The argument to be passed to $job->run() when the job is executed |
|
| 56 | - * @since 7.0.0 |
|
| 57 | - */ |
|
| 58 | - public function add($job, $argument = null): void; |
|
| 51 | + /** |
|
| 52 | + * Add a job to the list |
|
| 53 | + * |
|
| 54 | + * @param IJob|class-string<IJob> $job |
|
| 55 | + * @param mixed $argument The argument to be passed to $job->run() when the job is executed |
|
| 56 | + * @since 7.0.0 |
|
| 57 | + */ |
|
| 58 | + public function add($job, $argument = null): void; |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Remove a job from the list |
|
| 62 | - * |
|
| 63 | - * @param IJob|class-string<IJob> $job |
|
| 64 | - * @param mixed $argument |
|
| 65 | - * @since 7.0.0 |
|
| 66 | - */ |
|
| 67 | - public function remove($job, $argument = null): void; |
|
| 60 | + /** |
|
| 61 | + * Remove a job from the list |
|
| 62 | + * |
|
| 63 | + * @param IJob|class-string<IJob> $job |
|
| 64 | + * @param mixed $argument |
|
| 65 | + * @since 7.0.0 |
|
| 66 | + */ |
|
| 67 | + public function remove($job, $argument = null): void; |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * check if a job is in the list |
|
| 71 | - * |
|
| 72 | - * @param IJob|class-string<IJob> $job |
|
| 73 | - * @param mixed $argument |
|
| 74 | - * @since 7.0.0 |
|
| 75 | - */ |
|
| 76 | - public function has($job, $argument): bool; |
|
| 69 | + /** |
|
| 70 | + * check if a job is in the list |
|
| 71 | + * |
|
| 72 | + * @param IJob|class-string<IJob> $job |
|
| 73 | + * @param mixed $argument |
|
| 74 | + * @since 7.0.0 |
|
| 75 | + */ |
|
| 76 | + public function has($job, $argument): bool; |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Get jobs matching the search |
|
| 80 | - * |
|
| 81 | - * @param IJob|class-string<IJob>|null $job |
|
| 82 | - * @return array<IJob> |
|
| 83 | - * @since 25.0.0 |
|
| 84 | - * @deprecated 26.0.0 Use getJobsIterator instead to avoid duplicated job objects |
|
| 85 | - */ |
|
| 86 | - public function getJobs($job, ?int $limit, int $offset): array; |
|
| 78 | + /** |
|
| 79 | + * Get jobs matching the search |
|
| 80 | + * |
|
| 81 | + * @param IJob|class-string<IJob>|null $job |
|
| 82 | + * @return array<IJob> |
|
| 83 | + * @since 25.0.0 |
|
| 84 | + * @deprecated 26.0.0 Use getJobsIterator instead to avoid duplicated job objects |
|
| 85 | + */ |
|
| 86 | + public function getJobs($job, ?int $limit, int $offset): array; |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * Get jobs matching the search |
|
| 90 | - * |
|
| 91 | - * @param IJob|class-string<IJob>|null $job |
|
| 92 | - * @return iterable<IJob> |
|
| 93 | - * @since 26.0.0 |
|
| 94 | - */ |
|
| 95 | - public function getJobsIterator($job, ?int $limit, int $offset): iterable; |
|
| 88 | + /** |
|
| 89 | + * Get jobs matching the search |
|
| 90 | + * |
|
| 91 | + * @param IJob|class-string<IJob>|null $job |
|
| 92 | + * @return iterable<IJob> |
|
| 93 | + * @since 26.0.0 |
|
| 94 | + */ |
|
| 95 | + public function getJobsIterator($job, ?int $limit, int $offset): iterable; |
|
| 96 | 96 | |
| 97 | - /** |
|
| 98 | - * get the next job in the list |
|
| 99 | - * |
|
| 100 | - * @since 7.0.0 - In 24.0.0 parameter $onlyTimeSensitive got added |
|
| 101 | - */ |
|
| 102 | - public function getNext(bool $onlyTimeSensitive = false): ?IJob; |
|
| 97 | + /** |
|
| 98 | + * get the next job in the list |
|
| 99 | + * |
|
| 100 | + * @since 7.0.0 - In 24.0.0 parameter $onlyTimeSensitive got added |
|
| 101 | + */ |
|
| 102 | + public function getNext(bool $onlyTimeSensitive = false): ?IJob; |
|
| 103 | 103 | |
| 104 | - /** |
|
| 105 | - * @since 7.0.0 |
|
| 106 | - */ |
|
| 107 | - public function getById(int $id): ?IJob; |
|
| 104 | + /** |
|
| 105 | + * @since 7.0.0 |
|
| 106 | + */ |
|
| 107 | + public function getById(int $id): ?IJob; |
|
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * @since 23.0.0 |
|
| 111 | - */ |
|
| 112 | - public function getDetailsById(int $id): ?array; |
|
| 109 | + /** |
|
| 110 | + * @since 23.0.0 |
|
| 111 | + */ |
|
| 112 | + public function getDetailsById(int $id): ?array; |
|
| 113 | 113 | |
| 114 | - /** |
|
| 115 | - * set the job that was last ran to the current time |
|
| 116 | - * |
|
| 117 | - * @since 7.0.0 |
|
| 118 | - */ |
|
| 119 | - public function setLastJob(IJob $job): void; |
|
| 114 | + /** |
|
| 115 | + * set the job that was last ran to the current time |
|
| 116 | + * |
|
| 117 | + * @since 7.0.0 |
|
| 118 | + */ |
|
| 119 | + public function setLastJob(IJob $job): void; |
|
| 120 | 120 | |
| 121 | - /** |
|
| 122 | - * Remove the reservation for a job |
|
| 123 | - * |
|
| 124 | - * @since 9.1.0 |
|
| 125 | - */ |
|
| 126 | - public function unlockJob(IJob $job): void; |
|
| 121 | + /** |
|
| 122 | + * Remove the reservation for a job |
|
| 123 | + * |
|
| 124 | + * @since 9.1.0 |
|
| 125 | + */ |
|
| 126 | + public function unlockJob(IJob $job): void; |
|
| 127 | 127 | |
| 128 | - /** |
|
| 129 | - * set the lastRun of $job to now |
|
| 130 | - * |
|
| 131 | - * @since 7.0.0 |
|
| 132 | - */ |
|
| 133 | - public function setLastRun(IJob $job): void; |
|
| 128 | + /** |
|
| 129 | + * set the lastRun of $job to now |
|
| 130 | + * |
|
| 131 | + * @since 7.0.0 |
|
| 132 | + */ |
|
| 133 | + public function setLastRun(IJob $job): void; |
|
| 134 | 134 | |
| 135 | - /** |
|
| 136 | - * set the run duration of $job |
|
| 137 | - * |
|
| 138 | - * @since 12.0.0 |
|
| 139 | - */ |
|
| 140 | - public function setExecutionTime(IJob $job, int $timeTaken): void; |
|
| 135 | + /** |
|
| 136 | + * set the run duration of $job |
|
| 137 | + * |
|
| 138 | + * @since 12.0.0 |
|
| 139 | + */ |
|
| 140 | + public function setExecutionTime(IJob $job, int $timeTaken): void; |
|
| 141 | 141 | |
| 142 | - /** |
|
| 143 | - * Reset the $job so it executes on the next trigger |
|
| 144 | - * |
|
| 145 | - * @since 23.0.0 |
|
| 146 | - */ |
|
| 147 | - public function resetBackgroundJob(IJob $job): void; |
|
| 142 | + /** |
|
| 143 | + * Reset the $job so it executes on the next trigger |
|
| 144 | + * |
|
| 145 | + * @since 23.0.0 |
|
| 146 | + */ |
|
| 147 | + public function resetBackgroundJob(IJob $job): void; |
|
| 148 | 148 | |
| 149 | - /** |
|
| 150 | - * Checks whether a job of the passed class is reserved to run |
|
| 151 | - * |
|
| 152 | - * @param string|null $className |
|
| 153 | - * @return bool |
|
| 154 | - * @since 27.0.0 |
|
| 155 | - */ |
|
| 156 | - public function hasReservedJob(?string $className): bool; |
|
| 149 | + /** |
|
| 150 | + * Checks whether a job of the passed class is reserved to run |
|
| 151 | + * |
|
| 152 | + * @param string|null $className |
|
| 153 | + * @return bool |
|
| 154 | + * @since 27.0.0 |
|
| 155 | + */ |
|
| 156 | + public function hasReservedJob(?string $className): bool; |
|
| 157 | 157 | } |
@@ -33,64 +33,64 @@ |
||
| 33 | 33 | * @since 5.0.0 |
| 34 | 34 | */ |
| 35 | 35 | interface Share_Backend { |
| 36 | - /** |
|
| 37 | - * Check if this $itemSource exist for the user |
|
| 38 | - * @param string $itemSource |
|
| 39 | - * @param string $uidOwner Owner of the item |
|
| 40 | - * @return boolean|null Source |
|
| 41 | - * |
|
| 42 | - * Return false if the item does not exist for the user |
|
| 43 | - * @since 5.0.0 |
|
| 44 | - */ |
|
| 45 | - public function isValidSource($itemSource, $uidOwner); |
|
| 36 | + /** |
|
| 37 | + * Check if this $itemSource exist for the user |
|
| 38 | + * @param string $itemSource |
|
| 39 | + * @param string $uidOwner Owner of the item |
|
| 40 | + * @return boolean|null Source |
|
| 41 | + * |
|
| 42 | + * Return false if the item does not exist for the user |
|
| 43 | + * @since 5.0.0 |
|
| 44 | + */ |
|
| 45 | + public function isValidSource($itemSource, $uidOwner); |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Get a unique name of the item for the specified user |
|
| 49 | - * @param string $itemSource |
|
| 50 | - * @param string|false $shareWith User the item is being shared with |
|
| 51 | - * @param array|null $exclude List of similar item names already existing as shared items @deprecated since version OC7 |
|
| 52 | - * @return string Target name |
|
| 53 | - * |
|
| 54 | - * This function needs to verify that the user does not already have an item with this name. |
|
| 55 | - * If it does generate a new name e.g. name_# |
|
| 56 | - * @since 5.0.0 |
|
| 57 | - */ |
|
| 58 | - public function generateTarget($itemSource, $shareWith, $exclude = null); |
|
| 47 | + /** |
|
| 48 | + * Get a unique name of the item for the specified user |
|
| 49 | + * @param string $itemSource |
|
| 50 | + * @param string|false $shareWith User the item is being shared with |
|
| 51 | + * @param array|null $exclude List of similar item names already existing as shared items @deprecated since version OC7 |
|
| 52 | + * @return string Target name |
|
| 53 | + * |
|
| 54 | + * This function needs to verify that the user does not already have an item with this name. |
|
| 55 | + * If it does generate a new name e.g. name_# |
|
| 56 | + * @since 5.0.0 |
|
| 57 | + */ |
|
| 58 | + public function generateTarget($itemSource, $shareWith, $exclude = null); |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Converts the shared item sources back into the item in the specified format |
|
| 62 | - * @param array $items Shared items |
|
| 63 | - * @param int $format |
|
| 64 | - * @return array |
|
| 65 | - * |
|
| 66 | - * The items array is a 3-dimensional array with the item_source as the |
|
| 67 | - * first key and the share id as the second key to an array with the share |
|
| 68 | - * info. |
|
| 69 | - * |
|
| 70 | - * The key/value pairs included in the share info depend on the function originally called: |
|
| 71 | - * If called by getItem(s)Shared: id, item_type, item, item_source, |
|
| 72 | - * share_type, share_with, permissions, stime, file_source |
|
| 73 | - * |
|
| 74 | - * If called by getItem(s)SharedWith: id, item_type, item, item_source, |
|
| 75 | - * item_target, share_type, share_with, permissions, stime, file_source, |
|
| 76 | - * file_target |
|
| 77 | - * |
|
| 78 | - * This function allows the backend to control the output of shared items with custom formats. |
|
| 79 | - * It is only called through calls to the public getItem(s)Shared(With) functions. |
|
| 80 | - * @since 5.0.0 |
|
| 81 | - */ |
|
| 82 | - public function formatItems($items, $format, $parameters = null); |
|
| 60 | + /** |
|
| 61 | + * Converts the shared item sources back into the item in the specified format |
|
| 62 | + * @param array $items Shared items |
|
| 63 | + * @param int $format |
|
| 64 | + * @return array |
|
| 65 | + * |
|
| 66 | + * The items array is a 3-dimensional array with the item_source as the |
|
| 67 | + * first key and the share id as the second key to an array with the share |
|
| 68 | + * info. |
|
| 69 | + * |
|
| 70 | + * The key/value pairs included in the share info depend on the function originally called: |
|
| 71 | + * If called by getItem(s)Shared: id, item_type, item, item_source, |
|
| 72 | + * share_type, share_with, permissions, stime, file_source |
|
| 73 | + * |
|
| 74 | + * If called by getItem(s)SharedWith: id, item_type, item, item_source, |
|
| 75 | + * item_target, share_type, share_with, permissions, stime, file_source, |
|
| 76 | + * file_target |
|
| 77 | + * |
|
| 78 | + * This function allows the backend to control the output of shared items with custom formats. |
|
| 79 | + * It is only called through calls to the public getItem(s)Shared(With) functions. |
|
| 80 | + * @since 5.0.0 |
|
| 81 | + */ |
|
| 82 | + public function formatItems($items, $format, $parameters = null); |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Check if a given share type is allowed by the back-end |
|
| 86 | - * |
|
| 87 | - * @param int $shareType share type |
|
| 88 | - * @return boolean |
|
| 89 | - * |
|
| 90 | - * The back-end can enable/disable specific share types. Just return true if |
|
| 91 | - * the back-end doesn't provide any specific settings for it and want to allow |
|
| 92 | - * all share types defined by the share API |
|
| 93 | - * @since 8.0.0 |
|
| 94 | - */ |
|
| 95 | - public function isShareTypeAllowed($shareType); |
|
| 84 | + /** |
|
| 85 | + * Check if a given share type is allowed by the back-end |
|
| 86 | + * |
|
| 87 | + * @param int $shareType share type |
|
| 88 | + * @return boolean |
|
| 89 | + * |
|
| 90 | + * The back-end can enable/disable specific share types. Just return true if |
|
| 91 | + * the back-end doesn't provide any specific settings for it and want to allow |
|
| 92 | + * all share types defined by the share API |
|
| 93 | + * @since 8.0.0 |
|
| 94 | + */ |
|
| 95 | + public function isShareTypeAllowed($shareType); |
|
| 96 | 96 | } |
@@ -48,131 +48,131 @@ |
||
| 48 | 48 | * @since 6.0.0 |
| 49 | 49 | */ |
| 50 | 50 | interface IManager { |
| 51 | - /** |
|
| 52 | - * This function is used to search and find contacts within the users address books. |
|
| 53 | - * In case $pattern is empty all contacts will be returned. |
|
| 54 | - * |
|
| 55 | - * Example: |
|
| 56 | - * Following function shows how to search for contacts for the name and the email address. |
|
| 57 | - * |
|
| 58 | - * public static function getMatchingRecipient($term) { |
|
| 59 | - * $cm = \OC::$server->getContactsManager(); |
|
| 60 | - * // The API is not active -> nothing to do |
|
| 61 | - * if (!$cm->isEnabled()) { |
|
| 62 | - * return array(); |
|
| 63 | - * } |
|
| 64 | - * |
|
| 65 | - * $result = $cm->search($term, array('FN', 'EMAIL')); |
|
| 66 | - * $receivers = array(); |
|
| 67 | - * foreach ($result as $r) { |
|
| 68 | - * $id = $r['id']; |
|
| 69 | - * $fn = $r['FN']; |
|
| 70 | - * $email = $r['EMAIL']; |
|
| 71 | - * if (!is_array($email)) { |
|
| 72 | - * $email = array($email); |
|
| 73 | - * } |
|
| 74 | - * |
|
| 75 | - * // loop through all email addresses of this contact |
|
| 76 | - * foreach ($email as $e) { |
|
| 77 | - * $displayName = $fn . " <$e>"; |
|
| 78 | - * $receivers[] = array( |
|
| 79 | - * 'id' => $id, |
|
| 80 | - * 'label' => $displayName, |
|
| 81 | - * 'value' => $displayName); |
|
| 82 | - * } |
|
| 83 | - * } |
|
| 84 | - * |
|
| 85 | - * return $receivers; |
|
| 86 | - * } |
|
| 87 | - * |
|
| 88 | - * |
|
| 89 | - * @param string $pattern which should match within the $searchProperties |
|
| 90 | - * @param array $searchProperties defines the properties within the query pattern should match |
|
| 91 | - * @param array $options = array() to define the search behavior |
|
| 92 | - * - 'types' boolean (since 15.0.0) If set to true, fields that come with a TYPE property will be an array |
|
| 93 | - * example: ['id' => 5, 'FN' => 'Thomas Tanghus', 'EMAIL' => ['type => 'HOME', 'value' => '[email protected]']] |
|
| 94 | - * - 'escape_like_param' - If set to false wildcards _ and % are not escaped |
|
| 95 | - * - 'limit' - Set a numeric limit for the search results |
|
| 96 | - * - 'offset' - Set the offset for the limited search results |
|
| 97 | - * - 'enumeration' - (since 23.0.0) Whether user enumeration on system address book is allowed |
|
| 98 | - * - 'fullmatch' - (since 23.0.0) Whether matching on full detail in system address book is allowed |
|
| 99 | - * - 'strict_search' - (since 23.0.0) Whether the search pattern is full string or partial search |
|
| 100 | - * @psalm-param array{types?: bool, escape_like_param?: bool, limit?: int, offset?: int, enumeration?: bool, fullmatch?: bool, strict_search?: bool} $options |
|
| 101 | - * @return array an array of contacts which are arrays of key-value-pairs |
|
| 102 | - * @since 6.0.0 |
|
| 103 | - */ |
|
| 104 | - public function search($pattern, $searchProperties = [], $options = []); |
|
| 51 | + /** |
|
| 52 | + * This function is used to search and find contacts within the users address books. |
|
| 53 | + * In case $pattern is empty all contacts will be returned. |
|
| 54 | + * |
|
| 55 | + * Example: |
|
| 56 | + * Following function shows how to search for contacts for the name and the email address. |
|
| 57 | + * |
|
| 58 | + * public static function getMatchingRecipient($term) { |
|
| 59 | + * $cm = \OC::$server->getContactsManager(); |
|
| 60 | + * // The API is not active -> nothing to do |
|
| 61 | + * if (!$cm->isEnabled()) { |
|
| 62 | + * return array(); |
|
| 63 | + * } |
|
| 64 | + * |
|
| 65 | + * $result = $cm->search($term, array('FN', 'EMAIL')); |
|
| 66 | + * $receivers = array(); |
|
| 67 | + * foreach ($result as $r) { |
|
| 68 | + * $id = $r['id']; |
|
| 69 | + * $fn = $r['FN']; |
|
| 70 | + * $email = $r['EMAIL']; |
|
| 71 | + * if (!is_array($email)) { |
|
| 72 | + * $email = array($email); |
|
| 73 | + * } |
|
| 74 | + * |
|
| 75 | + * // loop through all email addresses of this contact |
|
| 76 | + * foreach ($email as $e) { |
|
| 77 | + * $displayName = $fn . " <$e>"; |
|
| 78 | + * $receivers[] = array( |
|
| 79 | + * 'id' => $id, |
|
| 80 | + * 'label' => $displayName, |
|
| 81 | + * 'value' => $displayName); |
|
| 82 | + * } |
|
| 83 | + * } |
|
| 84 | + * |
|
| 85 | + * return $receivers; |
|
| 86 | + * } |
|
| 87 | + * |
|
| 88 | + * |
|
| 89 | + * @param string $pattern which should match within the $searchProperties |
|
| 90 | + * @param array $searchProperties defines the properties within the query pattern should match |
|
| 91 | + * @param array $options = array() to define the search behavior |
|
| 92 | + * - 'types' boolean (since 15.0.0) If set to true, fields that come with a TYPE property will be an array |
|
| 93 | + * example: ['id' => 5, 'FN' => 'Thomas Tanghus', 'EMAIL' => ['type => 'HOME', 'value' => '[email protected]']] |
|
| 94 | + * - 'escape_like_param' - If set to false wildcards _ and % are not escaped |
|
| 95 | + * - 'limit' - Set a numeric limit for the search results |
|
| 96 | + * - 'offset' - Set the offset for the limited search results |
|
| 97 | + * - 'enumeration' - (since 23.0.0) Whether user enumeration on system address book is allowed |
|
| 98 | + * - 'fullmatch' - (since 23.0.0) Whether matching on full detail in system address book is allowed |
|
| 99 | + * - 'strict_search' - (since 23.0.0) Whether the search pattern is full string or partial search |
|
| 100 | + * @psalm-param array{types?: bool, escape_like_param?: bool, limit?: int, offset?: int, enumeration?: bool, fullmatch?: bool, strict_search?: bool} $options |
|
| 101 | + * @return array an array of contacts which are arrays of key-value-pairs |
|
| 102 | + * @since 6.0.0 |
|
| 103 | + */ |
|
| 104 | + public function search($pattern, $searchProperties = [], $options = []); |
|
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * This function can be used to delete the contact identified by the given id |
|
| 108 | - * |
|
| 109 | - * @param int $id the unique identifier to a contact |
|
| 110 | - * @param string $address_book_key identifier of the address book in which the contact shall be deleted |
|
| 111 | - * @return bool successful or not |
|
| 112 | - * @since 6.0.0 |
|
| 113 | - */ |
|
| 114 | - public function delete($id, $address_book_key); |
|
| 106 | + /** |
|
| 107 | + * This function can be used to delete the contact identified by the given id |
|
| 108 | + * |
|
| 109 | + * @param int $id the unique identifier to a contact |
|
| 110 | + * @param string $address_book_key identifier of the address book in which the contact shall be deleted |
|
| 111 | + * @return bool successful or not |
|
| 112 | + * @since 6.0.0 |
|
| 113 | + */ |
|
| 114 | + public function delete($id, $address_book_key); |
|
| 115 | 115 | |
| 116 | - /** |
|
| 117 | - * This function is used to create a new contact if 'id' is not given or not present. |
|
| 118 | - * Otherwise the contact will be updated by replacing the entire data set. |
|
| 119 | - * |
|
| 120 | - * @param array $properties this array if key-value-pairs defines a contact |
|
| 121 | - * @param string $address_book_key identifier of the address book in which the contact shall be created or updated |
|
| 122 | - * @return array an array representing the contact just created or updated |
|
| 123 | - * @since 6.0.0 |
|
| 124 | - */ |
|
| 125 | - public function createOrUpdate($properties, $address_book_key); |
|
| 116 | + /** |
|
| 117 | + * This function is used to create a new contact if 'id' is not given or not present. |
|
| 118 | + * Otherwise the contact will be updated by replacing the entire data set. |
|
| 119 | + * |
|
| 120 | + * @param array $properties this array if key-value-pairs defines a contact |
|
| 121 | + * @param string $address_book_key identifier of the address book in which the contact shall be created or updated |
|
| 122 | + * @return array an array representing the contact just created or updated |
|
| 123 | + * @since 6.0.0 |
|
| 124 | + */ |
|
| 125 | + public function createOrUpdate($properties, $address_book_key); |
|
| 126 | 126 | |
| 127 | - /** |
|
| 128 | - * Check if contacts are available (e.g. contacts app enabled) |
|
| 129 | - * |
|
| 130 | - * @return bool true if enabled, false if not |
|
| 131 | - * @since 6.0.0 |
|
| 132 | - */ |
|
| 133 | - public function isEnabled(); |
|
| 127 | + /** |
|
| 128 | + * Check if contacts are available (e.g. contacts app enabled) |
|
| 129 | + * |
|
| 130 | + * @return bool true if enabled, false if not |
|
| 131 | + * @since 6.0.0 |
|
| 132 | + */ |
|
| 133 | + public function isEnabled(); |
|
| 134 | 134 | |
| 135 | - /** |
|
| 136 | - * Registers an address book |
|
| 137 | - * |
|
| 138 | - * @param \OCP\IAddressBook $address_book |
|
| 139 | - * @return void |
|
| 140 | - * @since 6.0.0 |
|
| 141 | - */ |
|
| 142 | - public function registerAddressBook(\OCP\IAddressBook $address_book); |
|
| 135 | + /** |
|
| 136 | + * Registers an address book |
|
| 137 | + * |
|
| 138 | + * @param \OCP\IAddressBook $address_book |
|
| 139 | + * @return void |
|
| 140 | + * @since 6.0.0 |
|
| 141 | + */ |
|
| 142 | + public function registerAddressBook(\OCP\IAddressBook $address_book); |
|
| 143 | 143 | |
| 144 | - /** |
|
| 145 | - * Unregisters an address book |
|
| 146 | - * |
|
| 147 | - * @param \OCP\IAddressBook $address_book |
|
| 148 | - * @return void |
|
| 149 | - * @since 6.0.0 |
|
| 150 | - */ |
|
| 151 | - public function unregisterAddressBook(\OCP\IAddressBook $address_book); |
|
| 144 | + /** |
|
| 145 | + * Unregisters an address book |
|
| 146 | + * |
|
| 147 | + * @param \OCP\IAddressBook $address_book |
|
| 148 | + * @return void |
|
| 149 | + * @since 6.0.0 |
|
| 150 | + */ |
|
| 151 | + public function unregisterAddressBook(\OCP\IAddressBook $address_book); |
|
| 152 | 152 | |
| 153 | - /** |
|
| 154 | - * In order to improve lazy loading a closure can be registered which will be called in case |
|
| 155 | - * address books are actually requested |
|
| 156 | - * |
|
| 157 | - * @param \Closure $callable |
|
| 158 | - * @return void |
|
| 159 | - * @since 6.0.0 |
|
| 160 | - */ |
|
| 161 | - public function register(\Closure $callable); |
|
| 153 | + /** |
|
| 154 | + * In order to improve lazy loading a closure can be registered which will be called in case |
|
| 155 | + * address books are actually requested |
|
| 156 | + * |
|
| 157 | + * @param \Closure $callable |
|
| 158 | + * @return void |
|
| 159 | + * @since 6.0.0 |
|
| 160 | + */ |
|
| 161 | + public function register(\Closure $callable); |
|
| 162 | 162 | |
| 163 | - /** |
|
| 164 | - * Return a list of the user's addressbooks |
|
| 165 | - * |
|
| 166 | - * @return \OCP\IAddressBook[] |
|
| 167 | - * @since 16.0.0 |
|
| 168 | - */ |
|
| 169 | - public function getUserAddressBooks(); |
|
| 163 | + /** |
|
| 164 | + * Return a list of the user's addressbooks |
|
| 165 | + * |
|
| 166 | + * @return \OCP\IAddressBook[] |
|
| 167 | + * @since 16.0.0 |
|
| 168 | + */ |
|
| 169 | + public function getUserAddressBooks(); |
|
| 170 | 170 | |
| 171 | - /** |
|
| 172 | - * removes all registered address book instances |
|
| 173 | - * |
|
| 174 | - * @return void |
|
| 175 | - * @since 6.0.0 |
|
| 176 | - */ |
|
| 177 | - public function clear(); |
|
| 171 | + /** |
|
| 172 | + * removes all registered address book instances |
|
| 173 | + * |
|
| 174 | + * @return void |
|
| 175 | + * @since 6.0.0 |
|
| 176 | + */ |
|
| 177 | + public function clear(); |
|
| 178 | 178 | } |
@@ -56,566 +56,566 @@ |
||
| 56 | 56 | * @since 4.0.0 |
| 57 | 57 | */ |
| 58 | 58 | class Util { |
| 59 | - /** @var \OCP\Share\IManager */ |
|
| 60 | - private static $shareManager; |
|
| 61 | - |
|
| 62 | - /** @var array */ |
|
| 63 | - private static $scripts = []; |
|
| 64 | - |
|
| 65 | - /** @var array */ |
|
| 66 | - private static $scriptDeps = []; |
|
| 67 | - |
|
| 68 | - /** @var array */ |
|
| 69 | - private static $sortedScriptDeps = []; |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * get the current installed version of Nextcloud |
|
| 73 | - * @return array |
|
| 74 | - * @since 4.0.0 |
|
| 75 | - */ |
|
| 76 | - public static function getVersion() { |
|
| 77 | - return \OC_Util::getVersion(); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * @since 17.0.0 |
|
| 82 | - */ |
|
| 83 | - public static function hasExtendedSupport(): bool { |
|
| 84 | - try { |
|
| 85 | - /** @var \OCP\Support\Subscription\IRegistry */ |
|
| 86 | - $subscriptionRegistry = \OC::$server->query(\OCP\Support\Subscription\IRegistry::class); |
|
| 87 | - return $subscriptionRegistry->delegateHasExtendedSupport(); |
|
| 88 | - } catch (AppFramework\QueryException $e) { |
|
| 89 | - } |
|
| 90 | - return \OC::$server->getConfig()->getSystemValueBool('extendedSupport', false); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * Set current update channel |
|
| 95 | - * @param string $channel |
|
| 96 | - * @since 8.1.0 |
|
| 97 | - */ |
|
| 98 | - public static function setChannel($channel) { |
|
| 99 | - \OC::$server->getConfig()->setSystemValue('updater.release.channel', $channel); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * Get current update channel |
|
| 104 | - * @return string |
|
| 105 | - * @since 8.1.0 |
|
| 106 | - */ |
|
| 107 | - public static function getChannel() { |
|
| 108 | - return \OC_Util::getChannel(); |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - /** |
|
| 112 | - * write a message in the log |
|
| 113 | - * @param string $app |
|
| 114 | - * @param string $message |
|
| 115 | - * @param int $level |
|
| 116 | - * @since 4.0.0 |
|
| 117 | - * @deprecated 13.0.0 use log of \OCP\ILogger |
|
| 118 | - */ |
|
| 119 | - public static function writeLog($app, $message, $level) { |
|
| 120 | - $context = ['app' => $app]; |
|
| 121 | - \OC::$server->getLogger()->log($level, $message, $context); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * check if sharing is disabled for the current user |
|
| 126 | - * |
|
| 127 | - * @return boolean |
|
| 128 | - * @since 7.0.0 |
|
| 129 | - * @deprecated 9.1.0 Use \OC::$server->getShareManager()->sharingDisabledForUser |
|
| 130 | - */ |
|
| 131 | - public static function isSharingDisabledForUser() { |
|
| 132 | - if (self::$shareManager === null) { |
|
| 133 | - self::$shareManager = \OC::$server->getShareManager(); |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - $user = \OC::$server->getUserSession()->getUser(); |
|
| 137 | - if ($user !== null) { |
|
| 138 | - $user = $user->getUID(); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - return self::$shareManager->sharingDisabledForUser($user); |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * get l10n object |
|
| 146 | - * @param string $application |
|
| 147 | - * @param string|null $language |
|
| 148 | - * @return \OCP\IL10N |
|
| 149 | - * @since 6.0.0 - parameter $language was added in 8.0.0 |
|
| 150 | - */ |
|
| 151 | - public static function getL10N($application, $language = null) { |
|
| 152 | - return \OC::$server->getL10N($application, $language); |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * add a css file |
|
| 157 | - * @param string $application |
|
| 158 | - * @param string $file |
|
| 159 | - * @since 4.0.0 |
|
| 160 | - */ |
|
| 161 | - public static function addStyle($application, $file = null) { |
|
| 162 | - \OC_Util::addStyle($application, $file); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - /** |
|
| 166 | - * add a javascript file |
|
| 167 | - * |
|
| 168 | - * @param string $application |
|
| 169 | - * @param string|null $file |
|
| 170 | - * @param string $afterAppId |
|
| 171 | - * @since 4.0.0 |
|
| 172 | - */ |
|
| 173 | - public static function addScript(string $application, string $file = null, string $afterAppId = 'core'): void { |
|
| 174 | - if (!empty($application)) { |
|
| 175 | - $path = "$application/js/$file"; |
|
| 176 | - } else { |
|
| 177 | - $path = "js/$file"; |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - // Inject js translations if we load a script for |
|
| 181 | - // a specific app that is not core, as those js files |
|
| 182 | - // need separate handling |
|
| 183 | - if ($application !== 'core' |
|
| 184 | - && $file !== null |
|
| 185 | - && strpos($file, 'l10n') === false) { |
|
| 186 | - self::addTranslations($application); |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - // store app in dependency list |
|
| 190 | - if (!array_key_exists($application, self::$scriptDeps)) { |
|
| 191 | - self::$scriptDeps[$application] = new AppScriptDependency($application, [$afterAppId]); |
|
| 192 | - } else { |
|
| 193 | - self::$scriptDeps[$application]->addDep($afterAppId); |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - self::$scripts[$application][] = $path; |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - /** |
|
| 200 | - * Return the list of scripts injected to the page |
|
| 201 | - * |
|
| 202 | - * @return array |
|
| 203 | - * @since 24.0.0 |
|
| 204 | - */ |
|
| 205 | - public static function getScripts(): array { |
|
| 206 | - // Sort scriptDeps into sortedScriptDeps |
|
| 207 | - $scriptSort = \OC::$server->get(AppScriptSort::class); |
|
| 208 | - $sortedScripts = $scriptSort->sort(self::$scripts, self::$scriptDeps); |
|
| 209 | - |
|
| 210 | - // Flatten array and remove duplicates |
|
| 211 | - $sortedScripts = $sortedScripts ? array_merge(...array_values(($sortedScripts))) : []; |
|
| 212 | - |
|
| 213 | - // Override core-common and core-main order |
|
| 214 | - array_unshift($sortedScripts, 'core/js/common', 'core/js/main'); |
|
| 215 | - |
|
| 216 | - return array_unique($sortedScripts); |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - /** |
|
| 220 | - * Add a translation JS file |
|
| 221 | - * @param string $application application id |
|
| 222 | - * @param string $languageCode language code, defaults to the current locale |
|
| 223 | - * @since 8.0.0 |
|
| 224 | - */ |
|
| 225 | - public static function addTranslations($application, $languageCode = null) { |
|
| 226 | - if (is_null($languageCode)) { |
|
| 227 | - $languageCode = \OC::$server->getL10NFactory()->findLanguage($application); |
|
| 228 | - } |
|
| 229 | - if (!empty($application)) { |
|
| 230 | - $path = "$application/l10n/$languageCode"; |
|
| 231 | - } else { |
|
| 232 | - $path = "l10n/$languageCode"; |
|
| 233 | - } |
|
| 234 | - self::$scripts[$application][] = $path; |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - /** |
|
| 238 | - * Add a custom element to the header |
|
| 239 | - * If $text is null then the element will be written as empty element. |
|
| 240 | - * So use "" to get a closing tag. |
|
| 241 | - * @param string $tag tag name of the element |
|
| 242 | - * @param array $attributes array of attributes for the element |
|
| 243 | - * @param string $text the text content for the element |
|
| 244 | - * @since 4.0.0 |
|
| 245 | - */ |
|
| 246 | - public static function addHeader($tag, $attributes, $text = null) { |
|
| 247 | - \OC_Util::addHeader($tag, $attributes, $text); |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - /** |
|
| 251 | - * Creates an absolute url to the given app and file. |
|
| 252 | - * @param string $app app |
|
| 253 | - * @param string $file file |
|
| 254 | - * @param array $args array with param=>value, will be appended to the returned url |
|
| 255 | - * The value of $args will be urlencoded |
|
| 256 | - * @return string the url |
|
| 257 | - * @since 4.0.0 - parameter $args was added in 4.5.0 |
|
| 258 | - */ |
|
| 259 | - public static function linkToAbsolute($app, $file, $args = []) { |
|
| 260 | - $urlGenerator = \OC::$server->getURLGenerator(); |
|
| 261 | - return $urlGenerator->getAbsoluteURL( |
|
| 262 | - $urlGenerator->linkTo($app, $file, $args) |
|
| 263 | - ); |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - /** |
|
| 267 | - * Creates an absolute url for remote use. |
|
| 268 | - * @param string $service id |
|
| 269 | - * @return string the url |
|
| 270 | - * @since 4.0.0 |
|
| 271 | - */ |
|
| 272 | - public static function linkToRemote($service) { |
|
| 273 | - $urlGenerator = \OC::$server->getURLGenerator(); |
|
| 274 | - $remoteBase = $urlGenerator->linkTo('', 'remote.php') . '/' . $service; |
|
| 275 | - return $urlGenerator->getAbsoluteURL( |
|
| 276 | - $remoteBase . (($service[strlen($service) - 1] != '/') ? '/' : '') |
|
| 277 | - ); |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - /** |
|
| 281 | - * Creates an absolute url for public use |
|
| 282 | - * @param string $service id |
|
| 283 | - * @return string the url |
|
| 284 | - * @since 4.5.0 |
|
| 285 | - * @deprecated 15.0.0 - use OCP\IURLGenerator |
|
| 286 | - */ |
|
| 287 | - public static function linkToPublic($service) { |
|
| 288 | - $urlGenerator = \OC::$server->getURLGenerator(); |
|
| 289 | - if ($service === 'files') { |
|
| 290 | - return $urlGenerator->getAbsoluteURL('/s'); |
|
| 291 | - } |
|
| 292 | - return $urlGenerator->getAbsoluteURL($urlGenerator->linkTo('', 'public.php').'?service='.$service); |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - /** |
|
| 296 | - * Returns the server host name without an eventual port number |
|
| 297 | - * @return string the server hostname |
|
| 298 | - * @since 5.0.0 |
|
| 299 | - */ |
|
| 300 | - public static function getServerHostName() { |
|
| 301 | - $host_name = \OC::$server->getRequest()->getServerHost(); |
|
| 302 | - // strip away port number (if existing) |
|
| 303 | - $colon_pos = strpos($host_name, ':'); |
|
| 304 | - if ($colon_pos != false) { |
|
| 305 | - $host_name = substr($host_name, 0, $colon_pos); |
|
| 306 | - } |
|
| 307 | - return $host_name; |
|
| 308 | - } |
|
| 309 | - |
|
| 310 | - /** |
|
| 311 | - * Returns the default email address |
|
| 312 | - * @param string $user_part the user part of the address |
|
| 313 | - * @return string the default email address |
|
| 314 | - * |
|
| 315 | - * Assembles a default email address (using the server hostname |
|
| 316 | - * and the given user part, and returns it |
|
| 317 | - * Example: when given lostpassword-noreply as $user_part param, |
|
| 318 | - * and is currently accessed via http(s)://example.com/, |
|
| 319 | - * it would return '[email protected]' |
|
| 320 | - * |
|
| 321 | - * If the configuration value 'mail_from_address' is set in |
|
| 322 | - * config.php, this value will override the $user_part that |
|
| 323 | - * is passed to this function |
|
| 324 | - * @since 5.0.0 |
|
| 325 | - */ |
|
| 326 | - public static function getDefaultEmailAddress(string $user_part): string { |
|
| 327 | - $config = \OC::$server->getConfig(); |
|
| 328 | - $user_part = $config->getSystemValueString('mail_from_address', $user_part); |
|
| 329 | - $host_name = self::getServerHostName(); |
|
| 330 | - $host_name = $config->getSystemValueString('mail_domain', $host_name); |
|
| 331 | - $defaultEmailAddress = $user_part.'@'.$host_name; |
|
| 332 | - |
|
| 333 | - $mailer = \OC::$server->getMailer(); |
|
| 334 | - if ($mailer->validateMailAddress($defaultEmailAddress)) { |
|
| 335 | - return $defaultEmailAddress; |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - // in case we cannot build a valid email address from the hostname let's fallback to 'localhost.localdomain' |
|
| 339 | - return $user_part.'@localhost.localdomain'; |
|
| 340 | - } |
|
| 341 | - |
|
| 342 | - /** |
|
| 343 | - * Converts string to int of float depending if it fits an int |
|
| 344 | - * @param numeric-string|float|int $number numeric string |
|
| 345 | - * @return int|float int if it fits, float if it is too big |
|
| 346 | - * @since 26.0.0 |
|
| 347 | - */ |
|
| 348 | - public static function numericToNumber(string|float|int $number): int|float { |
|
| 349 | - /* This is a hack to cast to (int|float) */ |
|
| 350 | - return 0 + (string)$number; |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - /** |
|
| 354 | - * Make a human file size (2048 to 2 kB) |
|
| 355 | - * @param int|float $bytes file size in bytes |
|
| 356 | - * @return string a human readable file size |
|
| 357 | - * @since 4.0.0 |
|
| 358 | - */ |
|
| 359 | - public static function humanFileSize(int|float $bytes): string { |
|
| 360 | - return \OC_Helper::humanFileSize($bytes); |
|
| 361 | - } |
|
| 362 | - |
|
| 363 | - /** |
|
| 364 | - * Make a computer file size (2 kB to 2048) |
|
| 365 | - * @param string $str file size in a fancy format |
|
| 366 | - * @return false|int|float a file size in bytes |
|
| 367 | - * |
|
| 368 | - * Inspired by: https://www.php.net/manual/en/function.filesize.php#92418 |
|
| 369 | - * @since 4.0.0 |
|
| 370 | - */ |
|
| 371 | - public static function computerFileSize(string $str): false|int|float { |
|
| 372 | - return \OC_Helper::computerFileSize($str); |
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - /** |
|
| 376 | - * connects a function to a hook |
|
| 377 | - * |
|
| 378 | - * @param string $signalClass class name of emitter |
|
| 379 | - * @param string $signalName name of signal |
|
| 380 | - * @param string|object $slotClass class name of slot |
|
| 381 | - * @param string $slotName name of slot |
|
| 382 | - * @return bool |
|
| 383 | - * |
|
| 384 | - * This function makes it very easy to connect to use hooks. |
|
| 385 | - * |
|
| 386 | - * TODO: write example |
|
| 387 | - * @since 4.0.0 |
|
| 388 | - * @deprecated 21.0.0 use \OCP\EventDispatcher\IEventDispatcher::addListener |
|
| 389 | - */ |
|
| 390 | - public static function connectHook($signalClass, $signalName, $slotClass, $slotName) { |
|
| 391 | - return \OC_Hook::connect($signalClass, $signalName, $slotClass, $slotName); |
|
| 392 | - } |
|
| 393 | - |
|
| 394 | - /** |
|
| 395 | - * Emits a signal. To get data from the slot use references! |
|
| 396 | - * @param string $signalclass class name of emitter |
|
| 397 | - * @param string $signalname name of signal |
|
| 398 | - * @param array $params default: array() array with additional data |
|
| 399 | - * @return bool true if slots exists or false if not |
|
| 400 | - * |
|
| 401 | - * TODO: write example |
|
| 402 | - * @since 4.0.0 |
|
| 403 | - * @deprecated 21.0.0 use \OCP\EventDispatcher\IEventDispatcher::dispatchTypedEvent |
|
| 404 | - */ |
|
| 405 | - public static function emitHook($signalclass, $signalname, $params = []) { |
|
| 406 | - return \OC_Hook::emit($signalclass, $signalname, $params); |
|
| 407 | - } |
|
| 408 | - |
|
| 409 | - /** |
|
| 410 | - * Cached encrypted CSRF token. Some static unit-tests of ownCloud compare |
|
| 411 | - * multiple OC_Template elements which invoke `callRegister`. If the value |
|
| 412 | - * would not be cached these unit-tests would fail. |
|
| 413 | - * @var string |
|
| 414 | - */ |
|
| 415 | - private static $token = ''; |
|
| 416 | - |
|
| 417 | - /** |
|
| 418 | - * Register an get/post call. This is important to prevent CSRF attacks |
|
| 419 | - * @since 4.5.0 |
|
| 420 | - */ |
|
| 421 | - public static function callRegister() { |
|
| 422 | - if (self::$token === '') { |
|
| 423 | - self::$token = \OC::$server->getCsrfTokenManager()->getToken()->getEncryptedValue(); |
|
| 424 | - } |
|
| 425 | - return self::$token; |
|
| 426 | - } |
|
| 427 | - |
|
| 428 | - /** |
|
| 429 | - * Used to sanitize HTML |
|
| 430 | - * |
|
| 431 | - * This function is used to sanitize HTML and should be applied on any |
|
| 432 | - * string or array of strings before displaying it on a web page. |
|
| 433 | - * |
|
| 434 | - * @param string|string[] $value |
|
| 435 | - * @return string|string[] an array of sanitized strings or a single sanitized string, depends on the input parameter. |
|
| 436 | - * @since 4.5.0 |
|
| 437 | - */ |
|
| 438 | - public static function sanitizeHTML($value) { |
|
| 439 | - return \OC_Util::sanitizeHTML($value); |
|
| 440 | - } |
|
| 441 | - |
|
| 442 | - /** |
|
| 443 | - * Public function to encode url parameters |
|
| 444 | - * |
|
| 445 | - * This function is used to encode path to file before output. |
|
| 446 | - * Encoding is done according to RFC 3986 with one exception: |
|
| 447 | - * Character '/' is preserved as is. |
|
| 448 | - * |
|
| 449 | - * @param string $component part of URI to encode |
|
| 450 | - * @return string |
|
| 451 | - * @since 6.0.0 |
|
| 452 | - */ |
|
| 453 | - public static function encodePath($component) { |
|
| 454 | - return \OC_Util::encodePath($component); |
|
| 455 | - } |
|
| 456 | - |
|
| 457 | - /** |
|
| 458 | - * Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is. |
|
| 459 | - * |
|
| 460 | - * @param array $input The array to work on |
|
| 461 | - * @param int $case Either MB_CASE_UPPER or MB_CASE_LOWER (default) |
|
| 462 | - * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8 |
|
| 463 | - * @return array |
|
| 464 | - * @since 4.5.0 |
|
| 465 | - */ |
|
| 466 | - public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8') { |
|
| 467 | - return \OC_Helper::mb_array_change_key_case($input, $case, $encoding); |
|
| 468 | - } |
|
| 469 | - |
|
| 470 | - /** |
|
| 471 | - * performs a search in a nested array |
|
| 472 | - * |
|
| 473 | - * @param array $haystack the array to be searched |
|
| 474 | - * @param string $needle the search string |
|
| 475 | - * @param mixed $index optional, only search this key name |
|
| 476 | - * @return mixed the key of the matching field, otherwise false |
|
| 477 | - * @since 4.5.0 |
|
| 478 | - * @deprecated 15.0.0 |
|
| 479 | - */ |
|
| 480 | - public static function recursiveArraySearch($haystack, $needle, $index = null) { |
|
| 481 | - return \OC_Helper::recursiveArraySearch($haystack, $needle, $index); |
|
| 482 | - } |
|
| 483 | - |
|
| 484 | - /** |
|
| 485 | - * calculates the maximum upload size respecting system settings, free space and user quota |
|
| 486 | - * |
|
| 487 | - * @param string $dir the current folder where the user currently operates |
|
| 488 | - * @param int|float|null $free the number of bytes free on the storage holding $dir, if not set this will be received from the storage directly |
|
| 489 | - * @return int|float number of bytes representing |
|
| 490 | - * @since 5.0.0 |
|
| 491 | - */ |
|
| 492 | - public static function maxUploadFilesize(string $dir, int|float|null $free = null): int|float { |
|
| 493 | - return \OC_Helper::maxUploadFilesize($dir, $free); |
|
| 494 | - } |
|
| 495 | - |
|
| 496 | - /** |
|
| 497 | - * Calculate free space left within user quota |
|
| 498 | - * @param string $dir the current folder where the user currently operates |
|
| 499 | - * @return int|float number of bytes representing |
|
| 500 | - * @since 7.0.0 |
|
| 501 | - */ |
|
| 502 | - public static function freeSpace(string $dir): int|float { |
|
| 503 | - return \OC_Helper::freeSpace($dir); |
|
| 504 | - } |
|
| 505 | - |
|
| 506 | - /** |
|
| 507 | - * Calculate PHP upload limit |
|
| 508 | - * |
|
| 509 | - * @return int|float number of bytes representing |
|
| 510 | - * @since 7.0.0 |
|
| 511 | - */ |
|
| 512 | - public static function uploadLimit(): int|float { |
|
| 513 | - return \OC_Helper::uploadLimit(); |
|
| 514 | - } |
|
| 515 | - |
|
| 516 | - /** |
|
| 517 | - * Returns whether the given file name is valid |
|
| 518 | - * @param string $file file name to check |
|
| 519 | - * @return bool true if the file name is valid, false otherwise |
|
| 520 | - * @deprecated 8.1.0 use \OC\Files\View::verifyPath() |
|
| 521 | - * @since 7.0.0 |
|
| 522 | - * @suppress PhanDeprecatedFunction |
|
| 523 | - */ |
|
| 524 | - public static function isValidFileName($file) { |
|
| 525 | - return \OC_Util::isValidFileName($file); |
|
| 526 | - } |
|
| 527 | - |
|
| 528 | - /** |
|
| 529 | - * Compare two strings to provide a natural sort |
|
| 530 | - * @param string $a first string to compare |
|
| 531 | - * @param string $b second string to compare |
|
| 532 | - * @return int -1 if $b comes before $a, 1 if $a comes before $b |
|
| 533 | - * or 0 if the strings are identical |
|
| 534 | - * @since 7.0.0 |
|
| 535 | - */ |
|
| 536 | - public static function naturalSortCompare($a, $b) { |
|
| 537 | - return \OC\NaturalSort::getInstance()->compare($a, $b); |
|
| 538 | - } |
|
| 539 | - |
|
| 540 | - /** |
|
| 541 | - * Check if a password is required for each public link |
|
| 542 | - * |
|
| 543 | - * @param bool $checkGroupMembership Check group membership exclusion |
|
| 544 | - * @return boolean |
|
| 545 | - * @since 7.0.0 |
|
| 546 | - */ |
|
| 547 | - public static function isPublicLinkPasswordRequired(bool $checkGroupMembership = true) { |
|
| 548 | - return \OC_Util::isPublicLinkPasswordRequired($checkGroupMembership); |
|
| 549 | - } |
|
| 550 | - |
|
| 551 | - /** |
|
| 552 | - * check if share API enforces a default expire date |
|
| 553 | - * @return boolean |
|
| 554 | - * @since 8.0.0 |
|
| 555 | - */ |
|
| 556 | - public static function isDefaultExpireDateEnforced() { |
|
| 557 | - return \OC_Util::isDefaultExpireDateEnforced(); |
|
| 558 | - } |
|
| 559 | - |
|
| 560 | - protected static $needUpgradeCache = null; |
|
| 561 | - |
|
| 562 | - /** |
|
| 563 | - * Checks whether the current version needs upgrade. |
|
| 564 | - * |
|
| 565 | - * @return bool true if upgrade is needed, false otherwise |
|
| 566 | - * @since 7.0.0 |
|
| 567 | - */ |
|
| 568 | - public static function needUpgrade() { |
|
| 569 | - if (!isset(self::$needUpgradeCache)) { |
|
| 570 | - self::$needUpgradeCache = \OC_Util::needUpgrade(\OC::$server->getSystemConfig()); |
|
| 571 | - } |
|
| 572 | - return self::$needUpgradeCache; |
|
| 573 | - } |
|
| 574 | - |
|
| 575 | - /** |
|
| 576 | - * Sometimes a string has to be shortened to fit within a certain maximum |
|
| 577 | - * data length in bytes. substr() you may break multibyte characters, |
|
| 578 | - * because it operates on single byte level. mb_substr() operates on |
|
| 579 | - * characters, so does not ensure that the shortened string satisfies the |
|
| 580 | - * max length in bytes. |
|
| 581 | - * |
|
| 582 | - * For example, json_encode is messing with multibyte characters a lot, |
|
| 583 | - * replacing them with something along "\u1234". |
|
| 584 | - * |
|
| 585 | - * This function shortens the string with by $accuracy (-5) from |
|
| 586 | - * $dataLength characters, until it fits within $dataLength bytes. |
|
| 587 | - * |
|
| 588 | - * @since 23.0.0 |
|
| 589 | - */ |
|
| 590 | - public static function shortenMultibyteString(string $subject, int $dataLength, int $accuracy = 5): string { |
|
| 591 | - $temp = mb_substr($subject, 0, $dataLength); |
|
| 592 | - // json encodes encapsulates the string in double quotes, they need to be substracted |
|
| 593 | - while ((strlen(json_encode($temp)) - 2) > $dataLength) { |
|
| 594 | - $temp = mb_substr($temp, 0, -$accuracy); |
|
| 595 | - } |
|
| 596 | - return $temp; |
|
| 597 | - } |
|
| 598 | - |
|
| 599 | - /** |
|
| 600 | - * Check if a function is enabled in the php configuration |
|
| 601 | - * |
|
| 602 | - * @since 25.0.0 |
|
| 603 | - */ |
|
| 604 | - public static function isFunctionEnabled(string $functionName): bool { |
|
| 605 | - if (!function_exists($functionName)) { |
|
| 606 | - return false; |
|
| 607 | - } |
|
| 608 | - $ini = \OCP\Server::get(IniGetWrapper::class); |
|
| 609 | - $disabled = explode(',', $ini->get('disable_functions') ?: ''); |
|
| 610 | - $disabled = array_map('trim', $disabled); |
|
| 611 | - if (in_array($functionName, $disabled)) { |
|
| 612 | - return false; |
|
| 613 | - } |
|
| 614 | - $disabled = explode(',', $ini->get('suhosin.executor.func.blacklist') ?: ''); |
|
| 615 | - $disabled = array_map('trim', $disabled); |
|
| 616 | - if (in_array($functionName, $disabled)) { |
|
| 617 | - return false; |
|
| 618 | - } |
|
| 619 | - return true; |
|
| 620 | - } |
|
| 59 | + /** @var \OCP\Share\IManager */ |
|
| 60 | + private static $shareManager; |
|
| 61 | + |
|
| 62 | + /** @var array */ |
|
| 63 | + private static $scripts = []; |
|
| 64 | + |
|
| 65 | + /** @var array */ |
|
| 66 | + private static $scriptDeps = []; |
|
| 67 | + |
|
| 68 | + /** @var array */ |
|
| 69 | + private static $sortedScriptDeps = []; |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * get the current installed version of Nextcloud |
|
| 73 | + * @return array |
|
| 74 | + * @since 4.0.0 |
|
| 75 | + */ |
|
| 76 | + public static function getVersion() { |
|
| 77 | + return \OC_Util::getVersion(); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * @since 17.0.0 |
|
| 82 | + */ |
|
| 83 | + public static function hasExtendedSupport(): bool { |
|
| 84 | + try { |
|
| 85 | + /** @var \OCP\Support\Subscription\IRegistry */ |
|
| 86 | + $subscriptionRegistry = \OC::$server->query(\OCP\Support\Subscription\IRegistry::class); |
|
| 87 | + return $subscriptionRegistry->delegateHasExtendedSupport(); |
|
| 88 | + } catch (AppFramework\QueryException $e) { |
|
| 89 | + } |
|
| 90 | + return \OC::$server->getConfig()->getSystemValueBool('extendedSupport', false); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * Set current update channel |
|
| 95 | + * @param string $channel |
|
| 96 | + * @since 8.1.0 |
|
| 97 | + */ |
|
| 98 | + public static function setChannel($channel) { |
|
| 99 | + \OC::$server->getConfig()->setSystemValue('updater.release.channel', $channel); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * Get current update channel |
|
| 104 | + * @return string |
|
| 105 | + * @since 8.1.0 |
|
| 106 | + */ |
|
| 107 | + public static function getChannel() { |
|
| 108 | + return \OC_Util::getChannel(); |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + /** |
|
| 112 | + * write a message in the log |
|
| 113 | + * @param string $app |
|
| 114 | + * @param string $message |
|
| 115 | + * @param int $level |
|
| 116 | + * @since 4.0.0 |
|
| 117 | + * @deprecated 13.0.0 use log of \OCP\ILogger |
|
| 118 | + */ |
|
| 119 | + public static function writeLog($app, $message, $level) { |
|
| 120 | + $context = ['app' => $app]; |
|
| 121 | + \OC::$server->getLogger()->log($level, $message, $context); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * check if sharing is disabled for the current user |
|
| 126 | + * |
|
| 127 | + * @return boolean |
|
| 128 | + * @since 7.0.0 |
|
| 129 | + * @deprecated 9.1.0 Use \OC::$server->getShareManager()->sharingDisabledForUser |
|
| 130 | + */ |
|
| 131 | + public static function isSharingDisabledForUser() { |
|
| 132 | + if (self::$shareManager === null) { |
|
| 133 | + self::$shareManager = \OC::$server->getShareManager(); |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + $user = \OC::$server->getUserSession()->getUser(); |
|
| 137 | + if ($user !== null) { |
|
| 138 | + $user = $user->getUID(); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + return self::$shareManager->sharingDisabledForUser($user); |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * get l10n object |
|
| 146 | + * @param string $application |
|
| 147 | + * @param string|null $language |
|
| 148 | + * @return \OCP\IL10N |
|
| 149 | + * @since 6.0.0 - parameter $language was added in 8.0.0 |
|
| 150 | + */ |
|
| 151 | + public static function getL10N($application, $language = null) { |
|
| 152 | + return \OC::$server->getL10N($application, $language); |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * add a css file |
|
| 157 | + * @param string $application |
|
| 158 | + * @param string $file |
|
| 159 | + * @since 4.0.0 |
|
| 160 | + */ |
|
| 161 | + public static function addStyle($application, $file = null) { |
|
| 162 | + \OC_Util::addStyle($application, $file); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + /** |
|
| 166 | + * add a javascript file |
|
| 167 | + * |
|
| 168 | + * @param string $application |
|
| 169 | + * @param string|null $file |
|
| 170 | + * @param string $afterAppId |
|
| 171 | + * @since 4.0.0 |
|
| 172 | + */ |
|
| 173 | + public static function addScript(string $application, string $file = null, string $afterAppId = 'core'): void { |
|
| 174 | + if (!empty($application)) { |
|
| 175 | + $path = "$application/js/$file"; |
|
| 176 | + } else { |
|
| 177 | + $path = "js/$file"; |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + // Inject js translations if we load a script for |
|
| 181 | + // a specific app that is not core, as those js files |
|
| 182 | + // need separate handling |
|
| 183 | + if ($application !== 'core' |
|
| 184 | + && $file !== null |
|
| 185 | + && strpos($file, 'l10n') === false) { |
|
| 186 | + self::addTranslations($application); |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + // store app in dependency list |
|
| 190 | + if (!array_key_exists($application, self::$scriptDeps)) { |
|
| 191 | + self::$scriptDeps[$application] = new AppScriptDependency($application, [$afterAppId]); |
|
| 192 | + } else { |
|
| 193 | + self::$scriptDeps[$application]->addDep($afterAppId); |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + self::$scripts[$application][] = $path; |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + /** |
|
| 200 | + * Return the list of scripts injected to the page |
|
| 201 | + * |
|
| 202 | + * @return array |
|
| 203 | + * @since 24.0.0 |
|
| 204 | + */ |
|
| 205 | + public static function getScripts(): array { |
|
| 206 | + // Sort scriptDeps into sortedScriptDeps |
|
| 207 | + $scriptSort = \OC::$server->get(AppScriptSort::class); |
|
| 208 | + $sortedScripts = $scriptSort->sort(self::$scripts, self::$scriptDeps); |
|
| 209 | + |
|
| 210 | + // Flatten array and remove duplicates |
|
| 211 | + $sortedScripts = $sortedScripts ? array_merge(...array_values(($sortedScripts))) : []; |
|
| 212 | + |
|
| 213 | + // Override core-common and core-main order |
|
| 214 | + array_unshift($sortedScripts, 'core/js/common', 'core/js/main'); |
|
| 215 | + |
|
| 216 | + return array_unique($sortedScripts); |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + /** |
|
| 220 | + * Add a translation JS file |
|
| 221 | + * @param string $application application id |
|
| 222 | + * @param string $languageCode language code, defaults to the current locale |
|
| 223 | + * @since 8.0.0 |
|
| 224 | + */ |
|
| 225 | + public static function addTranslations($application, $languageCode = null) { |
|
| 226 | + if (is_null($languageCode)) { |
|
| 227 | + $languageCode = \OC::$server->getL10NFactory()->findLanguage($application); |
|
| 228 | + } |
|
| 229 | + if (!empty($application)) { |
|
| 230 | + $path = "$application/l10n/$languageCode"; |
|
| 231 | + } else { |
|
| 232 | + $path = "l10n/$languageCode"; |
|
| 233 | + } |
|
| 234 | + self::$scripts[$application][] = $path; |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + /** |
|
| 238 | + * Add a custom element to the header |
|
| 239 | + * If $text is null then the element will be written as empty element. |
|
| 240 | + * So use "" to get a closing tag. |
|
| 241 | + * @param string $tag tag name of the element |
|
| 242 | + * @param array $attributes array of attributes for the element |
|
| 243 | + * @param string $text the text content for the element |
|
| 244 | + * @since 4.0.0 |
|
| 245 | + */ |
|
| 246 | + public static function addHeader($tag, $attributes, $text = null) { |
|
| 247 | + \OC_Util::addHeader($tag, $attributes, $text); |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + /** |
|
| 251 | + * Creates an absolute url to the given app and file. |
|
| 252 | + * @param string $app app |
|
| 253 | + * @param string $file file |
|
| 254 | + * @param array $args array with param=>value, will be appended to the returned url |
|
| 255 | + * The value of $args will be urlencoded |
|
| 256 | + * @return string the url |
|
| 257 | + * @since 4.0.0 - parameter $args was added in 4.5.0 |
|
| 258 | + */ |
|
| 259 | + public static function linkToAbsolute($app, $file, $args = []) { |
|
| 260 | + $urlGenerator = \OC::$server->getURLGenerator(); |
|
| 261 | + return $urlGenerator->getAbsoluteURL( |
|
| 262 | + $urlGenerator->linkTo($app, $file, $args) |
|
| 263 | + ); |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + /** |
|
| 267 | + * Creates an absolute url for remote use. |
|
| 268 | + * @param string $service id |
|
| 269 | + * @return string the url |
|
| 270 | + * @since 4.0.0 |
|
| 271 | + */ |
|
| 272 | + public static function linkToRemote($service) { |
|
| 273 | + $urlGenerator = \OC::$server->getURLGenerator(); |
|
| 274 | + $remoteBase = $urlGenerator->linkTo('', 'remote.php') . '/' . $service; |
|
| 275 | + return $urlGenerator->getAbsoluteURL( |
|
| 276 | + $remoteBase . (($service[strlen($service) - 1] != '/') ? '/' : '') |
|
| 277 | + ); |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + /** |
|
| 281 | + * Creates an absolute url for public use |
|
| 282 | + * @param string $service id |
|
| 283 | + * @return string the url |
|
| 284 | + * @since 4.5.0 |
|
| 285 | + * @deprecated 15.0.0 - use OCP\IURLGenerator |
|
| 286 | + */ |
|
| 287 | + public static function linkToPublic($service) { |
|
| 288 | + $urlGenerator = \OC::$server->getURLGenerator(); |
|
| 289 | + if ($service === 'files') { |
|
| 290 | + return $urlGenerator->getAbsoluteURL('/s'); |
|
| 291 | + } |
|
| 292 | + return $urlGenerator->getAbsoluteURL($urlGenerator->linkTo('', 'public.php').'?service='.$service); |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + /** |
|
| 296 | + * Returns the server host name without an eventual port number |
|
| 297 | + * @return string the server hostname |
|
| 298 | + * @since 5.0.0 |
|
| 299 | + */ |
|
| 300 | + public static function getServerHostName() { |
|
| 301 | + $host_name = \OC::$server->getRequest()->getServerHost(); |
|
| 302 | + // strip away port number (if existing) |
|
| 303 | + $colon_pos = strpos($host_name, ':'); |
|
| 304 | + if ($colon_pos != false) { |
|
| 305 | + $host_name = substr($host_name, 0, $colon_pos); |
|
| 306 | + } |
|
| 307 | + return $host_name; |
|
| 308 | + } |
|
| 309 | + |
|
| 310 | + /** |
|
| 311 | + * Returns the default email address |
|
| 312 | + * @param string $user_part the user part of the address |
|
| 313 | + * @return string the default email address |
|
| 314 | + * |
|
| 315 | + * Assembles a default email address (using the server hostname |
|
| 316 | + * and the given user part, and returns it |
|
| 317 | + * Example: when given lostpassword-noreply as $user_part param, |
|
| 318 | + * and is currently accessed via http(s)://example.com/, |
|
| 319 | + * it would return '[email protected]' |
|
| 320 | + * |
|
| 321 | + * If the configuration value 'mail_from_address' is set in |
|
| 322 | + * config.php, this value will override the $user_part that |
|
| 323 | + * is passed to this function |
|
| 324 | + * @since 5.0.0 |
|
| 325 | + */ |
|
| 326 | + public static function getDefaultEmailAddress(string $user_part): string { |
|
| 327 | + $config = \OC::$server->getConfig(); |
|
| 328 | + $user_part = $config->getSystemValueString('mail_from_address', $user_part); |
|
| 329 | + $host_name = self::getServerHostName(); |
|
| 330 | + $host_name = $config->getSystemValueString('mail_domain', $host_name); |
|
| 331 | + $defaultEmailAddress = $user_part.'@'.$host_name; |
|
| 332 | + |
|
| 333 | + $mailer = \OC::$server->getMailer(); |
|
| 334 | + if ($mailer->validateMailAddress($defaultEmailAddress)) { |
|
| 335 | + return $defaultEmailAddress; |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + // in case we cannot build a valid email address from the hostname let's fallback to 'localhost.localdomain' |
|
| 339 | + return $user_part.'@localhost.localdomain'; |
|
| 340 | + } |
|
| 341 | + |
|
| 342 | + /** |
|
| 343 | + * Converts string to int of float depending if it fits an int |
|
| 344 | + * @param numeric-string|float|int $number numeric string |
|
| 345 | + * @return int|float int if it fits, float if it is too big |
|
| 346 | + * @since 26.0.0 |
|
| 347 | + */ |
|
| 348 | + public static function numericToNumber(string|float|int $number): int|float { |
|
| 349 | + /* This is a hack to cast to (int|float) */ |
|
| 350 | + return 0 + (string)$number; |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + /** |
|
| 354 | + * Make a human file size (2048 to 2 kB) |
|
| 355 | + * @param int|float $bytes file size in bytes |
|
| 356 | + * @return string a human readable file size |
|
| 357 | + * @since 4.0.0 |
|
| 358 | + */ |
|
| 359 | + public static function humanFileSize(int|float $bytes): string { |
|
| 360 | + return \OC_Helper::humanFileSize($bytes); |
|
| 361 | + } |
|
| 362 | + |
|
| 363 | + /** |
|
| 364 | + * Make a computer file size (2 kB to 2048) |
|
| 365 | + * @param string $str file size in a fancy format |
|
| 366 | + * @return false|int|float a file size in bytes |
|
| 367 | + * |
|
| 368 | + * Inspired by: https://www.php.net/manual/en/function.filesize.php#92418 |
|
| 369 | + * @since 4.0.0 |
|
| 370 | + */ |
|
| 371 | + public static function computerFileSize(string $str): false|int|float { |
|
| 372 | + return \OC_Helper::computerFileSize($str); |
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + /** |
|
| 376 | + * connects a function to a hook |
|
| 377 | + * |
|
| 378 | + * @param string $signalClass class name of emitter |
|
| 379 | + * @param string $signalName name of signal |
|
| 380 | + * @param string|object $slotClass class name of slot |
|
| 381 | + * @param string $slotName name of slot |
|
| 382 | + * @return bool |
|
| 383 | + * |
|
| 384 | + * This function makes it very easy to connect to use hooks. |
|
| 385 | + * |
|
| 386 | + * TODO: write example |
|
| 387 | + * @since 4.0.0 |
|
| 388 | + * @deprecated 21.0.0 use \OCP\EventDispatcher\IEventDispatcher::addListener |
|
| 389 | + */ |
|
| 390 | + public static function connectHook($signalClass, $signalName, $slotClass, $slotName) { |
|
| 391 | + return \OC_Hook::connect($signalClass, $signalName, $slotClass, $slotName); |
|
| 392 | + } |
|
| 393 | + |
|
| 394 | + /** |
|
| 395 | + * Emits a signal. To get data from the slot use references! |
|
| 396 | + * @param string $signalclass class name of emitter |
|
| 397 | + * @param string $signalname name of signal |
|
| 398 | + * @param array $params default: array() array with additional data |
|
| 399 | + * @return bool true if slots exists or false if not |
|
| 400 | + * |
|
| 401 | + * TODO: write example |
|
| 402 | + * @since 4.0.0 |
|
| 403 | + * @deprecated 21.0.0 use \OCP\EventDispatcher\IEventDispatcher::dispatchTypedEvent |
|
| 404 | + */ |
|
| 405 | + public static function emitHook($signalclass, $signalname, $params = []) { |
|
| 406 | + return \OC_Hook::emit($signalclass, $signalname, $params); |
|
| 407 | + } |
|
| 408 | + |
|
| 409 | + /** |
|
| 410 | + * Cached encrypted CSRF token. Some static unit-tests of ownCloud compare |
|
| 411 | + * multiple OC_Template elements which invoke `callRegister`. If the value |
|
| 412 | + * would not be cached these unit-tests would fail. |
|
| 413 | + * @var string |
|
| 414 | + */ |
|
| 415 | + private static $token = ''; |
|
| 416 | + |
|
| 417 | + /** |
|
| 418 | + * Register an get/post call. This is important to prevent CSRF attacks |
|
| 419 | + * @since 4.5.0 |
|
| 420 | + */ |
|
| 421 | + public static function callRegister() { |
|
| 422 | + if (self::$token === '') { |
|
| 423 | + self::$token = \OC::$server->getCsrfTokenManager()->getToken()->getEncryptedValue(); |
|
| 424 | + } |
|
| 425 | + return self::$token; |
|
| 426 | + } |
|
| 427 | + |
|
| 428 | + /** |
|
| 429 | + * Used to sanitize HTML |
|
| 430 | + * |
|
| 431 | + * This function is used to sanitize HTML and should be applied on any |
|
| 432 | + * string or array of strings before displaying it on a web page. |
|
| 433 | + * |
|
| 434 | + * @param string|string[] $value |
|
| 435 | + * @return string|string[] an array of sanitized strings or a single sanitized string, depends on the input parameter. |
|
| 436 | + * @since 4.5.0 |
|
| 437 | + */ |
|
| 438 | + public static function sanitizeHTML($value) { |
|
| 439 | + return \OC_Util::sanitizeHTML($value); |
|
| 440 | + } |
|
| 441 | + |
|
| 442 | + /** |
|
| 443 | + * Public function to encode url parameters |
|
| 444 | + * |
|
| 445 | + * This function is used to encode path to file before output. |
|
| 446 | + * Encoding is done according to RFC 3986 with one exception: |
|
| 447 | + * Character '/' is preserved as is. |
|
| 448 | + * |
|
| 449 | + * @param string $component part of URI to encode |
|
| 450 | + * @return string |
|
| 451 | + * @since 6.0.0 |
|
| 452 | + */ |
|
| 453 | + public static function encodePath($component) { |
|
| 454 | + return \OC_Util::encodePath($component); |
|
| 455 | + } |
|
| 456 | + |
|
| 457 | + /** |
|
| 458 | + * Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is. |
|
| 459 | + * |
|
| 460 | + * @param array $input The array to work on |
|
| 461 | + * @param int $case Either MB_CASE_UPPER or MB_CASE_LOWER (default) |
|
| 462 | + * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8 |
|
| 463 | + * @return array |
|
| 464 | + * @since 4.5.0 |
|
| 465 | + */ |
|
| 466 | + public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8') { |
|
| 467 | + return \OC_Helper::mb_array_change_key_case($input, $case, $encoding); |
|
| 468 | + } |
|
| 469 | + |
|
| 470 | + /** |
|
| 471 | + * performs a search in a nested array |
|
| 472 | + * |
|
| 473 | + * @param array $haystack the array to be searched |
|
| 474 | + * @param string $needle the search string |
|
| 475 | + * @param mixed $index optional, only search this key name |
|
| 476 | + * @return mixed the key of the matching field, otherwise false |
|
| 477 | + * @since 4.5.0 |
|
| 478 | + * @deprecated 15.0.0 |
|
| 479 | + */ |
|
| 480 | + public static function recursiveArraySearch($haystack, $needle, $index = null) { |
|
| 481 | + return \OC_Helper::recursiveArraySearch($haystack, $needle, $index); |
|
| 482 | + } |
|
| 483 | + |
|
| 484 | + /** |
|
| 485 | + * calculates the maximum upload size respecting system settings, free space and user quota |
|
| 486 | + * |
|
| 487 | + * @param string $dir the current folder where the user currently operates |
|
| 488 | + * @param int|float|null $free the number of bytes free on the storage holding $dir, if not set this will be received from the storage directly |
|
| 489 | + * @return int|float number of bytes representing |
|
| 490 | + * @since 5.0.0 |
|
| 491 | + */ |
|
| 492 | + public static function maxUploadFilesize(string $dir, int|float|null $free = null): int|float { |
|
| 493 | + return \OC_Helper::maxUploadFilesize($dir, $free); |
|
| 494 | + } |
|
| 495 | + |
|
| 496 | + /** |
|
| 497 | + * Calculate free space left within user quota |
|
| 498 | + * @param string $dir the current folder where the user currently operates |
|
| 499 | + * @return int|float number of bytes representing |
|
| 500 | + * @since 7.0.0 |
|
| 501 | + */ |
|
| 502 | + public static function freeSpace(string $dir): int|float { |
|
| 503 | + return \OC_Helper::freeSpace($dir); |
|
| 504 | + } |
|
| 505 | + |
|
| 506 | + /** |
|
| 507 | + * Calculate PHP upload limit |
|
| 508 | + * |
|
| 509 | + * @return int|float number of bytes representing |
|
| 510 | + * @since 7.0.0 |
|
| 511 | + */ |
|
| 512 | + public static function uploadLimit(): int|float { |
|
| 513 | + return \OC_Helper::uploadLimit(); |
|
| 514 | + } |
|
| 515 | + |
|
| 516 | + /** |
|
| 517 | + * Returns whether the given file name is valid |
|
| 518 | + * @param string $file file name to check |
|
| 519 | + * @return bool true if the file name is valid, false otherwise |
|
| 520 | + * @deprecated 8.1.0 use \OC\Files\View::verifyPath() |
|
| 521 | + * @since 7.0.0 |
|
| 522 | + * @suppress PhanDeprecatedFunction |
|
| 523 | + */ |
|
| 524 | + public static function isValidFileName($file) { |
|
| 525 | + return \OC_Util::isValidFileName($file); |
|
| 526 | + } |
|
| 527 | + |
|
| 528 | + /** |
|
| 529 | + * Compare two strings to provide a natural sort |
|
| 530 | + * @param string $a first string to compare |
|
| 531 | + * @param string $b second string to compare |
|
| 532 | + * @return int -1 if $b comes before $a, 1 if $a comes before $b |
|
| 533 | + * or 0 if the strings are identical |
|
| 534 | + * @since 7.0.0 |
|
| 535 | + */ |
|
| 536 | + public static function naturalSortCompare($a, $b) { |
|
| 537 | + return \OC\NaturalSort::getInstance()->compare($a, $b); |
|
| 538 | + } |
|
| 539 | + |
|
| 540 | + /** |
|
| 541 | + * Check if a password is required for each public link |
|
| 542 | + * |
|
| 543 | + * @param bool $checkGroupMembership Check group membership exclusion |
|
| 544 | + * @return boolean |
|
| 545 | + * @since 7.0.0 |
|
| 546 | + */ |
|
| 547 | + public static function isPublicLinkPasswordRequired(bool $checkGroupMembership = true) { |
|
| 548 | + return \OC_Util::isPublicLinkPasswordRequired($checkGroupMembership); |
|
| 549 | + } |
|
| 550 | + |
|
| 551 | + /** |
|
| 552 | + * check if share API enforces a default expire date |
|
| 553 | + * @return boolean |
|
| 554 | + * @since 8.0.0 |
|
| 555 | + */ |
|
| 556 | + public static function isDefaultExpireDateEnforced() { |
|
| 557 | + return \OC_Util::isDefaultExpireDateEnforced(); |
|
| 558 | + } |
|
| 559 | + |
|
| 560 | + protected static $needUpgradeCache = null; |
|
| 561 | + |
|
| 562 | + /** |
|
| 563 | + * Checks whether the current version needs upgrade. |
|
| 564 | + * |
|
| 565 | + * @return bool true if upgrade is needed, false otherwise |
|
| 566 | + * @since 7.0.0 |
|
| 567 | + */ |
|
| 568 | + public static function needUpgrade() { |
|
| 569 | + if (!isset(self::$needUpgradeCache)) { |
|
| 570 | + self::$needUpgradeCache = \OC_Util::needUpgrade(\OC::$server->getSystemConfig()); |
|
| 571 | + } |
|
| 572 | + return self::$needUpgradeCache; |
|
| 573 | + } |
|
| 574 | + |
|
| 575 | + /** |
|
| 576 | + * Sometimes a string has to be shortened to fit within a certain maximum |
|
| 577 | + * data length in bytes. substr() you may break multibyte characters, |
|
| 578 | + * because it operates on single byte level. mb_substr() operates on |
|
| 579 | + * characters, so does not ensure that the shortened string satisfies the |
|
| 580 | + * max length in bytes. |
|
| 581 | + * |
|
| 582 | + * For example, json_encode is messing with multibyte characters a lot, |
|
| 583 | + * replacing them with something along "\u1234". |
|
| 584 | + * |
|
| 585 | + * This function shortens the string with by $accuracy (-5) from |
|
| 586 | + * $dataLength characters, until it fits within $dataLength bytes. |
|
| 587 | + * |
|
| 588 | + * @since 23.0.0 |
|
| 589 | + */ |
|
| 590 | + public static function shortenMultibyteString(string $subject, int $dataLength, int $accuracy = 5): string { |
|
| 591 | + $temp = mb_substr($subject, 0, $dataLength); |
|
| 592 | + // json encodes encapsulates the string in double quotes, they need to be substracted |
|
| 593 | + while ((strlen(json_encode($temp)) - 2) > $dataLength) { |
|
| 594 | + $temp = mb_substr($temp, 0, -$accuracy); |
|
| 595 | + } |
|
| 596 | + return $temp; |
|
| 597 | + } |
|
| 598 | + |
|
| 599 | + /** |
|
| 600 | + * Check if a function is enabled in the php configuration |
|
| 601 | + * |
|
| 602 | + * @since 25.0.0 |
|
| 603 | + */ |
|
| 604 | + public static function isFunctionEnabled(string $functionName): bool { |
|
| 605 | + if (!function_exists($functionName)) { |
|
| 606 | + return false; |
|
| 607 | + } |
|
| 608 | + $ini = \OCP\Server::get(IniGetWrapper::class); |
|
| 609 | + $disabled = explode(',', $ini->get('disable_functions') ?: ''); |
|
| 610 | + $disabled = array_map('trim', $disabled); |
|
| 611 | + if (in_array($functionName, $disabled)) { |
|
| 612 | + return false; |
|
| 613 | + } |
|
| 614 | + $disabled = explode(',', $ini->get('suhosin.executor.func.blacklist') ?: ''); |
|
| 615 | + $disabled = array_map('trim', $disabled); |
|
| 616 | + if (in_array($functionName, $disabled)) { |
|
| 617 | + return false; |
|
| 618 | + } |
|
| 619 | + return true; |
|
| 620 | + } |
|
| 621 | 621 | } |
@@ -39,110 +39,110 @@ |
||
| 39 | 39 | * @since 21.0.0 |
| 40 | 40 | */ |
| 41 | 41 | class Exception extends BaseException { |
| 42 | - /** |
|
| 43 | - * Nextcloud lost connection to the database |
|
| 44 | - * |
|
| 45 | - * @since 21.0.0 |
|
| 46 | - */ |
|
| 47 | - public const REASON_CONNECTION_LOST = 1; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * A database constraint was violated |
|
| 51 | - * |
|
| 52 | - * @since 21.0.0 |
|
| 53 | - */ |
|
| 54 | - public const REASON_CONSTRAINT_VIOLATION = 2; |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * A database object (table, column, index) already exists |
|
| 58 | - * |
|
| 59 | - * @since 21.0.0 |
|
| 60 | - */ |
|
| 61 | - public const REASON_DATABASE_OBJECT_EXISTS = 3; |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * A database object (table, column, index) can't be found |
|
| 65 | - * |
|
| 66 | - * @since 21.0.0 |
|
| 67 | - */ |
|
| 68 | - public const REASON_DATABASE_OBJECT_NOT_FOUND = 4; |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * The database ran into a deadlock |
|
| 72 | - * |
|
| 73 | - * @since 21.0.0 |
|
| 74 | - */ |
|
| 75 | - public const REASON_DEADLOCK = 5; |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * The database driver encountered an issue |
|
| 79 | - * |
|
| 80 | - * @since 21.0.0 |
|
| 81 | - */ |
|
| 82 | - public const REASON_DRIVER = 6; |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * A foreign key constraint was violated |
|
| 86 | - * |
|
| 87 | - * @since 21.0.0 |
|
| 88 | - */ |
|
| 89 | - public const REASON_FOREIGN_KEY_VIOLATION = 7; |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * An invalid argument was passed to the database abstraction |
|
| 93 | - * |
|
| 94 | - * @since 21.0.0 |
|
| 95 | - */ |
|
| 96 | - public const REASON_INVALID_ARGUMENT = 8; |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * A field name was invalid |
|
| 100 | - * |
|
| 101 | - * @since 21.0.0 |
|
| 102 | - */ |
|
| 103 | - public const REASON_INVALID_FIELD_NAME = 9; |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * A name in the query was ambiguous |
|
| 107 | - * |
|
| 108 | - * @since 21.0.0 |
|
| 109 | - */ |
|
| 110 | - public const REASON_NON_UNIQUE_FIELD_NAME = 10; |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * A not null constraint was violated |
|
| 114 | - * |
|
| 115 | - * @since 21.0.0 |
|
| 116 | - */ |
|
| 117 | - public const REASON_NOT_NULL_CONSTRAINT_VIOLATION = 11; |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * A generic server error was encountered |
|
| 121 | - * |
|
| 122 | - * @since 21.0.0 |
|
| 123 | - */ |
|
| 124 | - public const REASON_SERVER = 12; |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * A syntax error was reported by the server |
|
| 128 | - * |
|
| 129 | - * @since 21.0.0 |
|
| 130 | - */ |
|
| 131 | - public const REASON_SYNTAX_ERROR = 13; |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * A unique constraint was violated |
|
| 135 | - * |
|
| 136 | - * @since 21.0.0 |
|
| 137 | - */ |
|
| 138 | - public const REASON_UNIQUE_CONSTRAINT_VIOLATION = 14; |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * @return int|null |
|
| 142 | - * @psalm-return Exception::REASON_* |
|
| 143 | - * @since 21.0.0 |
|
| 144 | - */ |
|
| 145 | - public function getReason(): ?int { |
|
| 146 | - return null; |
|
| 147 | - } |
|
| 42 | + /** |
|
| 43 | + * Nextcloud lost connection to the database |
|
| 44 | + * |
|
| 45 | + * @since 21.0.0 |
|
| 46 | + */ |
|
| 47 | + public const REASON_CONNECTION_LOST = 1; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * A database constraint was violated |
|
| 51 | + * |
|
| 52 | + * @since 21.0.0 |
|
| 53 | + */ |
|
| 54 | + public const REASON_CONSTRAINT_VIOLATION = 2; |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * A database object (table, column, index) already exists |
|
| 58 | + * |
|
| 59 | + * @since 21.0.0 |
|
| 60 | + */ |
|
| 61 | + public const REASON_DATABASE_OBJECT_EXISTS = 3; |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * A database object (table, column, index) can't be found |
|
| 65 | + * |
|
| 66 | + * @since 21.0.0 |
|
| 67 | + */ |
|
| 68 | + public const REASON_DATABASE_OBJECT_NOT_FOUND = 4; |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * The database ran into a deadlock |
|
| 72 | + * |
|
| 73 | + * @since 21.0.0 |
|
| 74 | + */ |
|
| 75 | + public const REASON_DEADLOCK = 5; |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * The database driver encountered an issue |
|
| 79 | + * |
|
| 80 | + * @since 21.0.0 |
|
| 81 | + */ |
|
| 82 | + public const REASON_DRIVER = 6; |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * A foreign key constraint was violated |
|
| 86 | + * |
|
| 87 | + * @since 21.0.0 |
|
| 88 | + */ |
|
| 89 | + public const REASON_FOREIGN_KEY_VIOLATION = 7; |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * An invalid argument was passed to the database abstraction |
|
| 93 | + * |
|
| 94 | + * @since 21.0.0 |
|
| 95 | + */ |
|
| 96 | + public const REASON_INVALID_ARGUMENT = 8; |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * A field name was invalid |
|
| 100 | + * |
|
| 101 | + * @since 21.0.0 |
|
| 102 | + */ |
|
| 103 | + public const REASON_INVALID_FIELD_NAME = 9; |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * A name in the query was ambiguous |
|
| 107 | + * |
|
| 108 | + * @since 21.0.0 |
|
| 109 | + */ |
|
| 110 | + public const REASON_NON_UNIQUE_FIELD_NAME = 10; |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * A not null constraint was violated |
|
| 114 | + * |
|
| 115 | + * @since 21.0.0 |
|
| 116 | + */ |
|
| 117 | + public const REASON_NOT_NULL_CONSTRAINT_VIOLATION = 11; |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * A generic server error was encountered |
|
| 121 | + * |
|
| 122 | + * @since 21.0.0 |
|
| 123 | + */ |
|
| 124 | + public const REASON_SERVER = 12; |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * A syntax error was reported by the server |
|
| 128 | + * |
|
| 129 | + * @since 21.0.0 |
|
| 130 | + */ |
|
| 131 | + public const REASON_SYNTAX_ERROR = 13; |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * A unique constraint was violated |
|
| 135 | + * |
|
| 136 | + * @since 21.0.0 |
|
| 137 | + */ |
|
| 138 | + public const REASON_UNIQUE_CONSTRAINT_VIOLATION = 14; |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * @return int|null |
|
| 142 | + * @psalm-return Exception::REASON_* |
|
| 143 | + * @since 21.0.0 |
|
| 144 | + */ |
|
| 145 | + public function getReason(): ?int { |
|
| 146 | + return null; |
|
| 147 | + } |
|
| 148 | 148 | } |
@@ -38,984 +38,984 @@ |
||
| 38 | 38 | * @psalm-taint-specialize |
| 39 | 39 | */ |
| 40 | 40 | interface IQueryBuilder { |
| 41 | - /** |
|
| 42 | - * @since 9.0.0 |
|
| 43 | - */ |
|
| 44 | - public const PARAM_NULL = \PDO::PARAM_NULL; |
|
| 45 | - /** |
|
| 46 | - * @since 9.0.0 |
|
| 47 | - */ |
|
| 48 | - public const PARAM_BOOL = \PDO::PARAM_BOOL; |
|
| 49 | - /** |
|
| 50 | - * @since 9.0.0 |
|
| 51 | - */ |
|
| 52 | - public const PARAM_INT = \PDO::PARAM_INT; |
|
| 53 | - /** |
|
| 54 | - * @since 9.0.0 |
|
| 55 | - */ |
|
| 56 | - public const PARAM_STR = \PDO::PARAM_STR; |
|
| 57 | - /** |
|
| 58 | - * @since 9.0.0 |
|
| 59 | - */ |
|
| 60 | - public const PARAM_LOB = \PDO::PARAM_LOB; |
|
| 61 | - /** |
|
| 62 | - * @since 9.0.0 |
|
| 63 | - */ |
|
| 64 | - public const PARAM_DATE = 'datetime'; |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * @since 24.0.0 |
|
| 68 | - */ |
|
| 69 | - public const PARAM_JSON = 'json'; |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * @since 9.0.0 |
|
| 73 | - */ |
|
| 74 | - public const PARAM_INT_ARRAY = Connection::PARAM_INT_ARRAY; |
|
| 75 | - /** |
|
| 76 | - * @since 9.0.0 |
|
| 77 | - */ |
|
| 78 | - public const PARAM_STR_ARRAY = Connection::PARAM_STR_ARRAY; |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * @since 24.0.0 Indicates how many rows can be deleted at once with MySQL |
|
| 82 | - * database server. |
|
| 83 | - */ |
|
| 84 | - public const MAX_ROW_DELETION = 100000; |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * Enable/disable automatic prefixing of table names with the oc_ prefix |
|
| 88 | - * |
|
| 89 | - * @param bool $enabled If set to true table names will be prefixed with the |
|
| 90 | - * owncloud database prefix automatically. |
|
| 91 | - * @since 8.2.0 |
|
| 92 | - */ |
|
| 93 | - public function automaticTablePrefix($enabled); |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * Gets an ExpressionBuilder used for object-oriented construction of query expressions. |
|
| 97 | - * This producer method is intended for convenient inline usage. Example: |
|
| 98 | - * |
|
| 99 | - * <code> |
|
| 100 | - * $qb = $conn->getQueryBuilder() |
|
| 101 | - * ->select('u') |
|
| 102 | - * ->from('users', 'u') |
|
| 103 | - * ->where($qb->expr()->eq('u.id', 1)); |
|
| 104 | - * </code> |
|
| 105 | - * |
|
| 106 | - * For more complex expression construction, consider storing the expression |
|
| 107 | - * builder object in a local variable. |
|
| 108 | - * |
|
| 109 | - * @return \OCP\DB\QueryBuilder\IExpressionBuilder |
|
| 110 | - * @since 8.2.0 |
|
| 111 | - */ |
|
| 112 | - public function expr(); |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * Gets an FunctionBuilder used for object-oriented construction of query functions. |
|
| 116 | - * This producer method is intended for convenient inline usage. Example: |
|
| 117 | - * |
|
| 118 | - * <code> |
|
| 119 | - * $qb = $conn->getQueryBuilder() |
|
| 120 | - * ->select('u') |
|
| 121 | - * ->from('users', 'u') |
|
| 122 | - * ->where($qb->fun()->md5('u.id')); |
|
| 123 | - * </code> |
|
| 124 | - * |
|
| 125 | - * For more complex function construction, consider storing the function |
|
| 126 | - * builder object in a local variable. |
|
| 127 | - * |
|
| 128 | - * @return \OCP\DB\QueryBuilder\IFunctionBuilder |
|
| 129 | - * @since 12.0.0 |
|
| 130 | - */ |
|
| 131 | - public function func(); |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * Gets the type of the currently built query. |
|
| 135 | - * |
|
| 136 | - * @return integer |
|
| 137 | - * @since 8.2.0 |
|
| 138 | - */ |
|
| 139 | - public function getType(); |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * Gets the associated DBAL Connection for this query builder. |
|
| 143 | - * |
|
| 144 | - * @return \OCP\IDBConnection |
|
| 145 | - * @since 8.2.0 |
|
| 146 | - */ |
|
| 147 | - public function getConnection(); |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * Gets the state of this query builder instance. |
|
| 151 | - * |
|
| 152 | - * @return integer Either QueryBuilder::STATE_DIRTY or QueryBuilder::STATE_CLEAN. |
|
| 153 | - * @since 8.2.0 |
|
| 154 | - */ |
|
| 155 | - public function getState(); |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * Executes this query using the bound parameters and their types. |
|
| 159 | - * |
|
| 160 | - * Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeStatement} |
|
| 161 | - * for insert, update and delete statements. |
|
| 162 | - * |
|
| 163 | - * Warning: until Nextcloud 20, this method could return a \Doctrine\DBAL\Driver\Statement but since |
|
| 164 | - * that interface changed in a breaking way the adapter \OCP\DB\QueryBuilder\IStatement is returned |
|
| 165 | - * to bridge old code to the new API |
|
| 166 | - * |
|
| 167 | - * @return IResult|int |
|
| 168 | - * @throws Exception since 21.0.0 |
|
| 169 | - * @since 8.2.0 |
|
| 170 | - * @deprecated 22.0.0 Use executeQuery or executeStatement |
|
| 171 | - */ |
|
| 172 | - public function execute(); |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * Execute for select statements |
|
| 176 | - * |
|
| 177 | - * @return IResult |
|
| 178 | - * @since 22.0.0 |
|
| 179 | - * |
|
| 180 | - * @throws Exception |
|
| 181 | - * @throws \RuntimeException in case of usage with non select query |
|
| 182 | - */ |
|
| 183 | - public function executeQuery(): IResult; |
|
| 184 | - |
|
| 185 | - /** |
|
| 186 | - * Execute insert, update and delete statements |
|
| 187 | - * |
|
| 188 | - * @return int the number of affected rows |
|
| 189 | - * @since 22.0.0 |
|
| 190 | - * |
|
| 191 | - * @throws Exception |
|
| 192 | - * @throws \RuntimeException in case of usage with select query |
|
| 193 | - */ |
|
| 194 | - public function executeStatement(): int; |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * Gets the complete SQL string formed by the current specifications of this QueryBuilder. |
|
| 198 | - * |
|
| 199 | - * <code> |
|
| 200 | - * $qb = $conn->getQueryBuilder() |
|
| 201 | - * ->select('u') |
|
| 202 | - * ->from('User', 'u') |
|
| 203 | - * echo $qb->getSQL(); // SELECT u FROM User u |
|
| 204 | - * </code> |
|
| 205 | - * |
|
| 206 | - * @return string The SQL query string. |
|
| 207 | - * @since 8.2.0 |
|
| 208 | - */ |
|
| 209 | - public function getSQL(); |
|
| 210 | - |
|
| 211 | - /** |
|
| 212 | - * Sets a query parameter for the query being constructed. |
|
| 213 | - * |
|
| 214 | - * <code> |
|
| 215 | - * $qb = $conn->getQueryBuilder() |
|
| 216 | - * ->select('u') |
|
| 217 | - * ->from('users', 'u') |
|
| 218 | - * ->where('u.id = :user_id') |
|
| 219 | - * ->setParameter(':user_id', 1); |
|
| 220 | - * </code> |
|
| 221 | - * |
|
| 222 | - * @param string|integer $key The parameter position or name. |
|
| 223 | - * @param mixed $value The parameter value. |
|
| 224 | - * @param string|null|int $type One of the IQueryBuilder::PARAM_* constants. |
|
| 225 | - * |
|
| 226 | - * @return $this This QueryBuilder instance. |
|
| 227 | - * @since 8.2.0 |
|
| 228 | - */ |
|
| 229 | - public function setParameter($key, $value, $type = null); |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * Sets a collection of query parameters for the query being constructed. |
|
| 233 | - * |
|
| 234 | - * <code> |
|
| 235 | - * $qb = $conn->getQueryBuilder() |
|
| 236 | - * ->select('u') |
|
| 237 | - * ->from('users', 'u') |
|
| 238 | - * ->where('u.id = :user_id1 OR u.id = :user_id2') |
|
| 239 | - * ->setParameters(array( |
|
| 240 | - * ':user_id1' => 1, |
|
| 241 | - * ':user_id2' => 2 |
|
| 242 | - * )); |
|
| 243 | - * </code> |
|
| 244 | - * |
|
| 245 | - * @param array $params The query parameters to set. |
|
| 246 | - * @param array $types The query parameters types to set. |
|
| 247 | - * |
|
| 248 | - * @return $this This QueryBuilder instance. |
|
| 249 | - * @since 8.2.0 |
|
| 250 | - */ |
|
| 251 | - public function setParameters(array $params, array $types = []); |
|
| 252 | - |
|
| 253 | - /** |
|
| 254 | - * Gets all defined query parameters for the query being constructed indexed by parameter index or name. |
|
| 255 | - * |
|
| 256 | - * @return array The currently defined query parameters indexed by parameter index or name. |
|
| 257 | - * @since 8.2.0 |
|
| 258 | - */ |
|
| 259 | - public function getParameters(); |
|
| 260 | - |
|
| 261 | - /** |
|
| 262 | - * Gets a (previously set) query parameter of the query being constructed. |
|
| 263 | - * |
|
| 264 | - * @param mixed $key The key (index or name) of the bound parameter. |
|
| 265 | - * |
|
| 266 | - * @return mixed The value of the bound parameter. |
|
| 267 | - * @since 8.2.0 |
|
| 268 | - */ |
|
| 269 | - public function getParameter($key); |
|
| 270 | - |
|
| 271 | - /** |
|
| 272 | - * Gets all defined query parameter types for the query being constructed indexed by parameter index or name. |
|
| 273 | - * |
|
| 274 | - * @return array The currently defined query parameter types indexed by parameter index or name. |
|
| 275 | - * @since 8.2.0 |
|
| 276 | - */ |
|
| 277 | - public function getParameterTypes(); |
|
| 278 | - |
|
| 279 | - /** |
|
| 280 | - * Gets a (previously set) query parameter type of the query being constructed. |
|
| 281 | - * |
|
| 282 | - * @param mixed $key The key (index or name) of the bound parameter type. |
|
| 283 | - * |
|
| 284 | - * @return mixed The value of the bound parameter type. |
|
| 285 | - * @since 8.2.0 |
|
| 286 | - */ |
|
| 287 | - public function getParameterType($key); |
|
| 288 | - |
|
| 289 | - /** |
|
| 290 | - * Sets the position of the first result to retrieve (the "offset"). |
|
| 291 | - * |
|
| 292 | - * @param int $firstResult The first result to return. |
|
| 293 | - * |
|
| 294 | - * @return $this This QueryBuilder instance. |
|
| 295 | - * @since 8.2.0 |
|
| 296 | - */ |
|
| 297 | - public function setFirstResult($firstResult); |
|
| 298 | - |
|
| 299 | - /** |
|
| 300 | - * Gets the position of the first result the query object was set to retrieve (the "offset"). |
|
| 301 | - * Returns 0 if {@link setFirstResult} was not applied to this QueryBuilder. |
|
| 302 | - * |
|
| 303 | - * @return int The position of the first result. |
|
| 304 | - * @since 8.2.0 |
|
| 305 | - */ |
|
| 306 | - public function getFirstResult(); |
|
| 307 | - |
|
| 308 | - /** |
|
| 309 | - * Sets the maximum number of results to retrieve (the "limit"). |
|
| 310 | - * |
|
| 311 | - * @param int|null $maxResults The maximum number of results to retrieve. |
|
| 312 | - * |
|
| 313 | - * @return $this This QueryBuilder instance. |
|
| 314 | - * @since 8.2.0 |
|
| 315 | - */ |
|
| 316 | - public function setMaxResults($maxResults); |
|
| 317 | - |
|
| 318 | - /** |
|
| 319 | - * Gets the maximum number of results the query object was set to retrieve (the "limit"). |
|
| 320 | - * Returns NULL if {@link setMaxResults} was not applied to this query builder. |
|
| 321 | - * |
|
| 322 | - * @return int|null The maximum number of results. |
|
| 323 | - * @since 8.2.0 |
|
| 324 | - */ |
|
| 325 | - public function getMaxResults(); |
|
| 326 | - |
|
| 327 | - /** |
|
| 328 | - * Specifies an item that is to be returned in the query result. |
|
| 329 | - * Replaces any previously specified selections, if any. |
|
| 330 | - * |
|
| 331 | - * <code> |
|
| 332 | - * $qb = $conn->getQueryBuilder() |
|
| 333 | - * ->select('u.id', 'p.id') |
|
| 334 | - * ->from('users', 'u') |
|
| 335 | - * ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id'); |
|
| 336 | - * </code> |
|
| 337 | - * |
|
| 338 | - * @param mixed ...$selects The selection expressions. |
|
| 339 | - * |
|
| 340 | - * @return $this This QueryBuilder instance. |
|
| 341 | - * @since 8.2.0 |
|
| 342 | - * |
|
| 343 | - * @psalm-taint-sink sql $selects |
|
| 344 | - */ |
|
| 345 | - public function select(...$selects); |
|
| 346 | - |
|
| 347 | - /** |
|
| 348 | - * Specifies an item that is to be returned with a different name in the query result. |
|
| 349 | - * |
|
| 350 | - * <code> |
|
| 351 | - * $qb = $conn->getQueryBuilder() |
|
| 352 | - * ->selectAlias('u.id', 'user_id') |
|
| 353 | - * ->from('users', 'u') |
|
| 354 | - * ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id'); |
|
| 355 | - * </code> |
|
| 356 | - * |
|
| 357 | - * @param mixed $select The selection expressions. |
|
| 358 | - * @param string $alias The column alias used in the constructed query. |
|
| 359 | - * |
|
| 360 | - * @return $this This QueryBuilder instance. |
|
| 361 | - * @since 8.2.1 |
|
| 362 | - * |
|
| 363 | - * @psalm-taint-sink sql $select |
|
| 364 | - * @psalm-taint-sink sql $alias |
|
| 365 | - */ |
|
| 366 | - public function selectAlias($select, $alias); |
|
| 367 | - |
|
| 368 | - /** |
|
| 369 | - * Specifies an item that is to be returned uniquely in the query result. |
|
| 370 | - * |
|
| 371 | - * <code> |
|
| 372 | - * $qb = $conn->getQueryBuilder() |
|
| 373 | - * ->selectDistinct('type') |
|
| 374 | - * ->from('users'); |
|
| 375 | - * </code> |
|
| 376 | - * |
|
| 377 | - * @param mixed $select The selection expressions. |
|
| 378 | - * |
|
| 379 | - * @return $this This QueryBuilder instance. |
|
| 380 | - * @since 9.0.0 |
|
| 381 | - * |
|
| 382 | - * @psalm-taint-sink sql $select |
|
| 383 | - */ |
|
| 384 | - public function selectDistinct($select); |
|
| 385 | - |
|
| 386 | - /** |
|
| 387 | - * Adds an item that is to be returned in the query result. |
|
| 388 | - * |
|
| 389 | - * <code> |
|
| 390 | - * $qb = $conn->getQueryBuilder() |
|
| 391 | - * ->select('u.id') |
|
| 392 | - * ->addSelect('p.id') |
|
| 393 | - * ->from('users', 'u') |
|
| 394 | - * ->leftJoin('u', 'phonenumbers', 'u.id = p.user_id'); |
|
| 395 | - * </code> |
|
| 396 | - * |
|
| 397 | - * @param mixed ...$select The selection expression. |
|
| 398 | - * |
|
| 399 | - * @return $this This QueryBuilder instance. |
|
| 400 | - * @since 8.2.0 |
|
| 401 | - * |
|
| 402 | - * @psalm-taint-sink sql $select |
|
| 403 | - */ |
|
| 404 | - public function addSelect(...$select); |
|
| 405 | - |
|
| 406 | - /** |
|
| 407 | - * Turns the query being built into a bulk delete query that ranges over |
|
| 408 | - * a certain table. |
|
| 409 | - * |
|
| 410 | - * <code> |
|
| 411 | - * $qb = $conn->getQueryBuilder() |
|
| 412 | - * ->delete('users', 'u') |
|
| 413 | - * ->where('u.id = :user_id'); |
|
| 414 | - * ->setParameter(':user_id', 1); |
|
| 415 | - * </code> |
|
| 416 | - * |
|
| 417 | - * @param string $delete The table whose rows are subject to the deletion. |
|
| 418 | - * @param string $alias The table alias used in the constructed query. |
|
| 419 | - * |
|
| 420 | - * @return $this This QueryBuilder instance. |
|
| 421 | - * @since 8.2.0 |
|
| 422 | - * |
|
| 423 | - * @psalm-taint-sink sql $delete |
|
| 424 | - */ |
|
| 425 | - public function delete($delete = null, $alias = null); |
|
| 426 | - |
|
| 427 | - /** |
|
| 428 | - * Turns the query being built into a bulk update query that ranges over |
|
| 429 | - * a certain table |
|
| 430 | - * |
|
| 431 | - * <code> |
|
| 432 | - * $qb = $conn->getQueryBuilder() |
|
| 433 | - * ->update('users', 'u') |
|
| 434 | - * ->set('u.password', md5('password')) |
|
| 435 | - * ->where('u.id = ?'); |
|
| 436 | - * </code> |
|
| 437 | - * |
|
| 438 | - * @param string $update The table whose rows are subject to the update. |
|
| 439 | - * @param string $alias The table alias used in the constructed query. |
|
| 440 | - * |
|
| 441 | - * @return $this This QueryBuilder instance. |
|
| 442 | - * @since 8.2.0 |
|
| 443 | - * |
|
| 444 | - * @psalm-taint-sink sql $update |
|
| 445 | - */ |
|
| 446 | - public function update($update = null, $alias = null); |
|
| 447 | - |
|
| 448 | - /** |
|
| 449 | - * Turns the query being built into an insert query that inserts into |
|
| 450 | - * a certain table |
|
| 451 | - * |
|
| 452 | - * <code> |
|
| 453 | - * $qb = $conn->getQueryBuilder() |
|
| 454 | - * ->insert('users') |
|
| 455 | - * ->values( |
|
| 456 | - * array( |
|
| 457 | - * 'name' => '?', |
|
| 458 | - * 'password' => '?' |
|
| 459 | - * ) |
|
| 460 | - * ); |
|
| 461 | - * </code> |
|
| 462 | - * |
|
| 463 | - * @param string $insert The table into which the rows should be inserted. |
|
| 464 | - * |
|
| 465 | - * @return $this This QueryBuilder instance. |
|
| 466 | - * @since 8.2.0 |
|
| 467 | - * |
|
| 468 | - * @psalm-taint-sink sql $insert |
|
| 469 | - */ |
|
| 470 | - public function insert($insert = null); |
|
| 471 | - |
|
| 472 | - /** |
|
| 473 | - * Creates and adds a query root corresponding to the table identified by the |
|
| 474 | - * given alias, forming a cartesian product with any existing query roots. |
|
| 475 | - * |
|
| 476 | - * <code> |
|
| 477 | - * $qb = $conn->getQueryBuilder() |
|
| 478 | - * ->select('u.id') |
|
| 479 | - * ->from('users', 'u') |
|
| 480 | - * </code> |
|
| 481 | - * |
|
| 482 | - * @param string|IQueryFunction $from The table. |
|
| 483 | - * @param string|null $alias The alias of the table. |
|
| 484 | - * |
|
| 485 | - * @return $this This QueryBuilder instance. |
|
| 486 | - * @since 8.2.0 |
|
| 487 | - * |
|
| 488 | - * @psalm-taint-sink sql $from |
|
| 489 | - */ |
|
| 490 | - public function from($from, $alias = null); |
|
| 491 | - |
|
| 492 | - /** |
|
| 493 | - * Creates and adds a join to the query. |
|
| 494 | - * |
|
| 495 | - * <code> |
|
| 496 | - * $qb = $conn->getQueryBuilder() |
|
| 497 | - * ->select('u.name') |
|
| 498 | - * ->from('users', 'u') |
|
| 499 | - * ->join('u', 'phonenumbers', 'p', 'p.is_primary = 1'); |
|
| 500 | - * </code> |
|
| 501 | - * |
|
| 502 | - * @param string $fromAlias The alias that points to a from clause. |
|
| 503 | - * @param string $join The table name to join. |
|
| 504 | - * @param string $alias The alias of the join table. |
|
| 505 | - * @param string|ICompositeExpression|null $condition The condition for the join. |
|
| 506 | - * |
|
| 507 | - * @return $this This QueryBuilder instance. |
|
| 508 | - * @since 8.2.0 |
|
| 509 | - * |
|
| 510 | - * @psalm-taint-sink sql $fromAlias |
|
| 511 | - * @psalm-taint-sink sql $join |
|
| 512 | - * @psalm-taint-sink sql $alias |
|
| 513 | - * @psalm-taint-sink sql $condition |
|
| 514 | - */ |
|
| 515 | - public function join($fromAlias, $join, $alias, $condition = null); |
|
| 516 | - |
|
| 517 | - /** |
|
| 518 | - * Creates and adds a join to the query. |
|
| 519 | - * |
|
| 520 | - * <code> |
|
| 521 | - * $qb = $conn->getQueryBuilder() |
|
| 522 | - * ->select('u.name') |
|
| 523 | - * ->from('users', 'u') |
|
| 524 | - * ->innerJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1'); |
|
| 525 | - * </code> |
|
| 526 | - * |
|
| 527 | - * @param string $fromAlias The alias that points to a from clause. |
|
| 528 | - * @param string $join The table name to join. |
|
| 529 | - * @param string $alias The alias of the join table. |
|
| 530 | - * @param string|ICompositeExpression|null $condition The condition for the join. |
|
| 531 | - * |
|
| 532 | - * @return $this This QueryBuilder instance. |
|
| 533 | - * @since 8.2.0 |
|
| 534 | - * |
|
| 535 | - * @psalm-taint-sink sql $fromAlias |
|
| 536 | - * @psalm-taint-sink sql $join |
|
| 537 | - * @psalm-taint-sink sql $alias |
|
| 538 | - * @psalm-taint-sink sql $condition |
|
| 539 | - */ |
|
| 540 | - public function innerJoin($fromAlias, $join, $alias, $condition = null); |
|
| 541 | - |
|
| 542 | - /** |
|
| 543 | - * Creates and adds a left join to the query. |
|
| 544 | - * |
|
| 545 | - * <code> |
|
| 546 | - * $qb = $conn->getQueryBuilder() |
|
| 547 | - * ->select('u.name') |
|
| 548 | - * ->from('users', 'u') |
|
| 549 | - * ->leftJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1'); |
|
| 550 | - * </code> |
|
| 551 | - * |
|
| 552 | - * @param string $fromAlias The alias that points to a from clause. |
|
| 553 | - * @param string $join The table name to join. |
|
| 554 | - * @param string $alias The alias of the join table. |
|
| 555 | - * @param string|ICompositeExpression|null $condition The condition for the join. |
|
| 556 | - * |
|
| 557 | - * @return $this This QueryBuilder instance. |
|
| 558 | - * @since 8.2.0 |
|
| 559 | - * |
|
| 560 | - * @psalm-taint-sink sql $fromAlias |
|
| 561 | - * @psalm-taint-sink sql $join |
|
| 562 | - * @psalm-taint-sink sql $alias |
|
| 563 | - * @psalm-taint-sink sql $condition |
|
| 564 | - */ |
|
| 565 | - public function leftJoin($fromAlias, $join, $alias, $condition = null); |
|
| 566 | - |
|
| 567 | - /** |
|
| 568 | - * Creates and adds a right join to the query. |
|
| 569 | - * |
|
| 570 | - * <code> |
|
| 571 | - * $qb = $conn->getQueryBuilder() |
|
| 572 | - * ->select('u.name') |
|
| 573 | - * ->from('users', 'u') |
|
| 574 | - * ->rightJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1'); |
|
| 575 | - * </code> |
|
| 576 | - * |
|
| 577 | - * @param string $fromAlias The alias that points to a from clause. |
|
| 578 | - * @param string $join The table name to join. |
|
| 579 | - * @param string $alias The alias of the join table. |
|
| 580 | - * @param string|ICompositeExpression|null $condition The condition for the join. |
|
| 581 | - * |
|
| 582 | - * @return $this This QueryBuilder instance. |
|
| 583 | - * @since 8.2.0 |
|
| 584 | - * |
|
| 585 | - * @psalm-taint-sink sql $fromAlias |
|
| 586 | - * @psalm-taint-sink sql $join |
|
| 587 | - * @psalm-taint-sink sql $alias |
|
| 588 | - * @psalm-taint-sink sql $condition |
|
| 589 | - */ |
|
| 590 | - public function rightJoin($fromAlias, $join, $alias, $condition = null); |
|
| 591 | - |
|
| 592 | - /** |
|
| 593 | - * Sets a new value for a column in a bulk update query. |
|
| 594 | - * |
|
| 595 | - * <code> |
|
| 596 | - * $qb = $conn->getQueryBuilder() |
|
| 597 | - * ->update('users', 'u') |
|
| 598 | - * ->set('u.password', md5('password')) |
|
| 599 | - * ->where('u.id = ?'); |
|
| 600 | - * </code> |
|
| 601 | - * |
|
| 602 | - * @param string $key The column to set. |
|
| 603 | - * @param ILiteral|IParameter|IQueryFunction|string $value The value, expression, placeholder, etc. |
|
| 604 | - * |
|
| 605 | - * @return $this This QueryBuilder instance. |
|
| 606 | - * @since 8.2.0 |
|
| 607 | - * |
|
| 608 | - * @psalm-taint-sink sql $key |
|
| 609 | - * @psalm-taint-sink sql $value |
|
| 610 | - */ |
|
| 611 | - public function set($key, $value); |
|
| 612 | - |
|
| 613 | - /** |
|
| 614 | - * Specifies one or more restrictions to the query result. |
|
| 615 | - * Replaces any previously specified restrictions, if any. |
|
| 616 | - * |
|
| 617 | - * <code> |
|
| 618 | - * $qb = $conn->getQueryBuilder() |
|
| 619 | - * ->select('u.name') |
|
| 620 | - * ->from('users', 'u') |
|
| 621 | - * ->where('u.id = ?'); |
|
| 622 | - * |
|
| 623 | - * // You can optionally programmatically build and/or expressions |
|
| 624 | - * $qb = $conn->getQueryBuilder(); |
|
| 625 | - * |
|
| 626 | - * $or = $qb->expr()->orx(); |
|
| 627 | - * $or->add($qb->expr()->eq('u.id', 1)); |
|
| 628 | - * $or->add($qb->expr()->eq('u.id', 2)); |
|
| 629 | - * |
|
| 630 | - * $qb->update('users', 'u') |
|
| 631 | - * ->set('u.password', md5('password')) |
|
| 632 | - * ->where($or); |
|
| 633 | - * </code> |
|
| 634 | - * |
|
| 635 | - * @param mixed $predicates The restriction predicates. |
|
| 636 | - * |
|
| 637 | - * @return $this This QueryBuilder instance. |
|
| 638 | - * @since 8.2.0 |
|
| 639 | - * |
|
| 640 | - * @psalm-taint-sink sql $predicates |
|
| 641 | - */ |
|
| 642 | - public function where(...$predicates); |
|
| 643 | - |
|
| 644 | - /** |
|
| 645 | - * Adds one or more restrictions to the query results, forming a logical |
|
| 646 | - * conjunction with any previously specified restrictions. |
|
| 647 | - * |
|
| 648 | - * <code> |
|
| 649 | - * $qb = $conn->getQueryBuilder() |
|
| 650 | - * ->select('u') |
|
| 651 | - * ->from('users', 'u') |
|
| 652 | - * ->where('u.username LIKE ?') |
|
| 653 | - * ->andWhere('u.is_active = 1'); |
|
| 654 | - * </code> |
|
| 655 | - * |
|
| 656 | - * @param mixed ...$where The query restrictions. |
|
| 657 | - * |
|
| 658 | - * @return $this This QueryBuilder instance. |
|
| 659 | - * |
|
| 660 | - * @see where() |
|
| 661 | - * @since 8.2.0 |
|
| 662 | - * |
|
| 663 | - * @psalm-taint-sink sql $where |
|
| 664 | - */ |
|
| 665 | - public function andWhere(...$where); |
|
| 666 | - |
|
| 667 | - /** |
|
| 668 | - * Adds one or more restrictions to the query results, forming a logical |
|
| 669 | - * disjunction with any previously specified restrictions. |
|
| 670 | - * |
|
| 671 | - * <code> |
|
| 672 | - * $qb = $conn->getQueryBuilder() |
|
| 673 | - * ->select('u.name') |
|
| 674 | - * ->from('users', 'u') |
|
| 675 | - * ->where('u.id = 1') |
|
| 676 | - * ->orWhere('u.id = 2'); |
|
| 677 | - * </code> |
|
| 678 | - * |
|
| 679 | - * @param mixed ...$where The WHERE statement. |
|
| 680 | - * |
|
| 681 | - * @return $this This QueryBuilder instance. |
|
| 682 | - * |
|
| 683 | - * @see where() |
|
| 684 | - * @since 8.2.0 |
|
| 685 | - * |
|
| 686 | - * @psalm-taint-sink sql $where |
|
| 687 | - */ |
|
| 688 | - public function orWhere(...$where); |
|
| 689 | - |
|
| 690 | - /** |
|
| 691 | - * Specifies a grouping over the results of the query. |
|
| 692 | - * Replaces any previously specified groupings, if any. |
|
| 693 | - * |
|
| 694 | - * <code> |
|
| 695 | - * $qb = $conn->getQueryBuilder() |
|
| 696 | - * ->select('u.name') |
|
| 697 | - * ->from('users', 'u') |
|
| 698 | - * ->groupBy('u.id'); |
|
| 699 | - * </code> |
|
| 700 | - * |
|
| 701 | - * @param mixed ...$groupBys The grouping expression. |
|
| 702 | - * |
|
| 703 | - * @return $this This QueryBuilder instance. |
|
| 704 | - * @since 8.2.0 |
|
| 705 | - * |
|
| 706 | - * @psalm-taint-sink sql $groupBys |
|
| 707 | - */ |
|
| 708 | - public function groupBy(...$groupBys); |
|
| 709 | - |
|
| 710 | - /** |
|
| 711 | - * Adds a grouping expression to the query. |
|
| 712 | - * |
|
| 713 | - * <code> |
|
| 714 | - * $qb = $conn->getQueryBuilder() |
|
| 715 | - * ->select('u.name') |
|
| 716 | - * ->from('users', 'u') |
|
| 717 | - * ->groupBy('u.lastLogin'); |
|
| 718 | - * ->addGroupBy('u.createdAt') |
|
| 719 | - * </code> |
|
| 720 | - * |
|
| 721 | - * @param mixed ...$groupBy The grouping expression. |
|
| 722 | - * |
|
| 723 | - * @return $this This QueryBuilder instance. |
|
| 724 | - * @since 8.2.0 |
|
| 725 | - * |
|
| 726 | - * @psalm-taint-sink sql $groupby |
|
| 727 | - */ |
|
| 728 | - public function addGroupBy(...$groupBy); |
|
| 729 | - |
|
| 730 | - /** |
|
| 731 | - * Sets a value for a column in an insert query. |
|
| 732 | - * |
|
| 733 | - * <code> |
|
| 734 | - * $qb = $conn->getQueryBuilder() |
|
| 735 | - * ->insert('users') |
|
| 736 | - * ->values( |
|
| 737 | - * array( |
|
| 738 | - * 'name' => '?' |
|
| 739 | - * ) |
|
| 740 | - * ) |
|
| 741 | - * ->setValue('password', '?'); |
|
| 742 | - * </code> |
|
| 743 | - * |
|
| 744 | - * @param string $column The column into which the value should be inserted. |
|
| 745 | - * @param IParameter|string $value The value that should be inserted into the column. |
|
| 746 | - * |
|
| 747 | - * @return $this This QueryBuilder instance. |
|
| 748 | - * @since 8.2.0 |
|
| 749 | - * |
|
| 750 | - * @psalm-taint-sink sql $column |
|
| 751 | - * @psalm-taint-sink sql $value |
|
| 752 | - */ |
|
| 753 | - public function setValue($column, $value); |
|
| 754 | - |
|
| 755 | - /** |
|
| 756 | - * Specifies values for an insert query indexed by column names. |
|
| 757 | - * Replaces any previous values, if any. |
|
| 758 | - * |
|
| 759 | - * <code> |
|
| 760 | - * $qb = $conn->getQueryBuilder() |
|
| 761 | - * ->insert('users') |
|
| 762 | - * ->values( |
|
| 763 | - * array( |
|
| 764 | - * 'name' => '?', |
|
| 765 | - * 'password' => '?' |
|
| 766 | - * ) |
|
| 767 | - * ); |
|
| 768 | - * </code> |
|
| 769 | - * |
|
| 770 | - * @param array $values The values to specify for the insert query indexed by column names. |
|
| 771 | - * |
|
| 772 | - * @return $this This QueryBuilder instance. |
|
| 773 | - * @since 8.2.0 |
|
| 774 | - * |
|
| 775 | - * @psalm-taint-sink sql $values |
|
| 776 | - */ |
|
| 777 | - public function values(array $values); |
|
| 778 | - |
|
| 779 | - /** |
|
| 780 | - * Specifies a restriction over the groups of the query. |
|
| 781 | - * Replaces any previous having restrictions, if any. |
|
| 782 | - * |
|
| 783 | - * @param mixed ...$having The restriction over the groups. |
|
| 784 | - * |
|
| 785 | - * @return $this This QueryBuilder instance. |
|
| 786 | - * @since 8.2.0 |
|
| 787 | - * |
|
| 788 | - * @psalm-taint-sink sql $having |
|
| 789 | - */ |
|
| 790 | - public function having(...$having); |
|
| 791 | - |
|
| 792 | - /** |
|
| 793 | - * Adds a restriction over the groups of the query, forming a logical |
|
| 794 | - * conjunction with any existing having restrictions. |
|
| 795 | - * |
|
| 796 | - * @param mixed ...$having The restriction to append. |
|
| 797 | - * |
|
| 798 | - * @return $this This QueryBuilder instance. |
|
| 799 | - * @since 8.2.0 |
|
| 800 | - * |
|
| 801 | - * @psalm-taint-sink sql $andHaving |
|
| 802 | - */ |
|
| 803 | - public function andHaving(...$having); |
|
| 804 | - |
|
| 805 | - /** |
|
| 806 | - * Adds a restriction over the groups of the query, forming a logical |
|
| 807 | - * disjunction with any existing having restrictions. |
|
| 808 | - * |
|
| 809 | - * @param mixed ...$having The restriction to add. |
|
| 810 | - * |
|
| 811 | - * @return $this This QueryBuilder instance. |
|
| 812 | - * @since 8.2.0 |
|
| 813 | - * |
|
| 814 | - * @psalm-taint-sink sql $having |
|
| 815 | - */ |
|
| 816 | - public function orHaving(...$having); |
|
| 817 | - |
|
| 818 | - /** |
|
| 819 | - * Specifies an ordering for the query results. |
|
| 820 | - * Replaces any previously specified orderings, if any. |
|
| 821 | - * |
|
| 822 | - * @param string|IQueryFunction|ILiteral|IParameter $sort The ordering expression. |
|
| 823 | - * @param string $order The ordering direction. |
|
| 824 | - * |
|
| 825 | - * @return $this This QueryBuilder instance. |
|
| 826 | - * @since 8.2.0 |
|
| 827 | - * |
|
| 828 | - * @psalm-taint-sink sql $sort |
|
| 829 | - * @psalm-taint-sink sql $order |
|
| 830 | - */ |
|
| 831 | - public function orderBy($sort, $order = null); |
|
| 832 | - |
|
| 833 | - /** |
|
| 834 | - * Adds an ordering to the query results. |
|
| 835 | - * |
|
| 836 | - * @param string|ILiteral|IParameter|IQueryFunction $sort The ordering expression. |
|
| 837 | - * @param string $order The ordering direction. |
|
| 838 | - * |
|
| 839 | - * @return $this This QueryBuilder instance. |
|
| 840 | - * @since 8.2.0 |
|
| 841 | - * |
|
| 842 | - * @psalm-taint-sink sql $sort |
|
| 843 | - * @psalm-taint-sink sql $order |
|
| 844 | - */ |
|
| 845 | - public function addOrderBy($sort, $order = null); |
|
| 846 | - |
|
| 847 | - /** |
|
| 848 | - * Gets a query part by its name. |
|
| 849 | - * |
|
| 850 | - * @param string $queryPartName |
|
| 851 | - * |
|
| 852 | - * @return mixed |
|
| 853 | - * @since 8.2.0 |
|
| 854 | - */ |
|
| 855 | - public function getQueryPart($queryPartName); |
|
| 856 | - |
|
| 857 | - /** |
|
| 858 | - * Gets all query parts. |
|
| 859 | - * |
|
| 860 | - * @return array |
|
| 861 | - * @since 8.2.0 |
|
| 862 | - */ |
|
| 863 | - public function getQueryParts(); |
|
| 864 | - |
|
| 865 | - /** |
|
| 866 | - * Resets SQL parts. |
|
| 867 | - * |
|
| 868 | - * @param array|null $queryPartNames |
|
| 869 | - * |
|
| 870 | - * @return $this This QueryBuilder instance. |
|
| 871 | - * @since 8.2.0 |
|
| 872 | - */ |
|
| 873 | - public function resetQueryParts($queryPartNames = null); |
|
| 874 | - |
|
| 875 | - /** |
|
| 876 | - * Resets a single SQL part. |
|
| 877 | - * |
|
| 878 | - * @param string $queryPartName |
|
| 879 | - * |
|
| 880 | - * @return $this This QueryBuilder instance. |
|
| 881 | - * @since 8.2.0 |
|
| 882 | - */ |
|
| 883 | - public function resetQueryPart($queryPartName); |
|
| 884 | - |
|
| 885 | - /** |
|
| 886 | - * Creates a new named parameter and bind the value $value to it. |
|
| 887 | - * |
|
| 888 | - * This method provides a shortcut for PDOStatement::bindValue |
|
| 889 | - * when using prepared statements. |
|
| 890 | - * |
|
| 891 | - * The parameter $value specifies the value that you want to bind. If |
|
| 892 | - * $placeholder is not provided bindValue() will automatically create a |
|
| 893 | - * placeholder for you. An automatic placeholder will be of the name |
|
| 894 | - * ':dcValue1', ':dcValue2' etc. |
|
| 895 | - * |
|
| 896 | - * For more information see {@link https://www.php.net/pdostatement-bindparam} |
|
| 897 | - * |
|
| 898 | - * Example: |
|
| 899 | - * <code> |
|
| 900 | - * $value = 2; |
|
| 901 | - * $q->eq( 'id', $q->bindValue( $value ) ); |
|
| 902 | - * $stmt = $q->executeQuery(); // executed with 'id = 2' |
|
| 903 | - * </code> |
|
| 904 | - * |
|
| 905 | - * @license New BSD License |
|
| 906 | - * @link http://www.zetacomponents.org |
|
| 907 | - * |
|
| 908 | - * @param mixed $value |
|
| 909 | - * @param mixed $type |
|
| 910 | - * @param string $placeHolder The name to bind with. The string must start with a colon ':'. |
|
| 911 | - * |
|
| 912 | - * @return IParameter |
|
| 913 | - * @since 8.2.0 |
|
| 914 | - * |
|
| 915 | - * @psalm-taint-escape sql |
|
| 916 | - */ |
|
| 917 | - public function createNamedParameter($value, $type = self::PARAM_STR, $placeHolder = null); |
|
| 918 | - |
|
| 919 | - /** |
|
| 920 | - * Creates a new positional parameter and bind the given value to it. |
|
| 921 | - * |
|
| 922 | - * Attention: If you are using positional parameters with the query builder you have |
|
| 923 | - * to be very careful to bind all parameters in the order they appear in the SQL |
|
| 924 | - * statement , otherwise they get bound in the wrong order which can lead to serious |
|
| 925 | - * bugs in your code. |
|
| 926 | - * |
|
| 927 | - * Example: |
|
| 928 | - * <code> |
|
| 929 | - * $qb = $conn->getQueryBuilder(); |
|
| 930 | - * $qb->select('u.*') |
|
| 931 | - * ->from('users', 'u') |
|
| 932 | - * ->where('u.username = ' . $qb->createPositionalParameter('Foo', IQueryBuilder::PARAM_STR)) |
|
| 933 | - * ->orWhere('u.username = ' . $qb->createPositionalParameter('Bar', IQueryBuilder::PARAM_STR)) |
|
| 934 | - * </code> |
|
| 935 | - * |
|
| 936 | - * @param mixed $value |
|
| 937 | - * @param integer $type |
|
| 938 | - * |
|
| 939 | - * @return IParameter |
|
| 940 | - * @since 8.2.0 |
|
| 941 | - * |
|
| 942 | - * @psalm-taint-escape sql |
|
| 943 | - */ |
|
| 944 | - public function createPositionalParameter($value, $type = self::PARAM_STR); |
|
| 945 | - |
|
| 946 | - /** |
|
| 947 | - * Creates a new parameter |
|
| 948 | - * |
|
| 949 | - * Example: |
|
| 950 | - * <code> |
|
| 951 | - * $qb = $conn->getQueryBuilder(); |
|
| 952 | - * $qb->select('u.*') |
|
| 953 | - * ->from('users', 'u') |
|
| 954 | - * ->where('u.username = ' . $qb->createParameter('name')) |
|
| 955 | - * ->setParameter('name', 'Bar', IQueryBuilder::PARAM_STR)) |
|
| 956 | - * </code> |
|
| 957 | - * |
|
| 958 | - * @param string $name |
|
| 959 | - * |
|
| 960 | - * @return IParameter |
|
| 961 | - * @since 8.2.0 |
|
| 962 | - * |
|
| 963 | - * @psalm-taint-escape sql |
|
| 964 | - */ |
|
| 965 | - public function createParameter($name); |
|
| 966 | - |
|
| 967 | - /** |
|
| 968 | - * Creates a new function |
|
| 969 | - * |
|
| 970 | - * Attention: Column names inside the call have to be quoted before hand |
|
| 971 | - * |
|
| 972 | - * Example: |
|
| 973 | - * <code> |
|
| 974 | - * $qb = $conn->getQueryBuilder(); |
|
| 975 | - * $qb->select($qb->createFunction('COUNT(*)')) |
|
| 976 | - * ->from('users', 'u') |
|
| 977 | - * echo $qb->getSQL(); // SELECT COUNT(*) FROM `users` u |
|
| 978 | - * </code> |
|
| 979 | - * <code> |
|
| 980 | - * $qb = $conn->getQueryBuilder(); |
|
| 981 | - * $qb->select($qb->createFunction('COUNT(`column`)')) |
|
| 982 | - * ->from('users', 'u') |
|
| 983 | - * echo $qb->getSQL(); // SELECT COUNT(`column`) FROM `users` u |
|
| 984 | - * </code> |
|
| 985 | - * |
|
| 986 | - * @param string $call |
|
| 987 | - * |
|
| 988 | - * @return IQueryFunction |
|
| 989 | - * @since 8.2.0 |
|
| 990 | - * |
|
| 991 | - * @psalm-taint-sink sql |
|
| 992 | - */ |
|
| 993 | - public function createFunction($call); |
|
| 994 | - |
|
| 995 | - /** |
|
| 996 | - * Used to get the id of the last inserted element |
|
| 997 | - * @return int |
|
| 998 | - * @throws \BadMethodCallException When being called before an insert query has been run. |
|
| 999 | - * @since 9.0.0 |
|
| 1000 | - */ |
|
| 1001 | - public function getLastInsertId(): int; |
|
| 1002 | - |
|
| 1003 | - /** |
|
| 1004 | - * Returns the table name quoted and with database prefix as needed by the implementation |
|
| 1005 | - * |
|
| 1006 | - * @param string|IQueryFunction $table |
|
| 1007 | - * @return string |
|
| 1008 | - * @since 9.0.0 |
|
| 1009 | - */ |
|
| 1010 | - public function getTableName($table); |
|
| 1011 | - |
|
| 1012 | - /** |
|
| 1013 | - * Returns the column name quoted and with table alias prefix as needed by the implementation |
|
| 1014 | - * |
|
| 1015 | - * @param string $column |
|
| 1016 | - * @param string $tableAlias |
|
| 1017 | - * @return string |
|
| 1018 | - * @since 9.0.0 |
|
| 1019 | - */ |
|
| 1020 | - public function getColumnName($column, $tableAlias = ''); |
|
| 41 | + /** |
|
| 42 | + * @since 9.0.0 |
|
| 43 | + */ |
|
| 44 | + public const PARAM_NULL = \PDO::PARAM_NULL; |
|
| 45 | + /** |
|
| 46 | + * @since 9.0.0 |
|
| 47 | + */ |
|
| 48 | + public const PARAM_BOOL = \PDO::PARAM_BOOL; |
|
| 49 | + /** |
|
| 50 | + * @since 9.0.0 |
|
| 51 | + */ |
|
| 52 | + public const PARAM_INT = \PDO::PARAM_INT; |
|
| 53 | + /** |
|
| 54 | + * @since 9.0.0 |
|
| 55 | + */ |
|
| 56 | + public const PARAM_STR = \PDO::PARAM_STR; |
|
| 57 | + /** |
|
| 58 | + * @since 9.0.0 |
|
| 59 | + */ |
|
| 60 | + public const PARAM_LOB = \PDO::PARAM_LOB; |
|
| 61 | + /** |
|
| 62 | + * @since 9.0.0 |
|
| 63 | + */ |
|
| 64 | + public const PARAM_DATE = 'datetime'; |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * @since 24.0.0 |
|
| 68 | + */ |
|
| 69 | + public const PARAM_JSON = 'json'; |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * @since 9.0.0 |
|
| 73 | + */ |
|
| 74 | + public const PARAM_INT_ARRAY = Connection::PARAM_INT_ARRAY; |
|
| 75 | + /** |
|
| 76 | + * @since 9.0.0 |
|
| 77 | + */ |
|
| 78 | + public const PARAM_STR_ARRAY = Connection::PARAM_STR_ARRAY; |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * @since 24.0.0 Indicates how many rows can be deleted at once with MySQL |
|
| 82 | + * database server. |
|
| 83 | + */ |
|
| 84 | + public const MAX_ROW_DELETION = 100000; |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * Enable/disable automatic prefixing of table names with the oc_ prefix |
|
| 88 | + * |
|
| 89 | + * @param bool $enabled If set to true table names will be prefixed with the |
|
| 90 | + * owncloud database prefix automatically. |
|
| 91 | + * @since 8.2.0 |
|
| 92 | + */ |
|
| 93 | + public function automaticTablePrefix($enabled); |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * Gets an ExpressionBuilder used for object-oriented construction of query expressions. |
|
| 97 | + * This producer method is intended for convenient inline usage. Example: |
|
| 98 | + * |
|
| 99 | + * <code> |
|
| 100 | + * $qb = $conn->getQueryBuilder() |
|
| 101 | + * ->select('u') |
|
| 102 | + * ->from('users', 'u') |
|
| 103 | + * ->where($qb->expr()->eq('u.id', 1)); |
|
| 104 | + * </code> |
|
| 105 | + * |
|
| 106 | + * For more complex expression construction, consider storing the expression |
|
| 107 | + * builder object in a local variable. |
|
| 108 | + * |
|
| 109 | + * @return \OCP\DB\QueryBuilder\IExpressionBuilder |
|
| 110 | + * @since 8.2.0 |
|
| 111 | + */ |
|
| 112 | + public function expr(); |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * Gets an FunctionBuilder used for object-oriented construction of query functions. |
|
| 116 | + * This producer method is intended for convenient inline usage. Example: |
|
| 117 | + * |
|
| 118 | + * <code> |
|
| 119 | + * $qb = $conn->getQueryBuilder() |
|
| 120 | + * ->select('u') |
|
| 121 | + * ->from('users', 'u') |
|
| 122 | + * ->where($qb->fun()->md5('u.id')); |
|
| 123 | + * </code> |
|
| 124 | + * |
|
| 125 | + * For more complex function construction, consider storing the function |
|
| 126 | + * builder object in a local variable. |
|
| 127 | + * |
|
| 128 | + * @return \OCP\DB\QueryBuilder\IFunctionBuilder |
|
| 129 | + * @since 12.0.0 |
|
| 130 | + */ |
|
| 131 | + public function func(); |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * Gets the type of the currently built query. |
|
| 135 | + * |
|
| 136 | + * @return integer |
|
| 137 | + * @since 8.2.0 |
|
| 138 | + */ |
|
| 139 | + public function getType(); |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * Gets the associated DBAL Connection for this query builder. |
|
| 143 | + * |
|
| 144 | + * @return \OCP\IDBConnection |
|
| 145 | + * @since 8.2.0 |
|
| 146 | + */ |
|
| 147 | + public function getConnection(); |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * Gets the state of this query builder instance. |
|
| 151 | + * |
|
| 152 | + * @return integer Either QueryBuilder::STATE_DIRTY or QueryBuilder::STATE_CLEAN. |
|
| 153 | + * @since 8.2.0 |
|
| 154 | + */ |
|
| 155 | + public function getState(); |
|
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * Executes this query using the bound parameters and their types. |
|
| 159 | + * |
|
| 160 | + * Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeStatement} |
|
| 161 | + * for insert, update and delete statements. |
|
| 162 | + * |
|
| 163 | + * Warning: until Nextcloud 20, this method could return a \Doctrine\DBAL\Driver\Statement but since |
|
| 164 | + * that interface changed in a breaking way the adapter \OCP\DB\QueryBuilder\IStatement is returned |
|
| 165 | + * to bridge old code to the new API |
|
| 166 | + * |
|
| 167 | + * @return IResult|int |
|
| 168 | + * @throws Exception since 21.0.0 |
|
| 169 | + * @since 8.2.0 |
|
| 170 | + * @deprecated 22.0.0 Use executeQuery or executeStatement |
|
| 171 | + */ |
|
| 172 | + public function execute(); |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * Execute for select statements |
|
| 176 | + * |
|
| 177 | + * @return IResult |
|
| 178 | + * @since 22.0.0 |
|
| 179 | + * |
|
| 180 | + * @throws Exception |
|
| 181 | + * @throws \RuntimeException in case of usage with non select query |
|
| 182 | + */ |
|
| 183 | + public function executeQuery(): IResult; |
|
| 184 | + |
|
| 185 | + /** |
|
| 186 | + * Execute insert, update and delete statements |
|
| 187 | + * |
|
| 188 | + * @return int the number of affected rows |
|
| 189 | + * @since 22.0.0 |
|
| 190 | + * |
|
| 191 | + * @throws Exception |
|
| 192 | + * @throws \RuntimeException in case of usage with select query |
|
| 193 | + */ |
|
| 194 | + public function executeStatement(): int; |
|
| 195 | + |
|
| 196 | + /** |
|
| 197 | + * Gets the complete SQL string formed by the current specifications of this QueryBuilder. |
|
| 198 | + * |
|
| 199 | + * <code> |
|
| 200 | + * $qb = $conn->getQueryBuilder() |
|
| 201 | + * ->select('u') |
|
| 202 | + * ->from('User', 'u') |
|
| 203 | + * echo $qb->getSQL(); // SELECT u FROM User u |
|
| 204 | + * </code> |
|
| 205 | + * |
|
| 206 | + * @return string The SQL query string. |
|
| 207 | + * @since 8.2.0 |
|
| 208 | + */ |
|
| 209 | + public function getSQL(); |
|
| 210 | + |
|
| 211 | + /** |
|
| 212 | + * Sets a query parameter for the query being constructed. |
|
| 213 | + * |
|
| 214 | + * <code> |
|
| 215 | + * $qb = $conn->getQueryBuilder() |
|
| 216 | + * ->select('u') |
|
| 217 | + * ->from('users', 'u') |
|
| 218 | + * ->where('u.id = :user_id') |
|
| 219 | + * ->setParameter(':user_id', 1); |
|
| 220 | + * </code> |
|
| 221 | + * |
|
| 222 | + * @param string|integer $key The parameter position or name. |
|
| 223 | + * @param mixed $value The parameter value. |
|
| 224 | + * @param string|null|int $type One of the IQueryBuilder::PARAM_* constants. |
|
| 225 | + * |
|
| 226 | + * @return $this This QueryBuilder instance. |
|
| 227 | + * @since 8.2.0 |
|
| 228 | + */ |
|
| 229 | + public function setParameter($key, $value, $type = null); |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * Sets a collection of query parameters for the query being constructed. |
|
| 233 | + * |
|
| 234 | + * <code> |
|
| 235 | + * $qb = $conn->getQueryBuilder() |
|
| 236 | + * ->select('u') |
|
| 237 | + * ->from('users', 'u') |
|
| 238 | + * ->where('u.id = :user_id1 OR u.id = :user_id2') |
|
| 239 | + * ->setParameters(array( |
|
| 240 | + * ':user_id1' => 1, |
|
| 241 | + * ':user_id2' => 2 |
|
| 242 | + * )); |
|
| 243 | + * </code> |
|
| 244 | + * |
|
| 245 | + * @param array $params The query parameters to set. |
|
| 246 | + * @param array $types The query parameters types to set. |
|
| 247 | + * |
|
| 248 | + * @return $this This QueryBuilder instance. |
|
| 249 | + * @since 8.2.0 |
|
| 250 | + */ |
|
| 251 | + public function setParameters(array $params, array $types = []); |
|
| 252 | + |
|
| 253 | + /** |
|
| 254 | + * Gets all defined query parameters for the query being constructed indexed by parameter index or name. |
|
| 255 | + * |
|
| 256 | + * @return array The currently defined query parameters indexed by parameter index or name. |
|
| 257 | + * @since 8.2.0 |
|
| 258 | + */ |
|
| 259 | + public function getParameters(); |
|
| 260 | + |
|
| 261 | + /** |
|
| 262 | + * Gets a (previously set) query parameter of the query being constructed. |
|
| 263 | + * |
|
| 264 | + * @param mixed $key The key (index or name) of the bound parameter. |
|
| 265 | + * |
|
| 266 | + * @return mixed The value of the bound parameter. |
|
| 267 | + * @since 8.2.0 |
|
| 268 | + */ |
|
| 269 | + public function getParameter($key); |
|
| 270 | + |
|
| 271 | + /** |
|
| 272 | + * Gets all defined query parameter types for the query being constructed indexed by parameter index or name. |
|
| 273 | + * |
|
| 274 | + * @return array The currently defined query parameter types indexed by parameter index or name. |
|
| 275 | + * @since 8.2.0 |
|
| 276 | + */ |
|
| 277 | + public function getParameterTypes(); |
|
| 278 | + |
|
| 279 | + /** |
|
| 280 | + * Gets a (previously set) query parameter type of the query being constructed. |
|
| 281 | + * |
|
| 282 | + * @param mixed $key The key (index or name) of the bound parameter type. |
|
| 283 | + * |
|
| 284 | + * @return mixed The value of the bound parameter type. |
|
| 285 | + * @since 8.2.0 |
|
| 286 | + */ |
|
| 287 | + public function getParameterType($key); |
|
| 288 | + |
|
| 289 | + /** |
|
| 290 | + * Sets the position of the first result to retrieve (the "offset"). |
|
| 291 | + * |
|
| 292 | + * @param int $firstResult The first result to return. |
|
| 293 | + * |
|
| 294 | + * @return $this This QueryBuilder instance. |
|
| 295 | + * @since 8.2.0 |
|
| 296 | + */ |
|
| 297 | + public function setFirstResult($firstResult); |
|
| 298 | + |
|
| 299 | + /** |
|
| 300 | + * Gets the position of the first result the query object was set to retrieve (the "offset"). |
|
| 301 | + * Returns 0 if {@link setFirstResult} was not applied to this QueryBuilder. |
|
| 302 | + * |
|
| 303 | + * @return int The position of the first result. |
|
| 304 | + * @since 8.2.0 |
|
| 305 | + */ |
|
| 306 | + public function getFirstResult(); |
|
| 307 | + |
|
| 308 | + /** |
|
| 309 | + * Sets the maximum number of results to retrieve (the "limit"). |
|
| 310 | + * |
|
| 311 | + * @param int|null $maxResults The maximum number of results to retrieve. |
|
| 312 | + * |
|
| 313 | + * @return $this This QueryBuilder instance. |
|
| 314 | + * @since 8.2.0 |
|
| 315 | + */ |
|
| 316 | + public function setMaxResults($maxResults); |
|
| 317 | + |
|
| 318 | + /** |
|
| 319 | + * Gets the maximum number of results the query object was set to retrieve (the "limit"). |
|
| 320 | + * Returns NULL if {@link setMaxResults} was not applied to this query builder. |
|
| 321 | + * |
|
| 322 | + * @return int|null The maximum number of results. |
|
| 323 | + * @since 8.2.0 |
|
| 324 | + */ |
|
| 325 | + public function getMaxResults(); |
|
| 326 | + |
|
| 327 | + /** |
|
| 328 | + * Specifies an item that is to be returned in the query result. |
|
| 329 | + * Replaces any previously specified selections, if any. |
|
| 330 | + * |
|
| 331 | + * <code> |
|
| 332 | + * $qb = $conn->getQueryBuilder() |
|
| 333 | + * ->select('u.id', 'p.id') |
|
| 334 | + * ->from('users', 'u') |
|
| 335 | + * ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id'); |
|
| 336 | + * </code> |
|
| 337 | + * |
|
| 338 | + * @param mixed ...$selects The selection expressions. |
|
| 339 | + * |
|
| 340 | + * @return $this This QueryBuilder instance. |
|
| 341 | + * @since 8.2.0 |
|
| 342 | + * |
|
| 343 | + * @psalm-taint-sink sql $selects |
|
| 344 | + */ |
|
| 345 | + public function select(...$selects); |
|
| 346 | + |
|
| 347 | + /** |
|
| 348 | + * Specifies an item that is to be returned with a different name in the query result. |
|
| 349 | + * |
|
| 350 | + * <code> |
|
| 351 | + * $qb = $conn->getQueryBuilder() |
|
| 352 | + * ->selectAlias('u.id', 'user_id') |
|
| 353 | + * ->from('users', 'u') |
|
| 354 | + * ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id'); |
|
| 355 | + * </code> |
|
| 356 | + * |
|
| 357 | + * @param mixed $select The selection expressions. |
|
| 358 | + * @param string $alias The column alias used in the constructed query. |
|
| 359 | + * |
|
| 360 | + * @return $this This QueryBuilder instance. |
|
| 361 | + * @since 8.2.1 |
|
| 362 | + * |
|
| 363 | + * @psalm-taint-sink sql $select |
|
| 364 | + * @psalm-taint-sink sql $alias |
|
| 365 | + */ |
|
| 366 | + public function selectAlias($select, $alias); |
|
| 367 | + |
|
| 368 | + /** |
|
| 369 | + * Specifies an item that is to be returned uniquely in the query result. |
|
| 370 | + * |
|
| 371 | + * <code> |
|
| 372 | + * $qb = $conn->getQueryBuilder() |
|
| 373 | + * ->selectDistinct('type') |
|
| 374 | + * ->from('users'); |
|
| 375 | + * </code> |
|
| 376 | + * |
|
| 377 | + * @param mixed $select The selection expressions. |
|
| 378 | + * |
|
| 379 | + * @return $this This QueryBuilder instance. |
|
| 380 | + * @since 9.0.0 |
|
| 381 | + * |
|
| 382 | + * @psalm-taint-sink sql $select |
|
| 383 | + */ |
|
| 384 | + public function selectDistinct($select); |
|
| 385 | + |
|
| 386 | + /** |
|
| 387 | + * Adds an item that is to be returned in the query result. |
|
| 388 | + * |
|
| 389 | + * <code> |
|
| 390 | + * $qb = $conn->getQueryBuilder() |
|
| 391 | + * ->select('u.id') |
|
| 392 | + * ->addSelect('p.id') |
|
| 393 | + * ->from('users', 'u') |
|
| 394 | + * ->leftJoin('u', 'phonenumbers', 'u.id = p.user_id'); |
|
| 395 | + * </code> |
|
| 396 | + * |
|
| 397 | + * @param mixed ...$select The selection expression. |
|
| 398 | + * |
|
| 399 | + * @return $this This QueryBuilder instance. |
|
| 400 | + * @since 8.2.0 |
|
| 401 | + * |
|
| 402 | + * @psalm-taint-sink sql $select |
|
| 403 | + */ |
|
| 404 | + public function addSelect(...$select); |
|
| 405 | + |
|
| 406 | + /** |
|
| 407 | + * Turns the query being built into a bulk delete query that ranges over |
|
| 408 | + * a certain table. |
|
| 409 | + * |
|
| 410 | + * <code> |
|
| 411 | + * $qb = $conn->getQueryBuilder() |
|
| 412 | + * ->delete('users', 'u') |
|
| 413 | + * ->where('u.id = :user_id'); |
|
| 414 | + * ->setParameter(':user_id', 1); |
|
| 415 | + * </code> |
|
| 416 | + * |
|
| 417 | + * @param string $delete The table whose rows are subject to the deletion. |
|
| 418 | + * @param string $alias The table alias used in the constructed query. |
|
| 419 | + * |
|
| 420 | + * @return $this This QueryBuilder instance. |
|
| 421 | + * @since 8.2.0 |
|
| 422 | + * |
|
| 423 | + * @psalm-taint-sink sql $delete |
|
| 424 | + */ |
|
| 425 | + public function delete($delete = null, $alias = null); |
|
| 426 | + |
|
| 427 | + /** |
|
| 428 | + * Turns the query being built into a bulk update query that ranges over |
|
| 429 | + * a certain table |
|
| 430 | + * |
|
| 431 | + * <code> |
|
| 432 | + * $qb = $conn->getQueryBuilder() |
|
| 433 | + * ->update('users', 'u') |
|
| 434 | + * ->set('u.password', md5('password')) |
|
| 435 | + * ->where('u.id = ?'); |
|
| 436 | + * </code> |
|
| 437 | + * |
|
| 438 | + * @param string $update The table whose rows are subject to the update. |
|
| 439 | + * @param string $alias The table alias used in the constructed query. |
|
| 440 | + * |
|
| 441 | + * @return $this This QueryBuilder instance. |
|
| 442 | + * @since 8.2.0 |
|
| 443 | + * |
|
| 444 | + * @psalm-taint-sink sql $update |
|
| 445 | + */ |
|
| 446 | + public function update($update = null, $alias = null); |
|
| 447 | + |
|
| 448 | + /** |
|
| 449 | + * Turns the query being built into an insert query that inserts into |
|
| 450 | + * a certain table |
|
| 451 | + * |
|
| 452 | + * <code> |
|
| 453 | + * $qb = $conn->getQueryBuilder() |
|
| 454 | + * ->insert('users') |
|
| 455 | + * ->values( |
|
| 456 | + * array( |
|
| 457 | + * 'name' => '?', |
|
| 458 | + * 'password' => '?' |
|
| 459 | + * ) |
|
| 460 | + * ); |
|
| 461 | + * </code> |
|
| 462 | + * |
|
| 463 | + * @param string $insert The table into which the rows should be inserted. |
|
| 464 | + * |
|
| 465 | + * @return $this This QueryBuilder instance. |
|
| 466 | + * @since 8.2.0 |
|
| 467 | + * |
|
| 468 | + * @psalm-taint-sink sql $insert |
|
| 469 | + */ |
|
| 470 | + public function insert($insert = null); |
|
| 471 | + |
|
| 472 | + /** |
|
| 473 | + * Creates and adds a query root corresponding to the table identified by the |
|
| 474 | + * given alias, forming a cartesian product with any existing query roots. |
|
| 475 | + * |
|
| 476 | + * <code> |
|
| 477 | + * $qb = $conn->getQueryBuilder() |
|
| 478 | + * ->select('u.id') |
|
| 479 | + * ->from('users', 'u') |
|
| 480 | + * </code> |
|
| 481 | + * |
|
| 482 | + * @param string|IQueryFunction $from The table. |
|
| 483 | + * @param string|null $alias The alias of the table. |
|
| 484 | + * |
|
| 485 | + * @return $this This QueryBuilder instance. |
|
| 486 | + * @since 8.2.0 |
|
| 487 | + * |
|
| 488 | + * @psalm-taint-sink sql $from |
|
| 489 | + */ |
|
| 490 | + public function from($from, $alias = null); |
|
| 491 | + |
|
| 492 | + /** |
|
| 493 | + * Creates and adds a join to the query. |
|
| 494 | + * |
|
| 495 | + * <code> |
|
| 496 | + * $qb = $conn->getQueryBuilder() |
|
| 497 | + * ->select('u.name') |
|
| 498 | + * ->from('users', 'u') |
|
| 499 | + * ->join('u', 'phonenumbers', 'p', 'p.is_primary = 1'); |
|
| 500 | + * </code> |
|
| 501 | + * |
|
| 502 | + * @param string $fromAlias The alias that points to a from clause. |
|
| 503 | + * @param string $join The table name to join. |
|
| 504 | + * @param string $alias The alias of the join table. |
|
| 505 | + * @param string|ICompositeExpression|null $condition The condition for the join. |
|
| 506 | + * |
|
| 507 | + * @return $this This QueryBuilder instance. |
|
| 508 | + * @since 8.2.0 |
|
| 509 | + * |
|
| 510 | + * @psalm-taint-sink sql $fromAlias |
|
| 511 | + * @psalm-taint-sink sql $join |
|
| 512 | + * @psalm-taint-sink sql $alias |
|
| 513 | + * @psalm-taint-sink sql $condition |
|
| 514 | + */ |
|
| 515 | + public function join($fromAlias, $join, $alias, $condition = null); |
|
| 516 | + |
|
| 517 | + /** |
|
| 518 | + * Creates and adds a join to the query. |
|
| 519 | + * |
|
| 520 | + * <code> |
|
| 521 | + * $qb = $conn->getQueryBuilder() |
|
| 522 | + * ->select('u.name') |
|
| 523 | + * ->from('users', 'u') |
|
| 524 | + * ->innerJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1'); |
|
| 525 | + * </code> |
|
| 526 | + * |
|
| 527 | + * @param string $fromAlias The alias that points to a from clause. |
|
| 528 | + * @param string $join The table name to join. |
|
| 529 | + * @param string $alias The alias of the join table. |
|
| 530 | + * @param string|ICompositeExpression|null $condition The condition for the join. |
|
| 531 | + * |
|
| 532 | + * @return $this This QueryBuilder instance. |
|
| 533 | + * @since 8.2.0 |
|
| 534 | + * |
|
| 535 | + * @psalm-taint-sink sql $fromAlias |
|
| 536 | + * @psalm-taint-sink sql $join |
|
| 537 | + * @psalm-taint-sink sql $alias |
|
| 538 | + * @psalm-taint-sink sql $condition |
|
| 539 | + */ |
|
| 540 | + public function innerJoin($fromAlias, $join, $alias, $condition = null); |
|
| 541 | + |
|
| 542 | + /** |
|
| 543 | + * Creates and adds a left join to the query. |
|
| 544 | + * |
|
| 545 | + * <code> |
|
| 546 | + * $qb = $conn->getQueryBuilder() |
|
| 547 | + * ->select('u.name') |
|
| 548 | + * ->from('users', 'u') |
|
| 549 | + * ->leftJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1'); |
|
| 550 | + * </code> |
|
| 551 | + * |
|
| 552 | + * @param string $fromAlias The alias that points to a from clause. |
|
| 553 | + * @param string $join The table name to join. |
|
| 554 | + * @param string $alias The alias of the join table. |
|
| 555 | + * @param string|ICompositeExpression|null $condition The condition for the join. |
|
| 556 | + * |
|
| 557 | + * @return $this This QueryBuilder instance. |
|
| 558 | + * @since 8.2.0 |
|
| 559 | + * |
|
| 560 | + * @psalm-taint-sink sql $fromAlias |
|
| 561 | + * @psalm-taint-sink sql $join |
|
| 562 | + * @psalm-taint-sink sql $alias |
|
| 563 | + * @psalm-taint-sink sql $condition |
|
| 564 | + */ |
|
| 565 | + public function leftJoin($fromAlias, $join, $alias, $condition = null); |
|
| 566 | + |
|
| 567 | + /** |
|
| 568 | + * Creates and adds a right join to the query. |
|
| 569 | + * |
|
| 570 | + * <code> |
|
| 571 | + * $qb = $conn->getQueryBuilder() |
|
| 572 | + * ->select('u.name') |
|
| 573 | + * ->from('users', 'u') |
|
| 574 | + * ->rightJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1'); |
|
| 575 | + * </code> |
|
| 576 | + * |
|
| 577 | + * @param string $fromAlias The alias that points to a from clause. |
|
| 578 | + * @param string $join The table name to join. |
|
| 579 | + * @param string $alias The alias of the join table. |
|
| 580 | + * @param string|ICompositeExpression|null $condition The condition for the join. |
|
| 581 | + * |
|
| 582 | + * @return $this This QueryBuilder instance. |
|
| 583 | + * @since 8.2.0 |
|
| 584 | + * |
|
| 585 | + * @psalm-taint-sink sql $fromAlias |
|
| 586 | + * @psalm-taint-sink sql $join |
|
| 587 | + * @psalm-taint-sink sql $alias |
|
| 588 | + * @psalm-taint-sink sql $condition |
|
| 589 | + */ |
|
| 590 | + public function rightJoin($fromAlias, $join, $alias, $condition = null); |
|
| 591 | + |
|
| 592 | + /** |
|
| 593 | + * Sets a new value for a column in a bulk update query. |
|
| 594 | + * |
|
| 595 | + * <code> |
|
| 596 | + * $qb = $conn->getQueryBuilder() |
|
| 597 | + * ->update('users', 'u') |
|
| 598 | + * ->set('u.password', md5('password')) |
|
| 599 | + * ->where('u.id = ?'); |
|
| 600 | + * </code> |
|
| 601 | + * |
|
| 602 | + * @param string $key The column to set. |
|
| 603 | + * @param ILiteral|IParameter|IQueryFunction|string $value The value, expression, placeholder, etc. |
|
| 604 | + * |
|
| 605 | + * @return $this This QueryBuilder instance. |
|
| 606 | + * @since 8.2.0 |
|
| 607 | + * |
|
| 608 | + * @psalm-taint-sink sql $key |
|
| 609 | + * @psalm-taint-sink sql $value |
|
| 610 | + */ |
|
| 611 | + public function set($key, $value); |
|
| 612 | + |
|
| 613 | + /** |
|
| 614 | + * Specifies one or more restrictions to the query result. |
|
| 615 | + * Replaces any previously specified restrictions, if any. |
|
| 616 | + * |
|
| 617 | + * <code> |
|
| 618 | + * $qb = $conn->getQueryBuilder() |
|
| 619 | + * ->select('u.name') |
|
| 620 | + * ->from('users', 'u') |
|
| 621 | + * ->where('u.id = ?'); |
|
| 622 | + * |
|
| 623 | + * // You can optionally programmatically build and/or expressions |
|
| 624 | + * $qb = $conn->getQueryBuilder(); |
|
| 625 | + * |
|
| 626 | + * $or = $qb->expr()->orx(); |
|
| 627 | + * $or->add($qb->expr()->eq('u.id', 1)); |
|
| 628 | + * $or->add($qb->expr()->eq('u.id', 2)); |
|
| 629 | + * |
|
| 630 | + * $qb->update('users', 'u') |
|
| 631 | + * ->set('u.password', md5('password')) |
|
| 632 | + * ->where($or); |
|
| 633 | + * </code> |
|
| 634 | + * |
|
| 635 | + * @param mixed $predicates The restriction predicates. |
|
| 636 | + * |
|
| 637 | + * @return $this This QueryBuilder instance. |
|
| 638 | + * @since 8.2.0 |
|
| 639 | + * |
|
| 640 | + * @psalm-taint-sink sql $predicates |
|
| 641 | + */ |
|
| 642 | + public function where(...$predicates); |
|
| 643 | + |
|
| 644 | + /** |
|
| 645 | + * Adds one or more restrictions to the query results, forming a logical |
|
| 646 | + * conjunction with any previously specified restrictions. |
|
| 647 | + * |
|
| 648 | + * <code> |
|
| 649 | + * $qb = $conn->getQueryBuilder() |
|
| 650 | + * ->select('u') |
|
| 651 | + * ->from('users', 'u') |
|
| 652 | + * ->where('u.username LIKE ?') |
|
| 653 | + * ->andWhere('u.is_active = 1'); |
|
| 654 | + * </code> |
|
| 655 | + * |
|
| 656 | + * @param mixed ...$where The query restrictions. |
|
| 657 | + * |
|
| 658 | + * @return $this This QueryBuilder instance. |
|
| 659 | + * |
|
| 660 | + * @see where() |
|
| 661 | + * @since 8.2.0 |
|
| 662 | + * |
|
| 663 | + * @psalm-taint-sink sql $where |
|
| 664 | + */ |
|
| 665 | + public function andWhere(...$where); |
|
| 666 | + |
|
| 667 | + /** |
|
| 668 | + * Adds one or more restrictions to the query results, forming a logical |
|
| 669 | + * disjunction with any previously specified restrictions. |
|
| 670 | + * |
|
| 671 | + * <code> |
|
| 672 | + * $qb = $conn->getQueryBuilder() |
|
| 673 | + * ->select('u.name') |
|
| 674 | + * ->from('users', 'u') |
|
| 675 | + * ->where('u.id = 1') |
|
| 676 | + * ->orWhere('u.id = 2'); |
|
| 677 | + * </code> |
|
| 678 | + * |
|
| 679 | + * @param mixed ...$where The WHERE statement. |
|
| 680 | + * |
|
| 681 | + * @return $this This QueryBuilder instance. |
|
| 682 | + * |
|
| 683 | + * @see where() |
|
| 684 | + * @since 8.2.0 |
|
| 685 | + * |
|
| 686 | + * @psalm-taint-sink sql $where |
|
| 687 | + */ |
|
| 688 | + public function orWhere(...$where); |
|
| 689 | + |
|
| 690 | + /** |
|
| 691 | + * Specifies a grouping over the results of the query. |
|
| 692 | + * Replaces any previously specified groupings, if any. |
|
| 693 | + * |
|
| 694 | + * <code> |
|
| 695 | + * $qb = $conn->getQueryBuilder() |
|
| 696 | + * ->select('u.name') |
|
| 697 | + * ->from('users', 'u') |
|
| 698 | + * ->groupBy('u.id'); |
|
| 699 | + * </code> |
|
| 700 | + * |
|
| 701 | + * @param mixed ...$groupBys The grouping expression. |
|
| 702 | + * |
|
| 703 | + * @return $this This QueryBuilder instance. |
|
| 704 | + * @since 8.2.0 |
|
| 705 | + * |
|
| 706 | + * @psalm-taint-sink sql $groupBys |
|
| 707 | + */ |
|
| 708 | + public function groupBy(...$groupBys); |
|
| 709 | + |
|
| 710 | + /** |
|
| 711 | + * Adds a grouping expression to the query. |
|
| 712 | + * |
|
| 713 | + * <code> |
|
| 714 | + * $qb = $conn->getQueryBuilder() |
|
| 715 | + * ->select('u.name') |
|
| 716 | + * ->from('users', 'u') |
|
| 717 | + * ->groupBy('u.lastLogin'); |
|
| 718 | + * ->addGroupBy('u.createdAt') |
|
| 719 | + * </code> |
|
| 720 | + * |
|
| 721 | + * @param mixed ...$groupBy The grouping expression. |
|
| 722 | + * |
|
| 723 | + * @return $this This QueryBuilder instance. |
|
| 724 | + * @since 8.2.0 |
|
| 725 | + * |
|
| 726 | + * @psalm-taint-sink sql $groupby |
|
| 727 | + */ |
|
| 728 | + public function addGroupBy(...$groupBy); |
|
| 729 | + |
|
| 730 | + /** |
|
| 731 | + * Sets a value for a column in an insert query. |
|
| 732 | + * |
|
| 733 | + * <code> |
|
| 734 | + * $qb = $conn->getQueryBuilder() |
|
| 735 | + * ->insert('users') |
|
| 736 | + * ->values( |
|
| 737 | + * array( |
|
| 738 | + * 'name' => '?' |
|
| 739 | + * ) |
|
| 740 | + * ) |
|
| 741 | + * ->setValue('password', '?'); |
|
| 742 | + * </code> |
|
| 743 | + * |
|
| 744 | + * @param string $column The column into which the value should be inserted. |
|
| 745 | + * @param IParameter|string $value The value that should be inserted into the column. |
|
| 746 | + * |
|
| 747 | + * @return $this This QueryBuilder instance. |
|
| 748 | + * @since 8.2.0 |
|
| 749 | + * |
|
| 750 | + * @psalm-taint-sink sql $column |
|
| 751 | + * @psalm-taint-sink sql $value |
|
| 752 | + */ |
|
| 753 | + public function setValue($column, $value); |
|
| 754 | + |
|
| 755 | + /** |
|
| 756 | + * Specifies values for an insert query indexed by column names. |
|
| 757 | + * Replaces any previous values, if any. |
|
| 758 | + * |
|
| 759 | + * <code> |
|
| 760 | + * $qb = $conn->getQueryBuilder() |
|
| 761 | + * ->insert('users') |
|
| 762 | + * ->values( |
|
| 763 | + * array( |
|
| 764 | + * 'name' => '?', |
|
| 765 | + * 'password' => '?' |
|
| 766 | + * ) |
|
| 767 | + * ); |
|
| 768 | + * </code> |
|
| 769 | + * |
|
| 770 | + * @param array $values The values to specify for the insert query indexed by column names. |
|
| 771 | + * |
|
| 772 | + * @return $this This QueryBuilder instance. |
|
| 773 | + * @since 8.2.0 |
|
| 774 | + * |
|
| 775 | + * @psalm-taint-sink sql $values |
|
| 776 | + */ |
|
| 777 | + public function values(array $values); |
|
| 778 | + |
|
| 779 | + /** |
|
| 780 | + * Specifies a restriction over the groups of the query. |
|
| 781 | + * Replaces any previous having restrictions, if any. |
|
| 782 | + * |
|
| 783 | + * @param mixed ...$having The restriction over the groups. |
|
| 784 | + * |
|
| 785 | + * @return $this This QueryBuilder instance. |
|
| 786 | + * @since 8.2.0 |
|
| 787 | + * |
|
| 788 | + * @psalm-taint-sink sql $having |
|
| 789 | + */ |
|
| 790 | + public function having(...$having); |
|
| 791 | + |
|
| 792 | + /** |
|
| 793 | + * Adds a restriction over the groups of the query, forming a logical |
|
| 794 | + * conjunction with any existing having restrictions. |
|
| 795 | + * |
|
| 796 | + * @param mixed ...$having The restriction to append. |
|
| 797 | + * |
|
| 798 | + * @return $this This QueryBuilder instance. |
|
| 799 | + * @since 8.2.0 |
|
| 800 | + * |
|
| 801 | + * @psalm-taint-sink sql $andHaving |
|
| 802 | + */ |
|
| 803 | + public function andHaving(...$having); |
|
| 804 | + |
|
| 805 | + /** |
|
| 806 | + * Adds a restriction over the groups of the query, forming a logical |
|
| 807 | + * disjunction with any existing having restrictions. |
|
| 808 | + * |
|
| 809 | + * @param mixed ...$having The restriction to add. |
|
| 810 | + * |
|
| 811 | + * @return $this This QueryBuilder instance. |
|
| 812 | + * @since 8.2.0 |
|
| 813 | + * |
|
| 814 | + * @psalm-taint-sink sql $having |
|
| 815 | + */ |
|
| 816 | + public function orHaving(...$having); |
|
| 817 | + |
|
| 818 | + /** |
|
| 819 | + * Specifies an ordering for the query results. |
|
| 820 | + * Replaces any previously specified orderings, if any. |
|
| 821 | + * |
|
| 822 | + * @param string|IQueryFunction|ILiteral|IParameter $sort The ordering expression. |
|
| 823 | + * @param string $order The ordering direction. |
|
| 824 | + * |
|
| 825 | + * @return $this This QueryBuilder instance. |
|
| 826 | + * @since 8.2.0 |
|
| 827 | + * |
|
| 828 | + * @psalm-taint-sink sql $sort |
|
| 829 | + * @psalm-taint-sink sql $order |
|
| 830 | + */ |
|
| 831 | + public function orderBy($sort, $order = null); |
|
| 832 | + |
|
| 833 | + /** |
|
| 834 | + * Adds an ordering to the query results. |
|
| 835 | + * |
|
| 836 | + * @param string|ILiteral|IParameter|IQueryFunction $sort The ordering expression. |
|
| 837 | + * @param string $order The ordering direction. |
|
| 838 | + * |
|
| 839 | + * @return $this This QueryBuilder instance. |
|
| 840 | + * @since 8.2.0 |
|
| 841 | + * |
|
| 842 | + * @psalm-taint-sink sql $sort |
|
| 843 | + * @psalm-taint-sink sql $order |
|
| 844 | + */ |
|
| 845 | + public function addOrderBy($sort, $order = null); |
|
| 846 | + |
|
| 847 | + /** |
|
| 848 | + * Gets a query part by its name. |
|
| 849 | + * |
|
| 850 | + * @param string $queryPartName |
|
| 851 | + * |
|
| 852 | + * @return mixed |
|
| 853 | + * @since 8.2.0 |
|
| 854 | + */ |
|
| 855 | + public function getQueryPart($queryPartName); |
|
| 856 | + |
|
| 857 | + /** |
|
| 858 | + * Gets all query parts. |
|
| 859 | + * |
|
| 860 | + * @return array |
|
| 861 | + * @since 8.2.0 |
|
| 862 | + */ |
|
| 863 | + public function getQueryParts(); |
|
| 864 | + |
|
| 865 | + /** |
|
| 866 | + * Resets SQL parts. |
|
| 867 | + * |
|
| 868 | + * @param array|null $queryPartNames |
|
| 869 | + * |
|
| 870 | + * @return $this This QueryBuilder instance. |
|
| 871 | + * @since 8.2.0 |
|
| 872 | + */ |
|
| 873 | + public function resetQueryParts($queryPartNames = null); |
|
| 874 | + |
|
| 875 | + /** |
|
| 876 | + * Resets a single SQL part. |
|
| 877 | + * |
|
| 878 | + * @param string $queryPartName |
|
| 879 | + * |
|
| 880 | + * @return $this This QueryBuilder instance. |
|
| 881 | + * @since 8.2.0 |
|
| 882 | + */ |
|
| 883 | + public function resetQueryPart($queryPartName); |
|
| 884 | + |
|
| 885 | + /** |
|
| 886 | + * Creates a new named parameter and bind the value $value to it. |
|
| 887 | + * |
|
| 888 | + * This method provides a shortcut for PDOStatement::bindValue |
|
| 889 | + * when using prepared statements. |
|
| 890 | + * |
|
| 891 | + * The parameter $value specifies the value that you want to bind. If |
|
| 892 | + * $placeholder is not provided bindValue() will automatically create a |
|
| 893 | + * placeholder for you. An automatic placeholder will be of the name |
|
| 894 | + * ':dcValue1', ':dcValue2' etc. |
|
| 895 | + * |
|
| 896 | + * For more information see {@link https://www.php.net/pdostatement-bindparam} |
|
| 897 | + * |
|
| 898 | + * Example: |
|
| 899 | + * <code> |
|
| 900 | + * $value = 2; |
|
| 901 | + * $q->eq( 'id', $q->bindValue( $value ) ); |
|
| 902 | + * $stmt = $q->executeQuery(); // executed with 'id = 2' |
|
| 903 | + * </code> |
|
| 904 | + * |
|
| 905 | + * @license New BSD License |
|
| 906 | + * @link http://www.zetacomponents.org |
|
| 907 | + * |
|
| 908 | + * @param mixed $value |
|
| 909 | + * @param mixed $type |
|
| 910 | + * @param string $placeHolder The name to bind with. The string must start with a colon ':'. |
|
| 911 | + * |
|
| 912 | + * @return IParameter |
|
| 913 | + * @since 8.2.0 |
|
| 914 | + * |
|
| 915 | + * @psalm-taint-escape sql |
|
| 916 | + */ |
|
| 917 | + public function createNamedParameter($value, $type = self::PARAM_STR, $placeHolder = null); |
|
| 918 | + |
|
| 919 | + /** |
|
| 920 | + * Creates a new positional parameter and bind the given value to it. |
|
| 921 | + * |
|
| 922 | + * Attention: If you are using positional parameters with the query builder you have |
|
| 923 | + * to be very careful to bind all parameters in the order they appear in the SQL |
|
| 924 | + * statement , otherwise they get bound in the wrong order which can lead to serious |
|
| 925 | + * bugs in your code. |
|
| 926 | + * |
|
| 927 | + * Example: |
|
| 928 | + * <code> |
|
| 929 | + * $qb = $conn->getQueryBuilder(); |
|
| 930 | + * $qb->select('u.*') |
|
| 931 | + * ->from('users', 'u') |
|
| 932 | + * ->where('u.username = ' . $qb->createPositionalParameter('Foo', IQueryBuilder::PARAM_STR)) |
|
| 933 | + * ->orWhere('u.username = ' . $qb->createPositionalParameter('Bar', IQueryBuilder::PARAM_STR)) |
|
| 934 | + * </code> |
|
| 935 | + * |
|
| 936 | + * @param mixed $value |
|
| 937 | + * @param integer $type |
|
| 938 | + * |
|
| 939 | + * @return IParameter |
|
| 940 | + * @since 8.2.0 |
|
| 941 | + * |
|
| 942 | + * @psalm-taint-escape sql |
|
| 943 | + */ |
|
| 944 | + public function createPositionalParameter($value, $type = self::PARAM_STR); |
|
| 945 | + |
|
| 946 | + /** |
|
| 947 | + * Creates a new parameter |
|
| 948 | + * |
|
| 949 | + * Example: |
|
| 950 | + * <code> |
|
| 951 | + * $qb = $conn->getQueryBuilder(); |
|
| 952 | + * $qb->select('u.*') |
|
| 953 | + * ->from('users', 'u') |
|
| 954 | + * ->where('u.username = ' . $qb->createParameter('name')) |
|
| 955 | + * ->setParameter('name', 'Bar', IQueryBuilder::PARAM_STR)) |
|
| 956 | + * </code> |
|
| 957 | + * |
|
| 958 | + * @param string $name |
|
| 959 | + * |
|
| 960 | + * @return IParameter |
|
| 961 | + * @since 8.2.0 |
|
| 962 | + * |
|
| 963 | + * @psalm-taint-escape sql |
|
| 964 | + */ |
|
| 965 | + public function createParameter($name); |
|
| 966 | + |
|
| 967 | + /** |
|
| 968 | + * Creates a new function |
|
| 969 | + * |
|
| 970 | + * Attention: Column names inside the call have to be quoted before hand |
|
| 971 | + * |
|
| 972 | + * Example: |
|
| 973 | + * <code> |
|
| 974 | + * $qb = $conn->getQueryBuilder(); |
|
| 975 | + * $qb->select($qb->createFunction('COUNT(*)')) |
|
| 976 | + * ->from('users', 'u') |
|
| 977 | + * echo $qb->getSQL(); // SELECT COUNT(*) FROM `users` u |
|
| 978 | + * </code> |
|
| 979 | + * <code> |
|
| 980 | + * $qb = $conn->getQueryBuilder(); |
|
| 981 | + * $qb->select($qb->createFunction('COUNT(`column`)')) |
|
| 982 | + * ->from('users', 'u') |
|
| 983 | + * echo $qb->getSQL(); // SELECT COUNT(`column`) FROM `users` u |
|
| 984 | + * </code> |
|
| 985 | + * |
|
| 986 | + * @param string $call |
|
| 987 | + * |
|
| 988 | + * @return IQueryFunction |
|
| 989 | + * @since 8.2.0 |
|
| 990 | + * |
|
| 991 | + * @psalm-taint-sink sql |
|
| 992 | + */ |
|
| 993 | + public function createFunction($call); |
|
| 994 | + |
|
| 995 | + /** |
|
| 996 | + * Used to get the id of the last inserted element |
|
| 997 | + * @return int |
|
| 998 | + * @throws \BadMethodCallException When being called before an insert query has been run. |
|
| 999 | + * @since 9.0.0 |
|
| 1000 | + */ |
|
| 1001 | + public function getLastInsertId(): int; |
|
| 1002 | + |
|
| 1003 | + /** |
|
| 1004 | + * Returns the table name quoted and with database prefix as needed by the implementation |
|
| 1005 | + * |
|
| 1006 | + * @param string|IQueryFunction $table |
|
| 1007 | + * @return string |
|
| 1008 | + * @since 9.0.0 |
|
| 1009 | + */ |
|
| 1010 | + public function getTableName($table); |
|
| 1011 | + |
|
| 1012 | + /** |
|
| 1013 | + * Returns the column name quoted and with table alias prefix as needed by the implementation |
|
| 1014 | + * |
|
| 1015 | + * @param string $column |
|
| 1016 | + * @param string $tableAlias |
|
| 1017 | + * @return string |
|
| 1018 | + * @since 9.0.0 |
|
| 1019 | + */ |
|
| 1020 | + public function getColumnName($column, $tableAlias = ''); |
|
| 1021 | 1021 | } |
@@ -35,133 +35,133 @@ |
||
| 35 | 35 | * @since 15.0.0 |
| 36 | 36 | */ |
| 37 | 37 | interface IAccount extends \JsonSerializable { |
| 38 | - /** |
|
| 39 | - * Set a property with data |
|
| 40 | - * |
|
| 41 | - * @since 15.0.0 |
|
| 42 | - * |
|
| 43 | - * @param string $property Must be one of the PROPERTY_ prefixed constants of \OCP\Accounts\IAccountManager |
|
| 44 | - * @param string $value |
|
| 45 | - * @param string $scope Must be one of the VISIBILITY_ prefixed constants of \OCP\Accounts\IAccountManager |
|
| 46 | - * @param string $verified \OCP\Accounts\IAccountManager::NOT_VERIFIED | \OCP\Accounts\IAccountManager::VERIFICATION_IN_PROGRESS | \OCP\Accounts\IAccountManager::VERIFIED |
|
| 47 | - * @param string $verificationData Optional, defaults to empty string. Since @22.0.0. |
|
| 48 | - * @return IAccount |
|
| 49 | - */ |
|
| 50 | - public function setProperty(string $property, string $value, string $scope, string $verified, string $verificationData = ''): IAccount; |
|
| 38 | + /** |
|
| 39 | + * Set a property with data |
|
| 40 | + * |
|
| 41 | + * @since 15.0.0 |
|
| 42 | + * |
|
| 43 | + * @param string $property Must be one of the PROPERTY_ prefixed constants of \OCP\Accounts\IAccountManager |
|
| 44 | + * @param string $value |
|
| 45 | + * @param string $scope Must be one of the VISIBILITY_ prefixed constants of \OCP\Accounts\IAccountManager |
|
| 46 | + * @param string $verified \OCP\Accounts\IAccountManager::NOT_VERIFIED | \OCP\Accounts\IAccountManager::VERIFICATION_IN_PROGRESS | \OCP\Accounts\IAccountManager::VERIFIED |
|
| 47 | + * @param string $verificationData Optional, defaults to empty string. Since @22.0.0. |
|
| 48 | + * @return IAccount |
|
| 49 | + */ |
|
| 50 | + public function setProperty(string $property, string $value, string $scope, string $verified, string $verificationData = ''): IAccount; |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Get a property by its key |
|
| 54 | - * |
|
| 55 | - * @since 15.0.0 |
|
| 56 | - * |
|
| 57 | - * @param string $property Must be one of the PROPERTY_ prefixed constants of \OCP\Accounts\IAccountManager |
|
| 58 | - * @return IAccountProperty |
|
| 59 | - * @throws PropertyDoesNotExistException |
|
| 60 | - */ |
|
| 61 | - public function getProperty(string $property): IAccountProperty; |
|
| 52 | + /** |
|
| 53 | + * Get a property by its key |
|
| 54 | + * |
|
| 55 | + * @since 15.0.0 |
|
| 56 | + * |
|
| 57 | + * @param string $property Must be one of the PROPERTY_ prefixed constants of \OCP\Accounts\IAccountManager |
|
| 58 | + * @return IAccountProperty |
|
| 59 | + * @throws PropertyDoesNotExistException |
|
| 60 | + */ |
|
| 61 | + public function getProperty(string $property): IAccountProperty; |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Get all properties of an account. Array indices are property names. |
|
| 65 | - * Values from IAccountPropertyCollections are not included in the return |
|
| 66 | - * array. |
|
| 67 | - * |
|
| 68 | - * @since 15.0.0 |
|
| 69 | - * @deprecated 22.0.0 use getAllProperties() |
|
| 70 | - */ |
|
| 71 | - public function getProperties(): array; |
|
| 63 | + /** |
|
| 64 | + * Get all properties of an account. Array indices are property names. |
|
| 65 | + * Values from IAccountPropertyCollections are not included in the return |
|
| 66 | + * array. |
|
| 67 | + * |
|
| 68 | + * @since 15.0.0 |
|
| 69 | + * @deprecated 22.0.0 use getAllProperties() |
|
| 70 | + */ |
|
| 71 | + public function getProperties(): array; |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Set all properties of an account |
|
| 75 | - * |
|
| 76 | - * @param array<string, array<string, string>>|array<string, array<int, array<string, string>>> $properties |
|
| 77 | - * |
|
| 78 | - * e.g. `[ |
|
| 79 | - * 'displayname' => [ |
|
| 80 | - * 'name' => 'displayname', |
|
| 81 | - * 'value' => 'Jonathan Smith', |
|
| 82 | - * 'scope' => 'v2-federated', |
|
| 83 | - * 'verified' => '0', |
|
| 84 | - * 'verificationData' => '', |
|
| 85 | - * ], |
|
| 86 | - * 'email' => [ |
|
| 87 | - * 'name' => 'email', |
|
| 88 | - * 'value' => '[email protected]', |
|
| 89 | - * 'scope' => 'v2-federated', |
|
| 90 | - * 'verified' => '0', |
|
| 91 | - * 'verificationData' => '', |
|
| 92 | - * ], |
|
| 93 | - * // ... |
|
| 94 | - * 'additional_mail' => [ |
|
| 95 | - * [ |
|
| 96 | - * 'name' => 'additional_mail', |
|
| 97 | - * 'value' => '[email protected]', |
|
| 98 | - * 'scope' => 'v2-local', |
|
| 99 | - * 'verified' => '0', |
|
| 100 | - * 'verificationData' => '', |
|
| 101 | - * ], |
|
| 102 | - * [ |
|
| 103 | - * 'name' => 'additional_mail', |
|
| 104 | - * 'value' => '[email protected]', |
|
| 105 | - * 'scope' => 'v2-local', |
|
| 106 | - * 'verified' => '0', |
|
| 107 | - * 'verificationData' => '', |
|
| 108 | - * ], |
|
| 109 | - * ], |
|
| 110 | - * ]` |
|
| 111 | - * |
|
| 112 | - * @since 24.0.0 |
|
| 113 | - */ |
|
| 114 | - public function setAllPropertiesFromJson(array $properties): IAccount; |
|
| 73 | + /** |
|
| 74 | + * Set all properties of an account |
|
| 75 | + * |
|
| 76 | + * @param array<string, array<string, string>>|array<string, array<int, array<string, string>>> $properties |
|
| 77 | + * |
|
| 78 | + * e.g. `[ |
|
| 79 | + * 'displayname' => [ |
|
| 80 | + * 'name' => 'displayname', |
|
| 81 | + * 'value' => 'Jonathan Smith', |
|
| 82 | + * 'scope' => 'v2-federated', |
|
| 83 | + * 'verified' => '0', |
|
| 84 | + * 'verificationData' => '', |
|
| 85 | + * ], |
|
| 86 | + * 'email' => [ |
|
| 87 | + * 'name' => 'email', |
|
| 88 | + * 'value' => '[email protected]', |
|
| 89 | + * 'scope' => 'v2-federated', |
|
| 90 | + * 'verified' => '0', |
|
| 91 | + * 'verificationData' => '', |
|
| 92 | + * ], |
|
| 93 | + * // ... |
|
| 94 | + * 'additional_mail' => [ |
|
| 95 | + * [ |
|
| 96 | + * 'name' => 'additional_mail', |
|
| 97 | + * 'value' => '[email protected]', |
|
| 98 | + * 'scope' => 'v2-local', |
|
| 99 | + * 'verified' => '0', |
|
| 100 | + * 'verificationData' => '', |
|
| 101 | + * ], |
|
| 102 | + * [ |
|
| 103 | + * 'name' => 'additional_mail', |
|
| 104 | + * 'value' => '[email protected]', |
|
| 105 | + * 'scope' => 'v2-local', |
|
| 106 | + * 'verified' => '0', |
|
| 107 | + * 'verificationData' => '', |
|
| 108 | + * ], |
|
| 109 | + * ], |
|
| 110 | + * ]` |
|
| 111 | + * |
|
| 112 | + * @since 24.0.0 |
|
| 113 | + */ |
|
| 114 | + public function setAllPropertiesFromJson(array $properties): IAccount; |
|
| 115 | 115 | |
| 116 | - /** |
|
| 117 | - * Get all properties of an account. Array indices are numeric. To get |
|
| 118 | - * the property name, call getName() against the value. |
|
| 119 | - * |
|
| 120 | - * IAccountPropertyCollections are being flattened into an IAccountProperty |
|
| 121 | - * for each value. |
|
| 122 | - * |
|
| 123 | - * @since 22.0.0 |
|
| 124 | - * |
|
| 125 | - * @return Generator<int, IAccountProperty> |
|
| 126 | - */ |
|
| 127 | - public function getAllProperties(): Generator; |
|
| 116 | + /** |
|
| 117 | + * Get all properties of an account. Array indices are numeric. To get |
|
| 118 | + * the property name, call getName() against the value. |
|
| 119 | + * |
|
| 120 | + * IAccountPropertyCollections are being flattened into an IAccountProperty |
|
| 121 | + * for each value. |
|
| 122 | + * |
|
| 123 | + * @since 22.0.0 |
|
| 124 | + * |
|
| 125 | + * @return Generator<int, IAccountProperty> |
|
| 126 | + */ |
|
| 127 | + public function getAllProperties(): Generator; |
|
| 128 | 128 | |
| 129 | - /** |
|
| 130 | - * Set a property collection (multi-value properties) |
|
| 131 | - * |
|
| 132 | - * @since 22.0.0 |
|
| 133 | - */ |
|
| 134 | - public function setPropertyCollection(IAccountPropertyCollection $propertyCollection): IAccount; |
|
| 129 | + /** |
|
| 130 | + * Set a property collection (multi-value properties) |
|
| 131 | + * |
|
| 132 | + * @since 22.0.0 |
|
| 133 | + */ |
|
| 134 | + public function setPropertyCollection(IAccountPropertyCollection $propertyCollection): IAccount; |
|
| 135 | 135 | |
| 136 | - /** |
|
| 137 | - * Returns the requested property collection (multi-value properties) |
|
| 138 | - * |
|
| 139 | - * @throws PropertyDoesNotExistException against invalid collection name |
|
| 140 | - * @since 22.0.0 |
|
| 141 | - */ |
|
| 142 | - public function getPropertyCollection(string $propertyCollectionName): IAccountPropertyCollection; |
|
| 136 | + /** |
|
| 137 | + * Returns the requested property collection (multi-value properties) |
|
| 138 | + * |
|
| 139 | + * @throws PropertyDoesNotExistException against invalid collection name |
|
| 140 | + * @since 22.0.0 |
|
| 141 | + */ |
|
| 142 | + public function getPropertyCollection(string $propertyCollectionName): IAccountPropertyCollection; |
|
| 143 | 143 | |
| 144 | - /** |
|
| 145 | - * Get all properties that match the provided filters for scope and verification status |
|
| 146 | - * |
|
| 147 | - * Since 22.0.0 values from IAccountPropertyCollection are included, but also |
|
| 148 | - * as IAccountProperty instances. They for properties of IAccountPropertyCollection are |
|
| 149 | - * suffixed incrementally, i.e. #0, #1 ... #n – the numbers have no further meaning. |
|
| 150 | - * |
|
| 151 | - * @since 15.0.0 |
|
| 152 | - * |
|
| 153 | - * @param string $scope Must be one of the VISIBILITY_ prefixed constants of \OCP\Accounts\IAccountManager |
|
| 154 | - * @param string $verified \OCP\Accounts\IAccountManager::NOT_VERIFIED | \OCP\Accounts\IAccountManager::VERIFICATION_IN_PROGRESS | \OCP\Accounts\IAccountManager::VERIFIED |
|
| 155 | - * @return IAccountProperty[] |
|
| 156 | - */ |
|
| 157 | - public function getFilteredProperties(string $scope = null, string $verified = null): array; |
|
| 144 | + /** |
|
| 145 | + * Get all properties that match the provided filters for scope and verification status |
|
| 146 | + * |
|
| 147 | + * Since 22.0.0 values from IAccountPropertyCollection are included, but also |
|
| 148 | + * as IAccountProperty instances. They for properties of IAccountPropertyCollection are |
|
| 149 | + * suffixed incrementally, i.e. #0, #1 ... #n – the numbers have no further meaning. |
|
| 150 | + * |
|
| 151 | + * @since 15.0.0 |
|
| 152 | + * |
|
| 153 | + * @param string $scope Must be one of the VISIBILITY_ prefixed constants of \OCP\Accounts\IAccountManager |
|
| 154 | + * @param string $verified \OCP\Accounts\IAccountManager::NOT_VERIFIED | \OCP\Accounts\IAccountManager::VERIFICATION_IN_PROGRESS | \OCP\Accounts\IAccountManager::VERIFIED |
|
| 155 | + * @return IAccountProperty[] |
|
| 156 | + */ |
|
| 157 | + public function getFilteredProperties(string $scope = null, string $verified = null): array; |
|
| 158 | 158 | |
| 159 | - /** |
|
| 160 | - * Get the related user for the account data |
|
| 161 | - * |
|
| 162 | - * @since 15.0.0 |
|
| 163 | - * |
|
| 164 | - * @return IUser |
|
| 165 | - */ |
|
| 166 | - public function getUser(): IUser; |
|
| 159 | + /** |
|
| 160 | + * Get the related user for the account data |
|
| 161 | + * |
|
| 162 | + * @since 15.0.0 |
|
| 163 | + * |
|
| 164 | + * @return IUser |
|
| 165 | + */ |
|
| 166 | + public function getUser(): IUser; |
|
| 167 | 167 | } |
@@ -37,64 +37,64 @@ |
||
| 37 | 37 | * @since 22.0.0 |
| 38 | 38 | */ |
| 39 | 39 | interface IAccountPropertyCollection extends JsonSerializable { |
| 40 | - /** |
|
| 41 | - * returns the collection name |
|
| 42 | - * |
|
| 43 | - * @since 22.0.0 |
|
| 44 | - */ |
|
| 45 | - public function getName(): string; |
|
| 40 | + /** |
|
| 41 | + * returns the collection name |
|
| 42 | + * |
|
| 43 | + * @since 22.0.0 |
|
| 44 | + */ |
|
| 45 | + public function getName(): string; |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * set properties of this collection |
|
| 49 | - * |
|
| 50 | - * @param IAccountProperty[] $properties |
|
| 51 | - * @throws InvalidArgumentException |
|
| 52 | - * @since 22.0.0 |
|
| 53 | - */ |
|
| 54 | - public function setProperties(array $properties): IAccountPropertyCollection; |
|
| 47 | + /** |
|
| 48 | + * set properties of this collection |
|
| 49 | + * |
|
| 50 | + * @param IAccountProperty[] $properties |
|
| 51 | + * @throws InvalidArgumentException |
|
| 52 | + * @since 22.0.0 |
|
| 53 | + */ |
|
| 54 | + public function setProperties(array $properties): IAccountPropertyCollection; |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @return IAccountProperty[] |
|
| 58 | - * @since 22.0.0 |
|
| 59 | - */ |
|
| 60 | - public function getProperties(): array; |
|
| 56 | + /** |
|
| 57 | + * @return IAccountProperty[] |
|
| 58 | + * @since 22.0.0 |
|
| 59 | + */ |
|
| 60 | + public function getProperties(): array; |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * adds a property to this collection |
|
| 64 | - * |
|
| 65 | - * @throws InvalidArgumentException |
|
| 66 | - * @since 22.0.0 |
|
| 67 | - */ |
|
| 68 | - public function addProperty(IAccountProperty $property): IAccountPropertyCollection; |
|
| 62 | + /** |
|
| 63 | + * adds a property to this collection |
|
| 64 | + * |
|
| 65 | + * @throws InvalidArgumentException |
|
| 66 | + * @since 22.0.0 |
|
| 67 | + */ |
|
| 68 | + public function addProperty(IAccountProperty $property): IAccountPropertyCollection; |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * adds a property to this collection with only specifying the value |
|
| 72 | - * |
|
| 73 | - * @throws InvalidArgumentException |
|
| 74 | - * @since 22.0.0 |
|
| 75 | - */ |
|
| 76 | - public function addPropertyWithDefaults(string $value): IAccountPropertyCollection; |
|
| 70 | + /** |
|
| 71 | + * adds a property to this collection with only specifying the value |
|
| 72 | + * |
|
| 73 | + * @throws InvalidArgumentException |
|
| 74 | + * @since 22.0.0 |
|
| 75 | + */ |
|
| 76 | + public function addPropertyWithDefaults(string $value): IAccountPropertyCollection; |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * removes a property of this collection |
|
| 80 | - * |
|
| 81 | - * @since 22.0.0 |
|
| 82 | - */ |
|
| 83 | - public function removeProperty(IAccountProperty $property): IAccountPropertyCollection; |
|
| 78 | + /** |
|
| 79 | + * removes a property of this collection |
|
| 80 | + * |
|
| 81 | + * @since 22.0.0 |
|
| 82 | + */ |
|
| 83 | + public function removeProperty(IAccountProperty $property): IAccountPropertyCollection; |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * removes a property identified by its value |
|
| 87 | - * |
|
| 88 | - * @since 22.0.0 |
|
| 89 | - */ |
|
| 90 | - public function removePropertyByValue(string $value): IAccountPropertyCollection; |
|
| 85 | + /** |
|
| 86 | + * removes a property identified by its value |
|
| 87 | + * |
|
| 88 | + * @since 22.0.0 |
|
| 89 | + */ |
|
| 90 | + public function removePropertyByValue(string $value): IAccountPropertyCollection; |
|
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * retrieves a property identified by its value. null, if none was found. |
|
| 94 | - * |
|
| 95 | - * Returns only the first property if there are more with the same value. |
|
| 96 | - * |
|
| 97 | - * @since 23.0.0 |
|
| 98 | - */ |
|
| 99 | - public function getPropertyByValue(string $value): ?IAccountProperty; |
|
| 92 | + /** |
|
| 93 | + * retrieves a property identified by its value. null, if none was found. |
|
| 94 | + * |
|
| 95 | + * Returns only the first property if there are more with the same value. |
|
| 96 | + * |
|
| 97 | + * @since 23.0.0 |
|
| 98 | + */ |
|
| 99 | + public function getPropertyByValue(string $value): ?IAccountProperty; |
|
| 100 | 100 | } |