Exemplo n.º 1
0
 function activate()
 {
     $mainframe = JFactory::getApplication();
     // Initialize some variables
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $document = JFactory::getDocument();
     $pathway =& $mainframe->getPathWay();
     $usersConfig = JComponentHelper::getParams('com_users');
     $userActivation = $usersConfig->get('useractivation');
     $allowUserRegistration = $usersConfig->get('allowUserRegistration');
     // Check to see if they're logged in, because they don't need activating!
     if ($user->get('id')) {
         // They're already logged in, so redirect them to the home page
         $mainframe->redirect('index.php');
     }
     if ($allowUserRegistration == '0' || $userActivation == '0') {
         JError::raiseError(403, JText::_('Access Forbidden'));
         return;
     }
     // create the view
     require_once JPATH_COMPONENT . DS . 'views' . DS . 'register' . DS . 'view.html.php';
     $view = new UserViewRegister();
     $message = new stdClass();
     // Do we even have an activation string?
     $activation = JRequest::getVar('activation', '', '', 'alnum');
     $activation = $db->getEscaped($activation);
     if (empty($activation)) {
         // Page Title
         $document->setTitle(JText::_('REG_ACTIVATE_NOT_FOUND_TITLE'));
         // Breadcrumb
         $pathway->addItem(JText::_('REG_ACTIVATE_NOT_FOUND_TITLE'));
         $message->title = JText::_('REG_ACTIVATE_NOT_FOUND_TITLE');
         $message->text = JText::_('REG_ACTIVATE_NOT_FOUND');
         $view->assign('message', $message);
         $view->display('message');
         return;
     }
     // Lets activate this user
     jimport('joomla.user.helper');
     if (JUserHelper::activateUser($activation)) {
         // Page Title
         $document->setTitle(JText::_('REG_ACTIVATE_COMPLETE_TITLE'));
         // Breadcrumb
         $pathway->addItem(JText::_('REG_ACTIVATE_COMPLETE_TITLE'));
         $message->title = JText::_('REG_ACTIVATE_COMPLETE_TITLE');
         $message->text = JText::_('REG_ACTIVATE_COMPLETE');
     } else {
         // Page Title
         $document->setTitle(JText::_('REG_ACTIVATE_NOT_FOUND_TITLE'));
         // Breadcrumb
         $pathway->addItem(JText::_('REG_ACTIVATE_NOT_FOUND_TITLE'));
         $message->title = JText::_('REG_ACTIVATE_NOT_FOUND_TITLE');
         $message->text = JText::_('REG_ACTIVATE_NOT_FOUND');
     }
     $view->assign('message', $message);
     $view->display('message');
 }
Exemplo n.º 2
0
 function activateuser()
 {
     global $mainframe;
     // Initialize some variables
     $db =& JFactory::getDBO();
     $user =& JFactory::getUser();
     $document =& JFactory::getDocument();
     $pathway =& $mainframe->getPathWay();
     $usersConfig =& JComponentHelper::getParams('com_users');
     $userActivation = $usersConfig->get('useractivation');
     $allowUserRegistration = $usersConfig->get('allowUserRegistration');
     // Check to see if they're logged in, because they don't need activating!
     if ($user->get('id')) {
         // They're already logged in, so redirect them to the home page
         $mainframe->redirect('index.php');
     }
     if ($allowUserRegistration == '0' || $userActivation == '0') {
         JError::raiseError(403, JText::_('Access Forbidden'));
         return;
     }
     // create the view
     require_once JPATH_COMPONENT . DS . 'views' . DS . 'register' . DS . 'view.html.php';
     $view = new UserViewRegister();
     $message = new stdClass();
     // Do we even have an activation string?
     $activation = JRequest::getVar('activation', '', '', 'alnum');
     $activation = $db->getEscaped($activation);
     if (empty($activation)) {
         // Page Title
         $document->setTitle(JText::_('REG_ACTIVATE_NOT_FOUND_TITLE'));
         // Breadcrumb
         $pathway->addItem(JText::_('REG_ACTIVATE_NOT_FOUND_TITLE'));
         $message->title = JText::_('REG_ACTIVATE_NOT_FOUND_TITLE');
         $message->text = JText::_('REG_ACTIVATE_NOT_FOUND');
         $view->assign('message', $message);
         $view->display('message');
         return;
     }
     $query = 'SELECT id' . ' FROM #__users' . ' WHERE activation = ' . $db->Quote($activation) . ' AND block = 1' . ' AND lastvisitDate = ' . $db->Quote('0000-00-00 00:00:00');
     $db->setQuery($query);
     $userid = intval($db->loadResult());
     // Lets activate this user
     jimport('joomla.user.helper');
     if (JUserHelper::activateUser($activation)) {
         // Page Title
         $document->setTitle(JText::_('REG_ACTIVATE_COMPLETE_TITLE'));
         // Breadcrumb
         $pathway->addItem(JText::_('REG_ACTIVATE_COMPLETE_TITLE'));
         $message->title = JText::_('REG_ACTIVATE_COMPLETE_TITLE');
         $message->text = JText::_('REG_ACTIVATE_COMPLETE');
         if ($userid != 0) {
             $query = "select profile_id from #__community_users where userid={$userid}";
             $db->setQuery($query);
             $profileInfo = $db->loadObject();
             //If profile exists
             if ($profileInfo !== false) {
                 /* HOOKED - no profile ID
                 					//If user is a contractor
                 					if($profileInfo->profile_id == 2) // Contractor Profile ID is 2
                 					{
                 */
                 //Forward user to Saasy
                 $this->setRedirect("http://sites.fastspring.com/{$this->company}/product/{$this->product}");
                 /* 					}	 */
             }
         }
     } else {
         // Page Title
         $document->setTitle(JText::_('REG_ACTIVATE_NOT_FOUND_TITLE'));
         // Breadcrumb
         $pathway->addItem(JText::_('REG_ACTIVATE_NOT_FOUND_TITLE'));
         $message->title = JText::_('REG_ACTIVATE_NOT_FOUND_TITLE');
         $message->text = JText::_('REG_ACTIVATE_NOT_FOUND');
     }
     $view->assign('message', $message);
     $view->display('message');
 }