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

Abstract parent class for all udf claiming plugin classes. More...

+ Inheritance diagram for ilUDFClaimingPlugin:
+ Collaboration diagram for ilUDFClaimingPlugin:

Public Member Functions

 getComponentType ()
 Get Component Type. More...
 
 getComponentName ()
 Get Component Name. More...
 
 getSlot ()
 Get Slot Name. More...
 
 getSlotId ()
 Get Slot ID. More...
 
 checkPermission ($a_user_id, $a_context_type, $a_context_id, $a_action_id, $a_action_sub_id)
 Check permission. More...
 
- Public Member Functions inherited from ilPlugin
 __construct ()
 
 getComponentType ()
 Get Component Type. More...
 
 getComponentName ()
 Get Component Name. More...
 
 getSlot ()
 Get Slot Name. More...
 
 getSlotId ()
 Get Slot ID. More...
 
 getPluginName ()
 Get Plugin Name. More...
 
 getId ()
 Get Id. More...
 
 getLastUpdateVersion ()
 Get Version of last update. More...
 
 getVersion ()
 Get Current Version (from plugin.php file). More...
 
 getIliasMinVersion ()
 Get Required ILIAS min. More...
 
 getIliasMaxVersion ()
 Get Required ILIAS max. More...
 
 getActive ()
 Get Active. More...
 
 setDBVersion ($a_dbversion)
 Set DB Version. More...
 
 getDBVersion ()
 Get DB Version. More...
 
 writeDBVersion ($a_dbversion)
 Write DB version to database. More...
 
 getDirectory ()
 Get Plugin Directory. More...
 
 includeClass ($a_class_file_name)
 Include (once) a class file. More...
 
 getPrefix ()
 Get plugin prefix, used for lang vars. More...
 
 getTablePrefix ()
 Get db table plugin prefix. More...
 
 updateLanguages ($a_lang_keys=null)
 
 updateDatabase ()
 Update database. More...
 
 loadLanguageModule ()
 Load language module for plugin. More...
 
 txt ($a_var)
 Get Language Variable (prefix will be prepended automatically) More...
 
 getTemplate ($a_template, $a_par1=true, $a_par2=true)
 Get template from plugin. More...
 
 getImagePath ($a_img)
 Get image path. More...
 
 getStyleSheetLocation ($a_css_file)
 Get css file location. More...
 
 addBlockFile ($a_tpl, $a_var, $a_block, $a_tplname)
 Add template content to placeholder variable. More...
 
 isActive ()
 Check whether plugin is active. More...
 
 needsUpdate ()
 Check whether update is needed. More...
 
 activate ()
 Activate. More...
 
 deactivate ()
 Deactivate. More...
 
 uninstall ()
 
 update ()
 Update plugin. More...
 
 lookupNameForId ($a_ctype, $a_cname, $a_slot_id, $a_plugin_id)
 Lookup name for id. More...
 
 lookupIdForName ($a_ctype, $a_cname, $a_slot_id, $a_plugin_name)
 Lookup id for name. More...
 

Static Public Member Functions

static hasDBField ($a_field_id)
 Check if field has db entry. More...
 
static createDBField ($a_type, $a_title, array $a_access=null, array $a_options=null)
 Create field db entry. More...
 
static updateDBField ($a_field_id, $a_title, array $a_access=null, array $a_options=null)
 Update field db entry. More...
 
static deleteDBField ($a_field_id)
 Delete field db entry. More...
 
- Static Public Member Functions inherited from ilPlugin
static _getDirectory ($a_ctype, $a_cname, $a_slot_id, $a_pname)
 Get plugin directory. More...
 
static getAvailableLangFiles ($a_lang_directory)
 Get array of all language files in the plugin. More...
 
static hasConfigureClass ($a_slot_dir, $a_name)
 Has the plugin a configure class? More...
 
static getConfigureClassName ($a_name)
 Get plugin configure class name. More...
 
static getDBUpdateScriptName ($a_ctype, $a_cname, $a_slot_name, $a_pname)
 Get DB update script filename (full path) More...
 
static lookupTxt ($a_mod_prefix, $a_pl_id, $a_lang_var)
 Lookup language text. More...
 
static _getImagePath ($a_ctype, $a_cname, $a_slot_id, $a_pname, $a_img)
 Get image path. More...
 
static createPluginRecord ($a_ctype, $a_cname, $a_slot_id, $a_pname)
 
static getPluginRecord ($a_ctype, $a_cname, $a_slot_id, $a_pname)
 Get record from il_plugin table. More...
 
static getPluginObject ($a_ctype, $a_cname, $a_slot_id, $a_pname)
 Get plugin object. More...
 
static lookupStoredData ($a_ctype, $a_cname, $a_slot_id, $a_pname)
 Lookup information data in il_plugin. More...
 
static getActivePluginsForSlot ($a_ctype, $a_cname, $a_slot_id)
 Get all active plugins for a slot. More...
 

Protected Member Functions

 slotInit ()
 Object initialization done by slot. More...
 
- Protected Member Functions inherited from ilPlugin
 setSlotObject ($a_slot)
 Set Plugin Slot. More...
 
 getSlotObject ()
 Get Plugin Slot. More...
 
 getClassesDirectory ()
 Get Plugin's classes Directory. More...
 
 getLanguageDirectory ()
 Get Plugin's language Directory. More...
 
 slotInit ()
 Object initialization done by slot. More...
 
 init ()
 Object initialization. More...
 
 beforeActivation ()
 Before activation processing. More...
 
 afterActivation ()
 After activation processing. More...
 
 afterDeactivation ()
 After deactivation processing. More...
 
 beforeUninstall ()
 
 afterUninstall ()
 
 beforeUpdate ()
 Before update processing. More...
 
 afterUpdate ()
 After update processing. More...
 

Static Protected Member Functions

static getDBField ($a_field_id)
 Get existing field values. More...
 
static isValidFieldType ($a_field_type)
 Validate field type. More...
 
static handleAccesss (array &$fields, array $a_access=null, array $a_existing=null)
 Convert access array to DB columns. More...
 

Additional Inherited Members

- Protected Attributes inherited from ilPlugin
 $lang_initialised = false
 
 $id = ''
 

Detailed Description

Abstract parent class for all udf claiming plugin classes.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

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

Member Function Documentation

◆ checkPermission()

ilUDFClaimingPlugin::checkPermission (   $a_user_id,
  $a_context_type,
  $a_context_id,
  $a_action_id,
  $a_action_sub_id 
)
abstract

Check permission.

Parameters
int$a_user_id
int$a_context_type
int$a_context_id
int$a_action_id
int$a_action_sub_id
Returns
bool

◆ createDBField()

static ilUDFClaimingPlugin::createDBField (   $a_type,
  $a_title,
array  $a_access = null,
array  $a_options = null 
)
static

Create field db entry.

Parameters
int$a_type
string$a_title
array$a_access
array$a_options
Returns
int field id

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

152 {
153 global $ilDB;
154
155 $field_id = $ilDB->nextId("udf_definition");
156
157 // validating type
158 $a_type = (int)$a_type;
159 if(!self::isValidFieldType($a_type))
160 {
161 return;
162 }
163
164 if($a_type != UDF_TYPE_SELECT)
165 {
166 $a_options = null;
167 }
168
169 // :TODO: check unique title?
170
171 $fields = array(
172 "field_id" => array("integer", $field_id),
173 "field_type" => array("integer", $a_type),
174 "field_name" => array("text", trim($a_title)),
175 "field_values" => array("text", serialize((array)$a_options))
176 );
177
178 self::handleAccesss($fields, $a_access);
179
180 $ilDB->insert("udf_definition", $fields);
181
182 return $field_id;
183 }
const UDF_TYPE_SELECT
static handleAccesss(array &$fields, array $a_access=null, array $a_existing=null)
Convert access array to DB columns.
global $ilDB

References $ilDB, handleAccesss(), and UDF_TYPE_SELECT.

+ Here is the call graph for this function:

◆ deleteDBField()

static ilUDFClaimingPlugin::deleteDBField (   $a_field_id)
static

Delete field db entry.

Parameters
int$a_field_id
Returns
bool

Definition at line 228 of file class.ilUDFClaimingPlugin.php.

229 {
230 global $ilDB;
231
232 if(self::hasDBField($a_field_id))
233 {
234 // :TODO: we are not deleting any values here
235
236 $ilDB->manipulate("DELETE FROM udf_definition".
237 " WHERE field_id = ".$ilDB->quote($a_field_id, "integer"));
238 return true;
239 }
240
241 return false;
242 }

References $ilDB.

◆ getComponentName()

ilUDFClaimingPlugin::getComponentName ( )
final

Get Component Name.

Must be overwritten in plugin class of plugin slot.

Returns
string Component Name

Reimplemented from ilPlugin.

Definition at line 26 of file class.ilUDFClaimingPlugin.php.

27 {
28 return "User";
29 }

◆ getComponentType()

ilUDFClaimingPlugin::getComponentType ( )
final

Get Component Type.

Must be overwritten in plugin class of plugin slot.

Returns
string Component Type

Reimplemented from ilPlugin.

Definition at line 21 of file class.ilUDFClaimingPlugin.php.

22 {
23 return IL_COMP_SERVICE;
24 }
const IL_COMP_SERVICE

References IL_COMP_SERVICE.

◆ getDBField()

static ilUDFClaimingPlugin::getDBField (   $a_field_id)
staticprotected

Get existing field values.

Parameters
int$a_field_id
Returns
array

Definition at line 89 of file class.ilUDFClaimingPlugin.php.

90 {
91 global $ilDB;
92
93 $set = $ilDB->query("SELECT * FROM udf_definition".
94 " WHERE field_id = ".$ilDB->quote($a_field_id, "integer"));
95 return $ilDB->fetchAssoc($set);
96 }

References $ilDB.

Referenced by updateDBField().

+ Here is the caller graph for this function:

◆ getSlot()

ilUDFClaimingPlugin::getSlot ( )
final

Get Slot Name.

Must be overwritten in plugin class of plugin slot.

Returns
string Slot Name

Reimplemented from ilPlugin.

Definition at line 31 of file class.ilUDFClaimingPlugin.php.

32 {
33 return "UDFClaiming";
34 }

◆ getSlotId()

ilUDFClaimingPlugin::getSlotId ( )
final

Get Slot ID.

Must be overwritten in plugin class of plugin slot.

Returns
string Slot Id

Reimplemented from ilPlugin.

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

37 {
38 return "udfc";
39 }

◆ handleAccesss()

static ilUDFClaimingPlugin::handleAccesss ( array &  $fields,
array  $a_access = null,
array  $a_existing = null 
)
staticprotected

Convert access array to DB columns.

Parameters
array$fields
array$a_access

Definition at line 120 of file class.ilUDFClaimingPlugin.php.

121 {
122 $map = array("visible", "changeable", "searchable", "required", "export",
123 "course_export", "group_export", "registration_visible", "visible_lua",
124 "changeable_lua", "certificate");
125 foreach($map as $prop)
126 {
127 if(isset($a_access[$prop]))
128 {
129 $fields[$prop] = array("integer", (int)$a_access[$prop]);
130 }
131 else if(isset($a_existing[$prop]))
132 {
133 $fields[$prop] = array("integer", (int)$a_existing[$prop]);
134 }
135 else
136 {
137 $fields[$prop] = array("integer", 0);
138 }
139 }
140 }

Referenced by createDBField(), and updateDBField().

+ Here is the caller graph for this function:

◆ hasDBField()

static ilUDFClaimingPlugin::hasDBField (   $a_field_id)
static

Check if field has db entry.

Parameters
int$a_field_id
Returns
bool

Definition at line 74 of file class.ilUDFClaimingPlugin.php.

75 {
76 global $ilDB;
77
78 $set = $ilDB->query("SELECT field_id FROM udf_definition".
79 " WHERE field_id = ".$ilDB->quote($a_field_id, "integer"));
80 return (bool)$ilDB->numRows($set);
81 }

References $ilDB.

◆ isValidFieldType()

static ilUDFClaimingPlugin::isValidFieldType (   $a_field_type)
staticprotected

Validate field type.

Parameters
string$a_field_type
Returns
bool

Definition at line 104 of file class.ilUDFClaimingPlugin.php.

105 {
106 // needed for the type constants
107 require_once "Services/User/classes/class.ilUserDefinedFields.php";
108
110
111 return in_array($a_field_type, $valid);
112 }
const UDF_TYPE_WYSIWYG
const UDF_TYPE_TEXT
$valid

References $valid, UDF_TYPE_SELECT, UDF_TYPE_TEXT, and UDF_TYPE_WYSIWYG.

◆ slotInit()

ilUDFClaimingPlugin::slotInit ( )
finalprotected

Object initialization done by slot.

Must be overwritten in plugin class of plugin slot.

(and should be made protected)

Reimplemented from ilPlugin.

Definition at line 41 of file class.ilUDFClaimingPlugin.php.

42 {
43 require_once "Services/User/classes/class.ilUDFPermissionHelper.php";
44 }

◆ updateDBField()

static ilUDFClaimingPlugin::updateDBField (   $a_field_id,
  $a_title,
array  $a_access = null,
array  $a_options = null 
)
static

Update field db entry.

Parameters
int$a_field_id
string$a_title
array$a_access
array$a_options
Returns
bool

Definition at line 194 of file class.ilUDFClaimingPlugin.php.

195 {
196 global $ilDB;
197
198 if(self::hasDBField($a_field_id))
199 {
200 $old = self::getDBField($a_field_id);
201
202 if($old["field_type"] != UDF_TYPE_SELECT)
203 {
204 $a_options = null;
205 }
206
207 $fields = array(
208 "field_name" => array("text", trim($a_title)),
209 "field_values" => array("text", serialize((array)$a_options))
210 );
211
212 self::handleAccesss($fields, $a_access, $old);
213
214 $ilDB->update("udf_definition", $fields,
215 array("field_id" => array("integer", $a_field_id)));
216 return true;
217 }
218
219 return false;
220 }
static getDBField($a_field_id)
Get existing field values.

References $ilDB, getDBField(), handleAccesss(), and UDF_TYPE_SELECT.

+ Here is the call graph for this function:

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