/** * Look if the information in $input is ok to send. * If yes, send and return a confirmation. * Otherwise, return an array that tells what is missing. * * required information in $input: * sender_id, receiver_id, text * * optional fields in $input: * reply_to_id, draft_id * * @param unknown_type $input */ public function sendOrComplain($input) { // check fields $problems = array(); // Maximum 50 emails can be send using the Invitation-Form if (isset($_SESSION['InviteCount']) && $_SESSION['InviteCount'] > 50) { $problems['email'] = 'You already sent more than 50 invitations. Maybe that is enough for now?'; } elseif (!isset($input['email'])) { // $problems['receiver'] = 'no receiver was specified.'; // receiver does not exist. $problems['email'] = 'No receiver set.'; } else { // receiver is set, let's check the email addresses: $input['email'] = strtolower($input['email']); $input['email'] = str_replace(';', ',', $input['email']); $input['email'] = str_replace(' ', '', $input['email']); $email_array = explode(',', $input['email']); foreach ($email_array as $email) { if (!isset($email) || !$this->isEmailAddress($email)) { $problems['email'] = 'no correct email addresses.'; } } } if (!isset($input['sender_id'])) { // sender is not set. $input['sender_id'] = $_SESSION['IdMember']; // $problems['sender_id'] = 'no sender was specified.'; } else { if (!$input['sender_id'] != $_SESSION['IdMember']) { // sender is not the person who is logged in. $problems['sender_id'] = 'you are not the sender.'; } } if (empty($input['text'])) { $problems['text'] = 'text is empty.'; } $input['status'] = 'ToSend'; if (!empty($problems)) { $status = false; } else { // set the sender // FIXME: Read & Uncrypt member's email address from the DB and make it the sender-address //$sender_uncrypted = new MOD_member()->getFromMembersTable('email'); $member = $this->createEntity('Member')->findById($_SESSION['IdMember']); $sender = MOD_crypt::MemberReadCrypted($member->Email); //$sender = PVars::getObj('syshcvol')->MessageSenderMail; $result = MOD_mail::sendEmail($input['subject'], $sender, $email_array, false, $input['text']); //Now check if Swift actually sends it if ($result) { $status = true; $_SESSION['InviteCount'] = isset($_SESSION['InviteCount']) ? $_SESSION['InviteCount'] + count($email_array) : count($email_array); } else { MOD_log::write("MOD_mail: Failed to send a mail to " . implode(',', $email_array), "MOD_mail"); $problems['notsend'] = 'InviteNotSent'; $status = false; } } return array('status' => $status, 'problems' => $problems); }
/** * singleton getter * * @param void * @return PApps */ public static function get() { if (!isset(self::$_instance)) { $c = __CLASS__; self::$_instance = new $c(); } return self::$_instance; }
private function getNamePart($namePartId) { $namePart = ""; if ($namePartId == 0) { return $namePart; } if (MOD_crypt::IsCrypted($namePartId) == 1) { } else { $namePart = MOD_crypt::get_crypted($namePartId, ""); } return $namePart; }
private function informSuggestionTeam($suggestion) { // get all team members $query = "\r\n SELECT\r\n username\r\n FROM\r\n members, rights, rightsvolunteers\r\n WHERE\r\n members.Status = 'Active'\r\n AND members.id = rightsvolunteers.IdMember\r\n AND rights.`Name` = 'Suggestions'\r\n AND rightsvolunteers.IdRight = rights.id\r\n AND rightsvolunteers.Level > 0\r\n ORDER BY\r\n username\r\n "; $res = $this->dao->query($query); if (!$res) { return false; } $receivers = array(); while ($row = $res->fetch(PDB::FETCH_OBJ)) { $member = $this->createEntity('Member')->findByUsername($row->username); $email = MOD_crypt::AdminReadCrypted($member->Email); $receivers[$email] = "BW " . $row->username; } //Create the Transport $transport = Swift_SmtpTransport::newInstance('localhost', 25); //Create the Mailer using your created Transport $mailer = Swift_Mailer::newInstance($transport); $purifier = MOD_htmlpure::getSuggestionsHtmlPurifier(); $plain = 'Please check the suggestion and take the necessary <a href="' . PVars::getObj('env')->baseuri . 'suggestions/' . $suggestion->id . '/approve">action</a>.'; $html = $purifier->purify($suggestion->description) . '<br/>' . $plain; try { $creator = $this->createEntity('Member')->findById($suggestion->createdby); $message = Swift_Message::newInstance(); $message->setSubject("New suggestion added by " . $creator->Username . ": " . $suggestion->summary); $message->setFrom("*****@*****.**"); $message->setBcc($receivers); $message->addPart($html, 'text/html', 'utf-8'); $message->addPart($plain, 'text/plain', 'utf-8'); $message->setBody($plain); } catch (Exception $e) { $this->logWrite("In suggestions model creating mail message threw exception.", "suggestions"); return false; } //Now check if Swift actually sends it try { $sendResult = $mailer->send($message); } catch (Exception $e) { $this->logWrite("Exception when executing Swift_Mailer::send()", "suggestions"); $sendResult = false; } if ($sendResult) { return true; } else { $this->logWrite("In suggestions model swift::send: Failed to send mail.", "suggestions"); return false; } }
/** * This needs to go someplace else, * pending architectural attention */ protected function get_crypted($crypted_id, $return_value = "") { if ($crypted_id == "" or $crypted_id == 0) { return ""; } // check for Admin $right = new MOD_right(); if ($right->hasRight('Admin') || $right->hasRight('SafetyTeam')) { return urldecode(strip_tags(MOD_crypt::AdminReadCrypted($crypted_id))); } // check for Member's own data if ($this->edit_mode) { if (($mCrypt = MOD_crypt::MemberReadCrypted($crypted_id)) != "cryptedhidden") { return urldecode(strip_tags($mCrypt)); } } return urldecode(MOD_crypt::get_crypted($crypted_id, $return_value)); }
/** * Resend the confirmation mail in case the user clicked on the link in the * login error message * * @param string $username */ public function resendConfirmationMail($username) { // fetch ID for member $username $vars = array(); $MembersModel = new MembersModel(); $member = $MembersModel->getMemberWithUsername($username); if ($member) { if ($member->Status == 'MailToConfirm') { $vars['firstname'] = MOD_crypt::AdminReadCrypted($member->Firstname); $vars['secondname'] = MOD_crypt::AdminReadCrypted($member->Secondname); $vars['lastname'] = MOD_crypt::AdminReadCrypted($member->Lastname); $vars['email'] = MOD_crypt::AdminReadCrypted($member->Email); $userId = APP_User::userId($username); if (!$userId) { return 'NoSuchMember'; } else { $View = new SignupView($this); define('DOMAIN_MESSAGE_ID', 'bewelcome.org'); // TODO: config $View->registerMail($vars, $member->id, $userId); } } else { return 'NoMailToConfirm'; } } else { return 'NoSuchMember'; } return true; }
$out .= "<option value=\"{$i}\" selected=\"selected\">{$i}</option>"; } else { $out .= "<option value=\"{$i}\">{$i}</option>"; } } return $out; } $callback_tag = $this->layoutkit->formkit->setPostCallback('MembersController', 'updateMandatoryCallback'); $member = $this->member; $m->firstname = MOD_crypt::MemberReadCrypted($member->FirstName, ''); $m->secondname = MOD_crypt::MemberReadCrypted($member->SecondName, ''); $m->lastname = MOD_crypt::MemberReadCrypted($member->LastName, ''); $m->geonameid = $member->IdCity; $m->street = MOD_crypt::MemberReadCrypted($member->address->StreetName); $m->housenumber = MOD_crypt::MemberReadCrypted($member->address->HouseNumber); $m->zip = MOD_crypt::MemberReadCrypted($member->address->Zip); $m->birthday = date("d", strtotime($member->BirthDate)); $m->birthmonth = date("m", strtotime($member->BirthDate)); $selYear = date("Y", strtotime($member->BirthDate)); $birthYearOptions = buildBirthYearOptions($selYear); $m->gender = $member->Gender; // values from previous form submit if (!($mem_redirect = $this->layoutkit->formkit->getMemFromRedirect())) { // this is a fresh form foreach ($m as $key => $value) { $vars[$key] = $value; } $Geo = new GeoModel(); if (isset($vars['geonameid']) && !isset($vars['geonamename'])) { $vars['geonamename'] = $Geo->getDataById($vars['geonameid'])->name; }
/** * Update Member's Profile * * @param unknown_type $vars * @return unknown */ public function updateProfile(&$vars) { $IdMember = (int) $vars['memberid']; $words = new MOD_words(); $rights = new MOD_right(); $m = $vars['member']; // fantastic ... love the implementation. Fake $CanTranslate = false; // $CanTranslate = CanTranslate($vars["memberid"], $_SESSION['IdMember']); $ReadCrypted = "MemberReadCrypted"; // This might be changed in the future if ($rights->hasRight('Admin') || $rights->hasRight('SafetyTeam')) { // admin or CanTranslate can alter other profiles $ReadCrypted = "AdminReadCrypted"; // In this case the AdminReadCrypted will be used } $m->removeLanguages(); foreach ($vars['languages_selected'] as $lang) { if ($language = $this->createEntity('Language')->findById($lang->IdLanguage)) { $ml = $this->createEntity('MemberLanguage'); $ml->setSpokenLanguage($m, $language, $lang->Level); } } // Set the language that ReplaceinMTrad uses for writing $words->setlangWrite($vars['profile_language']); // refactoring to use member entity // $m->LastLogin = '******' ? 'Never' : $layoutbits->ago(strtotime($TM->LastLogin)); // Members lastlogin is no to be updated here if (isset($vars['Status']) && !empty($vars['Status'])) { // this can only happen when an admin or the safety team edits a profile $m->Status = $vars['Status']; } $m->Gender = $vars['gender']; $m->HideGender = $vars['HideGender']; $m->BirthDate = $vars['BirthYear'] . '-' . $vars['BirthMonth'] . '-' . $vars['BirthDay']; $m->bday = $vars['BirthDay']; $m->bmonth = $vars['BirthMonth']; $m->byear = $vars['BirthYear']; $m->HideBirthDate = $vars['HideBirthDate']; $m->HideGender = $vars['HideGender']; $m->ProfileSummary = $words->ReplaceInMTrad($vars['ProfileSummary'], "members.ProfileSummary", $IdMember, $m->ProfileSummary, $IdMember); $m->WebSite = strip_tags($vars['WebSite']); $m->Accomodation = $vars['Accomodation']; $m->Organizations = $words->ReplaceInMTrad($vars['Organizations'], "members.Organizations", $IdMember, $m->Organizations, $IdMember); $m->Occupation = $words->ReplaceInMTrad(strip_tags($vars['Occupation']), "members.Occupation", $IdMember, $m->Occupation, $IdMember); $m->ILiveWith = $words->ReplaceInMTrad($vars['ILiveWith'], "members.ILiveWith", $IdMember, $m->ILiveWith, $IdMember); $m->MaxGuest = strip_tags($vars['MaxGuest']); $m->MaxLenghtOfStay = $words->ReplaceInMTrad($vars['MaxLenghtOfStay'], "members.MaxLenghtOfStay", $IdMember, $m->MaxLenghtOfStay, $IdMember); $m->AdditionalAccomodationInfo = $words->ReplaceInMTrad($vars['AdditionalAccomodationInfo'], "members.AdditionalAccomodationInfo", $IdMember, $m->AdditionalAccomodationInfo, $IdMember); $m->TypicOffer = strip_tags($vars['TypicOffer']); $m->Restrictions = strip_tags($vars['Restrictions']); $m->OtherRestrictions = $words->ReplaceInMTrad($vars['OtherRestrictions'], "members.OtherRestrictions", $IdMember, $m->OtherRestrictions, $IdMember); $m->Hobbies = $words->ReplaceInMTrad($vars['Hobbies'], "members.Hobbies", $IdMember, $m->Hobbies, $IdMember); $m->Books = $words->ReplaceInMTrad($vars['Books'], "members.Books", $IdMember, $m->Books, $IdMember); $m->Music = $words->ReplaceInMTrad($vars['Music'], "members.Music", $IdMember, $m->Music, $IdMember); $m->Movies = $words->ReplaceInMTrad($vars['Movies'], "members.Movies", $IdMember, $m->Movies, $IdMember); $m->PastTrips = $words->ReplaceInMTrad($vars['PastTrips'], "members.PastTrips", $IdMember, $m->PastTrips, $IdMember); $m->PlannedTrips = $words->ReplaceInMTrad($vars['PlannedTrips'], "members.PlannedTrips", $IdMember, $m->PlannedTrips, $IdMember); $m->PleaseBring = $words->ReplaceInMTrad($vars['PleaseBring'], "members.PleaseBring", $IdMember, $m->PleaseBring, $IdMember); $m->OfferGuests = $words->ReplaceInMTrad($vars['OfferGuests'], "members.OfferGuests", $IdMember, $m->OfferGuests, $IdMember); $m->OfferHosts = $words->ReplaceInMTrad($vars['OfferHosts'], "members.OfferHosts", $IdMember, $m->OfferHosts, $IdMember); $m->PublicTransport = $words->ReplaceInMTrad($vars['PublicTransport'], "members.PublicTransport", $IdMember, $m->PublicTransport, $IdMember); // as $CanTranslate is set explicitly above, this is disabled // if (!$CanTranslate) { // a volunteer translator will not be allowed to update crypted data if ($vars["HouseNumber"] != $m->get_housenumber()) { $this->logWrite("Housenumber updated", "Address Update"); } if ($vars["Street"] != $m->get_street()) { $this->logWrite("Street updated", "Address Update"); } if ($vars["Zip"] != $m->get_zip()) { $this->logWrite("Zip updated", "Address Update"); } if ($vars["Email"] == "cryptedhidden") { $this->logWrite("members.model updateprofile email keeps previous value (cryptedhidden detected)", "Debug"); } else { if ($vars["Email"] != $m->email) { $this->logWrite("Email updated (previous was " . $m->email . ")", "Email Update"); // Sticking to old BW, the previous email is stored in logs, // this might be discussed, but if the member fills a bad email, // there is no more way to retrieve him // Todo : get rid with this, but implement a confimmation mail $m->Email = MOD_crypt::NewReplaceInCrypted(strip_tags($vars['Email']), "members.Email", $IdMember, $m->Email, $IdMember, $this->ShallICrypt($vars, "Email")); } } if ($vars["HomePhoneNumber"] != "cryptedhidden") { $m->HomePhoneNumber = MOD_crypt::NewReplaceInCrypted(addslashes(strip_tags($vars['HomePhoneNumber'])), "members.HomePhoneNumber", $IdMember, $m->HomePhoneNumber, $IdMember, $this->ShallICrypt($vars, "HomePhoneNumber")); } if ($vars["CellPhoneNumber"] != "cryptedhidden") { $m->CellPhoneNumber = MOD_crypt::NewReplaceInCrypted(addslashes(strip_tags($vars['CellPhoneNumber'])), "members.CellPhoneNumber", $IdMember, $m->CellPhoneNumber, $IdMember, $this->ShallICrypt($vars, "CellPhoneNumber")); } if ($vars["WorkPhoneNumber"] != "cryptedhidden") { $m->WorkPhoneNumber = MOD_crypt::NewReplaceInCrypted(addslashes(strip_tags($vars['WorkPhoneNumber'])), "members.WorkPhoneNumber", $IdMember, $m->WorkPhoneNumber, $IdMember, $this->ShallICrypt($vars, "WorkPhoneNumber")); } if ($vars["chat_SKYPE"] != "cryptedhidden") { $m->chat_SKYPE = MOD_crypt::NewReplaceInCrypted(addslashes(strip_tags($vars['chat_SKYPE'])), "members.chat_SKYPE", $IdMember, $m->chat_SKYPE, $IdMember, $this->ShallICrypt($vars, "chat_SKYPE")); } if ($vars["chat_AOL"] != "cryptedhidden") { $m->chat_AOL = MOD_crypt::NewReplaceInCrypted(addslashes(strip_tags($vars['chat_AOL'])), "members.chat_AOL", $IdMember, $m->chat_AOL, $IdMember, $this->ShallICrypt($vars, "chat_AOL")); } if ($vars["chat_YAHOO"] != "cryptedhidden") { $m->chat_YAHOO = MOD_crypt::NewReplaceInCrypted(addslashes(strip_tags($vars['chat_YAHOO'])), "members.chat_YAHOO", $IdMember, $m->chat_YAHOO, $IdMember, $this->ShallICrypt($vars, "chat_YAHOO")); } if ($vars["chat_ICQ"] != "cryptedhidden") { $m->chat_ICQ = MOD_crypt::NewReplaceInCrypted(addslashes(strip_tags($vars['chat_ICQ'])), "members.chat_ICQ", $IdMember, $m->chat_ICQ, $IdMember, $this->ShallICrypt($vars, "chat_ICQ")); } if ($vars["chat_Others"] != "cryptedhidden") { $m->chat_Others = MOD_crypt::NewReplaceInCrypted(addslashes(strip_tags($vars['chat_Others'])), "members.chat_Others", $IdMember, $m->chat_Others, $IdMember, $this->ShallICrypt($vars, "chat_Others")); } if ($vars["chat_GOOGLE"] != "cryptedhidden") { $m->chat_GOOGLE = MOD_crypt::NewReplaceInCrypted(addslashes(strip_tags($vars['chat_GOOGLE'])), "members.chat_GOOGLE", $IdMember, $m->chat_GOOGLE, $IdMember, $this->ShallICrypt($vars, "chat_GOOGLE")); } $firstname = MOD_crypt::AdminReadCrypted($m->FirstName); $secondname = MOD_crypt::AdminReadCrypted($m->SecondName); $lastname = MOD_crypt::AdminReadCrypted($m->LastName); if ($firstname != strip_tags($vars['FirstName']) || $secondname != strip_tags($vars['SecondName']) || $lastname != strip_tags($vars['LastName'])) { $this->logWrite("{$m->Username} changed name. Firstname: {$firstname} -> " . strip_tags($vars['FirstName']) . ", second name: {$secondname} -> " . strip_tags($vars['SecondName']) . ", second name: {$lastname} -> " . strip_tags($vars['LastName']), 'Profile update'); } if ($vars["FirstName"] != "cryptedhidden") { MOD_crypt::NewReplaceInCrypted($this->dao->escape(strip_tags($vars['FirstName'])), "members.FirstName", $IdMember, $m->FirstName, $IdMember, $this->ShallICrypt($vars, "FirstName")); } if ($vars["SecondName"] != "cryptedhidden") { $cryptId = MOD_crypt::NewReplaceInCrypted($this->dao->escape(strip_tags($vars['SecondName'])), "members.SecondName", $IdMember, $m->SecondName, $IdMember, $this->ShallICrypt($vars, "SecondName")); // Update member if a new crypted SecondName value was added if ($cryptId != $m->SecondName) { $m->SecondName = $cryptId; } } if ($vars["LastName"] != "cryptedhidden") { MOD_crypt::NewReplaceInCrypted($this->dao->escape(strip_tags($vars['LastName'])), "members.LastName", $IdMember, $m->LastName, $IdMember, $this->ShallICrypt($vars, "LastName")); } if ($vars["Zip"] != "cryptedhidden") { $this->logWrite("in members.model updateprofile() Before Zip update addresss.Zip=" . $m->address->Zip, "Debug"); $cryptId = MOD_crypt::NewReplaceInCrypted($this->dao->escape(strip_tags($vars['Zip'])), "addresses.Zip", $m->IdAddress, $m->address->Zip, $IdMember, $this->ShallICrypt($vars, "Zip")); // Update addresses table if a new crypted zip value was added if ($cryptId != $m->address->Zip) { $m->setCryptedZip($cryptId); } $this->logWrite("in members.model updateprofile() After Zip update addresss.Zip=" . $m->address->Zip . " \$cryptId=" . $cryptId, "Debug"); } if ($vars["HouseNumber"] != "cryptedhidden") { $cryptId = MOD_crypt::NewReplaceInCrypted($this->dao->escape(strip_tags($vars['HouseNumber'])), "addresses.HouseNumber", $m->IdAddress, $m->address->HouseNumber, $IdMember, $this->ShallICrypt($vars, "Address")); // Update addresses table if a new crypted HouseNumber value was added if ($cryptId != $m->address->HouseNumber) { $m->setCryptedHouseNumber($cryptId); } } if ($vars["Street"] != "cryptedhidden") { $cryptId = MOD_crypt::NewReplaceInCrypted($this->dao->escape(strip_tags($vars['Street'])), "addresses.StreetName", $m->IdAddress, $m->address->StreetName, $IdMember, $this->ShallICrypt($vars, "Address")); // Update addresses table if a new crypted StreetName value was added if ($cryptId != $m->address->StreetName) { $m->setCryptedStreetName($cryptId); } } // Check relations, and update them if they have changed $Relations = $m->get_all_relations(); foreach ($Relations as $Relation) { if ($words->mInTrad($Relation->Comment, $vars['profile_language']) != $vars["RelationComment_" . $Relation->id] and !empty($vars["RelationComment_" . $Relation->id])) { // echo "Relation #".$Relation->id,"<br />", $words->mInTrad($Relation->Comment,$vars['profile_language']),"<br />",$vars['RelationComment_'.$Relation->id],"<br />" ; $IdTrad = $words->ReplaceInMTrad(strip_tags($vars["RelationComment_" . $Relation->id]), "specialrelations.Comment", $Relation->id, $Relation->Comment, $IdMember); // Empty comments have trad id 0. Causing ReplaceInMTrad to create // a new trad id and returning the new number. if ($IdTrad != $Relation->id) { $m->update_relation($Relation->id, $IdTrad); } $this->logWrite("updating relation #" . $Relation->id . " Relation Confirmed=" . $Relation->Confirmed, "Profile update"); } } // Check groups membership description, and update them if they have changed // Tod od with Peter: check if there is other feature to update a group membership (a groupmembership model for example, or entity) /* group membership should not be present here, disabled for now $Groups=$m->getGroups() ; for ($i = 0; $i < count($Groups) ; $i++) { $group=$Groups[$i] ; $group_id = $group->getPKValue() ; $group_name_translated = $words->get("Group_".$group->Name); $group_comment_translated = htmlspecialchars($words->mInTrad($m->getGroupMembership($group)->Comment,$vars['profile_language']), ENT_QUOTES); $IdMemberShip=$m->getGroupMembership($group)->id ; if (($words->mInTrad($m->getGroupMembership($group)->Comment,$vars['profile_language'])!=$vars["GroupMembership_".$IdMemberShip]) and (!empty($vars["GroupMembership_".$IdMemberShip]))) { echo "Group #".$group_id,"<br />",$words->mInTrad($m->getGroupMembership($group)->Comment,$vars['profile_language']),"<br />",$vars["GroupMembership_".$IdMemberShip],"<br />" ; $words->ReplaceInMTrad(strip_tags($vars["GroupMembership_".$IdMemberShip]),"membersgroups.Comment", $IdMemberShip, $m->getGroupMembership($group)->Comment, $IdMember); $this->logWrite("updating membership description in group #".$group_id." Group name=".$group->name, "Profil update"); } } */ // if a member with status NeedMore updates her/his profile, moving them back to pending if ($m->Status == 'NeedMore') { $m->Status = 'Pending'; } $status = $m->update(); if (!empty($_FILES['profile_picture']) && !empty($_FILES['profile_picture']['tmp_name'])) { if (isset($_FILES['profile_picture']) && $_FILES['profile_picture']['error'] == 0) { $this->avatarMake($vars['memberid'], $_FILES['profile_picture']['tmp_name']); } } if ($IdMember == $_SESSION['IdMember']) { $this->logWrite("Profile update by member himself [Status={$m->Status}]", "Profile update"); } else { $this->logWrite("update of another profile <b>" . $m->Username . "</b>", "Profile update"); // It can be an admin update or a delegated translation update } return $status; }
protected function editMyProfileFormPrepare($member) { $member->setEditMode(true); $Rights = MOD_right::get(); $lang = $this->model->get_profile_language(); $profile_language = $lang->id; $profile_language_code = $lang->ShortCode; $profile_language_name = $lang->Name; $all_spoken_languages = $this->sortLanguages($member->get_all_spoken_languages()); $all_signed_languages = $this->sortLanguages($member->get_all_signed_languages()); $layoutkit = $this->layoutkit; $formkit = $layoutkit->formkit; $ReadCrypted = 'MemberReadCrypted'; if ($this->adminedit) { $ReadCrypted = 'AdminReadCrypted'; } $vars = array(); // Prepare $vars $vars['ProfileSummary'] = $member->ProfileSummary > 0 ? $member->get_trad('ProfileSummary', $profile_language) : ''; $vars['BirthDate'] = $member->BirthDate; list($vars['BirthYear'], $vars['BirthMonth'], $vars['BirthDay']) = explode('-', $member->BirthDate); $vars['HideBirthDate'] = $member->HideBirthDate; $vars['Occupation'] = $member->Occupation > 0 ? $member->get_trad('Occupation', $profile_language) : ''; $vars['Gender'] = $member->Gender; $vars['HideGender'] = $member->HideGender; if ($vars['Gender'] == 'IDontTell') { $vars['Gender'] = 'other'; $vars['HideGender'] = true; } $vars['language_levels'] = $member->language_levels; $vars['languages_all_spoken'] = $all_spoken_languages; $vars['languages_all_signed'] = $all_signed_languages; $vars['languages_selected'] = $member->languages_spoken; $vars['FirstName'] = $member->get_firstname(); $vars['SecondName'] = $member->get_secondname(); $vars['LastName'] = $member->get_lastname(); $vars['HouseNumber'] = $member->get_housenumber(); $vars['Street'] = $member->get_street(); $vars['Zip'] = $member->get_zip(); $vars['IsHidden_FirstName'] = MOD_crypt::IsCrypted($member->FirstName); $vars['IsHidden_SecondName'] = MOD_crypt::IsCrypted($member->SecondName); $vars['IsHidden_LastName'] = MOD_crypt::IsCrypted($member->LastName); $vars['IsHidden_Address'] = MOD_crypt::IsCrypted($member->address->StreetName); $vars['IsHidden_Zip'] = MOD_crypt::IsCrypted($member->address->Zip); $vars['IsHidden_HomePhoneNumber'] = MOD_crypt::IsCrypted($member->HomePhoneNumber); $vars['IsHidden_CellPhoneNumber'] = MOD_crypt::IsCrypted($member->CellPhoneNumber); $vars['IsHidden_WorkPhoneNumber'] = MOD_crypt::IsCrypted($member->WorkPhoneNumber); $vars['HomePhoneNumber'] = $member->HomePhoneNumber > 0 ? MOD_crypt::$ReadCrypted($member->HomePhoneNumber) : ''; $vars['CellPhoneNumber'] = $member->CellPhoneNumber > 0 ? MOD_crypt::$ReadCrypted($member->CellPhoneNumber) : ''; $vars['WorkPhoneNumber'] = $member->WorkPhoneNumber > 0 ? MOD_crypt::$ReadCrypted($member->WorkPhoneNumber) : ''; $vars['Email'] = $member->Email > 0 ? MOD_crypt::$ReadCrypted($member->Email) : ''; $vars['WebSite'] = $member->WebSite; $vars['messengers'] = $member->messengers(); $vars['Accomodation'] = $member->Accomodation; $vars['MaxGuest'] = $member->MaxGuest; $vars['MaxLenghtOfStay'] = $member->get_trad("MaxLenghtOfStay", $profile_language); $vars['ILiveWith'] = $member->get_trad("ILiveWith", $profile_language); $vars['PleaseBring'] = $member->get_trad("PleaseBring", $profile_language); $vars['OfferGuests'] = $member->get_trad("OfferGuests", $profile_language); $vars['OfferHosts'] = $member->get_trad("OfferHosts", $profile_language); $vars['TabTypicOffer'] = $member->TabTypicOffer; $vars['PublicTransport'] = $member->get_trad("PublicTransport", $profile_language); $vars['TabRestrictions'] = $member->TabRestrictions; $vars['OtherRestrictions'] = $member->get_trad("OtherRestrictions", $profile_language); $vars['AdditionalAccomodationInfo'] = $member->get_trad("AdditionalAccomodationInfo", $profile_language); $vars['OfferHosts'] = $member->get_trad("OfferHosts", $profile_language); $vars['Hobbies'] = $member->get_trad("Hobbies", $profile_language); $vars['Books'] = $member->get_trad("Books", $profile_language); $vars['Music'] = $member->get_trad("Music", $profile_language); $vars['Movies'] = $member->get_trad("Movies", $profile_language); $vars['Organizations'] = $member->get_trad("Organizations", $profile_language); $vars['PastTrips'] = $member->get_trad("PastTrips", $profile_language); $vars['PlannedTrips'] = $member->get_trad("PlannedTrips", $profile_language); $vars['Relations'] = $member->get_all_relations(); $vars['Groups'] = $member->getGroups(); if (!($memory = $formkit->getMemFromRedirect())) { // no memory // echo 'no memory'; } else { // from previous form if ($memory->post) { $post = $memory->post; foreach ($post as $key => $value) { $vars[$key] = $value; } // update $vars for messengers if (isset($vars['messengers'])) { $ii = 0; foreach ($vars['messengers'] as $me) { $val = 'chat_' . $me['network_raw']; $vars['messengers'][$ii++]['address'] = $vars[$val]; } } // update $vars for $languages if (!isset($vars['languages_selected'])) { $vars['languages_selected'] = array(); } $ii = 0; $ii2 = 0; $lang_used = array(); foreach ($vars['memberslanguages'] as $lang) { if (ctype_digit($lang) and !in_array($lang, $lang_used)) { // check $lang is numeric, hence a legal IdLanguage $vars['languages_selected'][$ii]->IdLanguage = $lang; $vars['languages_selected'][$ii]->Level = $vars['memberslanguageslevel'][$ii2]; array_push($lang_used, $vars['languages_selected'][$ii]->IdLanguage); $ii++; } $ii2++; } } // problems from previous form if (is_array($memory->problems)) { require_once 'edit_warning.php'; } } // var_dump($vars); return $vars; }
/** * This function loads the private data of member IdMember * @cid can be an id or a username of the member. * @given_password is the password sent with the form. * @return a structure with the data, or false if password/Username dont match **/ public function LoadPrivateData($cid, $given_password) { // comment by lemon-head: I think we should encrypt the pw on PHP side, not in SQL. // It is said in MySQL documentation // that the PASSWORD() function is not recommended to be used by applications. // - correct, but as long as we're stuck with the mysql password function (and for now // we are, then we either have to replicate the password function [it doesn't exist in php] // or rely on mysql. Sucks to be us. $data = new stdClass(); if (!($m = $this->checkPassword($cid, $given_password))) { // user not found! explain something? return array(); // Returns empty array if no value found } // Password has been verified, load the encrypted data foreach (array('FirstName', 'SecondName', 'LastName') as $key) { $data->{$key} = MOD_crypt::AdminReadCrypted($m->{$key}); } foreach (array('HouseNumber', 'StreetName', 'Zip') as $key) { if (!isset($m->address)) { $housenumber = $m->get_housenumber(); } $data->{$key} = MOD_crypt::AdminReadCrypted($m->address->{$key}); } $data->CityName = $m->get_city(); return $data; }
} $Member = new MembersModel(); // set the location $result = $Member->setLocation($vars['id'], $vars['geonameid']); $errors['Geonameid'] = 'Geoname not set'; if (count($result['errors']) > 0) { $vars['errors'] = $result['errors']; } // unset($_SESSION['GeoVars']); } $callback_tag = $this->layoutkit->formkit->setPostCallback('MembersController', 'setLocationCallback'); $member = $this->member; $m = new StdClass(); $m->firstname = MOD_crypt::MemberReadCrypted($member->FirstName, ''); $m->secondname = MOD_crypt::MemberReadCrypted($member->SecondName, ''); $m->lastname = MOD_crypt::MemberReadCrypted($member->LastName, ''); $m->geonameid = $member->IdCity; $m->id = $member->id; $mem_redirect = $this->layoutkit->formkit->getMemFromRedirect(); // values from previous form submit if (!$mem_redirect || !isset($mem_redirect->post['id'])) { // this is a fresh form foreach ($m as $key => $value) { $vars[$key] = $value; } if (isset($vars['geonameid']) && !isset($vars['geonamename'])) { $geo = new GeoModel(); $location = $geo->getLocationById($vars['geonameid']); if ($location) { $country = $location->getCountry(); $parent = $location->getParent();