ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilTaxNodeAssignment Class Reference

Taxonomy node <-> item assignment. More...

+ Collaboration diagram for ilTaxNodeAssignment:

Public Member Functions

 __construct ($a_component_id, $a_item_type, $a_tax_id)
 Constructor.
 getComponentId ()
 Get component id.
 getItemType ()
 Get item type.
 getTaxonomyId ()
 Get taxonomy id.
 getAssignmentsOfNode ($a_node_id)
 Get assignments of node.
 getAssignmentsOfItem ($a_item_id)
 Get assignments for item.
 addAssignment ($a_node_id, $a_item_id)
 Add assignment.
 deleteAssignmentsOfItem ($a_item_id)
 Delete assignments of item.

Static Public Member Functions

static deleteAssignmentsOfNode ($a_node_id)
 Delete assignments of node.

Protected Member Functions

 setComponentId ($a_val)
 Set component id.
 setItemType ($a_val)
 Set item type.
 setTaxonomyId ($a_val)
 Set taxonomy id.

Detailed Description

Taxonomy node <-> item assignment.

This class allows to assign items to taxonomy nodes.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

/

Definition at line 17 of file class.ilTaxNodeAssignment.php.

Constructor & Destructor Documentation

ilTaxNodeAssignment::__construct (   $a_component_id,
  $a_item_type,
  $a_tax_id 
)

Constructor.

Parameters
string$a_component_idcomponent id (e.g. "glo" for Modules/Glossary)
string$a_item_typeitem type (e.g. "term", must be unique component wide)
int$a_tax_idtaxonomy id

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

References setComponentId(), setItemType(), and setTaxonomyId().

{
if ($a_component_id == "")
{
throw new ilTaxonomyException('No component ID passed to ilTaxNodeAssignment.');
}
if ($a_item_type == "")
{
throw new ilTaxonomyException('No item type passed to ilTaxNodeAssignment.');
}
if ((int) $a_tax_id == 0)
{
throw new ilTaxonomyException('No taxonomy ID passed to ilTaxNodeAssignment.');
}
$this->setComponentId($a_component_id);
$this->setItemType($a_item_type);
$this->setTaxonomyId($a_tax_id);
}

+ Here is the call graph for this function:

Member Function Documentation

ilTaxNodeAssignment::addAssignment (   $a_node_id,
  $a_item_id 
)

Add assignment.

Parameters
int$a_node_idnode id
int$a_item_iditem id

Definition at line 168 of file class.ilTaxNodeAssignment.php.

References getComponentId(), getItemType(), and getTaxonomyId().

Referenced by ilTaxonomyDataSet\importRecord().

{
global $ilDB;
// nothing to do, if not both IDs are greater 0
if ((int) $a_node_id == 0 || (int) $a_item_id == 0)
{
return;
}
// sanity check: does the node belong to the given taxonomy?
$set = $ilDB->query("SELECT tax_tree_id FROM tax_tree ".
" WHERE child = ".$ilDB->quote($a_node_id, "integer")
);
$rec = $ilDB->fetchAssoc($set);
if ($rec["tax_tree_id"] != $this->getTaxonomyId())
{
throw new ilTaxonomyException('addAssignment: Node ID does not belong to current taxonomy.');
}
$ilDB->replace("tax_node_assignment",
array(
"node_id" => array("integer", $a_node_id),
"component" => array("text", $this->getComponentId()),
"item_type" => array("text", $this->getItemType()),
"item_id" => array("integer", $a_item_id)
),
array()
);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTaxNodeAssignment::deleteAssignmentsOfItem (   $a_item_id)

Delete assignments of item.

Parameters
int$a_item_iditem id

Definition at line 204 of file class.ilTaxNodeAssignment.php.

{
global $ilDB;
$ilDB->manipulate("DELETE FROM tax_node_assignment WHERE ".
" component = ".$ilDB->quote($this->getComponentId(), "text").
" AND item_type = ".$ilDB->quote($this->getItemType(), "text").
" AND item_id = ".$ilDB->quote($a_item_id, "integer")
);
}
static ilTaxNodeAssignment::deleteAssignmentsOfNode (   $a_node_id)
static

Delete assignments of node.

Parameters
int$a_node_idnode id

Definition at line 220 of file class.ilTaxNodeAssignment.php.

Referenced by ilTaxonomyNode\delete().

{
global $ilDB;
$ilDB->manipulate("DELETE FROM tax_node_assignment WHERE ".
" node_id = ".$ilDB->quote($a_node_id, "integer"));
}

+ Here is the caller graph for this function:

ilTaxNodeAssignment::getAssignmentsOfItem (   $a_item_id)
final

Get assignments for item.

Parameters
int$a_item_iditem id
Returns
array array of tax node assignments arrays

Definition at line 145 of file class.ilTaxNodeAssignment.php.

{
global $ilDB;
$set = $ilDB->query("SELECT * FROM tax_node_assignment ".
" WHERE component = ".$ilDB->quote($this->getComponentId(), "text").
" AND item_type = ".$ilDB->quote($this->getItemType(), "text").
" AND item_id = ".$ilDB->quote($a_item_id, "integer")
);
$ass = array();
while ($rec = $ilDB->fetchAssoc($set))
{
$ass[] = $rec;
}
return $ass;
}
ilTaxNodeAssignment::getAssignmentsOfNode (   $a_node_id)
final

Get assignments of node.

Parameters
int$a_node_idnode id
Returns
array array of tax node assignments arrays

Definition at line 114 of file class.ilTaxNodeAssignment.php.

Referenced by ilObjTaxonomy\getSubTreeItems().

{
global $ilDB;
if (is_array($a_node_id))
{
$set = $ilDB->query("SELECT * FROM tax_node_assignment ".
" WHERE ".$ilDB->in("node_id", $a_node_id, false, "integer")
);
}
else
{
$set = $ilDB->query("SELECT * FROM tax_node_assignment ".
" WHERE node_id = ".$ilDB->quote($a_node_id, "integer")
);
}
$ass = array();
while ($rec = $ilDB->fetchAssoc($set))
{
$ass[] = $rec;
}
return $ass;
}

+ Here is the caller graph for this function:

ilTaxNodeAssignment::getComponentId ( )

Get component id.

Returns
string component id

Definition at line 63 of file class.ilTaxNodeAssignment.php.

Referenced by addAssignment().

{
return $this->component_id;
}

+ Here is the caller graph for this function:

ilTaxNodeAssignment::getItemType ( )

Get item type.

Returns
string item type

Definition at line 83 of file class.ilTaxNodeAssignment.php.

Referenced by addAssignment().

{
return $this->item_type;
}

+ Here is the caller graph for this function:

ilTaxNodeAssignment::getTaxonomyId ( )

Get taxonomy id.

Returns
int taxonomy id

Definition at line 103 of file class.ilTaxNodeAssignment.php.

Referenced by addAssignment().

{
return $this->taxonomy_id;
}

+ Here is the caller graph for this function:

ilTaxNodeAssignment::setComponentId (   $a_val)
protected

Set component id.

Parameters
string$a_valcomponent id

Definition at line 53 of file class.ilTaxNodeAssignment.php.

Referenced by __construct().

{
$this->component_id = $a_val;
}

+ Here is the caller graph for this function:

ilTaxNodeAssignment::setItemType (   $a_val)
protected

Set item type.

Parameters
string$a_valitem type

Definition at line 73 of file class.ilTaxNodeAssignment.php.

Referenced by __construct().

{
$this->item_type = $a_val;
}

+ Here is the caller graph for this function:

ilTaxNodeAssignment::setTaxonomyId (   $a_val)
protected

Set taxonomy id.

Parameters
int$a_valtaxonomy id

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

Referenced by __construct().

{
$this->taxonomy_id = $a_val;
}

+ Here is the caller graph for this function:


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