[Vtigercrm-commits] [vtiger-commits] r10351 - in /vtigercrm/branches/5.0.3/modules/Calendar: ActivityAjax.php CalendarCommon.php Save.php TodoSave.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Tue Mar 6 00:42:04 EST 2007
Author: saraj
Date: Mon Mar 5 22:41:56 2007
New Revision: 10351
Log:
fix for event notification failure. Fixes #3068 --Minnie
Modified:
vtigercrm/branches/5.0.3/modules/Calendar/ActivityAjax.php
vtigercrm/branches/5.0.3/modules/Calendar/CalendarCommon.php
vtigercrm/branches/5.0.3/modules/Calendar/Save.php
vtigercrm/branches/5.0.3/modules/Calendar/TodoSave.php
Modified: vtigercrm/branches/5.0.3/modules/Calendar/ActivityAjax.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Calendar/ActivityAjax.php (original)
+++ vtigercrm/branches/5.0.3/modules/Calendar/ActivityAjax.php Mon Mar 5 22:41:56 2007
@@ -142,6 +142,24 @@
$activity_type = "Events";
}
ChangeStatus($status,$return_id,$activity_type);
+ $mail_data = getActivityMailInfo($return_id,$status,$activity_type);
+ if($mail_data['sendnotification'] == 1)
+ {
+ getEventNotification($mail_data['user_id'],$activity_type,$mail_data['subject'],$mail_data);
+ }
+ $invitee_qry = "select * from vtiger_invitees where activityid=".$return_id;
+ $invitee_res = $adb->query($invitee_qry);
+ $count = $adb->num_rows($invitee_res);
+ if($count != 0)
+ {
+ for($j = 0; $j < $count; $j++)
+ {
+ $invitees_ids[]= $adb->query_result($invitee_res,$j,"inviteeid");
+
+ }
+ $invitees_ids_string = implode(';',$invitees_ids);
+ sendInvitation($invitees_ids_string,$activity_type,$mail_data['subject'],$mail_data);
+ }
}
if($type == 'activity_postpone')
{
Modified: vtigercrm/branches/5.0.3/modules/Calendar/CalendarCommon.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Calendar/CalendarCommon.php (original)
+++ vtigercrm/branches/5.0.3/modules/Calendar/CalendarCommon.php Mon Mar 5 22:41:56 2007
@@ -293,26 +293,26 @@
global $adb,$mod_strings;
$log->debug("Entering getActivityDetails(".$description.") method ...");
- $reply = (($_REQUEST['mode'] == 'edit')?'updated':'created');
+ $reply = (($description['mode'] == 'edit')?'updated':'created');
if($inviteeid=='')
- $name = getUserName($_REQUEST['assigned_user_id']);
+ $name = getUserName($description['user_id']);
else
$name = getUserName($inviteeid);
$current_username = getUserName($current_user->id);
- $status = (($_REQUEST['activity_mode']=='Task')?($_REQUEST['taskstatus']):($_REQUEST['eventstatus']));
+ $status = $description['status'];
$list = $name.',';
- $list .= '<br><br>'.$mod_strings['LBL_ACTIVITY_STRING'].' '.$reply.'.<br> '.$mod_strings['LBL_DETAILS_STRING'].':';
- $list .= '<br> '.$mod_strings["LBL_SUBJECT"].' '.$_REQUEST['subject'];
+ $list .= '<br><br>'.$mod_strings['LBL_ACTIVITY_STRING'].' '.$reply.'.<br> '.$mod_strings['LBL_DETAILS_STRING'].':<br>';
+ $list .= '<br> '.$mod_strings["LBL_SUBJECT"].' '.$description['subject'];
$list .= '<br> '.$mod_strings["LBL_STATUS"].': '.$status;
- $list .= '<br> '.$mod_strings["Priority"].': '.$_REQUEST['taskpriority'];
- $list .= '<br> '.$mod_strings["Related To"].' : '.$_REQUEST['parent_name'];
- if($_REQUEST['activity_mode']!= 'Events')
- {
- $list .= '<br>'.$mod_strings["LBL_CONTACT"].' '.$_REQUEST['contactlist'];
- }
- $list .= '<br> '.$mod_strings["LBL_APP_DESCRIPTION"].': '.$description;
+ $list .= '<br> '.$mod_strings["Priority"].': '.$description['taskpriority'];
+ $list .= '<br> '.$mod_strings["Related To"].' : '.$description['relatedto'];
+ if($description['activity_mode'] != 'Events')
+ {
+ $list .= '<br> '.$mod_strings["LBL_CONTACT"].' '.$description['contact_name'];
+ }
+ $list .= '<br> '.$mod_strings["LBL_APP_DESCRIPTION"].': '.$description['description'];
$list .= '<br><br>'.$mod_strings["LBL_REGARDS_STRING"].' ,';
$list .= '<br>'.$current_username.'.';
@@ -346,6 +346,120 @@
}
return $timeStr;
}
-
+//added to fix Ticket#3068
+function getEventNotification($mail_id,$mode,$subject,$desc)
+{
+ global $current_user,$adb;
+ require_once("modules/Emails/mail.php");
+ $subject = $mode.' : '.$subject;
+ $crmentity = new CRMEntity();
+
+ if($desc['assingn_type'] == "U")
+ {
+ $to_email = getUserEmailId('id',$mail_id);
+ $description = getActivityDetails($desc);
+ send_mail('Calendar',$to_email,$current_user->user_name,'',$subject,$description);
+ }
+ if($desc['assingn_type'] == "T")
+ {
+ $groupname=$desc['group_name'];
+ $resultqry=$adb->query("select groupid from vtiger_groups where groupname='".$groupname."'");
+ $groupid=$adb->query_result($resultqry,0,"groupid");
+ require_once('include/utils/GetGroupUsers.php');
+ $getGroupObj=new GetGroupUsers();
+ $getGroupObj->getAllUsersInGroup($groupid);
+ $userIds=$getGroupObj->group_users;
+ $groupqry="select email1,id from vtiger_users where id in(".implode(',',$userIds).")";
+ $groupqry_res=$adb->query($groupqry);
+ $noOfRows = $adb->num_rows($groupqry_res);
+ for($z=0;$z < $noOfRows;$z++)
+ {
+ $emailadd = $adb->query_result($groupqry_res,$z,'email1');
+ $curr_userid = $adb->query_result($groupqry_res,$z,'id');
+ $description = getActivityDetails($desc,$curr_userid);
+ $mail_status = send_mail('Calendar',$emailadd,getUserName($curr_userid),'',$subject,$description);
+
+ }
+ }
+}
+
+function sendInvitation($inviteesid,$mode,$subject,$desc)
+{
+ global $current_user;
+ require_once("modules/Emails/mail.php");
+ $invitees_array = explode(';',$inviteesid);
+ $subject = $mode.' : '.$subject;
+ $record = $focus->id;
+ foreach($invitees_array as $inviteeid)
+ {
+ if($inviteeid != '')
+ {
+ $description=getActivityDetails($desc,$inviteeid);
+ $to_email = getUserEmailId('id',$inviteeid);
+ send_mail('Calendar',$to_email,$current_user->user_name,'',$subject,$description);
+ }
+ }
+
+}
+
+function getActivityMailInfo($return_id,$status,$activity_type)
+{
+ $mail_data = Array();
+ global $adb;
+ $qry = "select * from vtiger_activity where activityid=".$return_id;
+ $ary_res = $adb->query($qry);
+ $send_notification = $adb->query_result($ary_res,0,"sendnotification");
+ $subject = $adb->query_result($ary_res,0,"subject");
+ $priority = $adb->query_result($ary_res,0,"priority");
+ //$parent_name = $adb->query_result($ary_res,0,"priority");
+
+ $usr_qry = "select smownerid from vtiger_crmentity where crmid=".$return_id;
+ $res = $adb->query($usr_qry);
+ $usr_id = $adb->query_result($res,0,"smownerid");
+ $assignType = "U";
+ if($usr_id == '')
+ {
+ $assignType = "T";
+ $group_qry = "select groupname from vtiger_activitygrouprelation where activityid=".$return_id;
+ $grp_res = $adb->query($group_qry);
+ $grp_name = $adb->query_result($res,0,"groupname");
+ }
+
+
+ $desc_qry = "select description from vtiger_crmentity where crmid=".$return_id;
+ $des_res = $adb->query($desc_qry);
+ $description = $adb->query_result($des_res,0,"description");
+
+
+ $rel_qry = "select case vtiger_crmentity.setype when 'Leads' then vtiger_leaddetails.lastname when 'Accounts' then vtiger_account.accountname when 'Potentials' then vtiger_potential.potentialname when 'Quotes' then vtiger_quotes.subject when 'PurchaseOrder' then vtiger_purchaseorder.subject when 'SalesOrder' then vtiger_salesorder.subject when 'Invoice' then vtiger_invoice.subject when 'Campaigns' then vtiger_campaign.campaignname when 'HelpDesk' then vtiger_troubletickets.title end as relname from vtiger_seactivityrel inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_seactivityrel.crmid left join vtiger_leaddetails on vtiger_leaddetails.leadid = vtiger_seactivityrel.crmid left join vtiger_account on vtiger_account.accountid=vtiger_seactivityrel.crmid left join vtiger_potential on vtiger_potential.potentialid=vtiger_seactivityrel.crmid left join vtiger_quotes on vtiger_quotes.quoteid= vtiger_seactivityrel.crmid left join vtiger_purchaseorder on vtiger_purchaseorder.purchaseorderid = vtiger_seactivityrel.crmid left join vtiger_salesorder on vtiger_salesorder.salesorderid = vtiger_seactivityrel.crmid left join vtiger_invoice on vtiger_invoice.invoiceid = vtiger_seactivityrel.crmid left join vtiger_campaign on vtiger_campaign.campaignid = vtiger_seactivityrel.crmid left join vtiger_troubletickets on vtiger_troubletickets.ticketid = vtiger_seactivityrel.crmid where vtiger_seactivityrel.activityid=".$return_id;
+
+ $rel_res = $adb->query($rel_qry);
+ $rel_name = $adb->query_result($rel_res,0,"relname");
+
+
+ $cont_qry = "select * from vtiger_cntactivityrel where activityid=".$return_id;
+ $cont_res = $adb->query($cont_qry);
+ $cont_id = $adb->query_result($cont_res,0,"contactid");
+ $cont_name = '';
+ if($cont_id != '')
+ {
+ $cont_name = getContactName($cont_id);
+ }
+ $mail_data['mode'] = "edit";
+ $mail_data['activity_mode'] = $activity_type;
+ $mail_data['sendnotification'] = $send_notification;
+ $mail_data['user_id'] = $usr_id;
+ $mail_data['subject'] = $subject;
+ $mail_data['status'] = $status;
+ $mail_data['taskpriority'] = $priority;
+ $mail_data['relatedto'] = $rel_name;
+ $mail_data['contact_name'] = $cont_name;
+ $mail_data['description'] = $description;
+ $mail_data['assingn_type'] = $assignType;
+ $mail_data['group_name'] = $grp_name;
+ return $mail_data;
+
+
+}
?>
Modified: vtigercrm/branches/5.0.3/modules/Calendar/Save.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Calendar/Save.php (original)
+++ vtigercrm/branches/5.0.3/modules/Calendar/Save.php Mon Mar 5 22:41:56 2007
@@ -23,11 +23,9 @@
require_once('modules/Calendar/Activity.php');
require_once('include/logging.php');
-//require("modules/Emails/class.phpmailer.php");
require_once("config.php");
require_once('include/database/PearDatabase.php');
require_once('modules/Calendar/CalendarCommon.php');
-require_once('data/CRMEntity.php');
global $adb;
$local_log =& LoggerManager::getLogger('index');
$focus = new Activity();
@@ -59,8 +57,27 @@
$status = $_REQUEST['eventstatus'];
$activity_type = "Events";
}
-
ChangeStatus($status,$return_id,$activity_type);
+ $mail_data = getActivityMailInfo($return_id,$status,$activity_type);
+ if($mail_data['sendnotification'] == 1)
+ {
+ getEventNotification($mail_data['user_id'],$activity_type,$mail_data['subject'],$mail_data);
+ }
+ $invitee_qry = "select * from vtiger_invitees where activityid=".$return_id;
+ $invitee_res = $adb->query($invitee_qry);
+ $count = $adb->num_rows($invitee_res);
+ if($count != 0)
+ {
+ for($j = 0; $j < $count; $j++)
+ {
+ $invitees_ids[]= $adb->query_result($invitee_res,$j,"inviteeid");
+
+ }
+ $invitees_ids_string = implode(';',$invitees_ids);
+ sendInvitation($invitees_ids_string,$activity_type,$mail_data['subject'],$mail_data);
+ }
+
+
}
else
{
@@ -137,68 +154,34 @@
if($activity_mode != '')
$activemode = "&activity_mode=".$activity_mode;
+function getRequestData()
+{
+ $mail_data = Array();
+ $mail_data['user_id'] = $_REQUEST['assigned_user_id'];
+ $mail_data['subject'] = $_REQUEST['subject'];
+ $mail_data['status'] = (($_REQUEST['activity_mode']=='Task')?($_REQUEST['taskstatus']):($_REQUEST['eventstatus']));
+ $mail_data['activity_mode'] = $_REQUEST['activity_mode'];
+ $mail_data['taskpriority'] = $_REQUEST['taskpriority'];
+ $mail_data['relatedto'] = $_REQUEST['parent_name'];
+ $mail_data['contact_name'] = $_REQUEST['contact_name'];
+ $mail_data['description'] = $_REQUEST['description'];
+ $mail_data['assingn_type'] = $_REQUEST['assigntype'];
+ $mail_data['group_name'] = $_REQUEST['assigned_group_name'];
+ $mail_data['mode'] = $_REQUEST['mode'];
+ return $mail_data;
+}
//Added code to send mail to the assigned to user about the details of the vtiger_activity if sendnotification = on and assigned to user
if($_REQUEST['sendnotification'] == 'on')
{
- global $current_user;
- $local_log->info("send notification is on");
- require_once("modules/Emails/mail.php");
- $subject = $_REQUEST['activity_mode'].' : '.$_REQUEST['subject'];
-
- $crmentity = new CRMEntity();
- if($_REQUEST['assigntype'] == 'U')
- {
- $to_email[0] = getUserEmailId('id',$_REQUEST['assigned_user_id']);
- $description = getActivityDetails($_REQUEST['description']);
- $mail_status = send_mail('Calendar',$to_email,$current_user->user_name,'',$subject,$description);
- }
- //code added to send mail to group
- if($_REQUEST['assigntype'] == 'T')
- {
- $groupname=$_REQUEST['assigned_group_name'];
- $resultqry=$adb->query("select groupid from vtiger_groups where groupname='".$groupname."'");
- $groupid=$adb->query_result($resultqry,0,"groupid");
- require_once('include/utils/GetGroupUsers.php');
- $getGroupObj=new GetGroupUsers();
- $getGroupObj->getAllUsersInGroup($groupid);
- $userIds=$getGroupObj->group_users;
- $groupqry="select email1,id from vtiger_users where id in(".implode(',',$userIds).")";
- $groupqry_res=$adb->query($groupqry);
- $noOfRows = $adb->num_rows($groupqry_res);
- for($z=0;$z < $noOfRows;$z++)
- {
- $emailadd = $adb->query_result($groupqry_res,$z,'email1');
- $curr_userid = $adb->query_result($groupqry_res,$z,'id');
- $description = getActivityDetails($_REQUEST['description'],$curr_userid);
- $mail_status = send_mail('Calendar',$emailadd,getUserName($curr_userid),'',$subject,$description);
-
- }
-
-
- }
-
-}
-
+ $mail_contents = getRequestData();
+ getEventNotification($_REQUEST['assigned_user_id'],$_REQUEST['activity_mode'],$_REQUEST['subject'],$mail_contents);
+}
//code added to send mail to the vtiger_invitees
if(isset($_REQUEST['inviteesid']) && $_REQUEST['inviteesid']!='')
{
- global $current_user;
- $local_log->info("send notification is on");
- require_once("modules/Emails/mail.php");
- $selected_users_string = $_REQUEST['inviteesid'];
- $invitees_array = explode(';',$selected_users_string);
- $subject = $_REQUEST['activity_mode'].' : '.$_REQUEST['subject'];
- $record = $focus->id;
- foreach($invitees_array as $inviteeid)
- {
- if($inviteeid != '')
- {
- $description=getActivityDetails($_REQUEST['description'],$inviteeid);
- $to_email = getUserEmailId('id',$inviteeid);
- $mail_status = send_mail('Calendar',$to_email,$current_user->user_name,'',$subject,$description);
- }
- }
+ $mail_contents = getRequestData();
+ sendInvitation($_REQUEST['inviteesid'],$_REQUEST['activity_mode'],$_REQUEST['subject'],$mail_contents);
}
if(isset($_REQUEST['contactidlist']) && $_REQUEST['contactidlist'] != '')
Modified: vtigercrm/branches/5.0.3/modules/Calendar/TodoSave.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Calendar/TodoSave.php (original)
+++ vtigercrm/branches/5.0.3/modules/Calendar/TodoSave.php Mon Mar 5 22:41:56 2007
@@ -15,7 +15,6 @@
require_once('include/database/PearDatabase.php');
$local_log =& LoggerManager::getLogger('index');
-
$focus = new Activity();
$activity_mode = $_REQUEST['activity_mode'];
if($activity_mode == 'Task')
@@ -48,22 +47,29 @@
$focus->column_fields["sendnotification"] = $_REQUEST["task_sendnotification"];
$focus->save($tab_type);
- if($_REQUEST["task_sendnotification"]=='on' && $_REQUEST['task_assigntype'] == 'U')
+ if($_REQUEST["task_sendnotification"]=='on')
{
-
- global $current_user;
- $local_log->info("send notification is on");
- require_once("modules/Emails/mail.php");
- $to_email = getUserEmailId('id',$_REQUEST['task_assigned_user_id']);
- $subject = $_REQUEST['activity_mode'].' : '.$_REQUEST['task_subject'];
- $_REQUEST["assigned_user_id"]= $_REQUEST["task_assigned_user_id"];
- $_REQUEST["subject"]=$subject;
- $_REQUEST["parent_name"]=$_REQUEST["task_parent_name"];
- $_REQUEST['contactlist']=$_REQUEST['task_contact_name'];
- $description = getActivityDetails($_REQUEST['task_description']);
- $mail_status = send_mail('Calendar',$to_email,$current_user->user_name,'',$subject,$description);
+ $mail_contents = getRequestedToData();
+ getEventNotification($_REQUEST['task_assigned_user_id'],$_REQUEST['activity_mode'],$_REQUEST['task_subject'],$mail_contents);
}
+function getRequestedToData()
+{
+ $mail_data = Array();
+ $mail_data['user_id'] = $_REQUEST["task_assigned_user_id"];
+ $mail_data['subject'] = $_REQUEST['task_subject'];
+ $mail_data['status'] = (($_REQUEST['activity_mode']=='Task')?($_REQUEST['taskstatus']):($_REQUEST['eventstatus']));
+ $mail_data['activity_mode'] = $_REQUEST['activity_mode'];
+ $mail_data['taskpriority'] = $_REQUEST['taskpriority'];
+ $mail_data['relatedto'] = $_REQUEST['task_parent_name'];
+ $mail_data['contact_name'] = $_REQUEST['task_contact_name'];
+ $mail_data['description'] = $_REQUEST['task_description'];
+ $mail_data['assingn_type'] = $_REQUEST['task_assigntype'];
+ $mail_data['group_name'] = $_REQUEST['task_assigned_group_name'];
+ $mail_data['mode'] = $_REQUEST['task_mode'];
+ return $mail_data;
+}
- header("Location: index.php?action=index&module=Calendar&view=".$_REQUEST['view']."&hour=".$_REQUEST['hour']."&day=".$_REQUEST['day']."&month=".$_REQUEST['month']."&year=".$_REQUEST['year']."&viewOption=".$_REQUEST['viewOption']."&subtab=".$_REQUEST['subtab']."&parenttab=".$_REQUEST['parenttab']);
+
+ header("Location: index.php?action=index&module=Calendar&view=".$_REQUEST['view']."&hour=".$_REQUEST['hour']."&day=".$_REQUEST['day']."&month=".$_REQUEST['month']."&year=".$_REQUEST['year']."&viewOption=".$_REQUEST['viewOption']."&subtab=todo&parenttab=".$_REQUEST['parenttab']);
?>
More information about the vtigercrm-commits
mailing list