Feng Forum
Other Topics => Development => Community Contributions => : brg October 21, 2010, 01:06:35 PM
-
Aloha everybody!
We created 2 small plugins and want present their
1. Spy. This plugins show what users modified while editing objects. For example:
(http://img249.imageshack.us/img249/4831/74952680.jpg)
This is standard notify email,but i think follow email look more informative:
(http://img232.imageshack.us/img232/9793/modkb.jpg)
And notes:
(http://img130.imageshack.us/img130/4729/modnote.jpg)
Or comment!
(http://img181.imageshack.us/img181/279/modcommc.jpg)
This plugin user Diff from PEAR. But it sometimes makes mistakes =(
Installation:
Unpack spy.zip and copy files. Only I file you must rewrite "application/views/notifier/general.php" =( This is little core files modification. Be careful while update FO.
2. Overdue reminder
This plugin create new cron job that notify subscribers about task that overdue, but not complete.
And write overdue days in email subject!
(http://img225.imageshack.us/img225/1755/overdue.jpg)
Installation:
Just unpack overdue_reminder.zip and copy files.
-
thanks for this improvement,i will try it asap
does it can be used in document differencing between versions.
as i see this works in txts but documents are in html form so something like
http://code.google.com/p/daisydiff/ (http://code.google.com/p/daisydiff/)
may be work.do you think it can be done?
-
Really great plugin! I am sure many people will be thanking you for this, and so we are.. thanks!
Best regards,
Francisco
-
For comparing html pages you can convert it to text equivalent and compare as plain text, for do this you can use library http://milianw.de/projects/markdownify/
-
Wow the spy plugin is fantastic looking, I'm going to grab it and try it out!
Thanks!
*Update*
This is fantastic! The email sent out doesn't quite formate correct for gmail, but its way better then the emails that we were getting before!
Also I was getting the error:
"Assigning the return value of new by reference is deprecated in" then a line number. I though I'd give the info on how to fix this issue.
In PHP5 the & in frount of new is no longer needed so for each line of error go though and find the &new and remove the "&"
Update #2
This add-on is the best!
I changed the code a bit so it works with events & gmail;
#update 3
I added isset($object->diff['dt']) to fix error for changing subscribers & invited ppl!
Code: for spy_hook
<?php
Hook::register("spy");
function spy_before_object_save($object, $ignored){
include_once 'Text/Diff.php';
include_once 'Text/Diff/Renderer.php';
require_once 'Text/Diff/Renderer/inline.php';
$cssDeleted ='<span style="background-color:#ffdddd; text-decoration: line-through;">';
$cssAdded ='<span style="background-color:#ddffdd;">';
$r_inline = new Text_Diff_Renderer_inline(
array(
'leading_context_lines' => 1,
'trailing_context_lines' => 1,
'ins_prefix' => $cssAdded,
'ins_suffix' => '</span>',
'del_prefix' => $cssDeleted,
'del_suffix' => '</span>'
)
);
if($object instanceof ProjectMessage || $object instanceof Comment || $object instanceof ProjectTask || $object instanceof Contact || $object instanceof ProjectEvent){
if(!$object->isNew() && $object->isModified()){
$code = 'return ' . $object->getObjectManagerName() . '::findById(' . $object->getId() . ', true);';
$original = eval($code);
foreach($object->getColumns() as $column){
if($object->isColumnModified($column)){
switch($object->getColumnType($column)){
case 'DATETIME':
if(in_array($column, array('start_date', 'due_date', 'start'))){
if($original->getColumnValue($column) instanceof DateTimeValue && $object->getColumnValue($column) instanceof DateTimeValue){
$time = DateTimeValueLib::get_time_difference($original->getColumnValue($column)->getTimestamp(), $object->getColumnValue($column)->getTimestamp());
$value = $time['days'] ? $object->getColumnValue($column)->format('d.m.y') . user_config_option('date format') . ' / <span class="' . ($time['days'] > 0 ? 'added">+' : 'deleted">') . $time['days'] . ' ' . lang('days') . '</span>' : false;
}elseif($original->getColumnValue($column) instanceof DateTimeValue){
$value = $cssDeleted . $original->getColumnValue($column)->format('d.m.y') . '</span>';
}elseif($object->getColumnValue($column) instanceof DateTimeValue){
$value = $cssAdded . $object->getColumnValue($column)->format('d.m.y') . '</span>';
}
}else{
$value = false;
}
break;
default:
switch($column){
case 'time_estimate':
$old_value = DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($original->getTimeEstimate() * 60), 'hm', 60);
$new_value = DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($object->getTimeEstimate() * 60), 'hm', 60);
break;
case 'completed_by_id':
case 'assigned_by_user_id':
case 'assigned_to_user_id':
$old_value = ($original->getAssignedTo() instanceof User) ? $original->getAssignedTo()->getObjectName() : '';
$new_value = ($object->getAssignedTo() instanceof User) ? $object->getAssignedTo()->getObjectName() : '';
break;
case 'priority':
$old_value = prepare_priority($original->getPriority());
$new_value = prepare_priority($object->getPriority());
break;
default:
$old_value = $original->getColumnValue($column);
$new_value = $object->getColumnValue($column);
break;
}
$diff = new Text_Diff(
'auto',
array(
explode("\n", $old_value),
explode("\n", $new_value)
)
);
$value = nl2br($r_inline->render($diff));
}
if($value){
$object->diff['dt'][$column] = array(
'label' => 'field ' . $object->getObjectManagerName() . ' ' . $column,
'value' => $value
);
}
}
}
}
}
if($object instanceof Comment && !$object->isNew() && $object->isModified()){
$parent = get_object_by_manager_and_id($object->getRelObjectId(), $object->getRelObjectManager());
Notifier::objectNotification($object, $parent->getSubscribers(), logged_user(), 'modified');
}
}
function prepare_priority($p){
//get this method from /application/views/task/view_list.php =(
$priority = '';
if ($p >= ProjectTasks::PRIORITY_URGENT) {
$priority = lang('urgent priority');
}else if ($p >= ProjectTasks::PRIORITY_HIGH) {
$priority = lang('high priority');
} else if ($p <= ProjectTasks::PRIORITY_LOW) {
$priority = lang('low priority');
}else{
$priority = lang('normal priority');
}
return $priority;
}
?>
Code for general:
<div style="font-family: Verdana, Arial, sans-serif; font-size: 12px;">
<a href="<?php echo $object->getViewUrl() ?>" target="_blank" style="font-size: 18px;"><?php echo $description ?></a><br><br>
<?php foreach ($properties as $k => $p) { ?>
<span style="font-family: Verdana, Arial, sans-serif; font-size: 12px;"><?php echo lang($k) ?>: <?php echo $p ?></span><br><br>
<?php } ?>
<?php if (isset($links) && is_array($links)) {
foreach ($links as $link) {
?><span style="font-family: Verdana, Arial, sans-serif; font-size: 12px;"><?php
if (isset($link['img']))
echo '<img src="'.$link['img'].'"/>';
echo '<a href="'.$link['url'].'" target="_blank">'.$link['text'].'</a>';
?></span><br><?php
}
}
?>
<?php if(isset($object->diff['dt'])){
foreach($object->diff['dt'] as $column => $value){
print '<p><b>' . lang($value['label']) . '</b>: ' . $value['value'] . '</p>';
}
} ?>
<br><br>
<?php if (isset($second_properties) && is_array($second_properties)){
foreach ($second_properties as $k => $p) { ?>
<span style="font-family: Verdana, Arial, sans-serif; font-size: 12px;"><?php echo lang($k) ?>: <?php echo $p ?></span><br><br>
<?php } ?>
<?php } ?>
<div style="color: #818283; font-style: italic; border-top: 2px solid #818283; padding-top: 2px; font-family: Verdana, Arial, sans-serif; font-size: 12px;">
<?php echo lang('system notification email'); ?><br>
<a href="<?php echo ROOT_URL; ?>" target="_blank" style="font-family: Verdana, Arial, sans-serif; font-size: 12px;"><?php echo ROOT_URL; ?></a>
</div>
</div>
Thanks again!
-
julius, thanx for your help!
I added your fixes and upgrade PEAR Diff library to Horde Diff.
Attached a new version 0.2 to thread.
Last version and git repository you can find on github.com/bragovo/spy
-
Is the minimum daily dose the smallest therapeutic daily dose administered to healthy adults, or should it encompass all potentially sensitive subpopulations and requisite dosing reductions e buy cheap lasix online (https://lasix.autos)
-
In patients who have no sperm in their ejaculate as a result of low sperm production non- obstructive azoospermia, a procedure called microsurgical testicular sperm extraction or microTESE should be performed to give the best results in finding sperm cialis cost (http://ccialiss.icu)
-
Medication order discrepancies, defined as differences between medications a person is taking and what they are intended to be taking, can include such high risk drugs as cardiovascular agents, opioid analgesics, neuropsychiatric agents, hypoglycemic agents, antibiotics, and anticoagulants 4, 5 lasix purchase online (http://lasix.one)
-
Magnetic resonance MR imaging of the internal auditory canals with gadolinium contrast identified an approximately 0 best cialis online (https://cialis.makeup) We excluded this study from the evidence synthesis because no data were reported for the prognostic effect of breast density change, only in those with hormone receptor positive breast cancer who had received tamoxifen the analysis measured the effect of breast density change on outcome after adjustment for tamoxifen use
-
When asked if they skipped a dose or if they modified the prescribed doses, 97 cialis daily (https://ccialiss.top) doxycycline hyclate 100 mg ww 112 round orange
-
tamoxifen without prescription (http://nolvadex.hair) Blackwell B