/**
  * Prepare body for display
  *
  * @param boolean $make_clickable
  * @param boolean $skip_blockquotes - to remove quoted elements from body, only if object is created via email
  * @return string
  */
 function getFormattedBody($make_clickable = true, $skip_blockquotes = false)
 {
     require_once SMARTY_PATH . '/plugins/modifier.clickable.php';
     $body = $this->getBody();
     if ($skip_blockquotes) {
         $body = preg_replace('@<blockquote[^>]*?>.*?</blockquote>@si', '', $body);
     }
     // if
     //BOF:mod 20120717
     /*
     //EOF:mod 20120717
           return $make_clickable ? nl2br_pre(smarty_modifier_clickable($body)) : nl2br_pre($body);
     //BOF:mod 20120717
     */
     //client informed to advise if any issue is encountered due to this modification
     return $make_clickable ? smarty_modifier_clickable($body) : $body;
     //EOF:mod 20120717
 }
 /**
  * Prepare project for display
  *
  * @param boolean $make_clickable
  * @return string
  */
 function getFormattedOverview($make_clickable = true)
 {
     $overview = $this->getOverview();
     if ($overview) {
         if ($make_clickable) {
             require_once SMARTY_PATH . '/plugins/modifier.clickable.php';
             $overview = smarty_modifier_clickable($overview);
         }
         // if
         return nl2br_pre($overview);
     }
     // if
     return $overview;
 }
 /**
  * Create a new reminder
  *
  * @param void
  * @return null
  */
 function add()
 {
     $this->wireframe->print_button = false;
     $parent = ProjectObjects::findById($this->request->getId('parent_id'));
     if (!instance_of($parent, 'ProjectObject')) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     $project = $parent->getProject();
     if (!instance_of($project, 'Project')) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     $assignees = $parent->getAssignees();
     $subscribers = $parent->getSubscribers();
     $commenters = Comments::findCommenters($parent, $this->logged_user);
     $reminder_data = $this->request->post('reminder');
     if (!is_array($reminder_data)) {
         $who = 'user';
         if (is_foreachable($assignees)) {
             $who = 'assignees';
         } elseif (is_foreachable($subscribers)) {
             $who = 'subscribers';
         } elseif (is_foreachable($commenters)) {
             $who = 'commenters';
         }
         // if
         $reminder_data = array('who' => $who);
     }
     // if
     $this->smarty->assign(array('parent' => $parent, 'assignees' => $assignees, 'subscribers' => $subscribers, 'commenters' => $commenters, 'project_users' => ProjectUsers::findUserIdsByProject($project), 'reminder_data' => $reminder_data));
     if ($this->request->isSubmitted()) {
         $send_to_users = null;
         switch ($reminder_data['who']) {
             case 'assignees':
                 $send_to_users = $assignees;
                 break;
             case 'subscribers':
                 $send_to_users = $subscribers;
                 break;
             case 'commenters':
                 $send_to_users = $commenters;
                 break;
             case 'user':
                 $user_id = (int) array_var($reminder_data, 'user_id');
                 if ($user_id) {
                     $user = Users::findById($user_id);
                     if (instance_of($user, 'User')) {
                         $send_to_users = array($user);
                     }
                     // if
                 }
                 // if
                 break;
         }
         // switch
         // Do reminder
         if (is_foreachable($send_to_users)) {
             $comment = trim(array_var($reminder_data, 'comment'));
             if ($comment) {
                 require_once SMARTY_PATH . '/plugins/modifier.clickable.php';
                 require_once ANGIE_PATH . '/classes/htmlpurifier/init.php';
                 $comment = strip_tags(prepare_html($comment, true));
                 // make sure we have clean text
                 $comment = nl2br(smarty_modifier_clickable($comment));
                 // preserve breaklines and convert links
             }
             // if
             db_begin_work();
             $reminders_sent = array();
             foreach ($send_to_users as $user) {
                 $reminder = new Reminder();
                 $reminder->setAttributes(array('user_id' => $user->getId(), 'object_id' => $parent->getId(), 'comment' => $comment));
                 $reminder->setCreatedBy($this->logged_user);
                 $save = $reminder->save();
                 if ($save && !is_error($save)) {
                     $reminders_sent[] = $user->getDisplayName();
                     ApplicationMailer::send($user, 'system/reminder', array('reminded_by_name' => $this->logged_user->getDisplayName(), 'reminded_by_url' => $this->logged_user->getViewUrl(), 'object_name' => $parent->getName(), 'object_url' => $parent->getViewUrl(), 'object_type' => strtolower($parent->getType()), 'comment_body' => $comment, 'project_name' => $project->getName(), 'project_url' => $project->getOverviewUrl()), $parent);
                 }
                 // if
             }
             // foreach
             db_commit();
             $message = lang('Users reminded: :users', array('users' => implode(', ', $reminders_sent)));
             if ($this->request->get('skip_layout')) {
                 $this->renderText($message);
             } else {
                 flash_success($message);
                 $this->redirectToUrl($parent->getViewUrl());
             }
             // if
             // No reminders
         } else {
             if ($this->request->get('skip_layout')) {
                 $this->renderText(lang('0 users reminded'));
             } else {
                 flash_success('0 users reminded');
                 $this->redirectToUrl($parent->getViewUrl());
             }
             // if
         }
         // if
     }
     // if
 }