Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions ajax/editActivity.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,6 @@
date('H:i:00', $time)
);

/* Highlight what needs highlighting. */
if (strpos($activityNote, 'Status change: ') === 0)
{
$pipelines = new Pipelines($siteID);

$statusRS = $pipelines->getStatusesForPicking();
foreach ($statusRS as $data)
{
$activityNote = StringUtility::replaceOnce(
$data['status'],
'<span style="color: #ff6c00;">' . $data['status'] . '</span>',
$activityNote
);
}
}

/* Save the new activity entry. */
$activityEntries = new ActivityEntries($siteID);
$activityEntries->update($activityID, $type, $activityNote, $jobOrderID, $date, $_SESSION['CATS']->getTimeZoneOffset());
Expand Down
2 changes: 1 addition & 1 deletion db/cats_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ insert into `module_schema`(`module_schema_id`,`name`,`version`) values (9,'ext
insert into `module_schema`(`module_schema_id`,`name`,`version`) values (10,'graphs',0);
insert into `module_schema`(`module_schema_id`,`name`,`version`) values (11,'home',0);
insert into `module_schema`(`module_schema_id`,`name`,`version`) values (12,'import',0);
insert into `module_schema`(`module_schema_id`,`name`,`version`) values (13,'install',365);
insert into `module_schema`(`module_schema_id`,`name`,`version`) values (13,'install',370);
insert into `module_schema`(`module_schema_id`,`name`,`version`) values (14,'joborders',0);
insert into `module_schema`(`module_schema_id`,`name`,`version`) values (15,'lists',0);
insert into `module_schema`(`module_schema_id`,`name`,`version`) values (16,'login',0);
Expand Down
26 changes: 26 additions & 0 deletions lib/TemplateUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,32 @@ public static function getAlternatingRowClass($rowNumber)
}
}

/**
* Highlights status change activity notes for HTML output.
*
* @param string activity note text
* @return string updated activity note
*/
public static function highlightStatusChangeActivityNote($notes)
{
$prefix = 'Status change: ';
if (strpos($notes, $prefix) !== 0)
{
return htmlspecialchars($notes, ENT_QUOTES | ENT_SUBSTITUTE, HTML_ENCODING);
}

$statusText = ltrim(substr($notes, strlen($prefix)));
if ($statusText === '')
{
return htmlspecialchars($notes, ENT_QUOTES | ENT_SUBSTITUTE, HTML_ENCODING);
}

return htmlspecialchars($prefix, ENT_QUOTES | ENT_SUBSTITUTE, HTML_ENCODING) .
'<span class="statusChangeHighlight">' .
htmlspecialchars($statusText, ENT_QUOTES | ENT_SUBSTITUTE, HTML_ENCODING) .
'</span>';
}

/**
* Removes from $text everything from starting block through ending block.
* Optionally also removes a following piece of text indicated by closing
Expand Down
5 changes: 5 additions & 0 deletions main.css
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,11 @@ span.jobLinkSubmitted
color: #ff6c00;
}

span.statusChangeHighlight
{
color: #ff6c00;
}

a.jobLinkSubmitted:hover
{
text-decoration: underline;
Expand Down
2 changes: 1 addition & 1 deletion modules/activity/Search.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
</td>

<td align="left" valign="top" >
<?php echo($activityData['notes']); ?>
<?php echo(TemplateUtility::highlightStatusChangeActivityNote($activityData['notes'])); ?>
</td>

<td align="left" valign="top">
Expand Down
23 changes: 5 additions & 18 deletions modules/candidates/CandidatesUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -2958,24 +2958,11 @@ private function _addActivityChangeStatus($isJobOrdersMode, $regardingID,

$activityTypeID = $_POST['activityTypeID'];

$activityNote = $this->getTrimmedInput('activityNote', $_POST);

$activityNote = htmlspecialchars($activityNote);

// FIXME: Move this to a highlighter-method? */
if (strpos($activityNote, 'Status change: ') === 0)
{
foreach ($statusRS as $data)
{
$activityNote = StringUtility::replaceOnce(
$data['status'],
'<span style="color: #ff6c00;">' . $data['status'] . '</span>',
$activityNote
);
}
}

/* Add the activity entry. */
$activityNote = $this->getTrimmedInput('activityNote', $_POST);

$activityNote = htmlspecialchars($activityNote);

/* Add the activity entry. */
$activityEntries = new ActivityEntries($this->_siteID);
$activityID = $activityEntries->add(
$candidateID,
Expand Down
2 changes: 1 addition & 1 deletion modules/candidates/Show.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ use OpenCATS\UI\CandidateDuplicateQuickActionMenu;
<td align="left" valign="top" id="activityType<?php echo($activityData['activityID']); ?>"><?php $this->_($activityData['typeDescription']) ?></td>
<td align="left" valign="top"><?php $this->_($activityData['enteredByAbbrName']) ?></td>
<td align="left" valign="top" id="activityRegarding<?php echo($activityData['activityID']); ?>"><?php $this->_($activityData['regarding']) ?></td>
<td align="left" valign="top" id="activityNotes<?php echo($activityData['activityID']); ?>"><?php echo($activityData['notes']); ?></td>
<td align="left" valign="top" id="activityNotes<?php echo($activityData['activityID']); ?>"><?php echo(TemplateUtility::highlightStatusChangeActivityNote($activityData['notes'])); ?></td>
<?php if (!$this->isPopup): ?>
<td align="center" >
<?php if ($this->getUserAccessLevel('candidates.edit') >= ACCESS_LEVEL_EDIT): ?>
Expand Down
2 changes: 1 addition & 1 deletion modules/contacts/Show.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ use OpenCATS\UI\QuickActionMenu;
<td align="left" valign="top" id="activityType<?php echo($activityData['activityID']); ?>"><?php $this->_($activityData['typeDescription']) ?></td>
<td align="left" valign="top"><?php $this->_($activityData['enteredByAbbrName']) ?></td>
<td align="left" valign="top" id="activityRegarding<?php echo($activityData['activityID']); ?>"><?php $this->_($activityData['regarding']) ?></td>
<td align="left" valign="top" id="activityNotes<?php echo($activityData['activityID']); ?>"><?php $this->_($activityData['notes']) ?></td>
<td align="left" valign="top" id="activityNotes<?php echo($activityData['activityID']); ?>"><?php echo(TemplateUtility::highlightStatusChangeActivityNote($activityData['notes'])); ?></td>
<td align="center" >
<?php if ($this->getUserAccessLevel('contacts.editActivity') >= ACCESS_LEVEL_EDIT): ?>
<a href="#" id="editActivity<?php echo($activityData['activityID']); ?>" onclick="Activity_editEntry(<?php echo($activityData['activityID']); ?>, <?php echo($this->contactID); ?>, <?php echo(DATA_ITEM_CONTACT); ?>, '<?php echo($this->sessionCookie); ?>'); return false;">
Expand Down
50 changes: 50 additions & 0 deletions modules/install/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,56 @@ public static function get()
);
}
',
'370' => 'PHP:
$lastActivityID = 0;
$batchSize = 200;
$highlightPattern = "/<span\\b(?=[^>]*\\bstyle\\s*=\\s*([\\"\\\']).*?\\bcolor\\s*:\\s*#ff6c00\\s*;?.*?\\1)[^>]*>(.*?)<\\/span>/is";

while (true)
{
$activityRS = $db->getAllAssoc(
"SELECT
activity_id,
notes
FROM
activity
WHERE
activity_id > " . $lastActivityID . "
AND notes LIKE \'%<span%\'
AND notes LIKE \'%#ff6c00%\'
ORDER BY
activity_id ASC
LIMIT " . $batchSize
);

if (empty($activityRS))
{
break;
}

foreach ($activityRS as $rowIndex => $row)
{
$updatedNotes = preg_replace($highlightPattern, \'$2\', $row[\'notes\']);

if ($updatedNotes === null)
{
$lastActivityID = (int) $row[\'activity_id\'];
continue;
}

if ($updatedNotes !== $row[\'notes\'])
{
$db->query(
"UPDATE activity
SET notes = " . $db->makeQueryString($updatedNotes) . "
WHERE activity_id = " . (int) $row[\'activity_id\']
);
}

$lastActivityID = (int) $row[\'activity_id\'];
}
}
',

);
}
Expand Down
Loading