예제 #1
0
 /**
  * function to construct the live feed text to display
  * @param object $obj
  * @return array
  */
 public function construct_feed_text($obj)
 {
     $action_user = $obj->firstname . ' ' . $obj->lastname;
     $thumb = '';
     if ($obj->user_avatar != '') {
         $avatar_path = $GLOBALS['AVATAR_DISPLAY_PATH'];
         $thumb = $avatar_path . '/ths_' . $obj->user_avatar . '.' . $obj->file_extension;
     }
     $date_added = i18nDate::i18n_long_date(TimeZoneUtil::convert_to_user_timezone($obj->date_added, true), true);
     $module_name = CommonUtils::get_module_name_as_text($obj->idmodule);
     $link_identifier = true;
     $related_identifer_text = '';
     $link_related_identifier = true;
     $mentions = false;
     switch ($obj->action) {
         case 'add':
             $content = _('Added') . ' ' . $module_name;
             break;
         case 'edit':
             $content = _('Updated') . ' ' . $module_name;
             break;
         case 'delete':
             $content = _('Deleted') . ' ' . $module_name . ' - ';
             $link_identifier = false;
             break;
         case 'lead_covert':
             $content = _('Converted') . ' ' . $module_name;
             break;
         case 'add_contact_lead_convert':
             $content = _('Added') . ' ' . $module_name;
             $related_identifer_text = _('during converting the lead');
             break;
         case 'add_organization_lead_convert':
             $content = _('Added') . ' ' . $module_name;
             $related_identifer_text = _('during converting the lead');
             break;
         case 'add_potential_lead_convert':
             $content = _('Added') . ' ' . $module_name;
             $related_identifer_text = _('during converting the lead');
             break;
         case 'changed_assigned_to':
             $content = _('Changed assigned to ') . ' ' . $module_name;
             break;
         case 'note_mention':
             $content = _('Mentions you in note on ') . ' ' . $module_name;
             $mentions = true;
             break;
     }
     if ($link_identifier === true) {
         if (true === $mentions) {
             $detail_url = NavigationControl::getNavigationLink($_SESSION["do_module"]->modules_full_details[$obj->idmodule]["name"], 'detail', $obj->idrecord, '#note' . $obj->related_identifier_idrecord);
             $identifier = '&nbsp;<a href="' . $GLOBALS['SITE_URL'] . $detail_url . '">' . $obj->identifier . '</a>';
         } else {
             $detail_url = NavigationControl::getNavigationLink($_SESSION["do_module"]->modules_full_details[$obj->idmodule]["name"], "detail", $obj->idrecord);
             $identifier = '&nbsp;<a href="' . $GLOBALS['SITE_URL'] . $detail_url . '">' . $obj->identifier . '</a>';
         }
     } else {
         $identifier = $obj->identifier;
     }
     $content .= ' ' . $identifier;
     if (strlen($related_identifer_text) > 5) {
         if ($link_related_identifier === true) {
             $related_detail_url = NavigationControl::getNavigationLink($_SESSION["do_module"]->modules_full_details[$obj->related_identifier_idmodule]["name"], "detail", $obj->related_identifier_idrecord);
             $related_identifier = '&nbsp;<a href="' . $GLOBALS['SITE_URL'] . $related_detail_url . '">' . $obj->related_identifier . '</a>';
         } else {
             $related_identifier = $obj->related_identifier;
         }
         $content .= ' ' . $related_identifer_text . $related_identifier;
     }
     return array("user_name" => $action_user, "avatar" => $thumb, "content" => $content, "action_date" => $date_added);
 }
예제 #2
0
 /**
  * function to get data history display text
  * @param object $obj
  * @param boolean $link
  * @param boolean $user_history
  * @return array $ret_array
  */
 public function get_data_history_display_text($obj, $link = false, $user_history = false)
 {
     $row1 = '<strong>' . $obj->firstname . ' ' . $obj->lastname . '</strong> ' . _('on ') . '<i>' . i18nDate::i18n_long_time(TimeZoneUtil::convert_to_user_timezone($obj->date_modified, true)) . '</i>';
     switch ($obj->action) {
         case 'add':
             if ($user_history === true) {
                 $row2 = _('Added') . ' ' . CommonUtils::get_module_name_as_text($obj->idmodule);
             } else {
                 $row2 = _('Added the record');
             }
             break;
         case 'delete':
             if ($user_history === true) {
                 $row2 = _('Deleted') . ' ' . CommonUtils::get_module_name_as_text($obj->idmodule);
             } else {
                 $row2 = _('Deleted the record');
             }
             break;
         case 'edit':
             if ($user_history === true) {
                 $row2 = _('Updated') . ' ' . CommonUtils::get_module_name_as_text($obj->idmodule);
             } else {
                 $row2 = _('Updated the record');
             }
             break;
         case 'value_changes':
             $do_crm_fields = new CRMFields();
             $do_crm_fields->getId($obj->idfields);
             if ($do_crm_fields->getNumRows() > 0) {
                 $field_label = $do_crm_fields->field_label;
                 $old_value = $obj->old_value;
                 $new_value = $obj->new_value;
                 if ($do_crm_fields->field_type == 9) {
                     $old_value = FieldType9::display_value($old_value);
                     $new_value = FieldType9::display_value($new_value);
                 }
                 if ($user_history === true) {
                     $row2 = _('Changed value in') . ' ' . CommonUtils::get_module_name_as_text($obj->idmodule) . ' , ' . $field_label . ' :: ' . $old_value . ' >>> ' . $new_value;
                 } else {
                     $row2 = _('Changed') . ' ' . $field_label . ' :: ' . $old_value . ' >>> ' . $new_value;
                 }
             }
             $do_crm_fields->free();
             break;
     }
     if ($obj->user_avatar != '') {
         $avatar_path = $GLOBALS['AVATAR_DISPLAY_PATH'];
         $thumb = $avatar_path . '/ths_' . $obj->user_avatar . '.' . $obj->file_extension;
     }
     if ($link === true) {
         $detail_url = NavigationControl::getNavigationLink($_SESSION["do_module"]->modules_full_details[$obj->idmodule]["name"], "detail", $obj->id_referrer);
         $row2 .= '&nbsp;<a href="' . $GLOBALS['SITE_URL'] . $detail_url . '">' . $GLOBALS['SITE_URL'] . $detail_url . '</a>';
     }
     $ret_array = array("avatar" => $thumb, "row1" => $row1, "row2" => $row2);
     return $ret_array;
 }
예제 #3
0
파일: Notes.class.php 프로젝트: sQcrm/sqcrm
 /**
  * function to send nudge email on a note
  * @param integer $idnotes
  * @param string $note_content
  * @param integer $related_module_id
  * @param integer $sqcrm_record_id
  */
 public function send_note_nudge_email($idnotes, $note_content, $related_module_id, $sqcrm_record_id)
 {
     if ((int) $idnotes > 0) {
         $mentioned_email_receiptents = array();
         preg_match_all("/(^|[^@\\w])@(\\w{1,15})\\b/im", $note_content, $mentioned_users);
         if (is_array($mentioned_users) && array_key_exists(2, $mentioned_users) && count($mentioned_users[2]) > 0) {
             $do_user = new \User();
             $active_users = $do_user->get_active_users();
             $current_user = 0;
             $active_users_key_as_username = array();
             foreach ($active_users as $key => $users) {
                 if ($users["iduser"] == $current_user) {
                     continue;
                 }
                 $active_users_key_as_username[$users["user_name"]] = array("firstname" => $users["firstname"], "lastname" => $users["lastname"], "email" => $users["email"]);
             }
             foreach ($mentioned_users[2] as $key => $val) {
                 if (array_key_exists($val, $active_users_key_as_username)) {
                     $mentioned_email_receiptents[] = $active_users_key_as_username[$val];
                 }
             }
         }
         if (is_array($mentioned_email_receiptents) && count($mentioned_email_receiptents) > 0) {
             $email_template = new \EmailTemplate("send_notes_user_mentioned_email");
             $emailer = new \SQEmailer();
             $do_module = new \Module();
             $do_module->getId($related_module_id);
             $entity_url = \NavigationControl::getNavigationLink($do_module->name, 'detail', $sqcrm_record_id, '#note' . $idnotes);
             $view_url = '<a href="' . SITE_URL . $entity_url . '">' . _('view on sQcrm') . '</a>';
             $note_content = \FieldType200::display_value($note_content);
             $note_content = str_replace('/themes/images/emoji-pngs', SITE_URL . '/themes/images/emoji-pngs', $note_content);
             foreach ($mentioned_email_receiptents as $key => $mentioned) {
                 $to_email = $mentioned["email"];
                 $email_data = array("notes_content" => $note_content, "firstname" => $mentioned["firstname"], "lastname" => $mentioned["lastname"], "view_url" => $view_url, "module_name" => \CommonUtils::get_module_name_as_text($related_module_id), "user_name" => $_SESSION["do_user"]->user_name);
                 $emailer->IsSendmail();
                 $emailer->setEmailTemplate($email_template);
                 $emailer->mergeArray($email_data);
                 $emailer->AddAddress($to_email, $mentioned["firstname"] . ' ' . $mentioned["lastname"]);
                 $emailer->send();
             }
         }
     }
 }