Esempio n. 1
0
 /**
  * Returns the user group
  *
  * @return Group
  */
 public function getGroup()
 {
     if (!is_object($this->_group_id)) {
         try {
             if (!is_numeric($this->_group_id)) {
                 $this->_group_id = tables\UserScopes::getTable()->getUserGroupIdByScope($this->getID(), framework\Context::getScope()->getID());
             }
             if (!is_numeric($this->_group_id)) {
                 $this->_group_id = framework\Settings::getDefaultGroup();
             } else {
                 $this->_group_id = tables\Groups::getTable()->selectById($this->_group_id);
             }
         } catch (\Exception $e) {
         }
     }
     return $this->_group_id;
 }
Esempio n. 2
0
?>
" id="defaultgroup" style="width: 400px;"<?php 
if ($access_level != \thebuggenie\core\framework\Settings::ACCESS_FULL) {
    ?>
 disabled<?php 
}
?>
>
                <?php 
foreach (\thebuggenie\core\entities\Group::getAll() as $aGroup) {
    ?>
                    <option value="<?php 
    print $aGroup->getID();
    ?>
"<?php 
    if (($default_group = \thebuggenie\core\framework\Settings::getDefaultGroup()) instanceof \thebuggenie\core\entities\Group && $default_group->getID() == $aGroup->getID()) {
        ?>
 selected<?php 
    }
    ?>
><?php 
    print $aGroup->getName();
    ?>
</option>
                <?php 
}
?>
            </select>
            <?php 
echo config_explanation(__('New users will automatically be added to this group'));
?>
Esempio n. 3
0
 /**
  * Registration logic
  *
  * @Route(name="register", url="/do/register")
  * @AnonymousRoute
  *
  * @param \thebuggenie\core\framework\Request $request
  */
 public function runRegister(framework\Request $request)
 {
     framework\Context::loadLibrary('common');
     $i18n = framework\Context::getI18n();
     $fields = array();
     try {
         $username = mb_strtolower(trim($request['fieldusername']));
         $buddyname = $request['buddyname'];
         $email = mb_strtolower(trim($request['email_address']));
         $confirmemail = mb_strtolower(trim($request['email_confirm']));
         $security = $request['verification_no'];
         $realname = $request['realname'];
         $available = tables\Users::getTable()->isUsernameAvailable($username);
         if (!$available) {
             throw new \Exception($i18n->__('This username is in use'));
         }
         if (!empty($buddyname) && !empty($email) && !empty($confirmemail) && !empty($security)) {
             if ($email != $confirmemail) {
                 array_push($fields, 'email_address', 'email_confirm');
                 throw new \Exception($i18n->__('The email address must be valid, and must be typed twice.'));
             }
             if ($security != $_SESSION['activation_number']) {
                 array_push($fields, 'verification_no');
                 throw new \Exception($i18n->__('To prevent automatic sign-ups, enter the verification number shown below.'));
             }
             $email_ok = false;
             if (tbg_check_syntax($email, "EMAIL")) {
                 $email_ok = true;
             }
             if ($email_ok && framework\Settings::get('limit_registration') != '') {
                 $allowed_domains = preg_replace('/[[:space:]]*,[[:space:]]*/', '|', framework\Settings::get('limit_registration'));
                 if (preg_match('/@(' . $allowed_domains . ')$/i', $email) == false) {
                     array_push($fields, 'email_address', 'email_confirm');
                     throw new \Exception($i18n->__('Email adresses from this domain can not be used.'));
                 }
             }
             if ($email_ok == false) {
                 array_push($fields, 'email_address', 'email_confirm');
                 throw new \Exception($i18n->__('The email address must be valid, and must be typed twice.'));
             }
             if ($security != $_SESSION['activation_number']) {
                 array_push($fields, 'verification_no');
                 throw new \Exception($i18n->__('To prevent automatic sign-ups, enter the verification number shown below.'));
             }
             $password = entities\User::createPassword();
             $user = new entities\User();
             $user->setUsername($username);
             $user->setRealname($realname);
             $user->setBuddyname($buddyname);
             $user->setGroup(framework\Settings::getDefaultGroup());
             $user->setEnabled();
             $user->setPassword($password);
             $user->setEmail($email);
             $user->setJoined();
             $user->save();
             $_SESSION['activation_number'] = tbg_printRandomNumber();
             if ($user->isActivated()) {
                 framework\Context::setMessage('auto_password', $password);
                 return $this->renderJSON(array('loginmessage' => $i18n->__('After pressing %continue, you need to set your password.', array('%continue' => $i18n->__('Continue'))), 'one_time_password' => $password, 'activated' => true));
             }
             return $this->renderJSON(array('loginmessage' => $i18n->__('The account has now been registered - check your email inbox for the activation email. Please be patient - this email can take up to two hours to arrive.'), 'activated' => false));
         } else {
             array_push($fields, 'email_address', 'email_confirm', 'buddyname', 'verification_no');
             throw new \Exception($i18n->__('You need to fill out all fields correctly.'));
         }
     } catch (\Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => $i18n->__($e->getMessage()), 'fields' => $fields));
     }
 }
\thebuggenie\core\framework\Event::createNew('core', 'config.createuser.email')->trigger();
?>
                                            <dt><label for="adduser_group"><?php 
echo __('Add user to group');
?>
:</label></dt>
                                            <dd>
                                                <select name="group_id">
                                                    <?php 
foreach ($groups as $group) {
    ?>
                                                        <option value="<?php 
    echo $group->getID();
    ?>
" <?php 
    if ($group->getID() == \thebuggenie\core\framework\Settings::getDefaultGroup()->getID()) {
        echo ' selected';
    }
    ?>
><?php 
    echo $group->getName();
    ?>
</option>
                                                    <?php 
}
?>
                                                </select>
                                            </dd>
                                            <dt><label for="adduser_teams"><?php 
echo __('Add user to team(s)');
?>