ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilParameterAppender Class Reference

Class ilParameterAppender. More...

+ Collaboration diagram for ilParameterAppender:

Public Member Functions

 __construct ($webr_id)
 Constructor public. More...
 
 getErrorCode ()
 
 setObjId ($a_obj_id)
 
 getObjId ()
 
 setName ($a_name)
 
 getName ()
 
 setValue ($a_value)
 
 getValue ()
 
 validate ()
 
 add ($a_link_id)
 
 delete ($a_param_id)
 

Static Public Member Functions

static getParameterIds ($a_webr_id, $a_link_id)
 Get Parameter ids of link. More...
 
static _isEnabled ()
 Check if dynamic parameters are enabled. More...
 
static _append ($a_link_data)
 
static _getParams ($a_link_id)
 Get dynamic parameter definitions. More...
 
static parameterToInfo ($a_name, $a_value)
 Get info text describing an existing dynamic link. More...
 
static _deleteAll ($a_webr_id)
 
static _getOptionSelect ()
 Get options as array. More...
 

Data Fields

 $webr_id = null
 
 $db = null
 
 $err = null
 

Detailed Description

Class ilParameterAppender.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 42 of file class.ilParameterAppender.php.

Constructor & Destructor Documentation

◆ __construct()

ilParameterAppender::__construct (   $webr_id)

Constructor public.

Definition at line 54 of file class.ilParameterAppender.php.

References $ilDB, and $webr_id.

55  {
56  global $ilDB;
57 
58  $this->webr_id = $webr_id;
59  $this->db = $ilDB;
60  }
global $ilDB

Member Function Documentation

◆ _append()

static ilParameterAppender::_append (   $a_link_data)
static

Definition at line 180 of file class.ilParameterAppender.php.

References $ilUser, $params, _getParams(), LINKS_LOGIN, LINKS_MATRICULATION, LINKS_SESSION_ID, and LINKS_USER_ID.

Referenced by ilObjLinkResourceListGUI\__readLink(), ilObjLinkResourceGUI\callDirectLink(), ilObjLinkResourceGUI\callLink(), and ilObjLinkResourceSubItemListGUI\getHTML().

181  {
182  global $ilUser;
183 
184  if (!is_array($a_link_data)) {
185  return false;
186  }
187  if (count($params = ilParameterAppender::_getParams($a_link_data['link_id']))) {
188  // Check for prefix
189  foreach ($params as $param_data) {
190  if (!strpos($a_link_data['target'], '?')) {
191  $a_link_data['target'] .= "?";
192  } else {
193  $a_link_data['target'] .= "&";
194  }
195  $a_link_data['target'] .= ($param_data['name'] . "=");
196  switch ($param_data['value']) {
197  case LINKS_LOGIN:
198  $a_link_data['target'] .= (urlencode($ilUser->getLogin()));
199  break;
200 
201  case LINKS_SESSION_ID:
202  $a_link_data['target'] .= (session_id());
203  break;
204 
205  case LINKS_USER_ID:
206  $a_link_data['target'] .= ($ilUser->getId());
207  break;
208 
209  case LINKS_MATRICULATION:
210  $a_link_data['target'] .= ($ilUser->getMatriculation());
211  break;
212  }
213  }
214  }
215  return $a_link_data;
216  }
$params
Definition: disable.php:11
const LINKS_MATRICULATION
const LINKS_LOGIN
$ilUser
Definition: imgupload.php:18
const LINKS_USER_ID
static _getParams($a_link_id)
Get dynamic parameter definitions.
const LINKS_SESSION_ID
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _deleteAll()

static ilParameterAppender::_deleteAll (   $a_webr_id)
static

Definition at line 265 of file class.ilParameterAppender.php.

References $ilDB, $query, and $res.

266  {
267  global $ilDB;
268 
269  $query = "DELETE FROM webr_params WHERE webr_id = " .
270  $ilDB->quote((int) $a_webr_id, 'integer');
271  $res = $ilDB->manipulate($query);
272 
273  return true;
274  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB

◆ _getOptionSelect()

static ilParameterAppender::_getOptionSelect ( )
static

Get options as array.

Returns

Definition at line 280 of file class.ilParameterAppender.php.

References $lng, array, LINKS_LOGIN, LINKS_MATRICULATION, LINKS_SESSION_ID, and LINKS_USER_ID.

Referenced by ilWebResourceEditableLinkTableGUI\fillRow(), and ilObjLinkResourceGUI\initFormLink().

281  {
282  global $lng;
283 
284  return array(0 => $lng->txt('links_select_one'),
285  LINKS_USER_ID => $lng->txt('links_user_id'),
286  LINKS_LOGIN => $lng->txt('links_user_name'),
287  LINKS_SESSION_ID => $lng->txt('links_session_id'),
288  LINKS_MATRICULATION => $lng->txt('matriculation')
289  );
290  }
const LINKS_MATRICULATION
const LINKS_LOGIN
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
const LINKS_USER_ID
const LINKS_SESSION_ID
+ Here is the caller graph for this function:

◆ _getParams()

static ilParameterAppender::_getParams (   $a_link_id)
static

Get dynamic parameter definitions.

Parameters
int$a_link_id
Returns

Definition at line 223 of file class.ilParameterAppender.php.

References $ilDB, $params, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by _append(), ilLinkResourceItems\cloneItems(), ilObjLinkResourceGUI\initFormLink(), ilWebResourceEditableLinkTableGUI\parse(), ilwebresourceTest\testWebResourceParameters(), and ilLinkResourceItems\toXML().

224  {
225  global $ilDB;
226 
227  $params = [];
228 
229  $res = $ilDB->query("SELECT * FROM webr_params WHERE link_id = " .
230  $ilDB->quote((int) $a_link_id, 'integer'));
231  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
232  $params[$row->param_id]['name'] = $row->name;
233  $params[$row->param_id]['value'] = $row->value;
234  }
235 
236  return $params;
237  }
$params
Definition: disable.php:11
foreach($_POST as $key=> $value) $res
global $ilDB
+ Here is the caller graph for this function:

◆ _isEnabled()

static ilParameterAppender::_isEnabled ( )
static

Check if dynamic parameters are enabled.

Returns

Definition at line 173 of file class.ilParameterAppender.php.

References $ilSetting.

Referenced by ilObjLinkResourceListGUI\__readLink(), ilObjLinkResourceGUI\callDirectLink(), ilObjLinkResourceGUI\callLink(), ilObjLinkResourceGUI\checkLinkInput(), ilWebResourceEditableLinkTableGUI\fillRow(), ilObjLinkResourceGUI\initFormLink(), ilObjLinkResourceGUI\saveAddLink(), ilObjLinkResourceGUI\setValuesFromLink(), and ilObjLinkResourceGUI\updateLink().

174  {
175  global $ilSetting;
176 
177  return $ilSetting->get('links_dynamic', false) ? true : false;
178  }
global $ilSetting
Definition: privfeed.php:17
+ Here is the caller graph for this function:

◆ add()

ilParameterAppender::add (   $a_link_id)

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

References $ilDB, $query, $res, getName(), getObjId(), and getValue().

134  {
135  global $ilDB;
136 
137  if (!$a_link_id) {
138  return false;
139  }
140  if (!strlen($this->getName() or !strlen($this->getValue()))) {
141  return false;
142  }
143 
144  $next_id = $ilDB->nextId('webr_params');
145  $query = "INSERT INTO webr_params (param_id,webr_id,link_id,name,value) " .
146  "VALUES( " .
147  $ilDB->quote($next_id, 'integer') . ", " .
148  $ilDB->quote($this->getObjId(), 'integer') . ", " .
149  $ilDB->quote($a_link_id, 'integer') . ", " .
150  $ilDB->quote($this->getName(), 'text') . ", " .
151  $ilDB->quote($this->getValue(), 'integer') .
152  ")";
153  $res = $ilDB->manipulate($query);
154 
155  return $next_id;
156  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:

◆ delete()

ilParameterAppender::delete (   $a_param_id)

Definition at line 158 of file class.ilParameterAppender.php.

References $ilDB, $query, $res, and getObjId().

Referenced by ilObjLinkResourceGUI\deleteParameter(), and ilObjLinkResourceGUI\deleteParameterForm().

159  {
160  global $ilDB;
161 
162  $query = "DELETE FROM webr_params " .
163  "WHERE param_id = " . $ilDB->quote($a_param_id, 'integer') . " " .
164  "AND webr_id = " . $ilDB->quote($this->getObjId(), 'integer');
165  $res = $ilDB->manipulate($query);
166  return true;
167  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getErrorCode()

ilParameterAppender::getErrorCode ( )

Definition at line 82 of file class.ilParameterAppender.php.

References $err.

83  {
84  return $this->err;
85  }

◆ getName()

ilParameterAppender::getName ( )

Definition at line 102 of file class.ilParameterAppender.php.

References $name.

Referenced by add(), and validate().

103  {
104  return $this->name;
105  }
if($format !==null) $name
Definition: metadata.php:146
+ Here is the caller graph for this function:

◆ getObjId()

ilParameterAppender::getObjId ( )

Definition at line 93 of file class.ilParameterAppender.php.

References $webr_id.

Referenced by add(), and delete().

+ Here is the caller graph for this function:

◆ getParameterIds()

static ilParameterAppender::getParameterIds (   $a_webr_id,
  $a_link_id 
)
static

Get Parameter ids of link.

Parameters
int$a_webr_id
int$a_link_id
Returns

Definition at line 68 of file class.ilParameterAppender.php.

References $ilDB, $params, $query, $res, $row, array, and ilDBConstants\FETCHMODE_ASSOC.

Referenced by ilWebLinkXmlParser\handlerBeginTag().

69  {
70  global $ilDB;
71 
72  $query = "SELECT * FROM webr_params " .
73  "WHERE webr_id = " . $ilDB->quote($a_webr_id, 'integer') . " " .
74  "AND link_id = " . $ilDB->quote($a_link_id, 'integer');
75  $res = $ilDB->query($query);
76  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
77  $params[] = $row['param_id'];
78  }
79  return (array) $params;
80  }
$params
Definition: disable.php:11
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ getValue()

ilParameterAppender::getValue ( )

Definition at line 110 of file class.ilParameterAppender.php.

Referenced by add(), and validate().

111  {
112  return $this->value;
113  }
+ Here is the caller graph for this function:

◆ parameterToInfo()

static ilParameterAppender::parameterToInfo (   $a_name,
  $a_value 
)
static

Get info text describing an existing dynamic link.

Parameters
string$a_name
int$a_value
Returns

Definition at line 245 of file class.ilParameterAppender.php.

References $info, LINKS_LOGIN, LINKS_MATRICULATION, LINKS_SESSION_ID, and LINKS_USER_ID.

Referenced by ilWebResourceEditableLinkTableGUI\fillRow(), and ilObjLinkResourceGUI\initFormLink().

246  {
247  $info = $a_name;
248 
249  switch ($a_value) {
250  case LINKS_USER_ID:
251  return $info . '=USER_ID';
252 
253  case LINKS_SESSION_ID:
254  return $info . '=SESSION_ID';
255 
256  case LINKS_LOGIN:
257  return $info . '=LOGIN';
258 
259  case LINKS_MATRICULATION:
260  return $info . '=MATRICULATION';
261  }
262  return '';
263  }
const LINKS_MATRICULATION
const LINKS_LOGIN
$info
Definition: index.php:5
const LINKS_USER_ID
const LINKS_SESSION_ID
+ Here is the caller graph for this function:

◆ setName()

ilParameterAppender::setName (   $a_name)

Definition at line 98 of file class.ilParameterAppender.php.

Referenced by ilObjLinkResourceGUI\updateLinks().

99  {
100  $this->name = $a_name;
101  }
+ Here is the caller graph for this function:

◆ setObjId()

ilParameterAppender::setObjId (   $a_obj_id)

Definition at line 88 of file class.ilParameterAppender.php.

89  {
90  $this->webr_id = $a_obj_id;
91  }

◆ setValue()

ilParameterAppender::setValue (   $a_value)

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

107  {
108  $this->value = $a_value;
109  }

◆ validate()

ilParameterAppender::validate ( )

Definition at line 115 of file class.ilParameterAppender.php.

References getName(), getValue(), LINKS_ERR_NO_NAME, LINKS_ERR_NO_NAME_VALUE, and LINKS_ERR_NO_VALUE.

116  {
117  if (!strlen($this->getName()) and !$this->getValue()) {
118  $this->err = LINKS_ERR_NO_NAME_VALUE;
119  return false;
120  }
121  if (!strlen($this->getName())) {
122  $this->err = LINKS_ERR_NO_NAME;
123  return false;
124  }
125  if (!$this->getValue()) {
126  $this->err = LINKS_ERR_NO_VALUE;
127  return false;
128  }
129  return true;
130  }
const LINKS_ERR_NO_VALUE
const LINKS_ERR_NO_NAME
const LINKS_ERR_NO_NAME_VALUE
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilParameterAppender::$db = null

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

◆ $err

ilParameterAppender::$err = null

Definition at line 47 of file class.ilParameterAppender.php.

Referenced by getErrorCode().

◆ $webr_id

ilParameterAppender::$webr_id = null

Definition at line 44 of file class.ilParameterAppender.php.

Referenced by __construct(), and getObjId().


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