53        $this->db = (
$db == 
null)
 
   57        $this->lng = (
$lng == 
null)
 
   61        $this->lng->loadLanguageModule(
"like");
 
   73            self::TYPE_LIKE => $this->lng->txt(
"like_like"),
 
   74            self::TYPE_DISLIKE => $this->lng->txt(
"like_dislike"),
 
   75            self::TYPE_LOVE => $this->lng->txt(
"like_love"),
 
   76            self::TYPE_LAUGH => $this->lng->txt(
"like_laugh"),
 
   77            self::TYPE_ASTOUNDED => $this->lng->txt(
"like_astounded"),
 
   78            self::TYPE_SAD => $this->lng->txt(
"like_sad"),
 
   79            self::TYPE_ANGRY => $this->lng->txt(
"like_angry")
 
  101        $a_sub_obj_type = 
"",
 
  106        if ($a_user_id == ANONYMOUS_USER_ID) {
 
  110        $this->data[$a_obj_id][$a_sub_obj_id][$a_sub_obj_type][$a_news_id][$a_like_type][$a_user_id] = 1;
 
  112        if ($a_sub_obj_type == 
"") {
 
  113            $a_sub_obj_type = 
"-";
 
  119                "user_id" => array(
"integer", (
int) $a_user_id),
 
  120                "obj_id" => array(
"integer", (
int) $a_obj_id),
 
  121                "obj_type" => array(
"text", $a_obj_type),
 
  122                "sub_obj_id" => array(
"integer", (
int) $a_sub_obj_id),
 
  123                "sub_obj_type" => array(
"text", $a_sub_obj_type),
 
  124                "news_id" => array(
"integer", (
int) $a_news_id),
 
  125                "like_type" => array(
"integer", (
int) $a_like_type)
 
  150        $a_sub_obj_type = 
"",
 
  155        if ($a_user_id == ANONYMOUS_USER_ID) {
 
  159        if (isset($this->data[$a_obj_id][$a_sub_obj_id][$a_sub_obj_type][$a_news_id][$a_like_type][$a_user_id])) {
 
  160            unset($this->data[$a_obj_id][$a_sub_obj_id][$a_sub_obj_type][$a_news_id][$a_like_type][$a_user_id]);
 
  163        if ($a_sub_obj_type == 
"") {
 
  164            $a_sub_obj_type = 
"-";
 
  168            "DELETE FROM like_data WHERE " .
 
  169            " user_id = " . 
$ilDB->quote($a_user_id, 
"integer") .
 
  170            " AND obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer") .
 
  171            " AND obj_type = " . 
$ilDB->quote($a_obj_type, 
"text") .
 
  172            " AND sub_obj_id = " . 
$ilDB->quote($a_sub_obj_id, 
"integer") .
 
  173            " AND sub_obj_type = " . 
$ilDB->quote($a_sub_obj_type, 
"text") .
 
  174            " AND news_id = " . 
$ilDB->quote($a_news_id, 
"integer") .
 
  175            " AND like_type = " . 
$ilDB->quote($a_like_type, 
"integer")
 
  188        foreach ($a_obj_ids as $id) {
 
  189            $this->data[$id] = array();
 
  192        $set = 
$ilDB->query(
"SELECT * FROM like_data " .
 
  193            " WHERE " . 
$ilDB->in(
"obj_id", $a_obj_ids, 
false, 
"integer") .
 
  194            " ORDER by exp_ts DESC");
 
  195        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
  196            $subtype = $rec[
"sub_obj_type"] == 
"-" 
  198                : $rec[
"sub_obj_type"];
 
  199            $this->data[$rec[
"obj_id"]][$rec[
"sub_obj_id"]][$subtype][$rec[
"news_id"]][$rec[
"like_type"]][$rec[
"user_id"]] =
 
  217        if (!is_array($this->data[$obj_id])) {
 
  218            include_once(
"./Services/Like/exceptions/class.ilLikeDataException.php");
 
  222        if ($sub_obj_type == 
"-") {
 
  229            if (is_array($this->data[$obj_id][$sub_obj_id][$sub_obj_type][$news_id][$k])) {
 
  230                $cnt[$k] = count($this->data[$obj_id][$sub_obj_id][$sub_obj_type][$news_id][$k]);
 
  254        $a_sub_obj_type = 
"",
 
  257        if (isset($this->data[$a_obj_id][$a_sub_obj_id][$a_sub_obj_type][$a_news_id][$a_like_type][$a_user_id])) {
 
  276        if (!is_array($this->data[$obj_id])) {
 
  277            include_once(
"./Services/Like/exceptions/class.ilLikeDataException.php");
 
  281        if ($sub_obj_type == 
"-") {
 
  287            if (is_array($this->data[$obj_id][$sub_obj_id][$sub_obj_type][$news_id][$k])) {
 
  288                foreach ($this->data[$obj_id][$sub_obj_id][$sub_obj_type][$news_id][$k] as $user => $ts) {
 
  312        if (!is_array($this->data[$obj_id])) {
 
  313            include_once(
"./Services/Like/exceptions/class.ilLikeDataException.php");
 
  317        foreach ($this->data[$obj_id] as $sub_obj_id => 
$si) {
 
  318            foreach (
$si as $sub_obj_type => $so) {
 
  319                foreach ($so as $news_id => $ni) {
 
  320                    foreach ($ni as $exp_type => $entry) {
 
  321                        foreach ($entry as $user => $ts) {
 
  322                            if ($since_ts == 
null || $ts > $since_ts) {
 
  324                                    "sub_obj_id" => $sub_obj_id,
 
  325                                    "sub_obj_type" => $sub_obj_type,
 
  326                                    "news_id" => $news_id,
 
  327                                    "expression" => $exp_type,
 
An exception for terminatinating execution or to throw for unit testing.
Data class for like feature.
removeExpression( $a_user_id, $a_like_type, $a_obj_id, $a_obj_type, $a_sub_obj_id=0, $a_sub_obj_type="", $a_news_id=0)
Remove expression for a user and object.
getExpressionEntriesForObject($obj_id, $since_ts=null)
Get expression entries for obj/subobj/news.
getExpressionEntries($obj_id, $obj_type, $sub_obj_id, $sub_obj_type, $news_id)
Get expression entries for obj/subobj/news.
getExpressionTypes()
Get types.
addExpression( $a_user_id, $a_like_type, $a_obj_id, $a_obj_type, $a_sub_obj_id=0, $a_sub_obj_type="", $a_news_id=0)
Add expression for a user and object.
loadDataForObjects($a_obj_ids=array())
Load data (for objects)
isExpressionSet( $a_user_id, $a_like_type, $a_obj_id, $a_obj_type, $a_sub_obj_id=0, $a_sub_obj_type="", $a_news_id=0)
Is expression set for a user and object?
getExpressionCounts($obj_id, $obj_type, $sub_obj_id, $sub_obj_type, $news_id)
Get expression counts for obj/subobj/news.
__construct(array $a_obj_ids=array(), ilDB $db=null, $lng=null)
Constructor.
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static now()
Return current timestamp in Y-m-d H:i:s format.