質問編集履歴
1
フォーマットに沿って記述しなおしました
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
### 前提・実現したいこと
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
```
|
6
|
+
|
1
7
|
前回osclassのアラートが機能せず質問したものです。指摘していただいた部分を直し、エラーはなくなったのですがいまだアラートは送信されません。
|
2
8
|
|
3
9
|
|
@@ -6,6 +12,180 @@
|
|
6
12
|
|
7
13
|
|
8
14
|
|
15
|
+
結局osclassのphpをいじらないといけないといけなさそうなのですがよくわかっていない現状です。
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
どのような情報でもよいので教えていただけるとありがたいです。よろしくお願いいたします。
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
```
|
24
|
+
|
25
|
+
### 発生している問題・エラーメッセージ
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
```
|
30
|
+
|
31
|
+
発生している問題は前述したとおりです。エラーメッセージは特にありません。
|
32
|
+
|
33
|
+
```
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
### 該当のソースコード
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
```PHP
|
44
|
+
|
45
|
+
<?php
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
function osc_runAlert($type = null, $last_exec = null) {
|
50
|
+
|
51
|
+
$mUser = User::newInstance();
|
52
|
+
|
53
|
+
if ( !in_array($type, array('HOURLY', 'DAILY', 'WEEKLY', 'INSTANT')) ) {
|
54
|
+
|
55
|
+
return;
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
if($last_exec==null) {
|
60
|
+
|
61
|
+
$cron = Cron::newInstance()->getCronByType($type);
|
62
|
+
|
63
|
+
if( is_array($cron) ) {
|
64
|
+
|
65
|
+
$last_exec = $cron['d_last_exec'];
|
66
|
+
|
67
|
+
} else {
|
68
|
+
|
69
|
+
$last_exec = '0000-00-00 00:00:00';
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
$internal_name = 'alert_email_hourly';
|
76
|
+
|
77
|
+
switch ($type) {
|
78
|
+
|
79
|
+
case 'HOURLY':
|
80
|
+
|
81
|
+
$internal_name = 'alert_email_hourly';
|
82
|
+
|
83
|
+
break;
|
84
|
+
|
85
|
+
case 'DAILY':
|
86
|
+
|
87
|
+
$internal_name = 'alert_email_daily';
|
88
|
+
|
89
|
+
break;
|
90
|
+
|
91
|
+
case 'WEEKLY':
|
92
|
+
|
93
|
+
$internal_name = 'alert_email_weekly';
|
94
|
+
|
95
|
+
break;
|
96
|
+
|
97
|
+
case 'INSTANT':
|
98
|
+
|
99
|
+
$internal_name = 'alert_email_instant';
|
100
|
+
|
101
|
+
break;
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
$active = TRUE;
|
106
|
+
|
107
|
+
$searches = Alerts::newInstance()->findByTypeGroup($type, $active);
|
108
|
+
|
109
|
+
foreach($searches as $s_search) {
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
$json = $s_search['s_search'];
|
114
|
+
|
115
|
+
$array_conditions = (array)json_decode($json);
|
116
|
+
|
117
|
+
$new_search = Search::newInstance();
|
118
|
+
|
119
|
+
$new_search->setJsonAlert($array_conditions);
|
120
|
+
|
121
|
+
$new_search->addConditions(sprintf(" %st_item.dt_pub_date > '%s' ", DB_TABLE_PREFIX, $last_exec));
|
122
|
+
|
123
|
+
$items = $new_search->doSearch();
|
124
|
+
|
125
|
+
$totalItems = $new_search->count();
|
126
|
+
|
127
|
+
if( count($items) > 0 ) {
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
$alerts = Alerts::newInstance()->findUsersBySearchAndType($s_search['s_search'], $type, $active);
|
132
|
+
|
133
|
+
if( count($alerts) > 0 ) {
|
134
|
+
|
135
|
+
$ads = '';
|
136
|
+
|
137
|
+
foreach($items as $item) {
|
138
|
+
|
139
|
+
$ads .= '<a href="'. osc_item_url_ns($item['pk_i_id']).'">' . $item['s_title'] . '</a><br/>';
|
140
|
+
|
141
|
+
}
|
142
|
+
|
143
|
+
foreach($alerts as $alert) {
|
144
|
+
|
145
|
+
$user = array();
|
146
|
+
|
147
|
+
if($alert['fk_i_user_id']!=0) {
|
148
|
+
|
149
|
+
$user = $mUser->findByPrimaryKey($alert['fk_i_user_id']);
|
150
|
+
|
151
|
+
}
|
152
|
+
|
153
|
+
if(!isset($user['s_name'])) {
|
154
|
+
|
155
|
+
$user = array(
|
156
|
+
|
157
|
+
's_name' => $alert['s_email'],
|
158
|
+
|
159
|
+
's_email' => $alert['s_email']
|
160
|
+
|
161
|
+
);
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
if(count($alert)>0) {
|
166
|
+
|
167
|
+
osc_run_hook('hook_'.$internal_name, $user, $ads, $alert, $items, $totalItems);
|
168
|
+
|
169
|
+
AlertsStats::newInstance()->increase(date('Y-m-d'));
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
}
|
176
|
+
|
177
|
+
}
|
178
|
+
|
179
|
+
}
|
180
|
+
|
181
|
+
}
|
182
|
+
|
183
|
+
```
|
184
|
+
|
185
|
+
### 試したこと
|
186
|
+
|
187
|
+
|
188
|
+
|
9
189
|
githubで見つけた方法「https://github.com/osclass/Osclass/commit/00b9158aebafc7c33392e4e1a4d2f654c31fe3cf?diff=unified」も試してはみたのですが上手くいきませんでした。
|
10
190
|
|
11
191
|
|
@@ -14,8 +194,8 @@
|
|
14
194
|
|
15
195
|
|
16
196
|
|
197
|
+
### 補足情報(FW/ツールのバージョンなど)
|
198
|
+
|
199
|
+
|
200
|
+
|
17
|
-
|
201
|
+
osclassは(最新バージョン 374) です。
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
どのような情報でもよいので教えていただけるとありがたいです。よろしくお願いいたします。
|