Ejemplo n.º 1
0
    /**
     *
     */
    function Write()
    {
        global $c, $session;
        if (parent::Write()) {
            if ($this->new_record) {
                $qry = new PgQuery("SELECT currval('organisation_org_code_seq');");
                $qry->Exec("OrganisationPlus::Write: Retrieve org_code");
                $sequence_value = $qry->Fetch(true);
                // Fetch as an array
                $org_code = $sequence_value[0];
                $GLOBALS['id'] = $org_code;
                $c->messages[] = "Organisation, System and User records created.";
                if (isset($_POST['invite']) && $_POST['invite'] == 'on') {
                    $username = $this->Get('username');
                    $fullname = $this->Get('fullname');
                    $invitation_template = <<<EOINVITE
Hi {$fullname},

Welcome to @@system_name@@!

Your access has now been configured by {$session->fullname} with the
following details:

    Username: {$username}
    Password: @@password@@

This is a temporary password which will be valid for 24 hours.  To
log on, please visit:

    {$c->base_dns}/

Once you have logged on, you will need to use the "Edit My Info"
option to set a permanent password.

If you have any problems, please contact {$session->fullname} or the
system administrator.

Thanks.

EOINVITE;
                    $session->Dbg("OrganisationPlus", "Inviting '%s' to join.", $username);
                    $session->EmailTemporaryPassword($username, null, $invitation_template);
                    $c->messages[] = "Invitation and password sent to " . $username;
                } else {
                    $session->Dbg("OrganisationPlus", "Invite is >>%s<<", $_POST['invite']);
                }
            } else {
                $c->messages[] = "Organisation, System and User details updated.";
            }
            return true;
        }
        return false;
        // Looks like we screwed up somewhere
    }
Ejemplo n.º 2
0
 /**
  * Write the User record.
  * @return Success.
  */
 function Write()
 {
     global $c, $session;
     if (parent::Write()) {
         $c->messages[] = i18n('User record written.');
         if ($this->WriteType == 'insert') {
             $qry = new AwlQuery("SELECT currval('usr_user_no_seq');");
             $qry->Exec("User::Write");
             $sequence_value = $qry->Fetch(true);
             // Fetch as an array
             $this->user_no = $sequence_value[0];
         } else {
             if ($this->user_no == $session->user_no && $this->Get("date_format_type") != $session->date_format_type) {
                 // Ensure we match the date style setting
                 $session->date_format_type = $this->Get("date_format_type");
                 unset($_POST['email_ok']);
                 $qry = new AwlQuery("SET DATESTYLE TO ?;", $this->Get("date_format_type") == 'E' ? 'European,ISO' : ($this->Get("date_format_type") == 'U' ? 'US,ISO' : 'ISO'));
                 $qry->Exec();
             }
         }
         return $this->WriteRoles();
     }
     return false;
 }