Exemplo n.º 1
0
 /**
  * @todo document this
  */
 function action_memberadd()
 {
     global $member, $manager;
     // check if allowed
     $member->isAdmin() or $this->disallow();
     if (postVar('password') != postVar('repeatpassword')) {
         $this->error(_ERROR_PASSWORDMISMATCH);
     }
     if (strlen(postVar('password')) < 6) {
         $this->error(_ERROR_PASSWORDTOOSHORT);
     }
     $res = MEMBER::create(postVar('name'), postVar('realname'), postVar('password'), postVar('email'), postVar('url'), postVar('admin'), postVar('canlogin'), postVar('notes'));
     if ($res != 1) {
         $this->error($res);
     }
     // fire PostRegister event
     $newmem = new MEMBER();
     $newmem->readFromName(postVar('name'));
     $manager->notify('PostRegister', array('member' => &$newmem));
     $this->action_usermanagement();
 }
Exemplo n.º 2
0
 /**
  *  Creates a new user account
  */
 function createAccount()
 {
     global $CONF, $manager;
     if (!$CONF['AllowMemberCreate']) {
         doError(_ERROR_MEMBERCREATEDISABLED);
     }
     // evaluate content from FormExtra
     $result = 1;
     $data = array('type' => 'membermail', 'error' => &$result);
     $manager->notify('ValidateForm', &$data);
     if ($result != 1) {
         return $result;
     } else {
         // even though the member can not log in, set some random initial password. One never knows.
         srand((double) microtime() * 1000000);
         $initialPwd = md5(uniqid(rand(), TRUE));
         // create member (non admin/can not login/no notes/random string as password)
         $name = shorten(postVar('name'), 32, '');
         $r = MEMBER::create($name, postVar('realname'), $initialPwd, postVar('email'), postVar('url'), 0, 0, '');
         if ($r != 1) {
             return $r;
         }
         // send message containing password.
         $newmem = new MEMBER();
         $newmem->readFromName($name);
         $newmem->sendActivationLink('register');
         $manager->notify('PostRegister', array('member' => &$newmem));
         if (postVar('desturl')) {
             redirect(postVar('desturl'));
         } else {
             // header has been already sent, so deleted the line below
             sendContentType('text/html', '', _CHARSET);
             echo _MSG_ACTIVATION_SENT;
             echo '<br /><br />Return to <a href="' . $CONF['IndexURL'] . '" title="' . $CONF['SiteName'] . '">' . $CONF['SiteName'] . '</a>';
             echo "\n</body>\n</html>";
         }
         exit;
     }
 }