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.

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

References $cmd.

◆ ignoreCommand()

ilBuddySystemGUI::ignoreCommand ( )
private

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

165 {
166 $this->transitionCommand('ignore', 'buddy_request_ignored');
167 }
transitionCommand($cmd, $positive_feedback_lng_id, callable $onBeforeExecute=null)

References transitionCommand().

+ 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.

134 {
135 switch($type)
136 {
138 return isset($_POST[$key]) && strlen($_POST[$key]);
139 break;
140
142 default:
143 return isset($_GET[$key]) && strlen($_GET[$key]);
144 break;
145 }
146 }
$_GET["client_id"]
$_POST['username']
Definition: cron.php:12

References $_GET, $_POST, BS_REQUEST_HTTP_GET, and BS_REQUEST_HTTP_POST.

Referenced by transitionCommand().

+ Here is the caller graph for this function:

◆ linkCommand()

ilBuddySystemGUI::linkCommand ( )
private

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

173 {
174 $this->transitionCommand('link', 'buddy_request_approved');
175 }

References transitionCommand().

+ Here is the call graph for this function:

◆ requestCommand()

ilBuddySystemGUI::requestCommand ( )
private

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

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 }
Class ilBuddySystemRelation.
_lookupPref($a_usr_id, $a_keyword)
static yn2tf($a_yn)
convert "y"/"n" to true/false

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

+ 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.

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 }
isRequestParameterGiven($key, $type)
Base class for ILIAS Exception handling.
static _lookupLogin($a_user_id)
lookup login
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.

References $_GET, ilObjUser\_lookupLogin(), isRequestParameterGiven(), ilUtil\sendInfo(), and ilUtil\sendSuccess().

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

+ 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.

◆ $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.

Referenced by isRequestParameterGiven().

◆ BS_REQUEST_HTTP_POST

const ilBuddySystemGUI::BS_REQUEST_HTTP_POST = 2

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

Referenced by isRequestParameterGiven().


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