Skip to content

Commit

Permalink
Merge pull request #1609 from Leantime/patches-2.3.21
Browse files Browse the repository at this point in the history
Patches 2.3.21
  • Loading branch information
marcelfolaron committed Apr 30, 2023
2 parents dbbcca1 + 6cb46dc commit 988dc79
Show file tree
Hide file tree
Showing 9 changed files with 166 additions and 111 deletions.
98 changes: 53 additions & 45 deletions app/domain/ideas/controllers/class.ideaDialog.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@

class ideaDialog extends controller
{
private $ideaRepo;
private $sprintService;
private $ticketRepo;
private $ticketService;
private $commentsRepo;
private repositories\ideas $ideaRepo;

private services\tickets $ticketService;
private repositories\comments $commentsRepo;
private services\projects $projectService;

/**
Expand All @@ -30,8 +29,7 @@ public function init()
{

$this->ideaRepo = new repositories\ideas();
$this->sprintService = new services\sprints();
$this->ticketRepo = new repositories\tickets();

$this->ticketService = new services\tickets();
$this->commentsRepo = new repositories\comments();
$this->projectService = new services\projects();
Expand Down Expand Up @@ -76,6 +74,7 @@ public function get($params)
$canvasItem = array(
"id" => "",
"box" => $params['type'],
"tags" => '',
"description" => "",
"status" => "idea",
"assumptions" => "",
Expand Down Expand Up @@ -104,6 +103,46 @@ public function get($params)
public function post($params)
{

if (isset($params['comment']) === true) {
if($params['text'] != '') {
$values = array(
'text' => $params['text'],
'date' => date("Y-m-d H:i:s"),
'userId' => ($_SESSION['userdata']['id']),
'moduleId' => (int)$_GET['id'],
'commentParent' => ($params['father'])
);

$message = $this->commentsRepo->addComment($values, 'idea');
$values["id"] = $message;
$this->tpl->setNotification($this->language->__('notifications.comment_create_success'), "success");

$subject = $this->language->__('email_notifications.new_comment_idea_subject');
$actual_link = BASE_URL . "/ideas/ideaDialog/" . (int)$_GET['id'];
$message = sprintf(
$this->language->__('email_notifications.new_comment_idea_message'),
$_SESSION["userdata"]["name"]
);


$notification = new models\notifications\notification();
$notification->url = array(
"url" => $actual_link,
"text" => $this->language->__('email_notifications.new_comment_idea_cta')
);
$notification->entity = $values;
$notification->module = "comments";
$notification->projectId = $_SESSION['currentProject'];
$notification->subject = $subject;
$notification->authorId = $_SESSION['userdata']['id'];
$notification->message = $message;

$this->projectService->notifyProjectUsers($notification);

$this->tpl->redirect(BASE_URL . "/ideas/ideaDialog/" . (int)$_GET['id']);
}
}

//changeItem is set for new or edited item changes.
if (isset($params['changeItem'])) {
if (isset($params['itemId']) && $params['itemId'] != '') {
Expand All @@ -118,18 +157,20 @@ public function post($params)
"assumptions" => "",
"data" => $params['data'],
"conclusion" => "",
"tags" => $params['tags'],
"itemId" => $params['itemId'],
"canvasId" => $currentCanvasId,
"milestoneId" => $params['milestoneId'],
"id" => $params['itemId']
);

if (isset($params['newMilestone']) && $params['newMilestone'] != '') {
$params['headline'] = $params['newMilestone'];
$params['tags'] = "#ccc";
$params['editFrom'] = date("Y-m-d");
$params['editTo'] = date("Y-m-d", strtotime("+1 week"));
$id = $this->ticketService->quickAddMilestone($params);
$milestone = array();
$milestone['headline'] = $params['newMilestone'];
$milestone['tags'] = "#ccc";
$milestone['editFrom'] = date("Y-m-d");
$milestone['editTo'] = date("Y-m-d", strtotime("+1 week"));
$id = $this->ticketService->quickAddMilestone($milestone);
if ($id !== false) {
$canvasItem['milestoneId'] = $id;
}
Expand Down Expand Up @@ -225,40 +266,7 @@ public function post($params)
}
}

if (isset($params['comment']) === true) {
$values = array(
'text' => $params['text'],
'date' => date("Y-m-d H:i:s"),
'userId' => ($_SESSION['userdata']['id']),
'moduleId' => (int)$_GET['id'],
'commentParent' => ($params['father'])
);

$message = $this->commentsRepo->addComment($values, 'idea');
$values["id"] = $message;
$this->tpl->setNotification($this->language->__('notifications.comment_create_success'), "success");

$subject = $this->language->__('email_notifications.new_comment_idea_subject');
$actual_link = BASE_URL . "/ideas/ideaDialog/" . (int)$_GET['id'];
$message = sprintf($this->language->__('email_notifications.new_comment_idea_message'), $_SESSION["userdata"]["name"]);


$notification = new models\notifications\notification();
$notification->url = array(
"url" => $actual_link,
"text" => $this->language->__('email_notifications.new_comment_idea_cta')
);
$notification->entity = $values;
$notification->module = "comments";
$notification->projectId = $_SESSION['currentProject'];
$notification->subject = $subject;
$notification->authorId = $_SESSION['userdata']['id'];
$notification->message = $message;

$this->projectService->notifyProjectUsers($notification);

$this->tpl->redirect(BASE_URL . "/ideas/ideaDialog/" . (int)$_GET['id']);
}

$this->tpl->assign('canvasTypes', $this->ideaRepo->canvasTypes);
$this->tpl->assign('canvasItem', $this->ideaRepo->getSingleCanvasItem($_GET['id']));
Expand Down
5 changes: 4 additions & 1 deletion app/domain/ideas/repositories/class.ideas.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ public function editCanvasItem($values)
conclusion = :conclusion,
modified = NOW(),
status = :status,
milestoneId = :milestoneId
milestoneId = :milestoneId,
tags = :tags
WHERE id = :id LIMIT 1 ";

$stmn = $this->db->database->prepare($sql);
Expand All @@ -213,6 +214,7 @@ public function editCanvasItem($values)
$stmn->bindValue(':conclusion', $values['conclusion'], PDO::PARAM_STR);
$stmn->bindValue(':status', $values['status'], PDO::PARAM_STR);
$stmn->bindValue(':milestoneId', $values['milestoneId'], PDO::PARAM_STR);
$stmn->bindValue(':tags', $values['tags'], PDO::PARAM_STR);


$stmn->execute();
Expand Down Expand Up @@ -346,6 +348,7 @@ public function getSingleCanvasItem($id)
zp_canvas_items.canvasId,
zp_canvas_items.sortindex,
zp_canvas_items.status,
zp_canvas_items.tags,
zp_canvas_items.milestoneId,
t1.firstname AS authorFirstname,
t1.lastname AS authorLastname,
Expand Down
22 changes: 15 additions & 7 deletions app/domain/ideas/templates/advancedBoards.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<div class="col-md-4">
<?php if ($login::userIsAtLeast($roles::$editor)) { ?>
<?php if (count($this->get('allCanvas')) > 0) { ?>
<a href="<?=BASE_URL ?>/ideas/ideaDialog?type=idea" class="ideaModal btn btn-primary" id="customersegment"><span
<a href="<?=BASE_URL ?>/ideas/advancedBoards/#/ideas/ideaDialog?type=idea" class="btn btn-primary" id="customersegment"><span
class="far fa-lightbulb"></span><?php echo $this->__("buttons.add_idea"); ?></a>

<?php }
Expand Down Expand Up @@ -133,18 +133,26 @@ class="editLabelModal editHeadline"><i class="fas fa-edit"></i></a>
&nbsp;&nbsp;&nbsp;
<ul class="dropdown-menu">
<li class="nav-header"><?php echo $this->__("subtitles.edit"); ?></li>
<li><a href="<?=BASE_URL ?>/ideas/ideaDialog/<?php echo $row["id"];?>" class="ideaModal" data="item_<?php echo $row["id"];?>"> <?php echo $this->__("links.edit_canvas_item"); ?></a></li>
<li><a href="<?=BASE_URL ?>/ideas/delCanvasItem/<?php echo $row["id"]; ?>" class="delete ideaModal" data="item_<?php echo $row["id"];?>"> <?php echo $this->__("links.delete_canvas_item"); ?></a></li>
<li><a href="<?=BASE_URL ?>/ideas/advancedBoards/#/ideas/ideaDialog/<?php echo $row["id"];?>" class="" data="item_<?php echo $row["id"];?>"> <?php echo $this->__("links.edit_canvas_item"); ?></a></li>
<li><a href="<?=BASE_URL ?>/ideas/advancedBoards/#/ideas/delCanvasItem/<?php echo $row["id"]; ?>" class="delete" data="item_<?php echo $row["id"];?>"> <?php echo $this->__("links.delete_canvas_item"); ?></a></li>

</ul>
</div>
<?php } ?>

<h4><a href="<?=BASE_URL ?>/ideas/ideaDialog/<?php echo $row["id"]; ?>" class="ideaModal"
<h4><a href="<?=BASE_URL ?>/ideas/advancedBoards/#/ideas/ideaDialog/<?php echo $row["id"]; ?>" class=""
data="item_<?php echo $row["id"]; ?>"><?php $this->e($row["description"]); ?></a></h4>

<div class="mainIdeaContent">
<?=$this->escapeMinimal($row["data"]) ?>

<div class="kanbanCardContent">

<div class="kanbanContent" style="margin-bottom: 20px">
<?=$this->escapeMinimal($row["data"]) ?>
</div>


</div>
</div>

<div class="clearfix" style="padding-bottom: 8px;"></div>
Expand Down Expand Up @@ -173,8 +181,8 @@ class="editLabelModal editHeadline"><i class="fas fa-edit"></i></a>

<div class="pull-right" style="margin-right:10px;">

<a href="<?=BASE_URL ?>/ideas/ideaDialog/<?php echo $row["id"]; ?>"
class="ideaModal" data="item_<?=$row['id'] ?>"
<a href="<?=BASE_URL ?>/ideas/advancedBoards/#/ideas/ideaDialog/<?php echo $row["id"]; ?>"
data="item_<?=$row['id'] ?>"
<?php echo $row['commentCount'] == 0 ? 'style="color: grey;"' : '' ?>>
<span class="fas fa-comments"></span></a> <small><?=$row['commentCount'] ?></small>

Expand Down
108 changes: 67 additions & 41 deletions app/domain/ideas/templates/ideaDialog.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,50 +17,56 @@
}
</script>

<div class="showDialogOnLoad" >
<?php echo $this->displayNotification(); ?>


<h4 class="widgettitle title-light"><i
class="fa fa-columns"></i>
<?php
if ($canvasItem['description'] == "") {
echo $this->__("headlines.ideas");
} else {
$this->e($canvasItem['description']);
} ?>
</h4>
<form class="formModal" method="post" action="<?=BASE_URL ?>/ideas/ideaDialog/<?php echo $id; ?>">

<?php echo $this->displayNotification(); ?>

<form class="ideaModal" method="post" action="<?=BASE_URL ?>/ideas/ideaDialog/<?php echo $id; ?>">
<div class="row">

<div class="col-md-8">

<input type="hidden" value="<?php echo $this->get('currentCanvas'); ?>" name="canvasId"/>
<input type="hidden" value="<?php $this->e($canvasItem['box']) ?>" name="box" id="box"/>
<input type="hidden" value="<?php echo $id ?>" name="itemId" id="itemId"/>
<input type="hidden" name="status" value="<?php echo $canvasItem['status'] ?>" />
<label><?php echo $this->__("label.name") ?></label>
<input type="text" name="description" value="<?php $this->e($canvasItem['description']); ?>"
placeholder="<?php echo $this->__("input.placeholders.short_name") ?>"/><br/>

<label><?php echo $this->__("label.description") ?></label>
<textarea rows="3" cols="10" name="data" class="tinymceSimple"
placeholder=""><?=$canvasItem['data'] ?></textarea><br/>

<input type="hidden" name="milestoneId" value="<?php echo $canvasItem['milestoneId'] ?>"/>
<input type="hidden" name="changeItem" value="1"/>

<?php if ($id != '') { ?>
<a href="<?=BASE_URL ?>/ideas/delCanvasItem/<?php echo $id; ?>" class="ideaModal delete right"><i
class="fa fa-trash"></i> <?php echo $this->__("links.delete") ?></a>
<?php } ?>
<input type="text" name="description" class="main-title-input" style="width:99%;" value="<?php $this->e($canvasItem['description']); ?>"
placeholder="<?php echo $this->__("input.placeholders.short_name") ?>"/><br/>

<input type="text" value="<?php $this->e($canvasItem['tags']); ?>" name="tags" id="tags" />


<textarea rows="3" cols="10" name="data" class="complexEditor"
placeholder=""><?=$canvasItem['data'] ?></textarea><br/>

<input type="submit" value="<?php echo $this->__("buttons.save")?>" id="primaryCanvasSubmitButton"/>
<input type="submit" value="<?php echo $this->__("buttons.save_and_close")?>" id="saveAndClose"
onclick="leantime.ideasController.setCloseModal();"/>

<?php if ($id !== '') { ?>
<br/>
<hr>
<input type="hidden" name="comment" value="1"/>

<h4 class="widgettitle title-light"><span class="fa fa-comments"></span><?php echo $this->__('subtitles.discussion'); ?></h4>
<?php
$this->assign("formUrl", BASE_URL . "/ideas/ideaDialog/" . $id . "");

$this->displaySubmodule('comments-generalComment'); ?>
<?php } ?>

</div>

<div class="col-md-4">
<?php if ($id !== '') { ?>
<br/><br/>
<h4 class="widgettitle title-light"><span
class="fas fa-map"></span> <?php echo $this->__("headlines.attached_milestone") ?></h4>
class="fas fa-map"></span> <?php echo $this->__("headlines.attached_milestone") ?></h4>


<ul class="sortableTicketList" style="width:99%">
Expand All @@ -70,12 +76,12 @@ class="fas fa-map"></span> <?php echo $this->__("headlines.attached_milestone")
<?php echo $this->__("text.use_milestone_to_track_idea") ?><br/>
<div class="row" id="milestoneSelectors">
<?php if ($login::userIsAtLeast($roles::$editor)) { ?>
<div class="col-md-12">
<a href="javascript:void(0);"
onclick="leantime.ideasController.toggleMilestoneSelectors('new');"><?php echo $this->__("links.create_attach_milestone") ?></a>
| <a href="javascript:void(0);"
onclick="leantime.ideasController.toggleMilestoneSelectors('existing');"><?php echo $this->__("links.attach_existing_milestone") ?></a>
</div>
<div class="col-md-12">
<a href="javascript:void(0);"
onclick="leantime.ideasController.toggleMilestoneSelectors('new');"><?php echo $this->__("links.create_attach_milestone") ?></a>
| <a href="javascript:void(0);"
onclick="leantime.ideasController.toggleMilestoneSelectors('existing');"><?php echo $this->__("links.attach_existing_milestone") ?></a>
</div>
<?php } ?>
</div>
<div class="row" id="newMilestone" style="display:none;">
Expand Down Expand Up @@ -171,29 +177,49 @@ class="ideaModal delete"><i class="fa fa-close"></i> <?php echo $this->__("links
</ul>

<?php } ?>
</div>




</div>


</form>


<div class="showDialogOnLoad" >









<?php if ($id != '') { ?>
<a href="<?=BASE_URL ?>/ideas/delCanvasItem/<?php echo $id; ?>" class="ideaModal delete right"><i
class="fa fa-trash"></i> <?php echo $this->__("links.delete") ?></a>
<?php } ?>



</form>

<?php if ($id !== '') { ?>
<br/>
<input type="hidden" name="comment" value="1"/>

<h4 class="widgettitle title-light"><span class="fa fa-comments"></span><?php echo $this->__('subtitles.discussion'); ?></h4>
<?php
$this->assign("formUrl", BASE_URL . "/ideas/ideaDialog/" . $id . "");

$this->displaySubmodule('comments-generalComment'); ?>
<?php } ?>

</div>

<script type="text/javascript">
jQuery(document).ready(function(){

leantime.generalController.initSimpleEditor();
leantime.generalController.initComplexEditor();
leantime.ticketsController.initTagsInput();

<?php if (!$login::userIsAtLeast($roles::$editor)) { ?>
leantime.generalController.makeInputReadonly(".nyroModalCont");
leantime.generalController.makeInputReadonly(".nyroModalCont");


<?php } ?>

Expand Down
Loading

0 comments on commit 988dc79

Please sign in to comment.