mirror of
https://github.com/openvk/openvk
synced 2024-12-22 16:42:32 +03:00
Merge branch 'master' of https://github.com/openvk/openvk
This commit is contained in:
commit
49a9a9bdb1
8 changed files with 63 additions and 3 deletions
|
@ -6,7 +6,7 @@ trait TOwnable
|
|||
{
|
||||
function canBeModifiedBy(User $user): bool
|
||||
{
|
||||
if(is_callable([$this, "isCreatedBySystem"]))
|
||||
if(method_exists($this, "isCreatedBySystem"))
|
||||
if($this->isCreatedBySystem())
|
||||
return false;
|
||||
|
||||
|
|
|
@ -54,6 +54,10 @@ final class NotesPresenter extends OpenVKPresenter
|
|||
$this->notFound();
|
||||
|
||||
if($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
if(empty($this->postParam("name"))) {
|
||||
$this->flashFail("err", tr("error"), tr("error_segmentation"));
|
||||
}
|
||||
|
||||
$note = new Note;
|
||||
$note->setOwner($this->user->id);
|
||||
$note->setCreated(time());
|
||||
|
@ -64,4 +68,22 @@ final class NotesPresenter extends OpenVKPresenter
|
|||
$this->redirect("/note" . $this->user->id . "_" . $note->getId());
|
||||
}
|
||||
}
|
||||
|
||||
function renderDelete(int $owner, int $id): void
|
||||
{
|
||||
$this->assertUserLoggedIn();
|
||||
$this->willExecuteWriteAction();
|
||||
$this->assertNoCSRF();
|
||||
|
||||
$note = $this->notes->get($id);
|
||||
if(!$note) $this->notFound();
|
||||
if($note->getOwner()->getId() . "_" . $note->getId() !== $owner . "_" . $id || $note->isDeleted()) $this->notFound();
|
||||
if(is_null($this->user) || !$note->canBeModifiedBy($this->user->identity))
|
||||
$this->flashFail("err", "Ошибка доступа", "Недостаточно прав для модификации данного ресурса.");
|
||||
|
||||
$name = $note->getName();
|
||||
$note->delete();
|
||||
$this->flash("succ", "Заметка удалена", "Заметка \"$name\" была успешно удалена.");
|
||||
$this->redirect("/notes" . $this->user->id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,6 +68,9 @@ final class PhotosPresenter extends OpenVKPresenter
|
|||
}
|
||||
|
||||
if($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
if(empty($this->postParam("name"))) {
|
||||
$this->flashFail("err", tr("error"), tr("error_segmentation"));
|
||||
}
|
||||
$album = new Album;
|
||||
$album->setOwner(isset($club) ? $club->getId() * -1 : $this->user->id);
|
||||
$album->setName($this->postParam("name"));
|
||||
|
|
|
@ -39,11 +39,19 @@
|
|||
</article>
|
||||
|
||||
<div style="width: 100%; min-height: 100px;">
|
||||
<div style="float: left; min-height: 100px; width: 70%;">
|
||||
{include "../components/comments.xml",
|
||||
comments => $comments,
|
||||
count => $cCount,
|
||||
page => $cPage,
|
||||
model => "notes",
|
||||
parent => $note}
|
||||
</div>
|
||||
<div style="float: right; min-height: 100px; width: 30%;">
|
||||
<h4>{_actions}</h4>
|
||||
<div n:if="isset($thisUser) && $thisUser->getId() === $note->getOwner()->getId()">
|
||||
<a id="_noteDelete" href="/note{$note->getOwner()->getId()}_{$note->getId()}/delete" class="profile_link" style="display:block;width:96%;">{_delete}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
<input type="text" name="pseudo" value="{$user->getPseudo()}" />
|
||||
</td>
|
||||
</tr>
|
||||
{if OPENVK_ROOT_CONF['openvk']['credentials']['zadarma']['enable']}
|
||||
<tr>
|
||||
<td width="120" valign="top">
|
||||
<span class="nobold">Телефон: </span>
|
||||
|
@ -70,6 +71,7 @@
|
|||
<input type="phone" name="phone" value="{$user->getPhone()}" />
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
<tr>
|
||||
<td width="120" valign="top">
|
||||
<span class="nobold">{_"status"}: </span>
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
|
||||
<div style="float: right; font-size: .7rem;">
|
||||
<a href="/comment{$comment->getId()}/like?hash={rawurlencode($csrfToken)}">
|
||||
<text style="{if $comment->hasLikeFrom($thisUser)}color: red;{else}filter: sepia(1){/if}">❤</text>
|
||||
{$comment->getLikesCount()}
|
||||
<div class="heart" style="{if $comment->hasLikeFrom($thisUser)}opacity: 1;{else}opacity: 0.4;{/if}"></div>
|
||||
<span class="likeCnt">{$comment->getLikesCount()}</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -173,6 +173,8 @@ routes:
|
|||
handler: "Notes->view"
|
||||
- url: "/notes/create"
|
||||
handler: "Notes->create"
|
||||
- url: "/note{num}_{num}/delete"
|
||||
handler: "Notes->delete"
|
||||
- url: "/invite"
|
||||
handler: "About->invite"
|
||||
- url: "/away.php"
|
||||
|
|
|
@ -59,4 +59,27 @@ u("#_photoDelete").on("click", function(e) {
|
|||
return e.preventDefault();
|
||||
});
|
||||
|
||||
/* @rem-pai why this func wasn't named as "#_deleteDialog"? It looks universal IMO */
|
||||
|
||||
u("#_noteDelete").on("click", function(e) {
|
||||
var formHtml = "<form id='tmpPhDelF' action='" + u(this).attr("href") + "' >";
|
||||
formHtml += "<input type='hidden' name='hash' value='" + u("meta[name=csrf]").attr("value") + "' />";
|
||||
formHtml += "</form>";
|
||||
u("body").append(formHtml);
|
||||
|
||||
MessageBox("Внимание", "Удаление нельзя отменить. Вы действительно уверены в том что хотите сделать?", [
|
||||
"Да",
|
||||
"Нет"
|
||||
], [
|
||||
(function() {
|
||||
u("#tmpPhDelF").nodes[0].submit();
|
||||
}),
|
||||
(function() {
|
||||
u("#tmpPhDelF").remove();
|
||||
}),
|
||||
]);
|
||||
|
||||
return e.preventDefault();
|
||||
});
|
||||
|
||||
}); //END ONREADY DECLS
|
Loading…
Reference in a new issue