public function afterStoreCallback() { if ($this->isDirty()) { //add notification to writer of review if (!$this->review['host_id'] && $this->review['user_id'] !== $this['user_id']) { PersonalNotifications::add($this->review['user_id'], URLHelper::getURL("plugins.php/lernmarktplatz/market/discussion/" . $this['review_id'] . "#comment_" . $this->getId()), sprintf(_("%s hat einen Kommentar zu Ihrem Review geschrieben."), $this['host_id'] ? LernmarktplatzUser::find($this['user_id'])->name : get_fullname($this['user_id'])), "comment_" . $this->getId(), Icon::create("support", "clickable")); } //add notification to all users of this servers who discussed this review but are neither the new //commentor nor the writer of the review $statement = DBManager::get()->prepare("\n SELECT user_id\n FROM lernmarktplatz_comments\n WHERE review_id = :review_id\n AND host_id IS NULL\n GROUP BY user_id\n "); $statement->execute(array('review_id' => $this->review->getId())); foreach ($statement->fetchAll(PDO::FETCH_COLUMN, 0) as $user_id) { if (!in_array($user_id, array($this->review['user_id'], $this['user_id']))) { PersonalNotifications::add($user_id, URLHelper::getURL("plugins.php/lernmarktplatz/market/discussion/" . $this['review_id'] . "#comment_" . $this->getId()), sprintf(_("%s hat auch einen Kommentar geschrieben."), $this['host_id'] ? LernmarktplatzUser::find($this['user_id'])->name : get_fullname($this['user_id'])), "comment_" . $this->getId(), Icon::create("support", "clickable")); } } //only push if the comment is from this server and the material-server is different if (!$this['host_id']) { $myHost = LernmarktplatzHost::thisOne(); $data = array(); $data['host'] = array('name' => $myHost['name'], 'url' => $myHost['url'], 'public_key' => $myHost['public_key']); $data['data'] = $this->toArray(); $data['data']['foreign_comment_id'] = $data['data']['comment_id']; unset($data['data']['comment_id']); unset($data['data']['id']); unset($data['data']['user_id']); unset($data['data']['host_id']); $user_description_datafield = DataField::find(get_config("LERNMARKTPLATZ_USER_DESCRIPTION_DATAFIELD")) ?: DataField::findOneBySQL("name = ?", array(get_config("LERNMARKTPLATZ_USER_DESCRIPTION_DATAFIELD"))); if ($user_description_datafield) { $datafield_entry = DatafieldEntryModel::findOneBySQL("range_id = ? AND datafield_id = ?", array($this['user_id'], $user_description_datafield->getId())); } $data['user'] = array('user_id' => $this['user_id'], 'name' => get_fullname($this['user_id']), 'avatar' => Avatar::getAvatar($this['user_id'])->getURL(Avatar::NORMAL), 'description' => $datafield_entry ? $datafield_entry['content'] : null); $statement = DBManager::get()->prepare("\n SELECT host_id\n FROM lernmarktplatz_comments\n WHERE review_id = :review_id\n AND host_id IS NOT NULL\n GROUP BY host_id\n "); $statement->execute(array('review_id' => $this->review->getId())); $hosts = $statement->fetchAll(PDO::FETCH_COLUMN, 0); if ($this->review['host_id'] && !in_array($this->review['host_id'], $hosts)) { $hosts[] = $this->review['host_id']; } if ($this->review->material['host_id'] && !in_array($this->review->material['host_id'], $hosts)) { $hosts[] = $this->review->material['host_id']; } foreach ($hosts as $host_id) { $remote = new LernmarktplatzHost($host_id); if (!$remote->isMe()) { $review_id = $this->review['foreign_review_id'] ?: $this->review->getId(); if ($this->review['foreign_review_id']) { if ($this->review->host_id === $remote->getId()) { $host_hash = null; } else { $host_hash = md5($this->review->host['public_key']); } } else { $host_hash = md5($myHost['public_key']); } $remote->pushDataToEndpoint("add_comment/" . $review_id . "/" . $host_hash, $data); } } } } }
public function afterStoreCallback() { if (!$this->material['host_id'] && $this->material['user_id'] !== $GLOBALS['user']->id) { PersonalNotifications::add($this->material['user_id'], URLHelper::getURL("plugins.php/lernmarktplatz/market/details/" . $this->material->getId() . "#review_" . $this->getId()), $this->isNew() ? sprintf(_("%s hat ein Review zu '%s' geschrieben."), $this['host_id'] ? LernmarktplatzUser::find($this['user_id'])->name : get_fullname($this['user_id']), $this->material['name']) : sprintf(_("%s hat ein Review zu '%s' verändert."), $this['host_id'] ? LernmarktplatzUser::find($this['user_id'])->name : get_fullname($this['user_id']), $this->material['name']), "review_" . $this->getId(), Icon::create("support", "clickable")); } //only push if the comment is from this server and the material-server is different if ($this->material['host_id'] && !$this['host_id'] && $this->isDirty()) { $remote = new LernmarktplatzHost($this->material['host_id']); $myHost = LernmarktplatzHost::thisOne(); $data = array(); $data['host'] = array('name' => $myHost['name'], 'url' => $myHost['url'], 'public_key' => $myHost['public_key']); $data['data'] = $this->toArray(); $data['data']['foreign_review_id'] = $data['data']['review_id']; unset($data['data']['review_id']); unset($data['data']['id']); unset($data['data']['user_id']); unset($data['data']['host_id']); $user_description_datafield = DataField::find(get_config("LERNMARKTPLATZ_USER_DESCRIPTION_DATAFIELD")) ?: DataField::findOneBySQL("name = ?", array(get_config("LERNMARKTPLATZ_USER_DESCRIPTION_DATAFIELD"))); if ($user_description_datafield) { $datafield_entry = DatafieldEntryModel::findOneBySQL("range_id = ? AND datafield_id = ?", array($this['user_id'], $user_description_datafield->getId())); } $data['user'] = array('user_id' => $this['user_id'], 'name' => get_fullname($this['user_id']), 'avatar' => Avatar::getAvatar($this['user_id'])->getURL(Avatar::NORMAL), 'description' => $datafield_entry ? $datafield_entry['content'] : null); if (!$remote->isMe()) { $remote->pushDataToEndpoint("add_review/" . $this->material['foreign_material_id'], $data); } } }
?> " title="<?php echo _("Schreiben Sie einen Kommentar dazu."); ?> "> <?php echo Icon::create("comment", "inactive")->asImg(14, array('class' => "text-bottom")); ?> </a> <?php echo date("j.n.Y G:i", $review['chdate']); ?> </div> <strong> <? if ($review['host_id']) : ?> <? $user = LernmarktplatzUser::find($review['user_id']) ?> <a href="<?php echo PluginEngine::getLink($plugin, array(), "market/profile/" . $user->getId()); ?> "> <?php echo htmlReady($user->name); ?> </a> <? else : ?> <? $user = new User($review['user_id']) ?> <a href="<?php echo URLHelper::getLink("dispatch.php/profile", array('username' => $user['username'])); ?> "> <?php
public function search_items_action() { $host = LernmarktplatzHost::thisOne(); if (Request::get("text")) { $this->materialien = LernmarktplatzMaterial::findByText(studip_utf8decode(Request::get("text"))); } elseif (Request::get("tag")) { $this->materialien = LernmarktplatzMaterial::findByTag(studip_utf8decode(Request::get("tag"))); } $output = array('results' => array()); foreach ($this->materialien as $material) { $data = array(); $data['host'] = array('name' => $material->host ? $material->host['name'] : $host['name'], 'url' => $material->host ? $material->host['url'] : $host['url'], 'public_key' => $material->host ? $material->host['public_key'] : $host['public_key']); $data['data'] = $material->toArray(); unset($data['data']['material_id']); if ($material->host) { $foreign_user = LernmarktplatzUser::find($material['user_id']); $data['user'] = array('user_id' => $foreign_user ? $foreign_user->foreign_user_id : "unbekannt", 'name' => $foreign_user ? $foreign_user->name : "unbekannt", 'avatar' => $foreign_user ? $foreign_user->avatar : null); } else { $data['user'] = array('user_id' => $material->host ? LernmarktplatzUser::find($material['user_id'])->foreign_user_id : $material['user_id'], 'name' => get_fullname($material['user_id']), 'avatar' => Avatar::getAvatar($material['user_id'])->getURL(Avatar::NORMAL)); } $data['topics'] = array(); foreach ($material->getTopics() as $topic) { $data['topics'][] = $topic['name']; } $output['results'][] = $data; } $this->render_json($output); }
<li id="comment_<?php echo $comment->getId(); ?> " class="review"> <div class="avatar"> <img width="50px" height="50px" src="<?php echo htmlReady($comment['host_id'] ? LernmarktplatzUser::find($comment['user_id'])->avatar : Avatar::getAvatar($comment['user_id'])->getURL(Avatar::MEDIUM)); ?> "> </div> <div class="content"> <div class="timestamp"> <?php echo date("j.n.Y G:i", $comment['chdate']); ?> </div> <strong><?php echo htmlReady($comment['host_id'] ? LernmarktplatzUser::find($comment['user_id'])->name : get_fullname($comment['user_id'])); ?> </strong> <span class="origin">(<?php echo htmlReady($comment['host_id'] ? $comment->host['name'] : $GLOBALS['UNI_NAME_CLEAN']); ?> )</span> <div class="review_text"> <?php echo formatReady($comment['comment']); ?> </div> </div> </li>
<a href="<?php echo PluginEngine::getLink($plugin, array(), "market/details/" . $review['material_id']); ?> "> <?php echo Icon::create("arr_1left", "clickable")->asImg("20px", array('class' => "text-bottom")); ?> <?php echo _("Zurück"); ?> </a> <div class="mainreview"> <div style="margin-bottom: 10px;"> <img width="50px" height="50px" src="<?php echo htmlReady($review['host_id'] ? LernmarktplatzUser::find($review['user_id'])->avatar : Avatar::getAvatar($review['user_id'])->getURL(Avatar::MEDIUM)); ?> " style="vertical-align: middle;"> <span class="stars" style="vertical-align: middle;"> <? $rating = round($review['rating'], 1) ?> <? $v = $rating >= 0.75 ? 3 : ($rating >= 0.25 ? 2 : "") ?> <?php echo Icon::create($plugin->getPluginURL() . "/assets/star{$v}.svg")->asImg(25); ?> <? $v = $rating >= 1.75 ? 3 : ($rating >= 1.25 ? 2 : "") ?> <?php echo Icon::create($plugin->getPluginURL() . "/assets/star{$v}.svg")->asImg(25); ?> <? $v = $rating >= 2.75 ? 3 : ($rating >= 2.25 ? 2 : "") ?> <?php echo Icon::create($plugin->getPluginURL() . "/assets/star{$v}.svg")->asImg(25);