ILIAS  release_4-4 Revision
ilECSAppEventListener Class Reference
+ Inheritance diagram for ilECSAppEventListener:
+ Collaboration diagram for ilECSAppEventListener:

Static Public Member Functions

static handleEvent ($a_component, $a_event, $a_parameter)
 Handle an event in a listener. More...
 

Protected Member Functions

 handleMembership (ilObjUser $user)
 Assign mmissing course/groups to new user accounts. More...
 

Static Protected Member Functions

static _sendNotification (ilECSSetting $server, ilObjUser $user_obj)
 send notification about new user accounts More...
 

Detailed Description

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 36 of file class.ilECSAppEventListener.php.

Member Function Documentation

◆ _sendNotification()

static ilECSAppEventListener::_sendNotification ( ilECSSetting  $server,
ilObjUser  $user_obj 
)
staticprotected

send notification about new user accounts

protected

Definition at line 106 of file class.ilECSAppEventListener.php.

References $lang, ilMail\_getAutoGeneratedMessageString(), ilLanguageFactory\_getLanguage(), ilObject\getId(), ilECSSetting\getServerId(), ilECSSetting\getUserRecipients(), and ilECSSetting\getUserRecipientsAsString().

107  {
108  if(!count($server->getUserRecipients()))
109  {
110  return true;
111  }
112  // If sub id is set => mail was send
113  include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
114  $import = new ilECSImport($server->getServerId(),$user_obj->getId());
115  if($import->getSubId())
116  {
117  return false;
118  }
119 
120  include_once('./Services/Language/classes/class.ilLanguageFactory.php');
122  $lang->loadLanguageModule('ecs');
123 
124  include_once('./Services/Mail/classes/class.ilMail.php');
125  $mail = new ilMail(6);
126  $mail->enableSoap(false);
127  $subject = $lang->txt('ecs_new_user_subject');
128 
129  // build body
130  $body = $lang->txt('ecs_new_user_body')."\n\n";
131  $body .= $lang->txt('ecs_new_user_profile')."\n\n";
132  $body .= $user_obj->getProfileAsString($lang)."\n\n";
134 
135  $mail->sendMail($server->getUserRecipientsAsString(),"","",$subject,$body,array(),array("normal"));
136 
137  // Store sub_id = 1 in ecs import which means mail is send
138  $import->setSubId(1);
139  $import->save();
140 
141  return true;
142  }
getServerId()
Get current server id.
static _getLanguage($a_lang_key='')
Get langauge object.
getId()
get object id public
getUserRecipientsAsString()
Get new user recipients.
Class Mail this class handles base functions for mail handling.
Storage of ECS imported objects.
static _getAutoGeneratedMessageString($lang=null)
get auto generated info string
getUserRecipients()
Get new user recipients.
+ Here is the call graph for this function:

◆ handleEvent()

static ilECSAppEventListener::handleEvent (   $a_component,
  $a_event,
  $a_parameter 
)
static

Handle an event in a listener.

Parameters
string$a_componentcomponent, e.g. "Modules/Forum" or "Services/User"
string$a_eventevent e.g. "createUser", "updateUser", "deleteUser", ...
array$a_parameterparameter array (assoc), array("name" => ..., "phone_office" => ...)

Implements ilAppEventListener.

Definition at line 45 of file class.ilECSAppEventListener.php.

References $GLOBALS, $ilLog, ilObjUser\_lookupAuthMode(), ilObjectFactory\getInstanceByObjId(), ilECSSetting\getInstanceByServerId(), handleMembership(), IL_CAL_MONTH, IL_CAL_UNIX, and ilECSImport\lookupServerId().

46  {
47  global $ilLog;
48 
49  $ilLog->write(__METHOD__.': Listening to event from: '.$a_component);
50 
51  switch($a_component)
52  {
53  case 'Services/User':
54  switch($a_event)
55  {
56  case 'afterCreation':
57  $user = $a_parameter['user_obj'];
58  $this->handleMembership($user);
59  break;
60  }
61  break;
62 
63  case 'Modules/Course':
64  switch($a_event)
65  {
66  case 'addSubscriber':
67  case 'addParticipant':
68 
69  if(ilObjUser::_lookupAuthMode($a_parameter['usr_id']) == 'ecs')
70  {
71  if(!$user = ilObjectFactory::getInstanceByObjId($a_parameter['usr_id']))
72  {
73  $GLOBALS['ilLog']->write(__METHOD__.': No valid user found for usr_id '.$a_parameter['usr_id']);
74  return true;
75  }
76 
77  include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
78  $server_id = ilECSImport::lookupServerId($a_parameter['usr_id']);
79  $GLOBALS['ilLog']->write(__METHOD__.': Found server id: '.$server_id);
80 
81  include_once('Services/WebServices/ECS/classes/class.ilECSSetting.php');
82  $settings = ilECSSetting::getInstanceByServerId($server_id);
83 
84  $end = new ilDateTime(time(),IL_CAL_UNIX);
85  $end->increment(IL_CAL_MONTH,$settings->getDuration());
86 
87  if($user->getTimeLimitUntil() < $end->get(IL_CAL_UNIX))
88  {
89  $user->setTimeLimitUntil($end->get(IL_CAL_UNIX));
90  $user->update();
91  }
92  self::_sendNotification($settings,$user);
93  unset($user);
94  }
95  break;
96  }
97  break;
98  }
99  }
static getInstanceByServerId($a_server_id)
Get singleton instance per server.
const IL_CAL_MONTH
const IL_CAL_UNIX
$GLOBALS['ct_recipient']
Date and time handling
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static lookupServerId($a_obj_id)
Lookup server id of imported content <type> $ilDB.
static _lookupAuthMode($a_usr_id)
lookup auth mode
handleMembership(ilObjUser $user)
Assign mmissing course/groups to new user accounts.
+ Here is the call graph for this function:

◆ handleMembership()

ilECSAppEventListener::handleMembership ( ilObjUser  $user)
protected

Assign mmissing course/groups to new user accounts.

Parameters
ilObjUser$user

Definition at line 148 of file class.ilECSAppEventListener.php.

References ilObjUser\getAuthMode(), and ilECSSetting\lookupAuthMode().

Referenced by handleEvent().

149  {
150  if($user->getAuthMode() != ilECSSetting::lookupAuthMode())
151  {
152  return true;
153  }
154 
155  }
getAuthMode($a_auth_key=false)
get auth mode public
static lookupAuthMode()
Lookup auth mode.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: