ILIAS
release_5-4 Revision v5.4.26-12-gabc799a52e6
◀ ilDoc Overview
class.ilUserCronCheckAccounts.php
Go to the documentation of this file.
1
<?
php
2
/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4
include_once
"Services/Cron/classes/class.ilCronJob.php"
;
5
14
class
ilUserCronCheckAccounts
extends
ilCronJob
15
{
16
protected
$counter
= 0;
// [int]
17
18
public
function
getId
()
19
{
20
return
"user_check_accounts"
;
21
}
22
23
public
function
getTitle
()
24
{
25
global
$DIC
;
26
27
$lng
= $DIC[
'lng'
];
28
29
return
$lng
->txt(
"check_user_accounts"
);
30
}
31
32
public
function
getDescription
()
33
{
34
global
$DIC
;
35
36
$lng
= $DIC[
'lng'
];
37
38
return
$lng
->txt(
"check_user_accounts_desc"
);
39
}
40
41
public
function
getDefaultScheduleType
()
42
{
43
return
self::SCHEDULE_TYPE_DAILY;
44
}
45
46
public
function
getDefaultScheduleValue
()
47
{
48
return
;
49
}
50
51
public
function
hasAutoActivation
()
52
{
53
return
false
;
54
}
55
56
public
function
hasFlexibleSchedule
()
57
{
58
return
false
;
59
}
60
61
public
function
run
()
62
{
63
global
$DIC
;
64
65
$ilDB
= $DIC[
'ilDB'
];
66
$ilLog
= $DIC[
'ilLog'
];
67
$lng
= $DIC[
'lng'
];
68
69
$status =
ilCronJobResult::STATUS_NO_ACTION
;
70
71
$now = time();
72
$two_weeks_in_seconds = $now + (60 * 60 * 24 * 14);
// #14630
73
74
// all users who are currently active and expire in the next 2 weeks
75
$query
=
"SELECT * FROM usr_data,usr_pref "
.
76
"WHERE time_limit_message = '0' "
.
77
"AND time_limit_unlimited = '0' "
.
78
"AND time_limit_from < "
.
$ilDB
->quote($now,
"integer"
) .
" "
.
79
"AND time_limit_until > "
.
$ilDB
->quote($now,
"integer"
) .
" "
.
80
"AND time_limit_until < "
.
$ilDB
->quote($two_weeks_in_seconds,
"integer"
) .
" "
.
81
"AND usr_data.usr_id = usr_pref.usr_id "
.
82
"AND keyword = "
.
$ilDB
->quote(
"language"
,
"text"
);
83
84
$res
=
$ilDB
->query($query);
85
87
$senderFactory =
$GLOBALS
[
'DIC'
][
"mail.mime.sender.factory"
];
88
$sender = $senderFactory->system();
89
90
while
(
$row
=
$ilDB
->fetchObject(
$res
)) {
91
include_once
'Services/Mail/classes/class.ilMimeMail.php'
;
92
93
$data
[
'expires'
] =
$row
->time_limit_until;
94
$data
[
'email'
] =
$row
->email;
95
$data
[
'login'
] =
$row
->login;
96
$data
[
'usr_id'
] =
$row
->usr_id;
97
$data
[
'language'
] =
$row
->value;
98
$data
[
'owner'
] =
$row
->time_limit_owner;
99
100
// Send mail
101
$mail =
new
ilMimeMail
();
102
103
$mail->From($sender);
104
$mail->To(
$data
[
'email'
]);
105
$mail->Subject($this->
txt
(
$data
[
'language'
],
'account_expires_subject'
),
true
);
106
$mail->Body($this->
txt
(
$data
[
'language'
],
'account_expires_body'
) .
" "
. strftime(
'%Y-%m-%d %R'
,
$data
[
'expires'
]));
107
$mail->send();
108
109
// set status 'mail sent'
110
$query =
"UPDATE usr_data SET time_limit_message = '1' WHERE usr_id = '"
.
$data
[
'usr_id'
] .
"'"
;
111
$ilDB
->query($query);
112
113
// Send log message
114
$ilLog
->write(
'Cron: (checkUserAccounts()) sent message to '
.
$data
[
'login'
] .
'.'
);
115
116
$this->counter++;
117
}
118
119
$this->
checkNotConfirmedUserAccounts
();
120
121
if
($this->counter) {
122
$status =
ilCronJobResult::STATUS_OK
;
123
}
124
$result
=
new
ilCronJobResult
();
125
$result
->setStatus($status);
126
return
$result
;
127
}
128
129
// #13288 / #12345
130
protected
function
txt
(
$language
,
$key
,
$module
=
'common'
)
131
{
132
include_once
'Services/Language/classes/class.ilLanguage.php'
;
133
return
ilLanguage::_lookupEntry
(
$language
,
$module
,
$key
);
134
}
135
136
protected
function
checkNotConfirmedUserAccounts
()
137
{
138
global
$DIC
;
139
140
$ilDB
= $DIC[
'ilDB'
];
141
$ilLog
= $DIC[
'ilLog'
];
142
143
require_once
'Services/Registration/classes/class.ilRegistrationSettings.php'
;
144
$oRegSettigs =
new
ilRegistrationSettings
();
145
146
$query
=
'SELECT usr_id FROM usr_data '
147
.
'WHERE (reg_hash IS NOT NULL AND reg_hash != %s)'
148
.
'AND active = %s '
149
.
'AND create_date < %s'
;
150
$res
=
$ilDB
->queryF(
151
$query
,
152
array(
'text'
,
'integer'
,
'timestamp'
),
153
array(
''
, 0, date(
'Y-m-d H:i:s'
, time() - (
int
) $oRegSettigs->getRegistrationHashLifetime()))
154
);
155
while
(
$row
=
$ilDB
->fetchAssoc(
$res
)) {
156
$oUser =
ilObjectFactory::getInstanceByObjId
((
int
)
$row
[
'usr_id'
]);
157
$oUser->delete();
158
$ilLog
->write(
'Cron: Deleted '
. $oUser->getLogin() .
' ['
. $oUser->getId() .
'] '
. __METHOD__);
159
160
$this->counter++;
161
}
162
}
163
}
ilUserCronCheckAccounts\getDescription
getDescription()
Definition:
class.ilUserCronCheckAccounts.php:32
ilCronJob\run
run()
Run job.
$language
$language
Definition:
frontpage_federation.php:120
$result
$result
Definition:
CleanUpTest.php:463
ilUserCronCheckAccounts\txt
txt($language, $key, $module='common')
Definition:
class.ilUserCronCheckAccounts.php:130
ilUserCronCheckAccounts\getTitle
getTitle()
Definition:
class.ilUserCronCheckAccounts.php:23
$DIC
global $DIC
Definition:
saml.php:7
ilCronJob
Cron job application base class.
Definition:
class.ilCronJob.php:11
ilUserCronCheckAccounts\$counter
$counter
Definition:
class.ilUserCronCheckAccounts.php:16
ilLanguage\_lookupEntry
static _lookupEntry($a_lang_key, $a_mod, $a_id)
Definition:
class.ilLanguage.php:364
ilUserCronCheckAccounts\hasFlexibleSchedule
hasFlexibleSchedule()
Definition:
class.ilUserCronCheckAccounts.php:56
ilUserCronCheckAccounts\getDefaultScheduleType
getDefaultScheduleType()
Definition:
class.ilUserCronCheckAccounts.php:41
$module
if($modEnd===false) $module
Definition:
module.php:59
ilUserCronCheckAccounts\checkNotConfirmedUserAccounts
checkNotConfirmedUserAccounts()
Definition:
class.ilUserCronCheckAccounts.php:136
$res
foreach($_POST as $key=> $value) $res
Definition:
save_question_post_data.php:15
ilMimeMail
Class ilMimeMail.
Definition:
class.ilMimeMail.php:7
$lng
$lng
Definition:
save_question_post_data.php:23
ilUserCronCheckAccounts\getId
getId()
Definition:
class.ilUserCronCheckAccounts.php:18
$query
$query
Definition:
proxy_ylocal.php:13
ilObjectFactory\getInstanceByObjId
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Definition:
class.ilObjectFactory.php:77
$ilLog
$ilLog
Definition:
inc.setup_header.php:123
$row
$row
Definition:
migrateto20.php:360
ilUserCronCheckAccounts
Definition:
class.ilUserCronCheckAccounts.php:14
ilCronJobResult\STATUS_OK
const STATUS_OK
Definition:
class.ilCronJobResult.php:15
$ilDB
global $ilDB
Definition:
storeScorm2004.php:16
php
ilRegistrationSettings
ilCronJobResult
Cron job result data container.
Definition:
class.ilCronJobResult.php:11
ilUserCronCheckAccounts\hasAutoActivation
hasAutoActivation()
Definition:
class.ilUserCronCheckAccounts.php:51
$key
$key
Definition:
croninfo.php:18
ilCronJobResult\STATUS_NO_ACTION
const STATUS_NO_ACTION
Definition:
class.ilCronJobResult.php:14
$GLOBALS
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
Definition:
module.tag.xmp.php:702
ilUserCronCheckAccounts\getDefaultScheduleValue
getDefaultScheduleValue()
Definition:
class.ilUserCronCheckAccounts.php:46
$data
$data
Definition:
bench.php:6
Services
User
classes
class.ilUserCronCheckAccounts.php
Generated on Thu Jan 30 2025 19:02:07 for ILIAS by
1.8.13 (using
Doxyfile
)