Php joomla 1.7用户注册定制问题
->我正在尝试新的用户注册定制 ->为此,我通过控制器中的调用函数创建表单和隐藏变量 ->在controller save function中,我编写了这段代码,但有些内部函数在1.7中不起作用,所以在这里产生了问题Php joomla 1.7用户注册定制问题,php,joomla,joomla-extensions,joomla1.7,Php,Joomla,Joomla Extensions,Joomla1.7,->我正在尝试新的用户注册定制 ->为此,我通过控制器中的调用函数创建表单和隐藏变量 ->在controller save function中,我编写了这段代码,但有些内部函数在1.7中不起作用,所以在这里产生了问题 function register_save() { global $mainframe; $db =& JFactory::getDBO(); // Check for request forgeries JRequest::ch
function register_save()
{
global $mainframe;
$db =& JFactory::getDBO();
// Check for request forgeries
JRequest::checkToken() or jexit( 'Invalid Token' );
//clean request
$post = JRequest::get( 'post' );
$post['username'] = JRequest::getVar('username', '', 'post', 'username');
$post['password'] = JRequest::getVar('password', '', 'post', 'string', JREQUEST_ALLOWRAW);
$post['password2'] = JRequest::getVar('password2', '', 'post', 'string', JREQUEST_ALLOWRAW);
// get the redirect
$return = JURI::base();
// do a password safety check
if(strlen($post['password']) || strlen($post['password2'])) { // so that "0" can be used as password e.g.
if($post['password'] != $post['password2']) {
$msg = JText::_('PASSWORD NOT MATCH');
// something is wrong. we are redirecting back to edit form.
// TODO: HTTP_REFERER should be replaced with a base64 encoded form field in a later release
$return = str_replace(array('"', '<', '>', "'"), '', @$_SERVER['HTTP_REFERER']);
if (empty($return) || !JURI::isInternal($return)) {
$return = JURI::base();
}
$this->setRedirect($return, $msg, 'error');
return false;
}
}
// Get required system objects
$user = clone(JFactory::getUser());
$pathway = JFactory::getApplication();
//$pathway =& $mainframe->getPathway();
$config =& JFactory::getConfig();
//print_r($config)."<br>";
$authorize =& JFactory::getACL();
//print_r($authorize)."<br>"; /// some mistake here
$newUsertype = 'Registered';
// Bind the post array to the user object
if (!$user->bind( JRequest::get('post'), 'usertype' )) {
JError::raiseError( 500, $user->getError());
}
// Set some initial user values
$user->set('id', 0);
$user->set('usertype', $newUsertype);
$user->set('gid', $authorize->get_group_id( '', $newUsertype, 'ARO' ));
$date =& JFactory::getDate();
$user->set('registerDate', $date->toMySQL());
// If user activation is turned on, we need to set the activation information
jimport('joomla.user.helper');
$user->set('activation', JUtility::getHash( JUserHelper::genRandomPassword()) );
$user->set('block', '1');
// If there was an error with registration, set the message and display form
if ( !$user->save() )
{
JError::raiseWarning('', JText::_( $user->getError()));
$this->register();
return false;
}
$obj1 = new stdClass();
$obj1->userid = $user->id;
$obj1->points = 0;
$obj1->posted_on = $date->toMySQL();
$obj1->avatar = '';
$obj1->thumb = '';
$obj1->params = 'notifyEmailSystem=1
privacyProfileView=0
privacyPhotoView=0
privacyFriendsView=0
privacyVideoView=1
notifyEmailMessage=1
notifyEmailApps=1
notifyWallComment=0';
$db->insertObject('#__community_users', $obj1, 'userid');
$extra_field = array(1=>2,2=>3,3=>4,4=>6,5=>7,6=>8,7=>9,8=>10,9=>11,10=>12,11=>14,12=>15,13=>16);
$i = 1;
$obj2 = new stdClass();
while($extra_field[$i] != "")
{
$obj2->id = '';
$obj2->user_id = $user->id;
$obj2->field_id = $extra_field[$i];
$obj2->value = '';
$db->insertObject('#__community_fields_values', $obj2, 'id');
$i++;
}
////////// end of joomsocial customisation///////////////////////////
// Send registration confirmation mail
$password = JRequest::getString('password', '', 'post', JREQUEST_ALLOWRAW);
$password = preg_replace('/[\x00-\x1F\x7F]/', '', $password); //Disallow control chars in the email
UserControllerRegister::_sendMail($user, $password);
// Everything went fine, set relevant message depending upon user activation state and display message
$message = JText::_( 'Your account has been created and an activation link has been sent to the e-mail address you entered. Note that you must activate the account by clicking on the activation link when you get the e-mail before you can login.' );
$this->setRedirect('index.php', $message);
}
函数寄存器\保存()
{
全球$大型机;
$db=&JFactory::getDBO();
//检查请求是否伪造
JRequest::checkToken()或jexit('Invalid Token');
//清洁要求
$post=JRequest::get('post');
$post['username']=JRequest::getVar('username',''post','username');
$post['password']=JRequest::getVar('password','','post','string',JRequest_ALLOWRAW);
$post['password2']=JRequest::getVar('password2','post','string',JRequest_ALLOWRAW);
//获取重定向
$return=JURI::base();
//进行密码安全检查
如果(strlen($post['password'])| strlen($post['password2']){//,那么“0”可以用作密码,例如。
如果($post['password']!=$post['password2']){
$msg=JText::((“密码不匹配”);
//出现问题。我们正在重定向回编辑表单。
//TODO:在以后的版本中,HTTP_REFERER应替换为base64编码的表单字段
$return=str_replace(数组(“,”,“,”,@$_服务器['HTTP_REFERER']);
if(空($return)| |!JURI::isInternal($return)){
$return=JURI::base();
}
$this->setRedirect($return,$msg,'error');
返回false;
}
}
//获取所需的系统对象
$user=clone(JFactory::getUser());
$PATH=JFactory::getApplication();
//$pathway=&$mainframe->getPathway();
$config=&JFactory::getConfig();
//打印($config)。“
”;
$authorize=&JFactory::getACL();
//打印($authorize)。“
”;///这里有些错误
$newUsertype='Registered';
//将post数组绑定到用户对象
if(!$user->bind(JRequest::get('post'),'usertype')){
JError::raiseError(500,$user->getError());
}
//设置一些初始用户值
$user->set('id',0);
$user->set('usertype',$newUsertype);
$user->set('gid',$authorize->get_group_id('',$newUsertype,'ARO');
$date=&JFactory::getDate();
$user->set('registerDate',$date->toMySQL());
//如果用户激活已打开,则需要设置激活信息
jimport('joomla.user.helper');
$user->set('activation',JUtility::getHash(JUserHelper::genRandomPassword());
$user->set('block','1');
//如果注册出错,请设置消息和显示表单
如果(!$user->save())
{
JError::raiseWarning(“”,JText::($user->getError());
$this->register();
返回false;
}
$obj1=新的stdClass();
$obj1->userid=$user->id;
$obj1->points=0;
$obj1->posted_on=$date->toMySQL();
$obj1->avatar='';
$obj1->thumb='';
$obj1->params='notifyEmailSystem=1
privacyProfileView=0
privacyPhotoView=0
privacyFriendsView=0
privacyVideoView=1
notifyEmailMessage=1
notifyEmailApps=1
notifyWallComment=0';
$db->insertObject(“#u社区u用户“,$obj1,'userid”);
$extra_field=array(1=>2,2=>3,3=>4,4=>6,5=>7,6=>8,7=>9,8=>10,9=>11,10=>12,11=>14,12=>15,13=>16);
$i=1;
$obj2=新的stdClass();
而($extra_字段[$i]!=“”)
{
$obj2->id='';
$obj2->user\u id=$user->id;
$obj2->field_id=$extra_field[$i];
$obj2->value='';
$db->insertObject(“#(社区)字段(值“,$obj2,'id”);
$i++;
}
//////////工作结束社会化定制////////
//发送注册确认邮件
$password=JRequest::getString('password','post',JRequest_ALLOWRAW);
$password=preg_replace('/[\x00-\x1F\x7F]/',''$password);//不允许在电子邮件中使用控制字符
UserControllerRegister::\u sendMail($user,$password);
//一切正常,根据用户激活状态设置相关消息并显示消息
$message=JText::(“您的帐户已创建,并且激活链接已发送到您输入的电子邮件地址。请注意,您必须在收到电子邮件后单击激活链接来激活帐户,然后才能登录。”;
$this->setRedirect('index.php',$message);
}
- 不在表中插入记录。 请帮帮我
- 我认为你是对的:
Joomla 1.5 ACL(访问控制列表)是分层的:每个用户组从其下面的组继承权限。
在Joomla 1.7中,ACL不一定是分层的。您可以使用任何权限设置组。
Joomla 1.5和1.7中ACL的区别不仅在于行为,还在于实现!这意味着身份验证/注册机制将以不同的方式实现:
代码太多了,不确定所有代码是否都相关。请注明所有不相关的代码,手动输入插入参数的值,然后尝试调用此方法,看看插入是否有效。如果有效,请开始调试并查看您收到的值感谢重播,我认为$authorize=&JFactory::getA的代码存在一些问题CL();这里我打印了这个,但是它给了我类似JAccess对象的输出()-如果我在1.5中运行它,那么它给了我类似JAuthorization对象的大数组([acl]=>array([0]=>array([0]=>com_user[1]=>edit…))我认为这里有一些问题