function install($aParams) { $bInclude = @(include $this->sFilePath); if (!$bInclude || empty($LANG) || empty($LANG_INFO) || !$this->_addLanguage($LANG, $LANG_INFO)) { return array('operation_title' => _t('_adm_txt_modules_operation_install', $this->_aConfig['title']), 'message' => 'Language file parse error or such language already exists: ' . $this->sFileName, 'result' => false); } $iLangId = getLangIdByName($LANG_INFO['Name']); $this->_recompileLanguageForAllModules($iLangId); compileLanguage($iLangId); return parent::install($aParams); }
function createProfile($aData, $bSendMails = true, $iMainMemberID = 0) { if (!$aData or !is_array($aData) or empty($aData)) { return false; } unset($aData['Couple']); unset($aData['Captcha']); unset($aData['TermsOfUse']); unset($aData['ProfilePhoto']); /* @var $this ->oPF BxDolProfileFields */ $this->oPF = new BxDolProfileFields(100); if (!$this->oPF->aArea) { echo 'Profile Fields cache not loaded. Cannot continue.'; return false; } $this->aItems = $this->oPF->aArea[0]['Items']; if ($iMainMemberID) { $aMainMember = $this->getProfileInfo($iMainMemberID); } else { $aMainMember = false; } // begin profile info collecting $aNewProfile = array(); foreach ($this->aItems as $aItem) { $sItemName = $aItem['Name']; if (array_key_exists($sItemName, $aData)) { $aNewProfile[$sItemName] = $aData[$sItemName]; } elseif ($aMainMember and array_key_exists($sItemName, $aMainMember) and $aItem['Type'] != 'system') { if ($aItem['Unique']) { $aNewProfile[$sItemName] = $this->genUniqueValue($sItemName, $aMainMember[$sItemName]); } else { $aNewProfile[$sItemName] = $aMainMember[$sItemName]; } } else { switch ($aItem['Type']) { case 'pass': $aNewProfile[$sItemName] = $this->genRandomPassword(); break; case 'num': $aNewProfile[$sItemName] = (int) $aItem['Default']; break; case 'bool': $aNewProfile[$sItemName] = (bool) $aItem['Default']; break; case 'system': switch ($sItemName) { case 'ID': //set automatically //set automatically case 'Captcha': //not been inserted //not been inserted case 'Location': //not been inserted //not been inserted case 'Keyword': //not been inserted //not been inserted case 'TermsOfUse': //not been inserted //pass break; case 'DateReg': $aNewProfile[$sItemName] = date('Y-m-d H:i:s'); // set current date break; case 'DateLastEdit': case 'DateLastLogin': $aNewProfile[$sItemName] = '0000-00-00'; break; case 'Couple': $aNewProfile[$sItemName] = $aMainMember ? $iMainMemberID : 0; //if main member exists, set him as a couple link break; case 'Featured': $aNewProfile[$sItemName] = false; break; case 'Status': if (getParam('autoApproval_ifNoConfEmail') == 'on') { if (getParam('autoApproval_ifJoin') == 'on' && !(getParam('sys_dnsbl_enable') && 'approval' == getParam('sys_dnsbl_behaviour') && bx_is_ip_dns_blacklisted('', 'join'))) { $aNewProfile[$sItemName] = 'Active'; } else { $aNewProfile[$sItemName] = 'Approval'; } } else { $aNewProfile[$sItemName] = 'Unconfirmed'; } break; } break; default: $aNewProfile[$sItemName] = $aItem['Default']; } } } //we completed collecting // set default language $aNewProfile['LangID'] = getLangIdByName(getCurrentLangName()); // set default privacy bx_import('BxDolPrivacyQuery'); $oPrivacy = new BxDolPrivacyQuery(); $aNewProfile['allow_view_to'] = $oPrivacy->getDefaultValueModule('profile', 'view_block'); $sSet = $this->collectSetString($aNewProfile); $sQuery = "INSERT INTO `Profiles` SET \n{$sSet}"; $rRes = db_res($sQuery); if ($rRes) { $iNewID = db_last_id(); $this->createProfileCache($iNewID); if ($aMainMember) { $this->updateProfile($iMainMemberID, array('Couple' => $iNewID)); } //set main member's couple. they will be linked each other //collect status text if ($bSendMails and !$aMainMember) { //send mail only to main member, not to couple $sStatusText = $aNewProfile['Status']; if (getParam('autoApproval_ifNoConfEmail') == 'on') { if ('Active' == $sStatusText) { $this->sendActivationMail($iNewID); } else { $this->sendApprovalMail($iNewID); } } else { if (!$this->sendConfMail($iNewID)) { $sStatusText = 'NotSent'; } } } else { $sStatusText = 'OK'; } //set crypted password $sSalt = genRndSalt(); $this->updateProfile($iNewID, array('Password' => encryptUserPwd($aNewProfile['Password'], $sSalt), 'Salt' => $sSalt)); bx_member_ip_store($iNewID); return array($iNewID, $sStatusText); } else { return array(false, 'Failed'); } }
function _removeLanguage($aLanguage, $aLangInfo) { $oDb = new BxDolModuleDb(); if (!($iLangKey = getLangIdByName($aLangInfo['Name']))) { // language doesn't exists, so it is already removed somehow return true; } if (!$oDb->res("DELETE FROM `sys_localization_languages` WHERE ID = {$iLangKey}")) { return false; } $oDb->res("DELETE FROM `sys_localization_strings` WHERE `IDLanguage` = {$iLangKey}"); return true; }
function setLangCookie($sLang) { $iProfileId = getLoggedId(); if ($iProfileId) { $iLangID = getLangIdByName($sLang); if (!$iLangID) { $iLangID = 0; } db_res('UPDATE `Profiles` SET `LangID` = ' . (int) $iLangID . ' WHERE `ID` = ' . (int) $_COOKIE['memberID']); // recompile profile cache ; createUserDataFile($iProfileId); } setcookie('lang', '', time() - 60 * 60 * 24, '/'); setcookie('lang', $sLang, time() + 60 * 60 * 24 * 365, '/'); }