Vilma_Driver::getUserStatus PHP Method

getUserStatus() public method

Does a series of checks for a given user to determine the status.
public getUserStatus ( array $user ) : array
$user array The user's details in an array as returned by the getUser() function.
return array Either an array of error messages found during the checks or an array with a single element stating that the user is ready.
    public function getUserStatus($user)
    {
        /* Some needed vars. */
        $error = false;
        $status = array();
        $domain_name = Vilma::stripDomain($user['user_name']);
        $user_name = Vilma::stripUser($user['user_name']);
        /* Check if user enabled. */
        if ($user['user_enabled'] !== 'active') {
            $error = true;
            $err_msg = _("User disabled.");
            $status[] = Horde::img('alerts/error.png', $err_msg) . ' ' . $err_msg;
        }
        /* Check if mailbox exists. */
        try {
            Vilma_MailboxDriver::factory()->checkMailbox($user_name, $domain_name);
        } catch (Exception $result) {
            $error = true;
            $err_msg = $result->getMessage();
            $status[] = Horde::img('alerts/warning.png', $err_msg) . ' ' . $err_msg;
        }
        /* TODO: Quota checking would be nice too. */
        /* If no errors have been found output a success message for this
         * user's status. */
        if (!$error) {
            $msg = _("User ready.");
            $status = array(Horde::img('alerts/success.png', $msg) . ' ' . $msg);
        }
        return $status;
    }