Ejemplo n.º 1
0
    /**
     * Action to handle getting a confirmation code. Confirms user and spits out
     * a success page if the code checks out... spits out an error page otherwise
     */
    public function executeConfirmUser()
    {
        $user = UserPeer::doSelectFromConfirmationCode($this->getRequestParameter('code'));
        if (!$user) {
            $newCode = $this->getRequestParameter('code');
            $oC = new Criteria();
            $oC->add(UserPeer::ID, "SHA1(CONCAT(user.password, 'salt', user.id)) = '{$newCode}'", Criteria::CUSTOM);
            $oC->add(UserPeer::TYPE, '1');
            $userCheck = UserPeer::doSelectOne($oC);
            if (!$userCheck) {
                return sfView::ERROR;
            }
        }
        if ($user) {
            $user->setTypeConfirmed();
            $user->save();
        }
        if ($user) {
            $this->getUser()->signIn($user);
        } else {
            $this->getUser()->signIn($userCheck);
        }
        if ($kinkarsoUser) {
            if ($user) {
                $query = mysql_query("select * from  shout where recipient_id=" . $user->getId() . " and  poster_id=" . $kinkarsoUser->getId() . "") or die(mysql_error());
                if (mysql_num_rows($query) == 0) {
                    ShoutPeer::createWelcomeComment($user, $kinkarsoUser);
                }
            }
            $subject = 'Here\'s how to start tutoring on Rayku';
            if ($user) {
                $body = 'Hey ' . $user->getName() . ', welcome to Rayku.com!<br><br>';
            }
            $body .= 'Thanks for joining our community!<br><br>

                Before you get started, there are 3 important steps before you can start tutoring!<br><br>
                1) Activated your tutor status by clicking \'on\' in your <a href="' . sfConfig::get('app_rayku_url') . '/dashboard">dashboard page</a>.<br>
                2) Important: Learn how to tutor on Rayku in 10 minutes by watching our <a href="' . sfConfig::get('app_rayku_url') . '/tutorshelp">tutor help videos</a>.<br>
                3) Prepare to receive question notifications by connecting to our <strong><a href="' . sfConfig::get('app_notification_bot_url') . '/download/rayku.dmg">MacOS</a> / <a href="http://notification-bot.rayku.com/download/rayku.exe">Windows</a> notification software</strong>, <a href="http://rayku.com/dashboard/gtalk">google talk</a> and <a href="http://rayku.com/dashboard/facebook">facebook chat</a>.<br><br>

                Enjoy, and do let us know if you ever have any questions - we\'re here to help!<br><br>

                Thanks!<br>
                Rayku Administration';
            $currentuser = $kinkarsoUser;
            //Send the message
            if ($user) {
                $currentuser->sendMessage($user->getId(), $subject, $body);
            }
        }
        $this->forward('regtutor', 'profile');
    }