Author Topic: The visual differences in the notifications and notifications of overdue tasks  (Read 7875 times)

brg

  • Freshman
  • *
  • Posts: 22
    • View Profile
Aloha everybody!
We created 2 small plugins and want present their

1. Spy. This plugins show what users modified while editing objects. For example:



This is standard notify email,but i think follow email look more informative:



And notes:



Or comment!


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!


Installation:
Just unpack overdue_reminder.zip and copy files.
« Last Edit: November 03, 2010, 12:39:23 PM by brg »

selyay

  • Freshman
  • *
  • Posts: 20
    • View Profile
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/
may be work.do you think it can be done?

franponce87

  • Administrator
  • Hero Member
  • *****
  • Posts: 1819
    • View Profile
    • Email
Really great plugin! I am sure many people will be thanking you for this, and so we are.. thanks!

Best regards,
Francisco
Would you like to install Feng Office Professional or Enterprise Edition in your servers? No problem! Read this article!

Murz

  • Full Member
  • ***
  • Posts: 147
    • View Profile
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/

julius

  • Newbie
  • *
  • Posts: 5
    • View Profile
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

Code: [Select]
<?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'] > '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:

Code: [Select]
<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!
« Last Edit: May 07, 2011, 12:36:26 AM by julius »

brg

  • Freshman
  • *
  • Posts: 22
    • View Profile
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
« Last Edit: August 15, 2011, 10:56:12 AM by brg »

 

anything