Skip to content

Commit

Permalink
Mention Feature Added
Browse files Browse the repository at this point in the history
  • Loading branch information
swetalina-orangescrum committed Sep 23, 2022
1 parent ec81aeb commit 3fb85ea
Show file tree
Hide file tree
Showing 12 changed files with 326 additions and 8 deletions.
17 changes: 17 additions & 0 deletions app/Controller/Component/PostcaseComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,25 @@ public function casePosting($formdata, $fromMobile = null, $gitissue = array())
}
}
} else {
$Mconditions = array('EasycaseMention.easycase_id' => $mtask_id, 'EasycaseMention.comment_id' => 0,'EasycaseMention.project_id' => $postParam['Easycase']['project_id']);
$EasycaseMention->deleteAll($Mconditions);
// $easycaseMentionList = $EasycaseMention->find('list',array('conditions'=>array('easycase_id'=>$mtask_id,'comment_id'=>0),'fields'=>array('id')));
}
if ($is_save_mention == 0) {
foreach ($mention_array['mention_type_id'] as $mk=>$mv) {
$marray = array();
$marray['EasycaseMention']['company_id'] = SES_COMP;
$marray['EasycaseMention']['project_id'] = $postParam['Easycase']['project_id'];
$marray['EasycaseMention']['mention_type_id'] = $mv;
$marray['EasycaseMention']['mention_type'] = $mention_array['mention_type'][$mk] == "task" ? 2: 1 ;
$marray['EasycaseMention']['easycase_id'] = $mtask_id;
$marray['EasycaseMention']['comment_id'] = $mcomment_id;
$marray['EasycaseMention']['mention_message'] = $postParam['Easycase']['message'];
$marray['EasycaseMention']['created'] = GMT_DATETIME;
$marray['EasycaseMention']['mention_by'] = SES_ID;
$EasycaseMention->saveAll($marray);
}
}
}
}
$Project = ClassRegistry::init('Project');
Expand Down
12 changes: 11 additions & 1 deletion app/Controller/EasycasesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8359,7 +8359,7 @@ public function ajax_task_recurring()
}
echo json_encode($arr);
exit;
}
}
public function edit_task_details()
{
$this->layout = 'ajax';
Expand Down Expand Up @@ -8431,6 +8431,16 @@ public function edit_task_details()
$arr['checklists'][$key]['CheckList']['title'] = $frmt->formatCms($val['CheckList']['title']);
}
}
$arr['mention_array'] = array();
$this->loadModel('EasycaseMention');
$case_mntn_lst = $this->EasycaseMention->find("all",array("conditions"=>array("EasycaseMention.easycase_id"=>$casedetails['Easycase']['id'],"EasycaseMention.comment_id"=>0)));
if(!empty($case_mntn_lst)){
foreach($case_mntn_lst as $km =>$vm){
$arr['mention_array']["mention_id"][$km] = $vm["EasycaseMention"]["id"];
$arr['mention_array']["mention_type_id"][$km] = $vm["EasycaseMention"]["mention_type_id"];
$arr['mention_array']["mention_type"][$km] = $vm["EasycaseMention"]["mention_type"] == 1 ? "user" : "task" ;
}
}
// Fetch custom field values of task
$caseId = $casedetails['Easycase']['id'];

Expand Down
74 changes: 73 additions & 1 deletion app/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8133,7 +8133,79 @@ function updateLeftMenu($last_user_id = 0){

exit;
}

public function ajax_mentioned_list()
{
$this->layout = 'ajax';
$limit1 = $this->params->data['limit1'];
$limit2 = $this->params->data['limit2'];
$project_id = $this->params->data['projid'];
if ($project_id == 'all') {
$cond = '';
$prj = array();
} else {
$cond = "AND `Project`.`uniq_id` = '" . $project_id . "'";
$prj = $this->Project->findByUniqId($project_id);
}

if (!$this->Format->isAllowed('View All Task', $roleAccess)) {
// $cond .= " AND (Easycase.assign_to=" . SES_ID . " OR Easycase.user_id=".SES_ID.") ";
}
if (SES_TYPE < 3) {
if ($project_id == 'all') {
$cond .= " AND EasycaseMention.mention_type='1' AND EasycaseMention.company_id='".SES_COMP."'";
} else {
$cond .= " AND EasycaseMention.mention_type='1' AND EasycaseMention.project_id ='".$prj["Project"]["id"]."' AND EasycaseMention.company_id='".SES_COMP."'";
}
} else {
if ($project_id == 'all') {
$cond .= " AND EasycaseMention.mention_type_id=" . SES_ID . " AND EasycaseMention.mention_type='1' AND EasycaseMention.company_id='".SES_COMP."'";
} else {
$cond .= " AND EasycaseMention.mention_type_id=" . SES_ID . " AND EasycaseMention.mention_type='1' AND EasycaseMention.project_id ='".$prj["Project"]["id"]."' AND EasycaseMention.company_id='".SES_COMP."'";
}
}

$clt_sql = 1;
if ($this->Auth->user('is_client') == 1) {
$clt_sql = "((Easycase.client_status = " . $this->Auth->user('is_client') . " AND Easycase.user_id = " . $this->Auth->user('id') . ") OR Easycase.client_status != " . $this->Auth->user('is_client') . ")";
}

// $sql = "SELECT SQL_CALC_FOUND_ROWS `Easycase`.*,DATE_FORMAT(Easycase.actual_dt_created,'%d%m%Y') AS ddate ,`User`.id,`User`.name,`User`.short_name,`User`.photo,`Project`.id,`Project`.uniq_id,`Project`.name FROM `easycases` AS `Easycase` inner JOIN users AS `User` ON (`Easycase`.`user_id` = `User`.`id`) inner JOIN projects AS `Project` ON (`Easycase`.`project_id` = `Project`.`id`) inner JOIN project_users AS `ProjectUser` ON (`Easycase`.`project_id` = `ProjectUser`.`project_id` AND `ProjectUser`.`user_id` = '" . SES_ID . "' AND `ProjectUser`.`company_id` = '" . SES_COMP . "') WHERE Project.isactive='1' AND " . $clt_sql . " AND Easycase.isactive='1' $cond ORDER BY Easycase.actual_dt_created DESC LIMIT $limit1,$limit2";
$sql = "SELECT SQL_CALC_FOUND_ROWS EasycaseMention.*,DATE_FORMAT(EasycaseMention.created,'%d%m%Y') AS ddate ,`Easycase`.id,`Easycase`.uniq_id,`Easycase`.title,`Easycase`.case_no,`MentionedUser`.id,`MentionedUser`.name,`MentionedUser`.short_name,`MentionedUser`.photo,`MentionedByUser`.id,`MentionedByUser`.name,`MentionedByUser`.short_name,`MentionedByUser`.photo,`Project`.id,`Project`.uniq_id,`Project`.name FROM easycase_mentions AS EasycaseMention inner JOIN `easycases` AS `Easycase` ON (Easycase.id = EasycaseMention.easycase_id) inner JOIN users AS `MentionedByUser` ON (`EasycaseMention`.`mention_by` = `MentionedByUser`.`id`) inner JOIN users as MentionedUser ON (`EasycaseMention`.`mention_type_id` = `MentionedUser`.`id`) inner JOIN projects AS `Project` ON (`EasycaseMention`.`project_id` = `Project`.`id`) WHERE Project.isactive='1' AND " . $clt_sql . " AND Easycase.isactive='1' $cond ORDER BY EasycaseMention.created DESC LIMIT $limit1,$limit2";
// echo $sql;exit;
$activity = $this->User->query($sql);
$tot = $this->User->query("SELECT FOUND_ROWS() as total");
// echo "<pre>";echo $sql;print_r($activity);exit;
$total = $tot[0][0]['total'];

/*$parent_task_id = array_filter(Hash::combine($activity, '{n}.Easycase.id', '{n}.Easycase.parent_task_id'));
$related_tasks = !empty($parent_task_id) ? $this->Easycase->getSubTasks($parent_task_id) : array();*/
$related_tasks = array();

//This section is meant for json loading.
//Load the helpers
$view = new View($this);
$tz = $view->loadHelper('Tmzone');
$dt = $view->loadHelper('Datetime');
$csq = $view->loadHelper('Casequery');
$fmt = $view->loadHelper('Format');
if ($total != 0) {
$frmtActivity['activity'] = array();
// echo "<pre>";print_r($activity);exit;
$frmtActivity = $this->User->formatMentionList($activity, $total, $fmt, $dt, $tz, $csq, $related_tasks, 1);
// echo "<pre>";print_r($frmtActivity);exit;
//Making one array to send in json format.
$lastDate = '';
$repeatDate = $frmtActivity['activity']['0']['EasycaseMention']['lastDate'];
$ajax_activity['activity'] = $frmtActivity['activity'];
$ajax_activity['total'] = $frmtActivity['total'];
} else {
$ajax_activity['activity'] = "";
$ajax_activity['total'] = $total;
}
$this->set('ajax_activity', json_encode($ajax_activity));
$this->set('related_tasks', $related_tasks);
//End
}
public function ajax_get_location($whitelist = ['127.0.0.1', '::1']){
$ip = $this->Format->getRealIpAddr();
#$ip = '182.66.61.253';
Expand Down
78 changes: 77 additions & 1 deletion app/Model/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -1586,7 +1586,83 @@ function addDummyUser($proj_id, $comp_id, $user_id, $comp_uid){
}
return $dumy_users;
}

function formatMentionList($activity, $total, $fmt, $dt, $tz, $csq, $related_tasks = array(), $flg=0) {
if ($total) {
App::import('Component', 'Format');
$format = new FormatComponent(new ComponentCollection);

$dateCurnt = $tz->GetDateTime(SES_TIMEZONE, TZ_GMT, TZ_DST, TZ_CODE, GMT_DATETIME, "date");
foreach ($activity as $k => $v) {
$updated = $tz->GetDateTime(SES_TIMEZONE, TZ_GMT, TZ_DST, TZ_CODE, $v['EasycaseMention']['created'], "datetime");
$lastDate = $dt->dateFormatOutputdateTime_day($updated, $dateCurnt, '', 1);
$lastDateArr = explode(',', $lastDate);
$activity[$k]['MentionedUser']['profile_bg_clr'] = $this->getProfileBgColr($v['MentionedUser']['id']);
$activity[$k]['MentionedByUser']['profile_bg_clr'] = $this->getProfileBgColr($v['MentionedByUser']['id']);
$activity[$k]['Easycase']['id'] = $v['Easycase']['id'];

$id = $v['Easycase']['id'];
$activity[$k]['MentionedUser']['full_name'] = ucfirst($fmt->formatText($v['MentionedUser']['name']));
$activity[$k]['MentionedByUser']['full_name'] = ucfirst($fmt->formatText($v['MentionedByUser']['name']));

$activity[$k]['MentionedUser']['name'] = ucfirst($fmt->formatText($v['MentionedUser']['name']));
$activity[$k]['MentionedByUser']['name'] = ucfirst($fmt->formatText($v['MentionedByUser']['name']));

$activity[$k]['EasycaseMention']['lastDate'] = $lastDate;
//$activity[$k]['Easycase']['uniqId'] = $csq->getCaseUniqId($v['Easycase']['case_no'], $v['Easycase']['project_id']);
$msg = '';
//$casetitle = $csq->getTaskTitle($v['Easycase']['id'], $v['Easycase']['istype'], $v['Easycase']['case_no'], $v['Project']['id']);
$casetitle = $v['Easycase']['title'];

$frmt_title_data = $fmt->formatText($casetitle);
$frmt_title_data = $fmt->formatTitle($fmt->convert_ascii($fmt->longstringwrap($frmt_title_data)));

//$frmt_title_data = $fmt->showSubtaskTitle($frmt_title_data, $id, $related_tasks, 1, $activity[$k]['Easycase']);

$eTitle = '<a href="javascript:void(0);" class="mention-task-dtls" data-uniqid="'.$activity[$k]['Easycase']['uniq_id'].'">#' . $v['Easycase']['case_no'] . ": " . $frmt_title_data . '</a>';
//$eTitle = $frmt_title_data;
$activity[$k]['Easycase']['title_data'] = $eTitle;
$new_mesg = '';
$new_text = '';
$msg = ' <span class="col-crt">'.__('Created',true).'</span> <p>' . $eTitle . '</p>';
if($activity[$k]['EasycaseMention']['mention_type_id'] == SES_ID){
$mntn_user = __("You have been mentioned");
} else{
$mntn_user = $activity[$k]['MentionedUser']['full_name']." ".__("have been mentioned");
}
if($activity[$k]['EasycaseMention']['comment_id'] == 0){
$mntn_typ = __("in a task description");
}else {
$mntn_typ = __("in a comment");
}
if($activity[$k]['EasycaseMention']['mention_by'] == SES_ID){
if($activity[$k]['EasycaseMention']['mention_type_id'] == SES_ID){
$mntn_by = "";
} else{
$mntn_by = __("by Me");
}

} else {
$mntn_by = __("by")." ".$activity[$k]['MentionedByUser']['full_name'];
}
$new_mesg = '<span class="col-crt"><b>'.$mntn_user.' '.$mntn_typ.' '.$mntn_by .'</b></span>';

$new_mesg .= '<p>' . $eTitle . '</p>';
// $new_text = $eTitle;
$activity[$k]['EasycaseMention']['msg'] = $activity[$k]['EasycaseMention']['mention_message'];
$activity[$k]['EasycaseMention']['nmsg'] = $new_mesg;
// $activity[$k]['Easycase']['ntxt'] = $new_text;
if ($project_id != 'all') {
if ($project_id == $v['Project']['id']) {
$activity[$k]['Project']['name'] = '';
} else {
$activity[$k]['Project']['name'] = $v['Project']['name'];
}
}
}
$activity = array_values($activity);
}
return array('activity' => $activity, 'total' => $total);
}
function getUserDtls($uid) {
$this->recursive = -1;
$usrDtls = $this->find('first', array('conditions' => array('User.id' => $uid), 'fields' => array('User.name', 'User.photo', 'User.email', 'User.last_name', 'User.dt_created', 'User.dt_last_login','User.btprofile_id','User.uniq_id')));
Expand Down
5 changes: 5 additions & 0 deletions app/View/Elements/top_bar.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,11 @@ PAGE_NAME == 'groupupdatealerts' || PAGE_NAME == 'importexport' || PAGE_NAME ==
</a>

</li>
<li class="mentionlist_breadcrumb mntn_li">
<a href="<?php echo HTTP_ROOT; ?>dashboard#/mentioned_list" onclick="trackEventLeadTracker('Breadcrumb Navigation','Mentioned','<?php echo $_SESSION['SES_EMAIL_USER_LOGIN'];?>');return checkHashLoad('mentioned_list');">
<i class="material-icons">&#xE8EF;</i> <?php echo __('Mentions');?>
</a>
</li>
</ul>
</div>
<div class="calendar-bar-text">
Expand Down
6 changes: 6 additions & 0 deletions app/View/Elements/top_bar_v2.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -1569,6 +1569,12 @@
<i class="material-icons">&#xE922;</i><?php echo __('Activities');?>
</a>
</li>
<li class="mentionlist_breadcrumb mntn_li">
<a href="<?php echo HTTP_ROOT; ?>dashboard#/mentioned_list"
onclick="trackEventLeadTracker('Breadcrumb Navigation','Mentioned','<?php echo $_SESSION['SES_EMAIL_USER_LOGIN'];?>');return checkHashLoad('mentioned_list');">
<i class="material-icons">&#xE8EF;</i> <?php echo __('Mentions');?>
</a>
</li>
</ul>
</div>
<div class="calendar-bar-text">
Expand Down
5 changes: 5 additions & 0 deletions app/View/Elements/top_menu_options_icon.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
<span title="<?php echo __('Activities');?>"><i class="material-icons">&#xE922;</i><?php echo __('Activities');?></span>
</a>
</li>
<li>
<a id="actvt_btns" class="" href="<?php echo HTTP_ROOT . 'dashboard#mentioned_list'; ?>" onclick="trackEventLeadTracker('Top Bar Navigation','Mention','<?php echo $_SESSION['SES_EMAIL_USER_LOGIN'];?>');return checkHashLoad('mentioned_list');">
<span title="<?php echo __('Mentions');?>"><i class="material-icons">alternate_email</i><?php echo __('Mentions');?></span>
</a>
</li>
<?php if($this->Format->isAllowed('View Calendar',$roleAccess)){ ?>
<li><a id="calendar_btn" class="" href="<?php echo HTTP_ROOT . 'dashboard#calendar'; ?>" onclick="trackEventLeadTracker('Top Bar Navigation','Calendar','<?php echo $_SESSION['SES_EMAIL_USER_LOGIN'];?>');return calendarView('calendar');">
<span title="<?php echo __('Calendar');?>"><i class="material-icons">&#xE916;</i><?php echo __('Calendar');?></span>
Expand Down
5 changes: 5 additions & 0 deletions app/View/Elements/top_menu_options_icon_v2.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,10 @@
<span title="<?php echo __('Activities');?>"><i class="material-icons">&#xE922;</i><?php echo __('Activities');?></span>
</a>
</li>
<li>
<a id="actvt_btns" class="" href="<?php echo HTTP_ROOT . 'dashboard#mentioned_list'; ?>" onclick="trackEventLeadTracker('Top Bar Navigation','Mention','<?php echo $_SESSION['SES_EMAIL_USER_LOGIN'];?>');return checkHashLoad('mentioned_list');">
<span title="<?php echo __('Mentions');?>"><i class="material-icons">alternate_email</i><?php echo __('Mentions');?></span>
</a>
</li>
</ul>
</span>
33 changes: 33 additions & 0 deletions app/View/Users/json_mentioned.ctp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<div ng-controller="mention_Controller" id="mentionController" >
<div ng-if="mention_total > 0" ng-repeat="(x,data) in mention_records" ng-init="setcurrent(mention_records,x)" on-finish-render="callMyCustomMethod()" ng-cloak >
<div class="gray-dot">
<div class="fl activity-date" ng-if="data.EasycaseMention.lastDate != activity_records[x - 1].EasycaseMention.lastDate">{{data.EasycaseMention.lastDate}}</div>


<div class="cb"></div>

<div class="activity-row" ng-if="data.EasycaseMention.nmsg !=''" >
<span>
<span class="cmn_profile_holder prof_hold_pos_absl" ng-if="data.User.photo !='' && data.User.photo != null">
<img class="round_profile_img ppl_invol lazy" data-original="<?php echo HTTP_ROOT ; ?>users/image_thumb/?type=photos&file={{data.User.photo}}&sizex=30&sizey=30&quality=100" width="30" height="30" title="{{data.User.name}} {{data.User.short_name }}" rel="tooltip" alt="Loading"/>
</span>
<span class="cmn_profile_holder prof_hold_pos_absl {{data.User.profile_bg_clr}}" ng-if="data.User.photo =='' || data.User.photo == null">{{data.User.name.charAt(0)}}</span>
</span>
<div class="activity-hover-bg">
<!-- small class="fr activity-time">{{data.Easycase.updated}}</small -->
<div ng-bind-html="trustAsHtml(data.EasycaseMention.nmsg)"></div>
<span ng-bind-html="trustAsHtml(data.EasycaseMention.mention_message)" class="mentioned_message_cls"></span>
</div>
</div>

</div>
</div>
<div ng-if="mention_total== 0" class="empty_mntn"><?php /*echo __("All your ");?><strong><?php echo __("@mentions ");?></strong> <?php echo __("will appear here! Start collaborating with your teams by using");?><strong> <?php echo __(" @mentions");?></strong><?php echo __(" on task description and task comments.");*/?>
<img src="<?php echo HTTP_ROOT;?>/img/images/no_mention_data.png">
</div>
<input type="hidden" id="totalmention" value="{{mention_total}}">
</div>
<style>
.dash-mention .dash-mentioned-cont .empty_mntn{text-align:center;border-left:none;}
.dash-mention .empty_mntn {background: #fff;position: relative;left: -1px;}
</style>
Loading

0 comments on commit 3fb85ea

Please sign in to comment.