Created
January 3, 2018 09:25
-
-
Save morozVA/97a18dddc21f2253cc059fce6193381c to your computer and use it in GitHub Desktop.
evo webloginPe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
В методе function Register в классе webloginPe просто | |
1. Напишите вместо строки | |
<code>$username = $_POST['username'];</code> | |
строку | |
<code>$username = $modx->db->escape($modx->stripTags($_POST['email']));</code> | |
2. Закомментируйте кусок кода чуть ниже (валидация username) | |
<code>if (!ctype_alnum($username)) | |
{ | |
return $this->FormatMessage($this->LanguageArray[32]); | |
}</code> | |
3. Сделайте в форме регистрации | |
<input type="hidden" name="username" value=""> | |
4. Сделайте при регистрации поле email обязательным | |
И все — вы получите username=email, а email — валидируется по правилам email и не допускает повторения. | |
webber | |
плагин вывода и сохранения дополнительных полей WebloginPE для админки | |
событие OnWebSaveUser | |
/********************************* | |
* webber | |
* плагин вывода и сохранения дополнительных полей WebloginPE для админки | |
/********************************** | |
* System Events: | |
* OnWUsrFormRender, OnWebSaveUser | |
* Конфигурация | |
* &fields=Поля;textarea;inn~ИНН|document~Документ&width=Ширина полей;string;300 | |
* В конфигурацию вносятся поля из перечня дополнительных полей WebloginPE | |
* и их русские названия для таблицы | |
***********************************/ | |
defined('IN_MANAGER_MODE') or die(); | |
$user_table = $modx->db->config['table_prefix']."web_user_attributes_extended"; | |
$e = &$modx->Event; | |
$output = ''; | |
if($e->name == 'OnWUsrFormRender'){//вывод полей в админке | |
$userid = isset($id) ? $id : 0; | |
$result = $modx->db->select("*", $user_table, "internalKey = '$userid'", "id ASC"); | |
if($modx->db->getRecordCount($result) > 0){ | |
if(IN_MANAGER_MODE==true && !isset($tpl)){ | |
if($fields!=''){ | |
$flds_config=explode("|",$fields); | |
$output.= ' | |
<div class="sectionHeader">Дополнительные поля</div> | |
<div class="sectionBody"> | |
<table border="0" cellspacing="0" cellpadding="3"> | |
'; | |
while($row = $modx->db->getRow($result,'assoc')){ | |
foreach ($flds_config as $k=>$v){ | |
$flds=explode("~",$v); | |
if(isset($row[$flds[0]])){ | |
$output .= "\n<tr>\n<td>".$flds[1].":</td>\n"; | |
$output .= '<td><input class="inputBox" style="width:'.$width.'px" type="text" name="ext__'.$flds[0].'" value="'.$row[$flds[0]].'" /></td></tr>'; | |
} | |
} | |
} | |
$output .= "\n</table>\n</div>\n"; | |
} | |
} | |
} | |
$e->output($output); | |
} | |
if($e->name == 'OnWebSaveUser'){//сохранение полей из админки | |
$mode = isset($mode) ? $mode : ''; | |
$userid = isset($userid) ? $userid : 0; | |
foreach($_POST as $key => $value){ | |
if(strpos($key,'ext__')!==false){ | |
$field_name = str_replace('ext__','',$key); | |
$customFields[$field_name]=$modx->db->escape($value); | |
} | |
} | |
if($mode=='upd'&&isset($customFields)){ | |
$result=$modx->db->update($customFields,$user_table,'`internalKey`='.$userid); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment