[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /********************************************************************************* 3 ** The contents of this file are subject to the vtiger CRM Public License Version 1.0 4 * ("License"); You may not use this file except in compliance with the License 5 * The Original Code is: vtiger CRM Open Source 6 * The Initial Developer of the Original Code is vtiger. 7 * Portions created by vtiger are Copyright (C) vtiger. 8 * All Rights Reserved. 9 * 10 ********************************************************************************/ 11 12 /** 13 * To get the lists of vtiger_users id who shared their calendar with specified user 14 * @param $sharedid -- The shared user id :: Type integer 15 * @returns $shared_ids -- a comma seperated vtiger_users id :: Type string 16 */ 17 function getSharedCalendarId($sharedid) 18 { 19 global $adb; 20 $query = "SELECT * from vtiger_sharedcalendar where sharedid=?"; 21 $result = $adb->pquery($query, array($sharedid)); 22 if($adb->num_rows($result)!=0) 23 { 24 for($j=0;$j<$adb->num_rows($result);$j++) 25 $userid[] = $adb->query_result($result,$j,'userid'); 26 $shared_ids = implode (",",$userid); 27 } 28 return $shared_ids; 29 } 30 31 /** 32 * To get hour,minute and format 33 * @param $starttime -- The date&time :: Type string 34 * @param $endtime -- The date&time :: Type string 35 * @param $format -- The format :: Type string 36 * @returns $timearr :: Type Array 37 */ 38 function getaddEventPopupTime($starttime,$endtime,$format) 39 { 40 $timearr = Array(); 41 list($sthr,$stmin) = explode(":",$starttime); 42 list($edhr,$edmin) = explode(":",$endtime); 43 if($format == 'am/pm' || $format == '12') 44 { 45 $hr = $sthr+0; 46 $timearr['startfmt'] = ($hr >= 12) ? "pm" : "am"; 47 if($hr == 0) $hr = 12; 48 $timearr['starthour'] = twoDigit(($hr>12)?($hr-12):$hr); 49 $timearr['startmin'] = $stmin; 50 51 $edhr = $edhr+0; 52 $timearr['endfmt'] = ($edhr >= 12) ? "pm" : "am"; 53 if($edhr == 0) $edhr = 12; 54 $timearr['endhour'] = twoDigit(($edhr>12)?($edhr-12):$edhr); 55 $timearr['endmin'] = $edmin; 56 return $timearr; 57 } 58 if($format == '24') 59 { 60 $timearr['starthour'] = twoDigit($sthr); 61 $timearr['startmin'] = $stmin; 62 $timearr['startfmt'] = ''; 63 $timearr['endhour'] = twoDigit($edhr); 64 $timearr['endmin'] = $edmin; 65 $timearr['endfmt'] = ''; 66 return $timearr; 67 } 68 } 69 70 /** 71 * Function to get the vtiger_activity details for mail body 72 * @param string $description - activity description 73 * @param string $from - to differenciate from notification to invitation. 74 * return string $list - HTML in string format 75 */ 76 function getActivityDetails($description,$user_id,$from='') 77 { 78 global $log,$current_user,$current_language; 79 global $adb; 80 require_once 'include/utils/utils.php'; 81 $mod_strings = return_module_language($current_language, 'Calendar'); 82 $log->debug("Entering getActivityDetails(".$description.") method ..."); 83 $updated = $mod_strings['LBL_UPDATED']; 84 $created = $mod_strings['LBL_CREATED']; 85 $reply = (($description['mode'] == 'edit')?"$updated":"$created"); 86 if($description['activity_mode'] == "Events") 87 { 88 $end_date_lable=$mod_strings['End date and time']; 89 } 90 else 91 { 92 $end_date_lable=$mod_strings['Due Date']; 93 } 94 95 $name = getUserFullName($user_id); 96 97 // Show the start date and end date in the users date format and in his time zone 98 $inviteeUser = CRMEntity::getInstance('Users'); 99 $inviteeUser->retrieveCurrentUserInfoFromFile($user_id); 100 $startDate = new DateTimeField($description['st_date_time']); 101 $endDate = new DateTimeField($description['end_date_time']); 102 103 if($from == "invite") 104 $msg = getTranslatedString($mod_strings['LBL_ACTIVITY_INVITATION']); 105 else 106 $msg = getTranslatedString($mod_strings['LBL_ACTIVITY_NOTIFICATION']); 107 108 $current_username = getUserFullName($current_user->id); 109 $status = getTranslatedString($description['status'],'Calendar'); 110 $list = $name.','; 111 $list .= '<br><br>'.$msg.' '.$reply.'.<br> '.$mod_strings['LBL_DETAILS_STRING'].':<br>'; 112 $list .= '<br> '.$mod_strings["LBL_SUBJECT"].' : '.$description['subject']; 113 $list .= '<br> '.$mod_strings["Start date and time"].' : '.$startDate->getDisplayDateTimeValue($inviteeUser) .' '.getTranslatedString($inviteeUser->time_zone, 'Users'); 114 $list .= '<br> '.$end_date_lable.' : '.$endDate->getDisplayDateTimeValue($inviteeUser).' '.getTranslatedString($inviteeUser->time_zone, 'Users'); 115 $list .= '<br> '.$mod_strings["LBL_STATUS"].': '.$status; 116 $list .= '<br> '.$mod_strings["Priority"].': '.getTranslatedString($description['taskpriority']); 117 $list .= '<br> '.$mod_strings["Related To"].': '.getTranslatedString($description['relatedto']); 118 if(!empty($description['contact_name'])) 119 { 120 $list .= '<br> '.$mod_strings["LBL_CONTACT_LIST"].' '.$description['contact_name']; 121 } 122 else 123 $list .= '<br> '.$mod_strings["Location"].' : '.$description['location']; 124 125 $list .= '<br> '.$mod_strings["LBL_APP_DESCRIPTION"].': '.$description['description']; 126 $list .= '<br><br>'.$mod_strings["LBL_REGARDS_STRING"].' ,'; 127 $list .= '<br>'.$current_username.'.'; 128 129 $log->debug("Exiting getActivityDetails method ..."); 130 return $list; 131 } 132 133 function twoDigit( $no ){ 134 if($no < 10 && strlen(trim($no)) < 2) return "0".$no; 135 else return "".$no; 136 } 137 138 function sendInvitation($inviteesid,$mode,$subject,$desc) 139 { 140 global $current_user,$mod_strings; 141 require_once ("modules/Emails/mail.php"); 142 $invites=$mod_strings['INVITATION']; 143 $invitees_array = explode(';',$inviteesid); 144 $subject = $invites.' : '.$subject; 145 $record = $focus->id; 146 foreach($invitees_array as $inviteeid) 147 { 148 if($inviteeid != '') 149 { 150 $description=getActivityDetails($desc,$inviteeid,"invite"); 151 $to_email = getUserEmailId('id',$inviteeid); 152 send_mail('Calendar',$to_email,$current_user->user_name,'',$subject,$description); 153 } 154 } 155 156 } 157 158 // User Select Customization 159 /** 160 * Function returns the id of the User selected by current user in the picklist of the ListView or Calendar view of Current User 161 * return String - Id of the user that the current user has selected 162 */ 163 function calendarview_getSelectedUserId() { 164 global $current_user, $default_charset; 165 $only_for_user = htmlspecialchars(strip_tags(vtlib_purifyForSql($_REQUEST['onlyforuser'])),ENT_QUOTES,$default_charset); 166 if($only_for_user == '') $only_for_user = $current_user->id; 167 return $only_for_user; 168 } 169 170 function calendarview_getSelectedUserFilterQuerySuffix() { 171 global $current_user, $adb; 172 $only_for_user = calendarview_getSelectedUserId(); 173 $qcondition = ''; 174 if(!empty($only_for_user)) { 175 if($only_for_user != 'ALL') { 176 // For logged in user include the group records also. 177 if($only_for_user == $current_user->id) { 178 $user_group_ids = fetchUserGroupids($current_user->id); 179 // User does not belong to any group? Let us reset to non-existent group 180 if(!empty($user_group_ids)) $user_group_ids .= ','; 181 else $user_group_ids = ''; 182 $user_group_ids .= $current_user->id; 183 $qcondition = " AND vtiger_crmentity.smownerid IN (" . $user_group_ids .")"; 184 } else { 185 $qcondition = " AND vtiger_crmentity.smownerid = " . $adb->sql_escape_string($only_for_user); 186 } 187 } 188 } 189 return $qcondition; 190 } 191 192 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |