4 * assignment management - for supplier.s
8 * _createPasswd : 1 = generate a password
9 * rawPasswd : use this as a password
11 * _create : 1 (create the account)
12 * email : email address
13 * if _createPassword is empty and rawPasswd is empty, then no message is sent.!!!!
15 * _create : 0 // or not set - password sending only.
21 require_once 'Pman.php';
23 class Pman_Core_SendIntro extends Pman
29 $au = $this->getAuthUser();
31 $this->jerror("LOGIN-NOAUTH", "Not authenticated", array('authFailure' => true));
33 $this->authUser = $au;
34 // check that it's a supplier!!!!
41 //DB_DataObject::debuglevel(1);
42 // gets id : c.id, rawPasswd: c.rawPasswd
44 if (!$this->hasPerm("Core.Person", "A")) {
45 $this->jerr("Not Permitted - no permission to add users.");
47 $p = DB_DataObject::factory('core_person');
49 // let's make a password anyway..
51 if (!empty($_REQUEST['_createPasswd'])) {
52 require_once 'Text/Password.php';
53 $rawPasswd = Text_Password::create(6). rand(11,99);
55 if (!empty($_REQUEST['rawPasswd'])) {
56 $rawPasswd = $_REQUEST['rawPasswd'];
59 $id = empty($_REQUEST['id']) ? 0 : $_REQUEST['id'];
61 if (!empty($_REQUEST['_create'])) {
62 // check account does not exist yet..
63 if ($p->get('email', $_REQUEST['email'])) {
64 $this->jerr("duplicate email address:" .$_REQUEST['email']);
66 $p = DB_DataObject::factory('core_person');
67 $p->setFrom($_REQUEST);
69 if ($rawPasswd == false) {
70 // -- needed for bulk adding... ?*** not sure why it's here, rather than in Roo?
75 // generate a password.
84 $p = DB_DataObject::factory('core_person');
86 if (!$id || !$p->get($_REQUEST['id'])) {
87 $this->jerr("Invalid user id");
91 if ($rawPasswd !== false) {
92 $p->setPassword($rawPasswd);
98 $ret = $p->sendTemplate('password_welcome', array(
99 'sender' => $this->authUser,
100 'rawPasswd' => $rawPasswd,
101 'baseURL' => $this->baseURL,
103 if (is_object($ret)) {
104 $this->jerr($ret->toString());