22 public static function handleUpdatedSourceObject($a_src_obj_type, $a_src_obj_id, $a_src_filesize, $a_owner_obj_ids = null, $a_is_prtf =
false)
27 if (is_array($a_owner_obj_ids) &&
sizeof($a_owner_obj_ids) && (
int) $a_src_filesize > 0) {
34 $set = $ilDB->query(
"SELECT DISTINCT(od.owner)" .
35 " FROM object_data od" .
36 " JOIN object_reference_ws ref ON (ref.obj_id = od.obj_id)" .
37 " JOIN tree_workspace t ON (t.child = ref.wsp_id)" .
38 " WHERE " . $ilDB->in(
"od.obj_id", $a_owner_obj_ids,
"",
"integer") .
39 " AND t.tree = od.owner");
41 while (
$row = $ilDB->fetchAssoc($set)) {
42 if (!in_array(
$row[
"owner"], $owners)) {
43 $owners[] =
$row[
"owner"];
46 $set = $ilDB->query(
"SELECT DISTINCT(od.owner)" .
47 " FROM object_data od" .
48 " JOIN usr_portfolio prtf ON (prtf.id = od.obj_id)" .
49 " WHERE " . $ilDB->in(
"od.obj_id", $a_owner_obj_ids,
"",
"integer"));
50 while (
$row = $ilDB->fetchAssoc($set)) {
51 if (!in_array(
$row[
"owner"], $owners)) {
52 $owners[] =
$row[
"owner"];
55 foreach ($owners as $owner) {
68 $existing = self::getOwnersBySourceObject($a_src_obj_type, $a_src_obj_id);
69 $existing = array_diff($existing, $done);
70 if (
sizeof($existing)) {
71 foreach ($existing as $owner) {
72 self::deleteEntry($owner, $a_src_obj_type, $a_src_obj_id);
84 protected static function deleteEntry($a_owner_id, $a_src_obj_type, $a_src_obj_id)
88 $ilDB->manipulate(
"DELETE FROM il_disk_quota" .
89 " WHERE owner_id = " . $ilDB->quote($a_owner_id,
"integer") .
90 " AND src_type = " . $ilDB->quote($a_src_obj_type,
"text") .
91 " AND src_obj_id = " . $ilDB->quote($a_src_obj_id,
"integer"));
103 $ilDB->manipulate(
"DELETE FROM il_disk_quota" .
104 " WHERE owner_id = " . $ilDB->quote($a_owner_id,
"integer"));
120 $set = $ilDB->query(
"SELECT owner_id" .
121 " FROM il_disk_quota" .
122 " WHERE src_type = " . $ilDB->quote($a_src_obj_type,
"text") .
123 " AND src_obj_id = " . $ilDB->quote($a_src_obj_id,
"integer"));
124 while (
$row = $ilDB->fetchAssoc($set)) {
143 $set = $ilDB->query(
"SELECT src_type, src_obj_id" .
144 " FROM il_disk_quota" .
145 " WHERE owner_id = " . $ilDB->quote($a_owner_id,
"integer"));
146 while (
$row = $ilDB->fetchAssoc($set)) {
147 $res[
$row[
"src_type"]][] = $row[
"src_obj_id"];
161 protected static function handleEntry($a_owner_id, $a_src_obj_type, $a_src_obj_id, $a_src_filesize)
165 $existing = self::getSourceObjectsByOwner($a_owner_id);
169 isset($existing[$a_src_obj_type]) &&
170 in_array($a_src_obj_id, $existing[$a_src_obj_type])) {
171 $ilDB->manipulate(
"UPDATE il_disk_quota" .
172 " SET src_size = " . $ilDB->quote($a_src_filesize,
"integer") .
173 " WHERE owner_id = " . $ilDB->quote($a_owner_id,
"integer") .
174 " AND src_type = " . $ilDB->quote($a_src_obj_type,
"text") .
175 " AND src_obj_id = " . $ilDB->quote($a_src_obj_id,
"integer"));
179 $ilDB->manipulate(
"INSERT INTO il_disk_quota" .
180 " (owner_id, src_type, src_obj_id, src_size)" .
181 " VALUES (" . $ilDB->quote($a_owner_id,
"integer") .
182 ", " . $ilDB->quote($a_src_obj_type,
"text") .
183 ", " . $ilDB->quote($a_src_obj_id,
"integer") .
184 ", " . $ilDB->quote($a_src_filesize,
"integer") .
")");
198 $set = $ilDB->query(
"SELECT sum(src_size) fsize" .
199 " FROM il_disk_quota" .
200 " WHERE owner_id = " . $ilDB->quote($a_owner_id,
"integer"));
201 $row = $ilDB->fetchAssoc($set);
202 return (
int)
$row[
"fsize"];
217 $set = $ilDB->query(
"SELECT sum(src_size) filesize, src_type, COUNT(*) count" .
218 " FROM il_disk_quota" .
219 " WHERE owner_id = " . $ilDB->quote($a_owner_id,
"integer") .
220 " GROUP BY src_type");
221 while (
$row = $ilDB->fetchAssoc($set)) {
232 include_once
"Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php";
237 include_once
"Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
239 if ($a_additional_size) {
240 $usage += $a_additional_size;
243 include_once
"Services/WebDAV/classes/class.ilDiskQuotaChecker.php";
245 $quota = $quota[
"disk_quota"];
248 if (is_infinite($quota)) {
252 return $usage < $quota;
259 include_once
"Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php";
264 include_once
"Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
267 include_once
"Services/WebDAV/classes/class.ilDiskQuotaChecker.php";
269 $quota = $quota[
"disk_quota"];
272 if (is_infinite($quota) || !(int) $quota) {
276 $lng->loadLanguageModule(
"file");
278 $lng->txt(
"personal_workspace_quota_status_legend"),
281 $quota ? round($usage / $quota * 100) : 0
static handleEntry($a_owner_id, $a_src_obj_type, $a_src_obj_id, $a_src_filesize)
Update/create owner-related entry of source object.
static deleteByOwner($a_owner_id)
Delete all entries for owner.
static getOwnersBySourceObject($a_src_obj_type, $a_src_obj_id)
Get owner ids by source object.
static _lookupPersonalWorkspaceDiskQuota($a_user_id)
static _isPersonalWorkspaceActive()
Static getter.
static deleteEntry($a_owner_id, $a_src_obj_type, $a_src_obj_id)
Delete entry for owner and source object.
foreach($_POST as $key=> $value) $res
Class ilDiskQuotaHandler.
static isUploadPossible($a_additional_size=null)
static getFilesizeByOwner($a_owner_id)
Get current storage size for owner.
static handleUpdatedSourceObject($a_src_obj_type, $a_src_obj_id, $a_src_filesize, $a_owner_obj_ids=null, $a_is_prtf=false)
Find and update/create all related entries for source object.
static formatSize($size, $a_mode='short', $a_lng=null)
Returns the specified file size value in a human friendly form.
static getSourceObjectsByOwner($a_owner_id)
Get all source objects for owner.
static getFilesizeByTypeAndOwner($a_owner_id)
Get current storage size for owner (grouped by type)