public static function update($id, $cols = array())
    {
        global $PPHP;
        $db = $PPHP['db'];
        $sessUserId = 0;

        if (isset($_SESSION['user']) && is_array($_SESSION['user'])) {
            $sessUserId = $_SESSION['user']['id'];
        };

        if (isset($cols['id'])) {
            unset($cols['id']);
        };

        if (isset($cols['newpassword1'])
            && strlen($cols['newpassword1']) >= 8
            && isset($cols['newpassword2'])
            && $cols['newpassword1'] === $cols['newpassword2']
        ) {
            $cols['passwordHash'] = password_hash($cols['newpassword1'], PASSWORD_DEFAULT);
            // Entries 'newpassword[12]' will be safely skipped by $db->update()
        };
        if (isset($cols['email'])) {
            $cols['email'] = strtolower($cols['email']);
        };
        $ott = '';
        $onetime = null;
        if (isset($cols['onetime'])) {
            $ott = ", onetimeTime=datetime('now') ";
            $onetime = md5(mcrypt_create_iv(32, MCRYPT_DEV_URANDOM));
            $cols['onetimeHash'] = password_hash($onetime, PASSWORD_DEFAULT);
            if (is_numeric($cols['onetime'])) {
                $cols['onetimeMax'] = $cols['onetime'];
            };
        };
        $result = $db->update(
            'users',
            $cols,
            $ott . 'WHERE id=?',
            array($id)
        );
        if ($result) {
            if ($sessUserId === $id) {
                trigger('user_changed', $db->selectSingleArray(self::$_selectFrom . " WHERE id=?", array($id)));
            };
            return ($onetime !== null ? $onetime : true);
        };

        return false;
    }