25        $this->db = (is_null($db))
 
   28        $this->tree = (is_null($tree))
 
   29            ? 
$DIC->repositoryTree()
 
   39    public function add(
int $user_id, 
int $ref_id)
 
   45        $item_set = $db->queryF(
 
   46            "SELECT * FROM desktop_item WHERE " .
 
   47            "item_id = %s AND type = %s AND user_id = %s",
 
   48            [
"integer", 
"text", 
"integer"],
 
   49            [$ref_id, 
$type, $user_id]
 
   53        if (!$db->fetchAssoc($item_set)) {
 
   55                "INSERT INTO desktop_item (item_id, type, user_id, parameters) VALUES " .
 
   57                array(
"integer", 
"text", 
"integer", 
"text"),
 
   58                array($ref_id,
$type,$user_id,
"")
 
   69    public function remove(
int $user_id, 
int $ref_id)
 
   74            "DELETE FROM desktop_item WHERE " .
 
   75            " item_id = %s AND user_id = %s",
 
   76            array(
"integer", 
"integer"),
 
   77            array($ref_id, $user_id)
 
   96        if (is_null($a_types)) {
 
   97            $item_set = 
$ilDB->queryF(
"SELECT obj.obj_id, obj.description, oref.ref_id, obj.title, obj.type " .
 
   98                " FROM desktop_item it, object_reference oref " .
 
  101                "it.item_id = oref.ref_id AND " .
 
  102                "oref.obj_id = obj.obj_id AND " .
 
  103                "it.user_id = %s", array(
"integer"), array($user_id));
 
  104            $items = $all_parent_path = array();
 
  105            while ($item_rec = 
$ilDB->fetchAssoc($item_set)) {
 
  106                if ($tree->isInTree($item_rec[
"ref_id"])
 
  107                    && $item_rec[
"type"] != 
"rolf" 
  108                    && $item_rec[
"type"] != 
"itgr") {   
 
  109                    $parent_ref = $tree->getParentId($item_rec[
"ref_id"]);
 
  111                    if (!isset($all_parent_path[$parent_ref])) {
 
  112                        if ($parent_ref > 0) {  
 
  113                            $node = $tree->getNodeData($parent_ref);
 
  114                            $all_parent_path[$parent_ref] = $node[
"title"];
 
  116                            $all_parent_path[$parent_ref] = 
"";
 
  120                    $parent_path = $all_parent_path[$parent_ref];
 
  124                    $items[$parent_path . $title . $item_rec[
"ref_id"]] =
 
  125                        array(
"ref_id" => $item_rec[
"ref_id"],
 
  126                            "obj_id" => $item_rec[
"obj_id"],
 
  127                            "type" => $item_rec[
"type"],
 
  129                            "description" => $desc,
 
  130                            "parent_ref" => $parent_ref);
 
  136            foreach ($a_types as 
$a_type) {
 
  140                $item_set = 
$ilDB->queryF(
 
  141                    "SELECT obj.obj_id, obj.description, oref.ref_id, obj.title FROM desktop_item it, object_reference oref " .
 
  142                    ", object_data obj WHERE " .
 
  143                    "it.item_id = oref.ref_id AND " .
 
  144                    "oref.obj_id = obj.obj_id AND " .
 
  145                    "it.type = %s AND " .
 
  148                    array(
"text", 
"integer"),
 
  152                while ($item_rec = 
$ilDB->fetchAssoc($item_set)) {
 
  155                    $items[$title . 
$a_type . $item_rec[
"ref_id"]] =
 
  156                        array(
"ref_id" => $item_rec[
"ref_id"],
 
  157                            "obj_id" => $item_rec[
"obj_id"], 
"type" => 
$a_type,
 
  158                            "title" => $title, 
"description" => $desc);
 
  176        if (!isset(self::$is_desktop_item[$user_id . 
":" . $ref_id])) {
 
  177            $item_set = $db->queryF(
 
  178                "SELECT item_id FROM desktop_item WHERE " .
 
  179                "item_id = %s AND user_id = %s",
 
  180                array(
"integer", 
"integer"),
 
  181                array($ref_id, $user_id)
 
  184            if ($db->fetchAssoc($item_set)) {
 
  185                self::$is_desktop_item[$user_id . 
":" . $ref_id] = 
true;
 
  187                self::$is_desktop_item[$user_id . 
":" . $ref_id] = 
false;
 
  190        return self::$is_desktop_item[$user_id . 
":" . $ref_id];
 
  198    public function loadData(
int $user_id, array $ref_ids)
 
  201        if (!is_array($ref_ids)) {
 
  206        foreach ($ref_ids as $ref_id) {
 
  207            if (!isset(self::$is_desktop_item[$user_id . 
":" . $ref_id])) {
 
  208                $load_ref_ids[] = $ref_id;
 
  212        if (count($load_ref_ids) > 0) {
 
  213            $item_set = $db->query(
"SELECT item_id FROM desktop_item WHERE " .
 
  214                $db->in(
"item_id", $load_ref_ids, 
false, 
"integer") .
 
  215                " AND user_id = " . $db->quote($user_id, 
"integer"));
 
  216            while ($r = $db->fetchAssoc($item_set)) {
 
  217                self::$is_desktop_item[$user_id . 
":" . $r[
"item_id"]] = 
true;
 
  219            foreach ($load_ref_ids as $ref_id) {
 
  220                if (!isset(self::$is_desktop_item[$user_id . 
":" . $ref_id])) {
 
  221                    self::$is_desktop_item[$user_id . 
":" . $ref_id] = 
false;
 
  237            "DELETE FROM desktop_item WHERE " .
 
  254            "DELETE FROM desktop_item WHERE " .
 
An exception for terminatinating execution or to throw for unit testing.
ifIsFavourite($user_id, $ref_id)
check wether an item is on the users desktop or not
add(int $user_id, int $ref_id)
Add favourite.
getFavouritesOfUser(int $user_id, array $a_types=null)
Get all desktop items of user and specified type.
__construct(\ilDBInterface $db=null, ilTree $tree=null)
Constructor.
removeFavouritesOfRefId(int $ref_id)
Remove favourite entries of a repository item.
loadData(int $user_id, array $ref_ids)
Load favourites data.
removeFavouritesOfUser(int $user_id)
Remove favourite entries of a user.
static _lookupTitle($a_id)
lookup object title
static _lookupDescription($a_id)
lookup object description
static _lookupType($a_id, $a_reference=false)
lookup object type
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...