ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilBuddySystemGUI Class Reference

Class ilBuddySystemGUI. More...

+ Collaboration diagram for ilBuddySystemGUI:

Public Member Functions

 executeCommand ()
 

Data Fields

const BS_REQUEST_HTTP_GET = 1
 
const BS_REQUEST_HTTP_POST = 2
 

Protected Member Functions

 isRequestParameterGiven ($key, $type)
 

Protected Attributes

 $ctrl
 
 $buddylist
 
 $statefactory
 
 $user
 
 $lng
 

Static Protected Attributes

static $frontend_initialized = false
 

Private Member Functions

 requestCommand ()
 
 ignoreCommand ()
 
 linkCommand ()
 
 transitionCommand ($cmd, $positive_feedback_lng_id, callable $onBeforeExecute=null)
 

Detailed Description

Member Function Documentation

◆ executeCommand()

ilBuddySystemGUI::executeCommand ( )
Exceptions
RuntimeException

Definition at line 109 of file class.ilBuddySystemGUI.php.

References $cmd.

110  {
111  if($this->user->isAnonymous())
112  {
113  throw new RuntimeException('This controller only accepts requests of logged in users');
114  }
115 
116  $next_class = $this->ctrl->getNextClass($this);
117  $cmd = $this->ctrl->getCmd();
118 
119  switch($next_class)
120  {
121  default:
122  $cmd .= 'Command';
123  $this->$cmd();
124  break;
125  }
126  }
$cmd
Definition: sahs_server.php:35

◆ ignoreCommand()

ilBuddySystemGUI::ignoreCommand ( )
private

Definition at line 164 of file class.ilBuddySystemGUI.php.

References transitionCommand().

165  {
166  $this->transitionCommand('ignore', 'buddy_request_ignored');
167  }
transitionCommand($cmd, $positive_feedback_lng_id, callable $onBeforeExecute=null)
+ Here is the call graph for this function:

◆ isRequestParameterGiven()

ilBuddySystemGUI::isRequestParameterGiven (   $key,
  $type 
)
protected
Parameters
string$key
int$type
Returns
bool

Definition at line 133 of file class.ilBuddySystemGUI.php.

References $_GET, and $_POST.

Referenced by transitionCommand().

134  {
135  switch($type)
136  {
137  case self::BS_REQUEST_HTTP_POST:
138  return isset($_POST[$key]) && strlen($_POST[$key]);
139  break;
140 
141  case self::BS_REQUEST_HTTP_GET:
142  default:
143  return isset($_GET[$key]) && strlen($_GET[$key]);
144  break;
145  }
146  }
$_POST['username']
Definition: cron.php:12
$_GET["client_id"]
+ Here is the caller graph for this function:

◆ linkCommand()

ilBuddySystemGUI::linkCommand ( )
private

Definition at line 172 of file class.ilBuddySystemGUI.php.

References transitionCommand().

173  {
174  $this->transitionCommand('link', 'buddy_request_approved');
175  }
transitionCommand($cmd, $positive_feedback_lng_id, callable $onBeforeExecute=null)
+ Here is the call graph for this function:

◆ requestCommand()

ilBuddySystemGUI::requestCommand ( )
private

Definition at line 151 of file class.ilBuddySystemGUI.php.

References ilObjUser\_lookupPref(), ilBuddySystemRelation\getBuddyUserId(), ilBuddySystemRelation\isUnlinked(), transitionCommand(), and ilUtil\yn2tf().

152  {
153  $this->transitionCommand('request', 'buddy_relation_requested', function(ilBuddySystemRelation $relation) {
154  if($relation->isUnlinked() && !ilUtil::yn2tf(ilObjUser::_lookupPref($relation->getBuddyUserId(), 'bs_allow_to_contact_me')))
155  {
156  throw new ilException("The requested user does not want to get contact requests");
157  }
158  });
159  }
Base class for ILIAS Exception handling.
_lookupPref($a_usr_id, $a_keyword)
Class ilBuddySystemRelation.
transitionCommand($cmd, $positive_feedback_lng_id, callable $onBeforeExecute=null)
static yn2tf($a_yn)
convert "y"/"n" to true/false
+ Here is the call graph for this function:

◆ transitionCommand()

ilBuddySystemGUI::transitionCommand (   $cmd,
  $positive_feedback_lng_id,
callable  $onBeforeExecute = null 
)
private
Parameters
string$cmd
string$positive_feedback_lng_id
callable | null$onBeforeExecute

Definition at line 182 of file class.ilBuddySystemGUI.php.

References $_GET, $_POST, $lng, ilObjUser\_isAnonymous(), ilObjUser\_lookupLogin(), ilObjUser\_lookupPref(), exit, isRequestParameterGiven(), ilUtil\sendInfo(), ilUtil\sendSuccess(), ilUtil\stripSlashes(), and ilUtil\yn2tf().

Referenced by ignoreCommand(), linkCommand(), and requestCommand().

183  {
184  if(!$this->isRequestParameterGiven('user_id', self::BS_REQUEST_HTTP_GET))
185  {
186  ilUtil::sendInfo($this->lng->txt('buddy_bs_action_not_possible'), true);
187  $this->ctrl->returnToParent($this);
188  }
189 
190  try
191  {
192  require_once 'Services/Contact/BuddySystem/classes/class.ilBuddyList.php';
193  $relation = ilBuddyList::getInstanceByGlobalUser()->getRelationByUserId((int)$_GET['user_id']);
194 
195  if(null !== $onBeforeExecute)
196  {
197  $onBeforeExecute($relation);
198  }
199 
200  ilBuddyList::getInstanceByGlobalUser()->$cmd($relation);
201  ilUtil::sendSuccess($this->lng->txt($positive_feedback_lng_id), true);
202 
203  }
205  {
206  ilUtil::sendInfo(sprintf($this->lng->txt($e->getMessage()), ilObjUser::_lookupLogin((int)$_GET['user_id'])), true);
207  }
209  {
210  ilUtil::sendInfo(sprintf($this->lng->txt($e->getMessage()), ilObjUser::_lookupLogin((int)$_GET['user_id'])), true);
211  }
212  catch(ilException $e)
213  {
214  ilUtil::sendInfo($this->lng->txt('buddy_bs_action_not_possible'), true);
215  }
216 
217  $this->ctrl->returnToParent($this);
218  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static _lookupLogin($a_user_id)
lookup login
Base class for ILIAS Exception handling.
isRequestParameterGiven($key, $type)
$_GET["client_id"]
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $buddylist

ilBuddySystemGUI::$buddylist
protected

Definition at line 30 of file class.ilBuddySystemGUI.php.

◆ $ctrl

ilBuddySystemGUI::$ctrl
protected

Definition at line 25 of file class.ilBuddySystemGUI.php.

◆ $frontend_initialized

ilBuddySystemGUI::$frontend_initialized = false
staticprotected

Definition at line 20 of file class.ilBuddySystemGUI.php.

◆ $lng

ilBuddySystemGUI::$lng
protected

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

Referenced by transitionCommand().

◆ $statefactory

ilBuddySystemGUI::$statefactory
protected

Definition at line 35 of file class.ilBuddySystemGUI.php.

◆ $user

ilBuddySystemGUI::$user
protected

Definition at line 40 of file class.ilBuddySystemGUI.php.

◆ BS_REQUEST_HTTP_GET

const ilBuddySystemGUI::BS_REQUEST_HTTP_GET = 1

Definition at line 14 of file class.ilBuddySystemGUI.php.

◆ BS_REQUEST_HTTP_POST

const ilBuddySystemGUI::BS_REQUEST_HTTP_POST = 2

Definition at line 15 of file class.ilBuddySystemGUI.php.


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