ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilMailCronAddressbookSync.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once "Services/Cron/classes/class.ilCronJob.php";
6
13{
14 public function getId()
15 {
16 return "mail_address_sync";
17 }
18
19 public function getTitle()
20 {
21 global $lng;
22
23 $lng->loadLanguageModule("mail");
24 return $lng->txt("cron_update_addressbook");
25 }
26
27 public function getDescription()
28 {
29 global $lng;
30
31 $lng->loadLanguageModule("mail");
32 return $lng->txt("cron_update_addressbook_desc");
33 }
34
35 public function getDefaultScheduleType()
36 {
38 }
39
40 public function getDefaultScheduleValue()
41 {
42 return;
43 }
44
45 public function hasAutoActivation()
46 {
47 return false;
48 }
49
50 public function hasFlexibleSchedule()
51 {
52 return false;
53 }
54
55 public function hasCustomSettings()
56 {
57 return false;
58 }
59
60 public function run()
61 {
62 global $ilDB;
63
64 if($ilDB->getDBType() == 'oracle')
65 {
66 $res1 = $ilDB->queryF('
67 SELECT addressbook.addr_id,
68 usr_data.firstname,
69 usr_data.lastname,
70 (CASE WHEN epref.value = %s THEN usr_data.email ELSE addressbook.email END) email
71 FROM addressbook
72 INNER JOIN usr_data ON usr_data.login = addressbook.login
73 INNER JOIN usr_pref ppref ON ppref.usr_id = usr_data.usr_id AND ppref.keyword = %s AND ppref.value != %s
74 LEFT JOIN usr_pref epref ON epref.usr_id = usr_data.usr_id AND epref.keyword = %s
75 WHERE addressbook.auto_update = %s',
76 array('text', 'text', 'text', 'text', 'integer'),
77 array('y', 'public_profile', 'n', 'public_email', 1)
78 );
79
80 $stmt = $ilDB->prepare('
81 UPDATE addressbook
82 SET firstname = ?,
83 lastname = ?,
84 email = ?
85 WHERE addr_id = ?',
86 array('text','text','text', 'integer')
87 );
88
89 while($row = $ilDB->fetchAssoc($res1))
90 {
91 $ilDB->execute($stmt, array($row['firstname'], $row['lastname'], $row['email'], $row['addr_id']));
92 }
93 }
94 else
95 {
96 $ilDB->queryF('
97 UPDATE addressbook
98 INNER JOIN usr_data ON usr_data.login = addressbook.login
99 INNER JOIN usr_pref ppref ON ppref.usr_id = usr_data.usr_id AND ppref.keyword = %s AND ppref.value != %s
100 LEFT JOIN usr_pref epref ON epref.usr_id = usr_data.usr_id AND epref.keyword = %s
101 SET
102 addressbook.firstname = usr_data.firstname,
103 addressbook.lastname = usr_data.lastname,
104 addressbook.email = (CASE WHEN epref.value = %s THEN usr_data.email ELSE addressbook.email END)
105 WHERE addressbook.auto_update = %s',
106 array('text', 'text', 'text', 'text', 'integer'),
107 array('public_profile', 'n', 'public_email', 'y', 1)
108 );
109 }
110
111 $result = new ilCronJobResult();
113 return $result;
114 }
115
116 public function activationWasToggled($a_currently_active)
117 {
118 global $ilSetting;
119
120 // propagate cron-job setting to object setting
121 $ilSetting->set('cron_upd_adrbook', (bool)$a_currently_active);
122 }
123}
124
125?>
$result
Cron job result data container.
Cron job application base class.
const SCHEDULE_TYPE_DAILY
activationWasToggled($a_currently_active)
Cron job status was changed.
hasFlexibleSchedule()
Can the schedule be configured?
hasCustomSettings()
Has cron job any custom setting which can be edited?
hasAutoActivation()
Is to be activated on "installation".
global $lng
Definition: privfeed.php:40
global $ilSetting
Definition: privfeed.php:40
global $ilDB