/** * Execute the console command. * * @return mixed */ public function fire() { Log::alert('Executed Cron Job to send weekly mail for pending karma note and meeting requests.'); $KarmaNotePending = ""; $KarmaNotePending = Meetingrequest::whereIn('status', array('pending', 'accepted'))->get(); if (!empty($KarmaNotePending)) { $test_id = ""; $test_id = Adminoption::Where('option_name', '=', 'Test User Emails')->first(); $test_user_id = $getfintrorecords = array(); if (!empty($test_id)) { $test_user_id = explode(',', $test_id->option_value); } $introducer = $giver = $receiver = $connidgiver = ''; foreach ($KarmaNotePending as $key => $value) { $diffDate = KarmaHelper::dateDiff(date("Y-m-d H:i:s"), $value->created_at); if (isset($value->user_id_giver)) { $giver = in_array($value->user_id_giver, $test_user_id); } if (isset($value->user_id_receiver)) { $receiver = in_array($value->user_id_receiver, $test_user_id); } if (isset($value->connection_id_giver)) { $connidgiver = in_array($value->connection_id_giver, $test_user_id); } if (isset($value->user_id_introducer)) { $introducer = in_array($value->user_id_introducer, $test_user_id); } if ($giver != 1 && $receiver != 1 && $connidgiver != 1 && $introducer != 1) { if ($diffDate->days > 7) { $meetingtimezone = $value->meetingtimezone; $meetingdatetime = $value->meetingdatetime; $user_id_giver = $value->user_id_giver; $user_id_receiver = $value->user_id_receiver; $meetingId = $value->id; $status = $value->status; $CurrentTimeWithZone = KarmaHelper::calculateTime($meetingtimezone); if ($CurrentTimeWithZone > $meetingdatetime && $status == 'accepted') { Queue::push('MessageSender', array('type' => '4', 'user_id_giver' => $user_id_giver, 'user_id_receiver' => $user_id_receiver, 'meetingId' => $meetingId)); } if ($status == 'pending') { //echo"<pre>";print_r($value->id);echo"</pre>"; if (isset($value->user_id_giver)) { Queue::push('MessageSender', array('type' => '1', 'user_id_giver' => $user_id_giver, 'user_id_receiver' => $user_id_receiver, 'meetingId' => $meetingId)); } else { Queue::push('MessageSender', array('type' => '2', 'user_id_giver' => $value->connection_id_giver, 'user_id_receiver' => $user_id_receiver, 'meetingId' => $meetingId)); } } } } } } }
/** * Execute the console command. * * @return mixed */ public function fire() { Log::alert('Executed Cron Job'); $KarmaNotePending = Meetingrequest::where('status', '=', 'confirmed')->where('cronjobflag', '=', '0')->get(); if (!empty($KarmaNotePending)) { foreach ($KarmaNotePending as $key => $value) { $meetingtimezone = $value->meetingtimezone; $meetingdatetime = $value->meetingdatetime; $user_id_giver = $value->user_id_giver; $user_id_receiver = $value->user_id_receiver; $meetingId = $value->id; $CurrentTimeWithZone = KarmaHelper::calculateTime($meetingtimezone); //echo "<pre>";print_r($meetingdatetime);echo "</pre>"; //echo "<pre>";print_r($meetingdatetime);echo "</pre>";die(); if ($CurrentTimeWithZone > $meetingdatetime) { $diffDate = KarmaHelper::dateDiff($CurrentTimeWithZone, $meetingdatetime); $diffDate = $diffDate->days * 24 + $diffDate->h; $EmailTriggerTime = Adminoption::where('option_name', '=', 'KarmaNote Email Trigger Time')->first(); if (!empty($EmailTriggerTime)) { $EmailTriggerTime = $EmailTriggerTime->toArray(); $EmailTriggerTime = $EmailTriggerTime['option_value']; } else { $EmailTriggerTime = '24'; } if ($diffDate >= $EmailTriggerTime) { //$date = Carbon::now()->addMinutes(5); Queue::push('MessageSender', array('type' => '4', 'user_id_giver' => $user_id_giver, 'user_id_receiver' => $user_id_receiver, 'meetingId' => $meetingId)); $Meetingrequest = Meetingrequest::find($meetingId); $Meetingrequest->cronjobflag = '1'; $Meetingrequest->status = 'over'; $Meetingrequest->save(); DB::table('users_mykarma')->where('entry_id', '=', $meetingId)->update(array('status' => 'over', 'unread_flag' => 'true', 'entry_updated_on' => Carbon::now())); $messageData = new Message(); $messageData->request_id = $meetingId; $messageData->sender_id = $user_id_giver; $messageData->giver_id = $user_id_giver; $messageData->receiver_id = $user_id_receiver; $messageData->message_type = 'system'; $messageText = 'Meeting should be over now.'; $messageData->messageText = $messageText; $messageData->save(); //Queue::push('UpdateUser', array('id' => $user_id,'result' => $result)); } } } } }
/** * Reads an email object from MAPI * * @param mixed $mapimessage * @param ContentParameters $contentparameters * * @access private * @return SyncEmail */ private function getEmail($mapimessage, $contentparameters) { $message = new SyncMail(); $this->getPropsFromMAPI($message, $mapimessage, MAPIMapping::GetEmailMapping()); $emailproperties = MAPIMapping::GetEmailProperties(); $messageprops = $this->getProps($mapimessage, $emailproperties); if (isset($messageprops[PR_SOURCE_KEY])) { $sourcekey = $messageprops[PR_SOURCE_KEY]; } else { return false; } //set the body according to contentparameters and supported AS version $this->setMessageBody($mapimessage, $contentparameters, $message); $fromname = $fromaddr = ""; if (isset($messageprops[$emailproperties["representingname"]])) { // remove encapsulating double quotes from the representingname $fromname = preg_replace('/^\\"(.*)\\"$/', "\${1}", $messageprops[$emailproperties["representingname"]]); } if (isset($messageprops[$emailproperties["representingentryid"]])) { $fromaddr = $this->getSMTPAddressFromEntryID($messageprops[$emailproperties["representingentryid"]]); } if ($fromname == $fromaddr) { $fromname = ""; } if ($fromname) { $from = "\"" . w2u($fromname) . "\" <" . w2u($fromaddr) . ">"; } else { //START CHANGED dw2412 HTC shows "error" if sender name is unknown $from = "\"" . w2u($fromaddr) . "\" <" . w2u($fromaddr) . ">"; } //END CHANGED dw2412 HTC shows "error" if sender name is unknown $message->from = $from; // process Meeting Requests if (isset($message->messageclass) && strpos($message->messageclass, "IPM.Schedule.Meeting") === 0) { $message->meetingrequest = new SyncMeetingRequest(); $this->getPropsFromMAPI($message->meetingrequest, $mapimessage, MAPIMapping::GetMeetingRequestMapping()); $meetingrequestproperties = MAPIMapping::GetMeetingRequestProperties(); $props = $this->getProps($mapimessage, $meetingrequestproperties); // Get the GOID if (isset($props[$meetingrequestproperties["goidtag"]])) { $message->meetingrequest->globalobjid = base64_encode($props[$meetingrequestproperties["goidtag"]]); } // Set Timezone if (isset($props[$meetingrequestproperties["timezonetag"]])) { $tz = $this->getTZFromMAPIBlob($props[$meetingrequestproperties["timezonetag"]]); } else { $tz = $this->getGMTTZ(); } $message->meetingrequest->timezone = base64_encode($this->getSyncBlobFromTZ($tz)); // send basedate if exception if (isset($props[$meetingrequestproperties["recReplTime"]]) || isset($props[$meetingrequestproperties["lidIsException"]]) && $props[$meetingrequestproperties["lidIsException"]] == true) { if (isset($props[$meetingrequestproperties["recReplTime"]])) { $basedate = $props[$meetingrequestproperties["recReplTime"]]; $message->meetingrequest->recurrenceid = $this->getGMTTimeByTZ($basedate, $this->getGMTTZ()); } else { if (!isset($props[$meetingrequestproperties["goidtag"]]) || !isset($props[$meetingrequestproperties["recurStartTime"]]) || !isset($props[$meetingrequestproperties["timezonetag"]])) { ZLog::Write(LOGLEVEL_WARN, "Missing property to set correct basedate for exception"); } else { $basedate = Utils::ExtractBaseDate($props[$meetingrequestproperties["goidtag"]], $props[$meetingrequestproperties["recurStartTime"]]); $message->meetingrequest->recurrenceid = $this->getGMTTimeByTZ($basedate, $tz); } } } // Organizer is the sender $message->meetingrequest->organizer = $message->from; // Process recurrence if (isset($props[$meetingrequestproperties["isrecurringtag"]]) && $props[$meetingrequestproperties["isrecurringtag"]]) { $myrec = new SyncMeetingRequestRecurrence(); // get recurrence -> put $message->meetingrequest as message so the 'alldayevent' is set correctly $this->getRecurrence($mapimessage, $props, $message->meetingrequest, $myrec, $tz); $message->meetingrequest->recurrences = array($myrec); } // Force the 'alldayevent' in the object at all times. (non-existent == 0) if (!isset($message->meetingrequest->alldayevent) || $message->meetingrequest->alldayevent == "") { $message->meetingrequest->alldayevent = 0; } // Instancetype // 0 = single appointment // 1 = master recurring appointment // 2 = single instance of recurring appointment // 3 = exception of recurring appointment $message->meetingrequest->instancetype = 0; if (isset($props[$meetingrequestproperties["isrecurringtag"]]) && $props[$meetingrequestproperties["isrecurringtag"]] == 1) { $message->meetingrequest->instancetype = 1; } else { if ((!isset($props[$meetingrequestproperties["isrecurringtag"]]) || $props[$meetingrequestproperties["isrecurringtag"]] == 0) && isset($message->meetingrequest->recurrenceid)) { if (isset($props[$meetingrequestproperties["appSeqNr"]]) && $props[$meetingrequestproperties["appSeqNr"]] == 0) { $message->meetingrequest->instancetype = 2; } else { $message->meetingrequest->instancetype = 3; } } } // Disable reminder if it is off if (!isset($props[$meetingrequestproperties["reminderset"]]) || $props[$meetingrequestproperties["reminderset"]] == false) { $message->meetingrequest->reminder = ""; } else { ///set the default reminder time to seconds if ($props[$meetingrequestproperties["remindertime"]] == 0x5ae980e1) { $message->meetingrequest->reminder = 900; } else { $message->meetingrequest->reminder = $props[$meetingrequestproperties["remindertime"]] * 60; } } // Set sensitivity to 0 if missing if (!isset($message->meetingrequest->sensitivity)) { $message->meetingrequest->sensitivity = 0; } // if a meeting request response hasn't been processed yet, // do it so that the attendee status is updated on the mobile if (!isset($messageprops[$emailproperties["processed"]])) { $req = new Meetingrequest($this->store, $mapimessage, $this->session); if ($req->isMeetingRequestResponse()) { $req->processMeetingRequestResponse(); } if ($req->isMeetingCancellation()) { $req->processMeetingCancellation(); } } } // Add attachments $attachtable = mapi_message_getattachmenttable($mapimessage); $rows = mapi_table_queryallrows($attachtable, array(PR_ATTACH_NUM)); $entryid = bin2hex($messageprops[$emailproperties["entryid"]]); foreach ($rows as $row) { if (isset($row[PR_ATTACH_NUM])) { $mapiattach = mapi_message_openattach($mapimessage, $row[PR_ATTACH_NUM]); $attachprops = mapi_getprops($mapiattach, array(PR_ATTACH_LONG_FILENAME, PR_ATTACH_FILENAME, PR_ATTACHMENT_HIDDEN, PR_ATTACH_CONTENT_ID, PR_ATTACH_CONTENT_ID_W, PR_ATTACH_MIME_TAG, PR_ATTACH_MIME_TAG_W)); $stream = mapi_openpropertytostream($mapiattach, PR_ATTACH_DATA_BIN); if ($stream) { $stat = mapi_stream_stat($stream); if (Request::GetProtocolVersion() >= 12.0) { $attach = new SyncBaseAttachment(); } else { $attach = new SyncAttachment(); } // the displayname is handled equal for all AS versions $attach->displayname = w2u(isset($attachprops[PR_ATTACH_LONG_FILENAME]) ? $attachprops[PR_ATTACH_LONG_FILENAME] : (isset($attachprops[PR_ATTACH_FILENAME]) ? $attachprops[PR_ATTACH_FILENAME] : "attachment.bin")); // fix attachment name in case of inline images if ($attach->displayname == "inline.txt" && (isset($attachprops[PR_ATTACH_MIME_TAG]) || $attachprops[PR_ATTACH_MIME_TAG_W])) { $mimetype = isset($attachprops[PR_ATTACH_MIME_TAG]) ? $attachprops[PR_ATTACH_MIME_TAG] : $attachprops[PR_ATTACH_MIME_TAG_W]; $mime = explode("/", $mimetype); if (count($mime) == 2 && $mime[0] == "image") { $attach->displayname = "inline." . $mime[1]; } } // set AS version specific parameters if (Request::GetProtocolVersion() >= 12.0) { $attach->filereference = $entryid . ":" . $row[PR_ATTACH_NUM]; $attach->method = 1; $attach->estimatedDataSize = $stat["cb"]; if (isset($attachprops[PR_ATTACH_CONTENT_ID]) && $attachprops[PR_ATTACH_CONTENT_ID]) { $attach->contentid = $attachprops[PR_ATTACH_CONTENT_ID]; } if (!isset($attach->contentid) && isset($attachprops[PR_ATTACH_CONTENT_ID_W]) && $attachprops[PR_ATTACH_CONTENT_ID_W]) { $attach->contentid = $attachprops[PR_ATTACH_CONTENT_ID_W]; } if (isset($attachprops[PR_ATTACHMENT_HIDDEN]) && $attachprops[PR_ATTACHMENT_HIDDEN]) { $attach->isinline = 1; } if (!isset($message->asattachments)) { $message->asattachments = array(); } array_push($message->asattachments, $attach); } else { $attach->attsize = $stat["cb"]; $attach->attname = $entryid . ":" . $row[PR_ATTACH_NUM]; if (!isset($message->attachments)) { $message->attachments = array(); } array_push($message->attachments, $attach); } } } } // Get To/Cc as SMTP addresses (this is different from displayto and displaycc because we are putting // in the SMTP addresses as well, while displayto and displaycc could just contain the display names $message->to = array(); $message->cc = array(); $reciptable = mapi_message_getrecipienttable($mapimessage); $rows = mapi_table_queryallrows($reciptable, array(PR_RECIPIENT_TYPE, PR_DISPLAY_NAME, PR_ADDRTYPE, PR_EMAIL_ADDRESS, PR_SMTP_ADDRESS, PR_ENTRYID)); foreach ($rows as $row) { $address = ""; $fulladdr = ""; $addrtype = isset($row[PR_ADDRTYPE]) ? $row[PR_ADDRTYPE] : ""; if (isset($row[PR_SMTP_ADDRESS])) { $address = $row[PR_SMTP_ADDRESS]; } elseif ($addrtype == "SMTP" && isset($row[PR_EMAIL_ADDRESS])) { $address = $row[PR_EMAIL_ADDRESS]; } elseif ($addrtype == "ZARAFA" && isset($row[PR_ENTRYID])) { $address = $this->getSMTPAddressFromEntryID($row[PR_ENTRYID]); } $name = isset($row[PR_DISPLAY_NAME]) ? $row[PR_DISPLAY_NAME] : ""; if ($name == "" || $name == $address) { $fulladdr = w2u($address); } else { if (substr($name, 0, 1) != '"' && substr($name, -1) != '"') { $fulladdr = "\"" . w2u($name) . "\" <" . w2u($address) . ">"; } else { $fulladdr = w2u($name) . "<" . w2u($address) . ">"; } } if ($row[PR_RECIPIENT_TYPE] == MAPI_TO) { array_push($message->to, $fulladdr); } else { if ($row[PR_RECIPIENT_TYPE] == MAPI_CC) { array_push($message->cc, $fulladdr); } } } if (is_array($message->to) && !empty($message->to)) { $message->to = implode(", ", $message->to); } if (is_array($message->cc) && !empty($message->cc)) { $message->cc = implode(", ", $message->cc); } // without importance some mobiles assume "0" (low) - Mantis #439 if (!isset($message->importance)) { $message->importance = IMPORTANCE_NORMAL; } //TODO contentclass and nativebodytype and internetcpid if (!isset($message->internetcpid)) { $message->internetcpid = defined('STORE_INTERNET_CPID') ? constant('STORE_INTERNET_CPID') : INTERNET_CPID_WINDOWS1252; } $this->setFlag($mapimessage, $message); $message->contentclass = DEFAULT_EMAIL_CONTENTCLASS; if (!isset($message->nativebodytype)) { $message->nativebodytype = $this->getNativeBodyType($messageprops); } return $message; }
/** * Processes a response to a meeting request. * CalendarID is a reference and has to be set if a new calendar item is created * * @param string $requestid id of the object containing the request * @param string $folderid id of the parent folder of $requestid * @param string $response * * @access public * @return string id of the created/updated calendar obj * @throws StatusException */ public function MeetingResponse($requestid, $folderid, $response) { // Use standard meeting response code to process meeting request $reqentryid = mapi_msgstore_entryidfromsourcekey($this->store, hex2bin($folderid), hex2bin($requestid)); if (!$reqentryid) { throw new StatusException(sprintf("BackendZarafa->MeetingResponse('%s', '%s', '%s'): Error, unable to entryid of the message 0x%X", $requestid, $folderid, $response, mapi_last_hresult()), SYNC_MEETRESPSTATUS_INVALIDMEETREQ); } $mapimessage = mapi_msgstore_openentry($this->store, $reqentryid); if (!$mapimessage) { throw new StatusException(sprintf("BackendZarafa->MeetingResponse('%s','%s', '%s'): Error, unable to open request message for response 0x%X", $requestid, $folderid, $response, mapi_last_hresult()), SYNC_MEETRESPSTATUS_INVALIDMEETREQ); } $meetingrequest = new Meetingrequest($this->store, $mapimessage); if (!$meetingrequest->isMeetingRequest()) { throw new StatusException(sprintf("BackendZarafa->MeetingResponse('%s','%s', '%s'): Error, attempt to respond to non-meeting request", $requestid, $folderid, $response), SYNC_MEETRESPSTATUS_INVALIDMEETREQ); } if ($meetingrequest->isLocalOrganiser()) { throw new StatusException(sprintf("BackendZarafa->MeetingResponse('%s','%s', '%s'): Error, attempt to response to meeting request that we organized", $requestid, $folderid, $response), SYNC_MEETRESPSTATUS_INVALIDMEETREQ); } // Process the meeting response. We don't have to send the actual meeting response // e-mail, because the device will send it itself. switch ($response) { case 1: // accept // accept default: $entryid = $meetingrequest->doAccept(false, false, false, false, false, false, true); // last true is the $userAction break; case 2: // tentative $entryid = $meetingrequest->doAccept(true, false, false, false, false, false, true); // last true is the $userAction break; case 3: // decline $meetingrequest->doDecline(false); break; } // F/B will be updated on logoff // We have to return the ID of the new calendar item, so do that here $calendarid = ""; if (isset($entryid)) { $newitem = mapi_msgstore_openentry($this->store, $entryid); $newprops = mapi_getprops($newitem, array(PR_SOURCE_KEY)); $calendarid = bin2hex($newprops[PR_SOURCE_KEY]); } // on recurring items, the MeetingRequest class responds with a wrong entryid if ($requestid == $calendarid) { ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendZarafa->MeetingResponse('%s','%s', '%s'): returned calender id is the same as the requestid - re-searching", $requestid, $folderid, $response)); $props = MAPIMapping::GetMeetingRequestProperties(); $props = getPropIdsFromStrings($this->store, $props); $messageprops = mapi_getprops($mapimessage, array($props["goidtag"])); $goid = $messageprops[$props["goidtag"]]; $items = $meetingrequest->findCalendarItems($goid); if (is_array($items)) { $newitem = mapi_msgstore_openentry($this->store, $items[0]); $newprops = mapi_getprops($newitem, array(PR_SOURCE_KEY)); $calendarid = bin2hex($newprops[PR_SOURCE_KEY]); ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendZarafa->MeetingResponse('%s','%s', '%s'): found other calendar entryid", $requestid, $folderid, $response)); } if ($requestid == $calendarid) { throw new StatusException(sprintf("BackendZarafa->MeetingResponse('%s','%s', '%s'): Error finding the accepted meeting response in the calendar", $requestid, $folderid, $response), SYNC_MEETRESPSTATUS_INVALIDMEETREQ); } } // delete meeting request from Inbox $folderentryid = mapi_msgstore_entryidfromsourcekey($this->store, hex2bin($folderid)); $folder = mapi_msgstore_openentry($this->store, $folderentryid); mapi_folder_deletemessages($folder, array($reqentryid), 0); return $calendarid; }
function MeetingResponse($requestid, $folderid, $response, &$calendarid) { // Use standard meeting response code to process meeting request $reqentryid = mapi_msgstore_entryidfromsourcekey($this->_defaultstore, hex2bin($folderid), hex2bin($requestid)); $mapimessage = mapi_msgstore_openentry($this->_defaultstore, $reqentryid); if (!$mapimessage) { debugLog("Unable to open request message for response"); return false; } $meetingrequest = new Meetingrequest($this->_defaultstore, $mapimessage); if (!$meetingrequest->isMeetingRequest()) { debugLog("Attempt to respond to non-meeting request"); return false; } if ($meetingrequest->isLocalOrganiser()) { debugLog("Attempt to response to meeting request that we organized"); return false; } // Process the meeting response. We don't have to send the actual meeting response // e-mail, because the device will send it itself. switch ($response) { case 1: // accept // accept default: $entryid = $meetingrequest->doAccept(false, false, false, false, false, false, true); // last true is the $userAction break; case 2: // tentative $entryid = $meetingrequest->doAccept(true, false, false, false, false, false, true); // last true is the $userAction break; case 3: // decline $meetingrequest->doDecline(false); break; } // F/B will be updated on logoff // We have to return the ID of the new calendar item, so do that here if (isset($entryid)) { $newitem = mapi_msgstore_openentry($this->_defaultstore, $entryid); $newprops = mapi_getprops($newitem, array(PR_SOURCE_KEY)); $calendarid = bin2hex($newprops[PR_SOURCE_KEY]); } // on recurring items, the MeetingRequest class responds with a wrong entryid if ($requestid == $calendarid) { debugLog("returned calender id is the same as the requestid - re-searching"); $goidprop = GetPropIDFromString($this->_defaultstore, "PT_BINARY:{6ED8DA90-450B-101B-98DA-00AA003F1305}:0x3"); $messageprops = mapi_getprops($mapimessage, array($goidprop, PR_OWNER_APPT_ID)); $goid = $messageprops[$goidprop]; if (isset($messageprops[PR_OWNER_APPT_ID])) { $apptid = $messageprops[PR_OWNER_APPT_ID]; } else { $apptid = false; } //findCalendarItems signature was changed in 6.40.8, Mantis #485 $items = checkMapiExtVersion("6.40.8") ? $meetingrequest->findCalendarItems($goid) : $meetingrequest->findCalendarItems($goid, $apptid); if (is_array($items)) { $newitem = mapi_msgstore_openentry($this->_defaultstore, $items[0]); $newprops = mapi_getprops($newitem, array(PR_SOURCE_KEY)); $calendarid = bin2hex($newprops[PR_SOURCE_KEY]); debugLog("found other calendar entryid"); } } // delete meeting request from Inbox $folderentryid = mapi_msgstore_entryidfromsourcekey($this->_defaultstore, hex2bin($folderid)); $folder = mapi_msgstore_openentry($this->_defaultstore, $folderentryid); mapi_folder_deletemessages($folder, array($reqentryid), 0); return true; }
public static function MeetingRequestMailNonKc($type, $connection_giverId, $receiverId, $meetingId, $giver_email) { $type = 16; $receiverDetail = User::find($receiverId); $giverDetail = Connection::find($connection_giverId); $ReceiverName = $receiverDetail->fname . ' ' . $receiverDetail->lname; $url = KarmaHelper::generateURL($meetingId, $receiverDetail, $giverDetail, '0'); $meetingDetail = Meetingrequest::find($meetingId); $to = $giver_email; $fullname = $giverDetail->fname . ' ' . $giverDetail->lname; $promises_email = ""; if ($meetingDetail->payitforward + $meetingDetail->sendKarmaNote + $meetingDetail->buyyoucoffee != 0) { $promises_email = "In gratitude, I shall do the following:<br>"; if ($meetingDetail->payitforward == '1') { $promises_email = $promises_email . "I'll pay it forward.<br>"; } if ($meetingDetail->sendKarmaNote == '1') { $promises_email = $promises_email . " I'll send you a Karma Note.<br>"; } if ($meetingDetail->buyyoucoffee == '1') { $promises_email = $promises_email . " I'll buy you coffee (in-person meetings only).<br>"; } } $besttime = $meetingDetail->weekday_call . ' ' . $meetingDetail->weekday_call_time; $subject = "KarmaMeeting request from " . $receiverDetail->fname . " " . $receiverDetail->lname; $meetingSubject = $meetingDetail->subject; Mail::send('emails.requestmeetingnonkc', array('Note' => $meetingDetail->notes, 'Besttime' => $besttime, 'Points' => $promises_email, 'giverDetail' => $giverDetail, 'receiverDetail' => $receiverDetail, 'subject' => $meetingSubject, 'url' => $url), function ($message) use($to, $subject, $fullname, $giverDetail, $receiverDetail) { $from = $receiverDetail->fname . ' ' . $receiverDetail->lname; $fromname = $from . " via karmacircles"; $message->to($to, $fullname)->replyTo($receiverDetail->email, $from)->subject($subject)->from('*****@*****.**', $fromname); }); }
function MeetingResponse($requestid, $folderid, $response, &$calendarid) { // Use standard meeting response code to process meeting request $entryid = mapi_msgstore_entryidfromsourcekey($this->_defaultstore, hex2bin($folderid), hex2bin($requestid)); $mapimessage = mapi_msgstore_openentry($this->_defaultstore, $entryid); if (!$mapimessage) { debugLog("Unable to open request message for response"); return false; } $meetingrequest = new Meetingrequest($this->_defaultstore, $mapimessage); if (!$meetingrequest->isMeetingRequest()) { debugLog("Attempt to respond to non-meeting request"); return false; } if ($meetingrequest->isLocalOrganiser()) { debugLog("Attempt to response to meeting request that we organized"); return false; } // Process the meeting response. We don't have to send the actual meeting response // e-mail, because the device will send it itself. switch ($response) { case 1: // accept // accept default: $entryid = $meetingrequest->doAccept(false, false, $meetingrequest->isInCalendar()); break; case 2: // tentative $meetingrequest->doAccept(true, false, $meetingrequest->isInCalendar()); break; case 3: // decline $meetingrequest->doDecline(false); break; } // Update F/B $root = mapi_msgstore_openentry($this->_defaultstore); $rootprops = mapi_getprops($root, array(PR_IPM_APPOINTMENT_ENTRYID)); $calendar = mapi_msgstore_openentry($this->_defaultstore, $rootprops[PR_IPM_APPOINTMENT_ENTRYID]); $storeprops = mapi_getprops($this->_defaultstore, array(PR_USER_ENTRYID)); $pub = new FreeBusyPublish($this->_session, $this->_defaultstore, $calendar, $storeprops[PR_USER_ENTRYID]); $pub->publishFB(time() - 7 * 24 * 60 * 60, 6 * 30 * 24 * 60 * 60); // publish from one week ago, 6 months ahead // We have to return the ID of the new calendar item, so do that here $newitem = mapi_msgstore_openentry($this->_defaultstore, $entryid); $newprops = mapi_getprops($newitem, array(PR_SOURCE_KEY)); $calendarid = bin2hex($newprops[PR_SOURCE_KEY]); return true; }
/** * Reads an email object from MAPI * * @param mixed $mapimessage * @param ContentParameters $contentparameters * * @access private * @return SyncEmail */ private function getEmail($mapimessage, $contentparameters) { // This workaround fixes ZP-729 and still works with Outlook. // FIXME: It should be properly fixed when refactoring. $bpReturnType = Utils::GetBodyPreferenceBestMatch($contentparameters->GetBodyPreference()); if ($contentparameters->GetMimeSupport() == SYNC_MIMESUPPORT_NEVER || ($key = array_search(SYNC_BODYPREFERENCE_MIME, $contentparameters->GetBodyPreference()) === false) || $bpReturnType != SYNC_BODYPREFERENCE_MIME) { MAPIUtils::ParseSmime($this->session, $this->store, $this->getAddressbook(), $mapimessage); } $message = new SyncMail(); $this->getPropsFromMAPI($message, $mapimessage, MAPIMapping::GetEmailMapping()); $emailproperties = MAPIMapping::GetEmailProperties(); $messageprops = $this->getProps($mapimessage, $emailproperties); if (isset($messageprops[PR_SOURCE_KEY])) { $sourcekey = $messageprops[PR_SOURCE_KEY]; } else { return false; } //set the body according to contentparameters and supported AS version $this->setMessageBody($mapimessage, $contentparameters, $message); $fromname = $fromaddr = ""; if (isset($messageprops[$emailproperties["representingname"]])) { // remove encapsulating double quotes from the representingname $fromname = preg_replace('/^\\"(.*)\\"$/', "\${1}", $messageprops[$emailproperties["representingname"]]); } if (isset($messageprops[$emailproperties["representingentryid"]])) { $fromaddr = $this->getSMTPAddressFromEntryID($messageprops[$emailproperties["representingentryid"]]); } if ($fromname == $fromaddr) { $fromname = ""; } if ($fromname) { $from = "\"" . w2u($fromname) . "\" <" . w2u($fromaddr) . ">"; } else { //START CHANGED dw2412 HTC shows "error" if sender name is unknown $from = "\"" . w2u($fromaddr) . "\" <" . w2u($fromaddr) . ">"; } //END CHANGED dw2412 HTC shows "error" if sender name is unknown $message->from = $from; // process Meeting Requests if (isset($message->messageclass) && strpos($message->messageclass, "IPM.Schedule.Meeting") === 0) { $message->meetingrequest = new SyncMeetingRequest(); $this->getPropsFromMAPI($message->meetingrequest, $mapimessage, MAPIMapping::GetMeetingRequestMapping()); $meetingrequestproperties = MAPIMapping::GetMeetingRequestProperties(); $props = $this->getProps($mapimessage, $meetingrequestproperties); // Get the GOID if (isset($props[$meetingrequestproperties["goidtag"]])) { // GlobalObjId support was removed in AS 16.0 if (Request::IsGlobalObjIdHexClient()) { $message->meetingrequest->globalobjid = strtoupper(bin2hex($props[$meetingrequestproperties["goidtag"]])); } else { $message->meetingrequest->globalobjid = base64_encode($props[$meetingrequestproperties["goidtag"]]); } } // Set Timezone if (isset($props[$meetingrequestproperties["timezonetag"]])) { $tz = $this->getTZFromMAPIBlob($props[$meetingrequestproperties["timezonetag"]]); } else { $tz = $this->getGMTTZ(); } $message->meetingrequest->timezone = base64_encode(TimezoneUtil::GetSyncBlobFromTZ($tz)); // send basedate if exception if (isset($props[$meetingrequestproperties["recReplTime"]]) || isset($props[$meetingrequestproperties["lidIsException"]]) && $props[$meetingrequestproperties["lidIsException"]] == true) { if (isset($props[$meetingrequestproperties["recReplTime"]])) { $basedate = $props[$meetingrequestproperties["recReplTime"]]; $message->meetingrequest->recurrenceid = $this->getGMTTimeByTZ($basedate, $this->getGMTTZ()); } else { if (!isset($props[$meetingrequestproperties["goidtag"]]) || !isset($props[$meetingrequestproperties["recurStartTime"]]) || !isset($props[$meetingrequestproperties["timezonetag"]])) { ZLog::Write(LOGLEVEL_WARN, "Missing property to set correct basedate for exception"); } else { $basedate = Utils::ExtractBaseDate($props[$meetingrequestproperties["goidtag"]], $props[$meetingrequestproperties["recurStartTime"]]); $message->meetingrequest->recurrenceid = $this->getGMTTimeByTZ($basedate, $tz); } } } // Organizer is the sender if (strpos($message->messageclass, "IPM.Schedule.Meeting.Resp") === 0) { $message->meetingrequest->organizer = $message->to; } else { $message->meetingrequest->organizer = $message->from; } // Process recurrence if (isset($props[$meetingrequestproperties["isrecurringtag"]]) && $props[$meetingrequestproperties["isrecurringtag"]]) { $myrec = new SyncMeetingRequestRecurrence(); // get recurrence -> put $message->meetingrequest as message so the 'alldayevent' is set correctly $this->getRecurrence($mapimessage, $props, $message->meetingrequest, $myrec, $tz); $message->meetingrequest->recurrences = array($myrec); } // Force the 'alldayevent' in the object at all times. (non-existent == 0) if (!isset($message->meetingrequest->alldayevent) || $message->meetingrequest->alldayevent == "") { $message->meetingrequest->alldayevent = 0; } // Instancetype // 0 = single appointment // 1 = master recurring appointment // 2 = single instance of recurring appointment // 3 = exception of recurring appointment $message->meetingrequest->instancetype = 0; if (isset($props[$meetingrequestproperties["isrecurringtag"]]) && $props[$meetingrequestproperties["isrecurringtag"]] == 1) { $message->meetingrequest->instancetype = 1; } else { if ((!isset($props[$meetingrequestproperties["isrecurringtag"]]) || $props[$meetingrequestproperties["isrecurringtag"]] == 0) && isset($message->meetingrequest->recurrenceid)) { if (isset($props[$meetingrequestproperties["appSeqNr"]]) && $props[$meetingrequestproperties["appSeqNr"]] == 0) { $message->meetingrequest->instancetype = 2; } else { $message->meetingrequest->instancetype = 3; } } } // Disable reminder if it is off if (!isset($props[$meetingrequestproperties["reminderset"]]) || $props[$meetingrequestproperties["reminderset"]] == false) { $message->meetingrequest->reminder = ""; } else { ///set the default reminder time to seconds if ($props[$meetingrequestproperties["remindertime"]] == 0x5ae980e1) { $message->meetingrequest->reminder = 900; } else { $message->meetingrequest->reminder = $props[$meetingrequestproperties["remindertime"]] * 60; } } // Set sensitivity to 0 if missing if (!isset($message->meetingrequest->sensitivity)) { $message->meetingrequest->sensitivity = 0; } // If the user is working from a location other than the office the busystatus should be interpreted as free. if (isset($message->meetingrequest->busystatus) && $message->meetingrequest->busystatus == fbWorkingElsewhere) { $message->meetingrequest->busystatus = fbFree; } // If the busystatus has the value of -1, we should be interpreted as tentative (1) / ZP-581 if (isset($message->meetingrequest->busystatus) && $message->meetingrequest->busystatus == -1) { $message->meetingrequest->busystatus = fbTentative; } // if a meeting request response hasn't been processed yet, // do it so that the attendee status is updated on the mobile if (!isset($messageprops[$emailproperties["processed"]])) { // check if we are not sending the MR so we can process it - ZP-581 $cuser = ZPush::GetBackend()->GetUserDetails(ZPush::GetBackend()->GetCurrentUsername()); if (isset($cuser["emailaddress"]) && $cuser["emailaddress"] != $fromaddr) { $req = new Meetingrequest($this->store, $mapimessage, $this->session); if ($req->isMeetingRequestResponse()) { $req->processMeetingRequestResponse(); } if ($req->isMeetingCancellation()) { $req->processMeetingCancellation(); } } } $message->contentclass = DEFAULT_CALENDAR_CONTENTCLASS; } // Add attachments $attachtable = mapi_message_getattachmenttable($mapimessage); $rows = mapi_table_queryallrows($attachtable, array(PR_ATTACH_NUM)); $entryid = bin2hex($messageprops[$emailproperties["entryid"]]); $parentSourcekey = bin2hex($messageprops[$emailproperties["parentsourcekey"]]); foreach ($rows as $row) { if (isset($row[PR_ATTACH_NUM])) { if (Request::GetProtocolVersion() >= 12.0) { $attach = new SyncBaseAttachment(); } else { $attach = new SyncAttachment(); } $mapiattach = mapi_message_openattach($mapimessage, $row[PR_ATTACH_NUM]); $attachprops = mapi_getprops($mapiattach, array(PR_ATTACH_LONG_FILENAME, PR_ATTACH_FILENAME, PR_ATTACHMENT_HIDDEN, PR_ATTACH_CONTENT_ID, PR_ATTACH_CONTENT_ID_W, PR_ATTACH_MIME_TAG, PR_ATTACH_MIME_TAG_W, PR_ATTACH_METHOD, PR_DISPLAY_NAME, PR_DISPLAY_NAME_W, PR_ATTACH_SIZE)); if (isset($attachprops[PR_ATTACH_MIME_TAG]) && strpos(strtolower($attachprops[PR_ATTACH_MIME_TAG]), 'signed') !== false || isset($attachprops[PR_ATTACH_MIME_TAG_W]) && strpos(strtolower($attachprops[PR_ATTACH_MIME_TAG_W]), 'signed') !== false) { continue; } // the displayname is handled equaly for all AS versions $attach->displayname = w2u(isset($attachprops[PR_ATTACH_LONG_FILENAME]) ? $attachprops[PR_ATTACH_LONG_FILENAME] : (isset($attachprops[PR_ATTACH_FILENAME]) ? $attachprops[PR_ATTACH_FILENAME] : (isset($attachprops[PR_DISPLAY_NAME]) ? $attachprops[PR_DISPLAY_NAME] : "attachment.bin"))); // fix attachment name in case of inline images if ($attach->displayname == "inline.txt" && (isset($attachprops[PR_ATTACH_MIME_TAG]) || $attachprops[PR_ATTACH_MIME_TAG_W])) { $mimetype = isset($attachprops[PR_ATTACH_MIME_TAG]) ? $attachprops[PR_ATTACH_MIME_TAG] : $attachprops[PR_ATTACH_MIME_TAG_W]; $mime = explode("/", $mimetype); if (count($mime) == 2 && $mime[0] == "image") { $attach->displayname = "inline." . $mime[1]; } } // set AS version specific parameters if (Request::GetProtocolVersion() >= 12.0) { $attach->filereference = sprintf("%s:%s:%s", $entryid, $row[PR_ATTACH_NUM], $parentSourcekey); $attach->method = isset($attachprops[PR_ATTACH_METHOD]) ? $attachprops[PR_ATTACH_METHOD] : ATTACH_BY_VALUE; // if displayname does not have the eml extension for embedde messages, android and WP devices won't open it if ($attach->method == ATTACH_EMBEDDED_MSG) { if (strtolower(substr($attach->displayname, -4)) != '.eml') { $attach->displayname .= '.eml'; } } // android devices require attachment size in order to display an attachment properly if (!isset($attachprops[PR_ATTACH_SIZE])) { $stream = mapi_openpropertytostream($mapiattach, PR_ATTACH_DATA_BIN); $stat = mapi_stream_stat($stream); $attach->estimatedDataSize = $stat['cb']; } else { $attach->estimatedDataSize = $attachprops[PR_ATTACH_SIZE]; } if (isset($attachprops[PR_ATTACH_CONTENT_ID]) && $attachprops[PR_ATTACH_CONTENT_ID]) { $attach->contentid = $attachprops[PR_ATTACH_CONTENT_ID]; } if (!isset($attach->contentid) && isset($attachprops[PR_ATTACH_CONTENT_ID_W]) && $attachprops[PR_ATTACH_CONTENT_ID_W]) { $attach->contentid = $attachprops[PR_ATTACH_CONTENT_ID_W]; } if (isset($attachprops[PR_ATTACHMENT_HIDDEN]) && $attachprops[PR_ATTACHMENT_HIDDEN]) { $attach->isinline = 1; } if (!isset($message->asattachments)) { $message->asattachments = array(); } array_push($message->asattachments, $attach); } else { $attach->attsize = $attachprops[PR_ATTACH_SIZE]; $attach->attname = sprintf("%s:%s:%s", $entryid, $row[PR_ATTACH_NUM], $parentSourcekey); if (!isset($message->attachments)) { $message->attachments = array(); } array_push($message->attachments, $attach); } } } // Get To/Cc as SMTP addresses (this is different from displayto and displaycc because we are putting // in the SMTP addresses as well, while displayto and displaycc could just contain the display names $message->to = array(); $message->cc = array(); $reciptable = mapi_message_getrecipienttable($mapimessage); $rows = mapi_table_queryallrows($reciptable, array(PR_RECIPIENT_TYPE, PR_DISPLAY_NAME, PR_ADDRTYPE, PR_EMAIL_ADDRESS, PR_SMTP_ADDRESS, PR_ENTRYID)); foreach ($rows as $row) { $address = ""; $fulladdr = ""; $addrtype = isset($row[PR_ADDRTYPE]) ? $row[PR_ADDRTYPE] : ""; if (isset($row[PR_SMTP_ADDRESS])) { $address = $row[PR_SMTP_ADDRESS]; } elseif ($addrtype == "SMTP" && isset($row[PR_EMAIL_ADDRESS])) { $address = $row[PR_EMAIL_ADDRESS]; } elseif ($addrtype == "ZARAFA" && isset($row[PR_ENTRYID])) { $address = $this->getSMTPAddressFromEntryID($row[PR_ENTRYID]); } $name = isset($row[PR_DISPLAY_NAME]) ? $row[PR_DISPLAY_NAME] : ""; if ($name == "" || $name == $address) { $fulladdr = w2u($address); } else { if (substr($name, 0, 1) != '"' && substr($name, -1) != '"') { $fulladdr = "\"" . w2u($name) . "\" <" . w2u($address) . ">"; } else { $fulladdr = w2u($name) . "<" . w2u($address) . ">"; } } if ($row[PR_RECIPIENT_TYPE] == MAPI_TO) { array_push($message->to, $fulladdr); } else { if ($row[PR_RECIPIENT_TYPE] == MAPI_CC) { array_push($message->cc, $fulladdr); } } } if (is_array($message->to) && !empty($message->to)) { $message->to = implode(", ", $message->to); } if (is_array($message->cc) && !empty($message->cc)) { $message->cc = implode(", ", $message->cc); } // without importance some mobiles assume "0" (low) - Mantis #439 if (!isset($message->importance)) { $message->importance = IMPORTANCE_NORMAL; } //TODO contentclass and nativebodytype and internetcpid if (!isset($message->internetcpid)) { $message->internetcpid = defined('STORE_INTERNET_CPID') ? constant('STORE_INTERNET_CPID') : INTERNET_CPID_WINDOWS1252; } $this->setFlag($mapimessage, $message); if (!isset($message->contentclass)) { $message->contentclass = DEFAULT_EMAIL_CONTENTCLASS; } if (!isset($message->nativebodytype)) { $message->nativebodytype = $this->getNativeBodyType($messageprops); } // reply, reply to all, forward flags if (isset($message->lastverbexecuted) && $message->lastverbexecuted) { $message->lastverbexecuted = Utils::GetLastVerbExecuted($message->lastverbexecuted); } return $message; }
/** * Function name: updateKarmaNoteStatus() * Created by : Evon * Created on : 04/10/2014 * Arguments : $noteId, $status **/ public function updateKarmaNoteStatus() { $CurrentUser = Auth::user(); $user_id = $noteId = $status = ''; $user_id = Input::get('user_id'); $noteId = Input::get('noteId'); $status = Input::get('status'); $publicPage = Input::get('publicPage'); if ($user_id && $noteId && $status) { if ($user_id == 'receiver') { $updateColumn = 'statusreceiver'; } else { $updateColumn = 'statusgiver'; } if ($status == 'Hide') { $updateStatus = 'hidden'; } elseif ($status == 'Show') { $updateStatus = 'visible'; } $KarmaNotes = Karmanote::find($noteId); $KarmaNotes->{$updateColumn} = $updateStatus; $KarmaNotes->save(); $KarmaNotes = $KarmaNotes->toArray(); $Meetingrequest = Meetingrequest::find($KarmaNotes['req_id']); $receiverDetail = User::find($Meetingrequest->user_id_receiver)->toArray(); //echo "<pre>";print_r($Meetingrequest);echo "</pre>";die; if (!empty($Meetingrequest->user_id_giver)) { $giverDetail = User::find($Meetingrequest->user_id_giver)->toArray(); } else { $giverDetail = Connection::find($Meetingrequest->connection_id_giver)->toArray(); } if ($publicPage == '1') { return Redirect::to('profile/' . strtolower($CurrentUser->fname . '-' . $CurrentUser->lname) . '/' . $CurrentUser->id); } else { return Redirect::to('KarmaNotes'); } } else { return Redirect::to('404'); } }
// Open contents table $l_rInboxTable = mapi_folder_getcontentstable($l_rInbox); echo 'Opening contents table result (0=success): ' . mapi_last_hresult() . "\n"; // Find the item by restricting all items to the correct ID $restrict = array(RES_AND, array(array(RES_PROPERTY, array(RELOP => RELOP_NE, ULPROPTAG => PR_PROCESSED, VALUE => array(PR_PROCESSED => true))), array(RES_CONTENT, array(FUZZYLEVEL => FL_PREFIX, ULPROPTAG => PR_MESSAGE_CLASS, VALUE => array(PR_SUBJECT => 'IPM.Schedule.Meeting'))), array(RES_BITMASK, array(ULTYPE => BMR_EQZ, ULMASK => MSGFLAG_READ, ULPROPTAG => PR_MESSAGE_FLAGS)))); // Just get all items from table $l_aRows = mapi_table_queryallrows($l_rInboxTable, array(PR_ENTRYID, PR_MESSAGE_CLASS, PR_SUBJECT, PR_PROCESSED), $restrict); echo 'Querying contents table result (0=success): ' . mapi_last_hresult() . "\n"; //print_r(count($l_aRows)); //exit; echo 'Processing messages' . "\n"; $l_iCounter = 0; for ($i = 0; $i < count($l_aRows); $i++) { $l_sMsgClassSearch = 'IPM.Schedule.Meeting'; $l_rMessage = mapi_msgstore_openentry($l_rDefaultStore, $l_aRows[$i][PR_ENTRYID]); $req = new Meetingrequest($l_rDefaultStore, $l_rMessage, $l_rSession); if ($req->isMeetingRequest() && !$req->isLocalOrganiser()) { // Put the item in the calendar 'tentatively' $req->doAccept(true, false, false); $l_iCounter++; } elseif ($req->isMeetingCancellation()) { // Let's do some processing of this Meeting Cancellation Object we received $req->processMeetingCancellation(); $l_iCounter++; } } echo 'Processed ' . $l_iCounter . ' ' . ($l_iCounter == 1 ? 'message' : 'messages') . "\n"; if ($l_iCounter > 0) { // Publish updated free/busy information publishFreeBusy($l_rDefaultStore, $l_rSession); echo 'Published FreeBusy information!' . "\n";
function MeetingResponse($requestid, $folderid, $response, &$calendarid) { // Use standard meeting response code to process meeting request $reqentryid = mapi_msgstore_entryidfromsourcekey($this->_defaultstore, hex2bin($folderid), hex2bin($requestid)); $mapimessage = mapi_msgstore_openentry($this->_defaultstore, $reqentryid); if (!$mapimessage) { debugLog("Unable to open request message for response"); return false; } $meetingrequest = new Meetingrequest($this->_defaultstore, $mapimessage); if (!$meetingrequest->isMeetingRequest()) { debugLog("Attempt to respond to non-meeting request"); return false; } if ($meetingrequest->isLocalOrganiser()) { debugLog("Attempt to response to meeting request that we organized"); return false; } // Process the meeting response. We don't have to send the actual meeting response // e-mail, because the device will send it itself. switch ($response) { case 1: // accept // accept default: $entryid = $meetingrequest->doAccept(false, false, false, false, false, false, true); // last true is the $userAction break; case 2: // tentative $entryid = $meetingrequest->doAccept(true, false, false, false, false, false, true); // last true is the $userAction break; case 3: // decline $meetingrequest->doDecline(false); break; } // F/B will be updated on logoff // We have to return the ID of the new calendar item, so do that here $newitem = mapi_msgstore_openentry($this->_defaultstore, $entryid); $newprops = mapi_getprops($newitem, array(PR_SOURCE_KEY)); $calendarid = bin2hex($newprops[PR_SOURCE_KEY]); // delete meeting request from Inbox $folderentryid = mapi_msgstore_entryidfromsourcekey($this->_defaultstore, hex2bin($folderid)); $folder = mapi_msgstore_openentry($this->_defaultstore, $folderentryid); mapi_folder_deletemessages($folder, array($reqentryid), 0); return true; }
public function submitIntroform() { $payitforward = $sendKarmaNote = $buyyoucoffee = '0'; $receiverWR = Input::get('receiverWR'); if (!empty($receiverWR)) { foreach ($receiverWR as $key => $value) { if ($value == "I'd pay it forward") { $payitforward = '1'; } elseif ($value == "I'd send you a Karma Note") { $sendKarmaNote = '1'; } } } $giver_email = Input::get('giver_email'); $user_id_receiver = Input::get('receiver_id'); $connection_id_receiver = Input::get('receiver_conn_id'); if (!empty(Input::get('giver_id') && Input::get('giver_id') != 'undefined')) { echo $user_id_giver = Input::get('giver_id'); } $connection_id_giver = Input::get('giver_conn_id'); $user_id_introducer = Input::get('user_id_Intro'); $detail = Input::get('note'); if (!empty($user_id_giver)) { $Meetingrequest = new Meetingrequest(); $Meetingrequest->user_id_introducer = $user_id_introducer; $Meetingrequest->user_id_receiver = $user_id_receiver; $Meetingrequest->user_id_giver = $user_id_giver; $Meetingrequest->connection_id_giver = $connection_id_giver; $Meetingrequest->notes = strip_tags($detail); $Meetingrequest->payitforward = $payitforward; $Meetingrequest->sendKarmaNote = $sendKarmaNote; $Meetingrequest->buyyoucoffee = $buyyoucoffee; $Meetingrequest->status = 'pending'; $Meetingrequest->req_createdate = KarmaHelper::currentDate(); $Meetingrequest->save(); $meetingId = $Meetingrequest->id; Queue::push('MessageSender', array('type' => '12', 'user_id_giver' => $user_id_giver, 'user_id_receiver' => $user_id_receiver, 'meetingId' => $meetingId)); //$sendLinkedinMessage = MessageHelper::triggerEmailAndMessage($user_id_giver,$user_id_receiver,'12',$meetingId); //echo "<pre>";print_r($sendLinkedinMessage);echo "</pre>";die(); return Redirect::to('/karma-intro'); } else { $Meetingrequest = new Meetingrequest(); $Meetingrequest->user_id_introducer = $user_id_introducer; $Meetingrequest->user_id_receiver = $user_id_receiver; $Meetingrequest->connection_id_giver = $connection_id_giver; $Meetingrequest->notes = strip_tags($detail); $Meetingrequest->payitforward = $payitforward; $Meetingrequest->sendKarmaNote = $sendKarmaNote; $Meetingrequest->buyyoucoffee = $buyyoucoffee; $Meetingrequest->status = 'pending'; $Meetingrequest->req_createdate = KarmaHelper::currentDate(); $Meetingrequest->save(); $meetingId = $Meetingrequest->id; if ($giver_email != "") { Queue::push('MessageSender@IntroEmailToNonKarmaGiver', array('type' => '15', 'user_id_giver' => $connection_id_giver, 'user_id_receiver' => $user_id_receiver, 'giver_email' => $giver_email, 'meetingId' => $meetingId)); } Queue::push('MessageSender', array('type' => '13', 'user_id_giver' => $connection_id_giver, 'user_id_receiver' => $user_id_receiver, 'meetingId' => $meetingId)); return Redirect::to('/karma-intro'); /*For Sending Intro Email to Non Karma User if email id is given*/ } }
/** * Function to save confirm meeting data. * * @return Response */ public static function commonMeetingHappened($meetingId, $userRole) { $getMeetingId = Meetingrequest::where('id', '=', $meetingId)->first(); $userId = $getMeetingId->user_id_receiver; $getUser = User::find($userId); DB::table('users_mykarma')->where('entry_id', '=', $meetingId)->update(array('status' => 'happened', 'entry_updated_on' => Carbon::now())); DB::table('requests')->where('id', '=', $meetingId)->update(array('status' => 'happened')); $getGiverData = DB::table('requests')->join('users', 'requests.user_id_giver', '=', 'users.id')->where('requests.id', '=', $meetingId)->select('requests.user_id_giver', 'users.fname', 'users.lname')->get(); //Add message in requests_messages table if (!empty($getGiverData)) { $messageData = new Message(); $messageData->request_id = $meetingId; $messageData->sender_id = $getGiverData[0]->user_id_giver; $messageData->giver_id = $getGiverData[0]->user_id_giver; $messageData->receiver_id = $userId; $messageText = $getGiverData[0]->fname . ' ' . $getGiverData[0]->lname . ' has indicated that the meeting has happened.'; $messageData->messageText = $messageText; $messageData->save(); $changeStatus = KarmaHelper::updateMeetingStatus($meetingId, $userRole); } else { $getGiverData = array(); } return $getGiverData; }
public function loadmoreProfile() { //Karma notes block $karmaTrailUser = $karmaReceivedUser = $karmaSentUser = ''; $profileSelf = 0; $CurrentUserDetail = ""; $CurrentUserId = 0; if (!empty($_REQUEST)) { $start = $_REQUEST['hitcount'] + 1; $action = $_REQUEST['action']; $id = $_REQUEST['userProfile']; $perpage = 10; $profileUserDetail = User::find($id); if (Auth::check()) { $CurrentUserDetail = Auth::User(); $CurrentUserId = $CurrentUserDetail->id; if ($CurrentUserId == $profileUserDetail['id']) { $profileSelf = "1"; } else { $profileSelf = "0"; } } if ($action == 'KarmaTrail') { $karmaTrail = KarmaHelper::getKarmaTrail($id, $start, $perpage); if (count($karmaTrail) > 0) { foreach ($karmaTrail as $trail) { $userSkills = ""; $karma['user_id_receiver'] = User::find($trail->user_id_receiver)->toArray(); if (!empty($trail->user_id_giver)) { $karma['user_id_giver'] = User::find($trail->user_id_giver)->toArray(); } else { $karma['user_id_giver'] = Connection::find($trail->connection_id_giver)->toArray(); } if ($id == $trail->user_id_receiver) { $karma['status'] = $trail->statusreceiver; } else { $karma['status'] = $trail->statusgiver; } $karma['piclink'] = $trail->piclink; $karma['karmaNotes'] = $trail->details; if (!empty($trail->skills)) { $userSkills = KarmaHelper::getSkillsname($trail->skills); } $karma['skills'] = $userSkills; $karma['req_id'] = $trail->req_id; $karma['meetingdatetime'] = date('F d, Y', strtotime($trail->meetingdatetime)); $karma['created_at'] = date('F d, Y', strtotime($trail->created_at)); $karmaTrailUser[] = $karma; } } } //echo "<pre>";print_r($karmaTrailUser);echo "</pre>";die; if ($action == 'KarmaNotesReceived') { $karmaReceived = $profileUserDetail->KarmanoteReceiver()->orderBy('karmanotes.created_at', 'desc')->skip($start)->take($perpage)->get(); if (!empty($karmaReceived)) { foreach ($karmaReceived->toArray() as $received) { $userReceivedSkills = ""; $karmareceived['user_id_receiver'] = User::find($received['user_idreceiver'])->toArray(); if (!empty($received['user_id_giver'])) { $karmareceived['user_id_giver'] = User::find($received['user_idgiver'])->toArray(); } else { $karmareceived['user_id_giver'] = Connection::find($received['connection_idgiver'])->toArray(); } $karmareceived['karmaNotes'] = $received['details']; if (!empty($received['skills'])) { $userReceivedSkills = KarmaHelper::getSkillsname($received['skills']); } $karmareceived['skills'] = $userReceivedSkills; $karmareceived['status'] = $received['statusgiver']; $karmareceived['req_id'] = $received['req_id']; $karmareceived['req_detail'] = Meetingrequest::find($received['req_id']); $karmareceived['created_at'] = date('F d, Y', strtotime($received['created_at'])); $karmaReceivedUser[] = $karmareceived; } } } //echo "<pre>";print_r($karmaReceived->toArray());echo "</pre>";die; if ($action == 'KarmaNotesSent') { $karmaSent = $profileUserDetail->KarmanoteGiver()->orderBy('karmanotes.created_at', 'desc')->skip($start)->take($perpage)->get(); //echo "<pre>";print_r($karmaSent->toArray());echo "</pre>";die; if (!empty($karmaSent)) { foreach ($karmaSent->toArray() as $sent) { $userSentSkills = ""; $karmasent['user_id_receiver'] = User::find($sent['user_idreceiver'])->toArray(); if (!empty($sent['user_idgiver'])) { $karmasent['user_id_giver'] = User::find($sent['user_idgiver'])->toArray(); } else { $karmasent['user_id_giver'] = Connection::find($sent['connection_idgiver'])->toArray(); } $karmasent['karmaNotes'] = $sent['details']; if (!empty($sent['skills'])) { $userSentSkills = KarmaHelper::getSkillsname($sent['skills']); } $karmasent['skills'] = $userSentSkills; $karmasent['req_id'] = $sent['req_id']; $karmasent['req_detail'] = Meetingrequest::find($sent['req_id'])->toArray(); $karmasent['status'] = $sent['statusreceiver']; $karmasent['created_at'] = date('F d, Y', strtotime($sent['created_at'])); $karmaSentUser[] = $karmasent; } } } return View::make('ajax_loadmoreProfile', array('id' => $id, 'CurrentUserDetail' => $CurrentUserDetail, 'profileSelf' => $profileSelf, 'karmaTrail' => $karmaTrailUser, 'profileUserDetail' => $profileUserDetail, 'countTrail' => 0, 'countReceived' => 0, 'countSent' => 0, 'profielURL' => '', 'karmascore' => '', 'karmaReceived' => $karmaReceivedUser, 'karmaSent' => $karmaSentUser)); } }
/** * Processes a response to a meeting request. * CalendarID is a reference and has to be set if a new calendar item is created * * @param string $requestid id of the object containing the request * @param string $folderid id of the parent folder of $requestid * @param string $response * * @access public * @return string id of the created/updated calendar obj * @throws StatusException */ public function MeetingResponse($requestid, $folderid, $response) { // Use standard meeting response code to process meeting request list($fid, $requestid) = Utils::SplitMessageId($requestid); $reqentryid = mapi_msgstore_entryidfromsourcekey($this->store, hex2bin($folderid), hex2bin($requestid)); if (!$reqentryid) { throw new StatusException(sprintf("BackendKopano->MeetingResponse('%s', '%s', '%s'): Error, unable to entryid of the message 0x%X", $requestid, $folderid, $response, mapi_last_hresult()), SYNC_MEETRESPSTATUS_INVALIDMEETREQ); } $mapimessage = mapi_msgstore_openentry($this->store, $reqentryid); if (!$mapimessage) { throw new StatusException(sprintf("BackendKopano->MeetingResponse('%s','%s', '%s'): Error, unable to open request message for response 0x%X", $requestid, $folderid, $response, mapi_last_hresult()), SYNC_MEETRESPSTATUS_INVALIDMEETREQ); } $meetingrequest = new Meetingrequest($this->store, $mapimessage, $this->session); if (!$meetingrequest->isMeetingRequest()) { throw new StatusException(sprintf("BackendKopano->MeetingResponse('%s','%s', '%s'): Error, attempt to respond to non-meeting request", $requestid, $folderid, $response), SYNC_MEETRESPSTATUS_INVALIDMEETREQ); } if ($meetingrequest->isLocalOrganiser()) { throw new StatusException(sprintf("BackendKopano->MeetingResponse('%s','%s', '%s'): Error, attempt to response to meeting request that we organized", $requestid, $folderid, $response), SYNC_MEETRESPSTATUS_INVALIDMEETREQ); } // Process the meeting response. We don't have to send the actual meeting response // e-mail, because the device will send it itself. switch ($response) { case 1: // accept // accept default: $entryid = $meetingrequest->doAccept(false, false, false, false, false, false, true); // last true is the $userAction break; case 2: // tentative $entryid = $meetingrequest->doAccept(true, false, false, false, false, false, true); // last true is the $userAction break; case 3: // decline $meetingrequest->doDecline(false); break; } // F/B will be updated on logoff // We have to return the ID of the new calendar item, so do that here $calendarid = ""; $calFolderId = ""; if (isset($entryid)) { $newitem = mapi_msgstore_openentry($this->store, $entryid); // new item might be in a delegator's store. ActiveSync does not support accepting them. if (!$newitem) { throw new StatusException(sprintf("BackendKopano->MeetingResponse('%s','%s', '%s'): Object with entryid '%s' was not found in user's store (0x%X). It might be in a delegator's store.", $requestid, $folderid, $response, bin2hex($entryid), mapi_last_hresult()), SYNC_MEETRESPSTATUS_SERVERERROR, null, LOGLEVEL_WARN); } $newprops = mapi_getprops($newitem, array(PR_SOURCE_KEY, PR_PARENT_SOURCE_KEY)); $calendarid = bin2hex($newprops[PR_SOURCE_KEY]); $calFolderId = bin2hex($newprops[PR_PARENT_SOURCE_KEY]); } // on recurring items, the MeetingRequest class responds with a wrong entryid if ($requestid == $calendarid) { ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendKopano->MeetingResponse('%s','%s', '%s'): returned calender id is the same as the requestid - re-searching", $requestid, $folderid, $response)); $props = MAPIMapping::GetMeetingRequestProperties(); $props = getPropIdsFromStrings($this->store, $props); $messageprops = mapi_getprops($mapimessage, array($props["goidtag"])); $goid = $messageprops[$props["goidtag"]]; $items = $meetingrequest->findCalendarItems($goid); if (is_array($items)) { $newitem = mapi_msgstore_openentry($this->store, $items[0]); $newprops = mapi_getprops($newitem, array(PR_SOURCE_KEY, PR_PARENT_SOURCE_KEY)); $calendarid = bin2hex($newprops[PR_SOURCE_KEY]); $calFolderId = bin2hex($newprops[PR_PARENT_SOURCE_KEY]); ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendKopano->MeetingResponse('%s','%s', '%s'): found other calendar entryid", $requestid, $folderid, $response)); } if ($requestid == $calendarid) { throw new StatusException(sprintf("BackendKopano->MeetingResponse('%s','%s', '%s'): Error finding the accepted meeting response in the calendar", $requestid, $folderid, $response), SYNC_MEETRESPSTATUS_INVALIDMEETREQ); } } // delete meeting request from Inbox $folderentryid = mapi_msgstore_entryidfromsourcekey($this->store, hex2bin($folderid)); $folder = mapi_msgstore_openentry($this->store, $folderentryid); mapi_folder_deletemessages($folder, array($reqentryid), 0); $prefix = ''; // prepend the short folderid of the target calendar: if available and short ids are used if ($calFolderId) { $shortFolderId = ZPush::GetDeviceManager()->GetFolderIdForBackendId($calFolderId); if ($calFolderId != $shortFolderId) { $prefix = $shortFolderId . ':'; } } return $prefix . $calendarid; }
public function deleteUser() { $id = Input::get('userId'); $test_user = DB::table('admin_option')->where('option_name', 'Test User Emails')->select('option_value')->get(); if (!empty($test_user)) { $count = 0; foreach ($test_user as $value) { foreach (explode(',', $value->option_value) as $test_user_id) { if ($id == $test_user_id) { $count = $count + 1; } } } } else { $count = 0; } if ($count > 0) { $connections = Connection::Where('user_id', '=', $id)->first(); if (!empty($connections)) { $connections->user_id = null; $connections->save(); } $deletekarmanote = Karmanote::where('user_idreceiver', '=', $id)->delete(); $deletekarmanote = Karmanote::where('user_idgiver', '=', $id)->delete(); $deleterequest = Meetingrequest::where('user_id_receiver', '=', $id)->delete(); $deletekarmanote = Meetingrequest::where('user_id_giver', '=', $id)->delete(); $deletekarmanote = Meetingrequest::where('user_id_introducer', '=', $id)->delete(); $deleteusergroups = Usersgroup::where('user_id', '=', $id)->delete(); $findquestion = Question::Where('user_id', '=', $id)->get(); if (!empty($findquestion)) { foreach ($findquestion as $val) { $question_id = $val->id; $findgroupquestion = Groupquestion::Where('question_id', '=', $question_id)->get(); if (!empty($findgroupquestion)) { $deletegroupquestion = Groupquestion::Where('question_id', '=', $question_id)->delete(); } $findQuestionwillingtohelp = Questionwillingtohelp::Where('question_id', '=', $question_id)->get(); if (!empty($findQuestionwillingtohelp)) { $deleteQuestionwillingtohelp = Questionwillingtohelp::Where('question_id', '=', $question_id)->delete(); } } } $deleteQuestionwillingtohelp = Questionwillingtohelp::Where('user_id', '=', $id)->delete(); if (!empty($findquestion)) { $deletequestion = Question::where('user_id', '=', $id)->delete(); } $deletekarmacircles = Karmacircle::where('user_id', '=', $id)->delete(); $deletekarmaFeed = Karmafeed::where('receiver_id', '=', $id)->orWhere('giver_id', '=', $id)->delete(); $userMykarmaDelete = Mykarma::where('user_id', '=', $id)->delete(); $userMessageDelete = Message::where('receiver_id', '=', $id)->orWhere('giver_id', '=', $id)->delete(); $getIntroDataDelete = KarmaIntro::where('intro_giver_id', '=', $id)->orWhere('intro_receiver_id', '=', $id)->orWhere('intro_introducer_id', '=', $id)->delete(); $getMyKarmaDataDelete = Mykarma::where('user_id', '=', $id)->delete(); $user = User::find($id); $user->delete(); echo "User " . $id . " deleted"; } else { echo "User " . $id . " cant be deleted.Its not a test user."; } }