Skip to content

Commit

Permalink
カレンダーで活動をマウスオーバーした際に参加者が表示されるように修正 (#1083)
Browse files Browse the repository at this point in the history
Co-authored-by: Jun Matsuda <{ID}+{username}@users.noreply.github.com>
  • Loading branch information
junmt and Jun Matsuda authored Aug 27, 2024
1 parent 1a3f69d commit 1c8a945
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 2 deletions.
3 changes: 3 additions & 0 deletions modules/Calendar/CalendarCommon.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ function generateIcsAttachment($record, $inviteeid) {
$fp = fopen($ics_filename, "w");

// TZ OFFSETを設定
if(empty($time_zone)) {
$time_zone = DateTimeField::getDBTimeZone();
}
$userTz = new DateTime(date('Y/m/d H:i:s', strtotime($stDatetime)), new DateTimeZone($time_zone));
$userOffset = $userTz->getOffset() / 3600;
$code = ($userOffset < 0) ? "-" : "+";
Expand Down
71 changes: 69 additions & 2 deletions modules/Calendar/actions/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,24 @@ protected function pullEvents($start, $end, &$result, $userid = false, $color =
$item['location'] = $record['location'];
$item['description'] = $record['description'];

$inviteeDetails = $this->getInviteeNames($record['activityid']);
$group = Settings_Groups_Record_Model::getInstance($ownerId);
if(!empty($group)) {
$inviteeDetails[$ownerId] = $group->getName();
}
if(php7_count($inviteeDetails) > 0) {
$inviteeMessage = '';
if(count($inviteeDetails) == 1 && array_key_exists($currentUser->getId(), $inviteeDetails)) {
$inviteeMessage = '';
} else {
$inviteeMessage = '<br>'.vtranslate('LBL_INVITE_USERS', 'Events').'<br>'.implode(', ', $inviteeDetails).'';
}
if(!empty($record['description']) && !empty($inviteeMessage)) {
$inviteeMessage ='<br>'.$inviteeMessage;
}
$item['description'] = $record['description'].$inviteeMessage;
}

$result[] = $item;
}
}
Expand All @@ -448,7 +466,7 @@ protected function pullTasks($start, $end, &$result, $color = null,$textColor =
$userAndGroupIds = array_merge(array($user->getId()),$this->getGroupsIdsForUsers($user->getId()));
$queryGenerator = new QueryGenerator($moduleModel->get('name'), $user);

$queryGenerator->setFields(array('activityid','subject', 'taskstatus','activitytype', 'date_start','time_start','due_date','time_end','id', 'smownerid','parent_id','description'));
$queryGenerator->setFields(array('activityid','subject', 'taskstatus','activitytype', 'date_start','time_start','due_date','time_end','id', 'assigned_user_id','parent_id','description'));
$query = $queryGenerator->getQuery();

$query.= " AND vtiger_activity.activitytype = 'Task' AND ";
Expand Down Expand Up @@ -501,10 +519,59 @@ protected function pullTasks($start, $end, &$result, $color = null,$textColor =
} else {
$item['parent_id'] = '';
}
$item['description'] = $record['description'];

$ownerId = $record['smownerid'];

$inviteeDetails = $this->getInviteeNames($record['activityid']);
$group = Settings_Groups_Record_Model::getInstance($ownerId);
if(!empty($group)) {
$inviteeDetails[$ownerId] = $group->getName();
}
if(php7_count($inviteeDetails) > 0) {
$inviteeMessage = '';
if(count($inviteeDetails) == 1 && array_key_exists($currentUser->getId(), $inviteeDetails)) {
$inviteeMessage = '';
} else {
$inviteeMessage = '<br>'.vtranslate('LBL_INVITE_USERS', 'Events').'<br>'.implode(', ', $inviteeDetails).'';
}
if(!empty($record['description']) && !empty($inviteeMessage)) {
$inviteeMessage ='<br>'.$inviteeMessage;
}
$item['description'] = $record['description'].$inviteeMessage;
}

$result[] = $item;
}
}

private function getInviteeNames($activityid) {
global $adb;

$inviteeDetails = array();

$sql = "SELECT
i.*,
u.first_name,
u.last_name
FROM
vtiger_invitees i
INNER JOIN vtiger_users u ON u.id = i.inviteeid
WHERE
i.activityid=(SELECT invitee_parentid FROM vtiger_activity WHERE activityid = ?)";

$result = $adb->pquery($sql, array($activityid));
$num_rows = $adb->num_rows($result);

for($i=0; $i<$num_rows; $i++) {
$userid = $adb->query_result($result, $i, 'inviteeid');
$name = $adb->query_result($result, $i, 'last_name').''.$adb->query_result($result, $i, 'first_name');
if(empty($name)) {
$group = Settings_Groups_Record_Model::getInstance($userid);
$name = $group->getName();
}
$inviteeDetails[$userid] = $name;
}

return $inviteeDetails;
}
}

0 comments on commit 1c8a945

Please sign in to comment.